Init Repo
This commit is contained in:
commit
55ab6e2822
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FlipScope", "FlipScope.vcxproj", "{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Debug|x64.Build.0 = Debug|x64
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Release|x64.ActiveCfg = Release|x64
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Release|x64.Build.0 = Release|x64
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B88A50A3-94F6-4CDC-B92D-940418AD1F7C}</ProjectGuid>
|
||||
<RootNamespace>FlipScope</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="FlipScopeProperty.props" />
|
||||
<Import Project="UsdPropertySheet.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level1</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<DisableSpecificWarnings>4819</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(TargetPath) $(SolutionDir)build\$(ProjectName) /Y/B</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\FlipScope\Core\AppController.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Core\Log.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Renderer\FrameBuffer.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Renderer\Texture.cpp" />
|
||||
<ClCompile Include="src\FlipScope\core\Window.cpp" />
|
||||
<ClCompile Include="src\FlipScope\ImGui\ImGuiLayer.cpp" />
|
||||
<ClCompile Include="src\FlipScope\ImGui\ImGuiBuild.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Pipeline\Episode.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Pipeline\Project.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Pipeline\ProjectInfo.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Pipeline\Shot.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Renderer\GraphicsContext.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Renderer\RenderCommand.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Renderer\Renderer.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Renderer\RendererAPI.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Renderer\ViewportRenderer.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Usd\FreeCamera.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Usd\HdRenderer.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Usd\HydraRenderer.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Usd\StageDataModel.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Usd\StageNoticeListener.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Usd\ViewSettings.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Widgets\StageView.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Usd\SelectionModel.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Widgets\ShotView.cpp" />
|
||||
<ClCompile Include="src\FlipScope\Widgets\Viewport.cpp" />
|
||||
<ClCompile Include="src\pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLFramebuffer.cpp" />
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLRendererAPI.cpp" />
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLContext.cpp" />
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLTexture.cpp" />
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLViewportRenderer.cpp" />
|
||||
<ClCompile Include="src\Platform\Windows\WindowsWindow.cpp" />
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
<ClCompile Include="src\FlipScope\core\Application.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="libs\ext\icons_font_awesome5.h" />
|
||||
<ClInclude Include="libs\ext\portable_file_dialogs.h" />
|
||||
<ClInclude Include="src\FlipScope\Core\AppController.h" />
|
||||
<ClInclude Include="src\FlipScope\core\Application.h" />
|
||||
<ClInclude Include="src\FlipScope\Core\Core.h" />
|
||||
<ClInclude Include="src\FlipScope\Core\Log.h" />
|
||||
<ClInclude Include="src\FlipScope\Renderer\FrameBuffer.h" />
|
||||
<ClInclude Include="src\FlipScope\Renderer\Texture.h" />
|
||||
<ClInclude Include="src\FlipScope\core\Window.h" />
|
||||
<ClInclude Include="src\FlipScope\Event\ApplicationEvent.h" />
|
||||
<ClInclude Include="src\FlipScope\Event\Event.h" />
|
||||
<ClInclude Include="src\FlipScope\ImGui\ImGuiLayer.h" />
|
||||
<ClInclude Include="src\FlipScope\Pipeline\Episode.h" />
|
||||
<ClInclude Include="src\FlipScope\Pipeline\Project.h" />
|
||||
<ClInclude Include="src\FlipScope\Pipeline\ProjectInfo.h" />
|
||||
<ClInclude Include="src\FlipScope\Pipeline\Shot.h" />
|
||||
<ClInclude Include="src\FlipScope\Renderer\GraphicsContext.h" />
|
||||
<ClInclude Include="src\FlipScope\Renderer\RenderCommand.h" />
|
||||
<ClInclude Include="src\FlipScope\Renderer\RendererAPI.h" />
|
||||
<ClInclude Include="src\FlipScope\Renderer\Renderer.h" />
|
||||
<ClInclude Include="src\FlipScope\Renderer\ViewportRenderer.h" />
|
||||
<ClInclude Include="src\FlipScope\Usd\FreeCamera.h" />
|
||||
<ClInclude Include="src\FlipScope\Usd\HdRenderer.h" />
|
||||
<ClInclude Include="src\FlipScope\Usd\HydraRenderer.h" />
|
||||
<ClInclude Include="src\FlipScope\Usd\StageDataModel.h" />
|
||||
<ClInclude Include="src\FlipScope\Usd\StageNoticeListener.h" />
|
||||
<ClInclude Include="src\FlipScope\Usd\ViewSettings.h" />
|
||||
<ClInclude Include="src\FlipScope\Widgets\StageView.h" />
|
||||
<ClInclude Include="src\FlipScope\Usd\SelectionModel.h" />
|
||||
<ClInclude Include="src\FlipScope\Widgets\ShotView.h" />
|
||||
<ClInclude Include="src\FlipScope\Widgets\Viewport.h" />
|
||||
<ClInclude Include="src\pch.h" />
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLContext.h" />
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLFramebuffer.h" />
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLRendererAPI.h" />
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLTexture.h" />
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLViewportRenderer.h" />
|
||||
<ClInclude Include="src\Platform\Windows\WindowsWindow.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Font Include="C:\Users\indigo\Downloads\Roboto-Regular.ttf" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,243 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\FlipScope\core\Application.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\core\Window.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Platform\Windows\WindowsWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLRendererAPI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Core\Log.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Renderer\RendererAPI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Renderer\Renderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLContext.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Renderer\GraphicsContext.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Renderer\RenderCommand.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\ImGui\ImGuiBuild.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\ImGui\ImGuiLayer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Pipeline\ProjectInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Pipeline\Project.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Pipeline\Shot.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Pipeline\Episode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Renderer\Texture.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLTexture.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Renderer\FrameBuffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLFramebuffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Platform\OpenGL\OpenGLViewportRenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Renderer\ViewportRenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Usd\HydraRenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Usd\StageNoticeListener.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Usd\StageDataModel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Widgets\Viewport.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Usd\FreeCamera.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Core\AppController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Usd\ViewSettings.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Widgets\ShotView.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Usd\SelectionModel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Widgets\StageView.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FlipScope\Usd\HdRenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\FlipScope\core\Application.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\core\Window.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Platform\Windows\WindowsWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLRendererAPI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Core\Log.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Renderer\Renderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Renderer\RendererAPI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLContext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Renderer\GraphicsContext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Renderer\RenderCommand.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Event\Event.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Core\Core.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Event\ApplicationEvent.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\ImGui\ImGuiLayer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Pipeline\ProjectInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Pipeline\Project.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Pipeline\Shot.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Pipeline\Episode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLTexture.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Renderer\Texture.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Renderer\FrameBuffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLFramebuffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Platform\OpenGL\OpenGLViewportRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Renderer\ViewportRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Usd\HydraRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Usd\StageNoticeListener.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Usd\StageDataModel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Widgets\Viewport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Core\AppController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Usd\FreeCamera.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libs\ext\icons_font_awesome5.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libs\ext\portable_file_dialogs.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Usd\ViewSettings.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Widgets\ShotView.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Usd\SelectionModel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Widgets\StageView.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FlipScope\Usd\HdRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Font Include="C:\Users\indigo\Downloads\Roboto-Regular.ttf" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerCommand>$(SolutionDir)Build\$(ProjectName)\$(TargetName)$(TargetExt)</LocalDebuggerCommand>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)Build\$(ProjectName)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerEnvironment>PATH=%PATH%;$(SolutionDir)libs\usd\build\bin;$(SolutionDir)libs\usd\build\lib
|
||||
$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\glfw\build\include;$(SolutionDir)libs\glad\build\include;$(SolutionDir)libs\spdlog\build\include;$(SolutionDir)libs\imgui\build\include;$(SolutionDir)libs\stb_image\build\include;$(SolutionDir)libs\jsoncpp\build\include;$(SolutionDir)libs\glm;$(SolutionDir)libs\stb;$(SolutionDir)libs\usd\build\include;$(SolutionDir)libs\ext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>GLEW_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)libs\glfw\build\lib;$(SolutionDir)libs\glad\build\lib;$(SolutionDir)libs\spdlog\build\lib;$(SolutionDir)libs\imgui\build\lib;$(SolutionDir)libs\jsoncpp\build\lib;$(SolutionDir)libs\stb_image\build\lib;$(SolutionDir)libs\usd\build\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>glfw3.lib;glad.lib;spdlog.lib;imgui.lib;jsoncpp.lib;stb_image.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# FlipScope
|
||||
Usd Layer Editor for lighing. Basic concept is create layer override like maya render layer. Prototype for now
|
||||
|
||||
## Requirements
|
||||
* Imgui
|
||||
* glad
|
||||
* glew
|
||||
* jsoncpp
|
||||
* spdlog
|
||||
* stb_image
|
||||
* USD 20.02
|
||||
* Visual Studio 2022
|
||||
|
||||

|
||||
|
||||
## To Do
|
||||
* Outliner Editor
|
||||
* Property Editor
|
||||
* Layer Editor
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\usd\build\include;$(SolutionDir)libs\usd\build\include\boost-1_61;C:\Python27\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)libs\usd\build\lib;C:\Python27\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>hgi.lib;hgiGL.lib;hio.lib;usd.lib;usdAppUtils.lib;usdGeom.lib;usdHydra.lib;usdImaging.lib;usdImagingGL.lib;usdLux.lib;usdMedia.lib;usdRender.lib;usdRi.lib;usdRiImaging.lib;usdShade.lib;usdSkel.lib;usdSkelImaging.lib;usdUI.lib;usdUtils.lib;usdviewq.lib;usdVol.lib;usdVolImaging.lib;vt.lib;work.lib;ar.lib;arch.lib;boost_atomic-vc140-mt-1_61.lib;boost_chrono-vc140-mt-1_61.lib;boost_date_time-vc140-mt-1_61.lib;boost_filesystem-vc140-mt-1_61.lib;boost_program_options-vc140-mt-1_61.lib;boost_python-vc140-mt-1_61.lib;boost_regex-vc140-mt-1_61.lib;boost_system-vc140-mt-1_61.lib;boost_thread-vc140-mt-1_61.lib;cameraUtil.lib;garch.lib;gf.lib;glf.lib;Half.lib;hd.lib;hdSt.lib;hdx.lib;hf.lib;sdf.lib;tf.lib;js.lib;python27.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 329 KiB |
|
|
@ -0,0 +1,46 @@
|
|||
[Window][DockSpace Demo]
|
||||
Pos=0,0
|
||||
Size=1280,720
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Dear ImGui Demo]
|
||||
ViewportPos=1168,64
|
||||
ViewportId=0xE927CF2F
|
||||
Size=378,580
|
||||
Collapsed=0
|
||||
|
||||
[Window][Example: Console]
|
||||
Pos=0,646
|
||||
Size=1140,292
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][Example: Property editor]
|
||||
Pos=1142,601
|
||||
Size=378,337
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Window][Example: Simple layout]
|
||||
Pos=0,19
|
||||
Size=1140,625
|
||||
Collapsed=0
|
||||
DockId=0x00000003,0
|
||||
|
||||
[Window][Example: Auto-resizing window]
|
||||
Pos=515,424
|
||||
Size=450,267
|
||||
Collapsed=0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0x3BC79352 Window=0x4647B76E Pos=26,64 Size=1280,701 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x3BC79352 SizeRef=1140,919 Split=Y
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=1270,366 CentralNode=1 Selected=0x32FFF4A6
|
||||
DockNode ID=0x00000005 Parent=0x00000001 SizeRef=1270,292 Selected=0x46B5E99C
|
||||
DockNode ID=0x00000002 Parent=0x3BC79352 SizeRef=378,919 Selected=0xE927CF2F
|
||||
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
#include "FlipScope/Core/AppController.h"
|
||||
|
||||
#include "FlipScope/Usd/StageDataModel.h"
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
|
||||
#include <portable_file_dialogs.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::shared_ptr<StageDataModel> AppController::m_StageDataModel;
|
||||
|
||||
bool AppController::m_StageChanged = false;
|
||||
AppController::AppController()
|
||||
{
|
||||
m_StageDataModel = std::make_shared<StageDataModel>();
|
||||
NewStage();
|
||||
m_StageChanged = false;
|
||||
}
|
||||
|
||||
AppController::~AppController()
|
||||
{
|
||||
}
|
||||
|
||||
void AppController::NewStage()
|
||||
{
|
||||
auto stageDataModel = GetStageDataModel();
|
||||
std::string tmpDir = getenv("TEMP");
|
||||
std::string stageFilePath = tmpDir + "/untitled.usd";
|
||||
m_StageDataModel->SetStage(UsdStage::CreateNew(stageFilePath));
|
||||
m_StageDataModel->SetStageFilePath(stageFilePath);
|
||||
}
|
||||
|
||||
void AppController::OpenStageDialog()
|
||||
{
|
||||
static std::vector<std::string> filters = {
|
||||
"USD Formats (*.usd, *.usdc, *.usda, *.usdz)", "*.usd; *.usda; *.usdc; *.usdz"
|
||||
};
|
||||
|
||||
std::vector<std::string> selection = pfd::open_file("Open USD Stage", "", filters, false).result();
|
||||
|
||||
if (!selection.size())
|
||||
{
|
||||
FS_ERROR("OpenStageDialog() :: Nothing to open...");
|
||||
return;
|
||||
}
|
||||
|
||||
auto stageDataModel = GetStageDataModel();
|
||||
|
||||
if (stageDataModel->GetStageFilePath() == selection[0])
|
||||
{
|
||||
FS_WARN("OpenStageDialog() :: Stage {} is aleady opened...", selection[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
stageDataModel->SetStage(UsdStage::Open(selection[0]));
|
||||
stageDataModel->SetStageFilePath(selection[0]);
|
||||
m_StageChanged = true;
|
||||
FS_INFO("OpenStageDialog() :: Stage {} opened...", selection[0]);
|
||||
}
|
||||
|
||||
bool AppController::SaveStage()
|
||||
{
|
||||
auto stageDataModel = GetStageDataModel();
|
||||
std::string result = stageDataModel->GetStageFilePath();
|
||||
if (!stageDataModel->GetStage()->GetRootLayer()->Save())
|
||||
{
|
||||
FS_ERROR("Stage not saved :: {}", result);
|
||||
return false;
|
||||
}
|
||||
FS_INFO("SaveStage() : Stage saved :: {}", result);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppController::ExportStage(std::string filePath, bool composed = false)
|
||||
{
|
||||
auto stageDataModel = GetStageDataModel();
|
||||
if (composed)
|
||||
{
|
||||
if (!stageDataModel->GetStage()->Export(filePath))
|
||||
{
|
||||
FS_ERROR("ExportStage() :: Stage (composed) not export");
|
||||
return false;
|
||||
}
|
||||
FS_INFO("ExportStage() :: Stage (composed) exported :: {}", filePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!stageDataModel->GetStage()->GetRootLayer()->Export(filePath))
|
||||
{
|
||||
FS_ERROR("ExportStage() :: Stage not exported :: {}", filePath);
|
||||
return false;
|
||||
}
|
||||
FS_INFO("ExportStage() :: Stage exported :: {}", filePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppController::ExportDialog(bool composed = false)
|
||||
{
|
||||
static std::vector<std::string> filters = {
|
||||
"USDC (*.usdc)", "*.usdc",
|
||||
"USDA (*.usda)", "*.usda",
|
||||
"USDZ (*.usdz)", "*.usdz"
|
||||
};
|
||||
std::string result = pfd::save_file("Export Stage as ...", "", filters, true).result();
|
||||
return ExportStage(result, composed);
|
||||
}
|
||||
|
||||
bool AppController::ExportComposedDialog()
|
||||
{
|
||||
return ExportDialog(true);
|
||||
}
|
||||
|
||||
bool AppController::CreatePrim(std::string path, std::string typeName)
|
||||
{
|
||||
auto stageDataModel = GetStageDataModel();
|
||||
UsdPrim prim = stageDataModel->GetStage()->DefinePrim(SdfPath(path), TfToken(typeName));
|
||||
if ( !prim || !prim.IsDefined())
|
||||
{
|
||||
FS_WARN("Prim({}) : {} is not defined", typeName, path);
|
||||
return false;
|
||||
}
|
||||
FS_INFO("Prim({}) : {} defined", typeName, path);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppController::CreateOverridePrim(std::string path)
|
||||
{
|
||||
auto stageDataModel = GetStageDataModel();
|
||||
UsdPrim prim = stageDataModel->GetStage()->OverridePrim(SdfPath(path));
|
||||
if ( !prim )
|
||||
{
|
||||
FS_WARN("Override Prim : {} is not defined", path);
|
||||
return false;
|
||||
}
|
||||
FS_INFO("Override Prim : {} defined", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usd/stagePopulationMask.h"
|
||||
|
||||
#include "FlipScope/Usd/StageDataModel.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class AppController
|
||||
{
|
||||
public:
|
||||
AppController();
|
||||
virtual ~AppController();
|
||||
|
||||
static void NewStage();
|
||||
static void OpenStageDialog();
|
||||
|
||||
static bool SaveStage();
|
||||
static bool ExportStage(std::string filePath, bool composed);
|
||||
|
||||
bool IsStageChanged() { return m_StageChanged; }
|
||||
void SetStageChanged(bool value) { m_StageChanged = value; }
|
||||
|
||||
static bool ExportDialog(bool composed);
|
||||
static bool ExportComposedDialog();
|
||||
|
||||
static bool CreatePrim(std::string path, std::string typeName);
|
||||
static bool CreateOverridePrim(std::string path);
|
||||
|
||||
static std::shared_ptr<StageDataModel> GetStageDataModel() { return m_StageDataModel; };
|
||||
|
||||
|
||||
private:
|
||||
static std::shared_ptr<StageDataModel> m_StageDataModel;
|
||||
static bool m_StageChanged;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Core.h"
|
||||
#include "FlipScope/Core/Application.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
#include "FlipScope/Pipeline/ProjectInfo.h"
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
#include "FlipScope/Core/AppController.h"
|
||||
|
||||
namespace FSV {
|
||||
Application* Application::s_Instance = nullptr;
|
||||
ProjectInfo* Application::s_ProjectInfo = nullptr;
|
||||
AppController* Application::s_Controller = nullptr;
|
||||
|
||||
Application::Application()
|
||||
{
|
||||
s_Instance = this;
|
||||
s_ProjectInfo = new ProjectInfo();
|
||||
s_Controller = new AppController();
|
||||
m_Window = Window::Create();
|
||||
|
||||
Renderer::Init();
|
||||
|
||||
m_ImGuiLayer = new ImGuiLayer();
|
||||
m_ImGuiLayer->OnAttach();
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
Renderer::Shutdown();
|
||||
m_ImGuiLayer->OnDetach();
|
||||
}
|
||||
|
||||
void Application::Run() {
|
||||
FS_INFO("FlipScope Running...");
|
||||
while (!m_Window->Close())
|
||||
{
|
||||
m_ImGuiLayer->OnUpdate();
|
||||
|
||||
glClearColor(0.45f, 0.55f, 0.6f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
m_ImGuiLayer->Begin();
|
||||
m_ImGuiLayer->Render();
|
||||
m_ImGuiLayer->End();
|
||||
|
||||
m_Window->OnUpdate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Application * CreateApplication() {
|
||||
Application *app = new Application();
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Core/Window.h"
|
||||
|
||||
#include "FlipScope/Pipeline/ProjectInfo.h"
|
||||
#include "FlipScope/ImGui/ImGuiLayer.h"
|
||||
#include "FlipScope/Core/AppController.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
int main(int argc, char** argv);
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
Application();
|
||||
~Application();
|
||||
|
||||
//void OnEvent()
|
||||
Window& GetWindow(){ return *m_Window; }
|
||||
static Application& Get() { return *s_Instance; }
|
||||
static ProjectInfo& GetProjectInfo() { return *s_ProjectInfo; }
|
||||
static AppController& GetController() { return *s_Controller; }
|
||||
void Run();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Window> m_Window;
|
||||
ImGuiLayer* m_ImGuiLayer;
|
||||
bool m_Running = true;
|
||||
bool m_Minimized = false;
|
||||
|
||||
private:
|
||||
static Application* s_Instance;
|
||||
static ProjectInfo* s_ProjectInfo;
|
||||
static AppController* s_Controller;
|
||||
friend int ::main(int argc, char** argv);
|
||||
};
|
||||
|
||||
Application* CreateApplication();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#include <glad/glad.h>
|
||||
//#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define BIT(x) (1 << x)
|
||||
|
||||
#define BIND_EVENT_FN(fn) std::bind(&fn, this, std::placeholders::_1)
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
#include <spdlog/sinks/basic_file_sink.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::shared_ptr<spdlog::logger> Log::s_Logger;
|
||||
|
||||
void Log::Init()
|
||||
{
|
||||
std::vector<spdlog::sink_ptr> logSinks;
|
||||
logSinks.emplace_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
|
||||
logSinks[0]->set_pattern("%^[%T] %n: %v%$");
|
||||
s_Logger = std::make_shared<spdlog::logger>("FlipScope", begin(logSinks), end(logSinks));
|
||||
|
||||
spdlog::register_logger(s_Logger);
|
||||
s_Logger->set_level(spdlog::level::trace);
|
||||
s_Logger->flush_on(spdlog::level::trace);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/spdlog-inl.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
static std::shared_ptr<spdlog::logger> GetLogger() { return s_Logger; }
|
||||
|
||||
private:
|
||||
static std::shared_ptr<spdlog::logger> s_Logger;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Log macros
|
||||
#define FS_TRACE(...) ::FSV::Log::GetLogger()->trace(__VA_ARGS__)
|
||||
#define FS_INFO(...) ::FSV::Log::GetLogger()->info(__VA_ARGS__)
|
||||
#define FS_WARN(...) ::FSV::Log::GetLogger()->warn(__VA_ARGS__)
|
||||
#define FS_ERROR(...) ::FSV::Log::GetLogger()->error(__VA_ARGS__)
|
||||
#define FS_CRITICAL(...) ::FSV::Log::GetLogger()->critical(__VA_ARGS__)
|
||||
|
||||
#define FsTrace(...) ::FSV::Log::GetLogger()->trace(__VA_ARGS__)
|
||||
#define fsInfo(...) ::FSV::Log::GetLogger()->info(__VA_ARGS__)
|
||||
#define fsWarn(...) ::FSV::Log::GetLogger()->warn(__VA_ARGS__)
|
||||
#define fsError(...) ::FSV::Log::GetLogger()->error(__VA_ARGS__)
|
||||
#define fsCritical(...) ::FSV::Log::GetLogger()->critical(__VA_ARGS__)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "Window.h"
|
||||
|
||||
#include "Platform/Windows/WindowsWindow.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::unique_ptr<Window> Window::Create(const WindowProps& props)
|
||||
{
|
||||
return std::make_unique<WindowsWindow>(props);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Event/Event.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace FSV {
|
||||
|
||||
struct WindowProps
|
||||
{
|
||||
std::string Title;
|
||||
unsigned int Width;
|
||||
unsigned int Height;
|
||||
|
||||
WindowProps(const std::string& title="FlipScope Viewer",
|
||||
unsigned int width=1280,
|
||||
unsigned int height=720)
|
||||
:Title(title), Width(width), Height(height)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
using EventCallbackFn = std::function<void(Event&)>;
|
||||
|
||||
virtual ~Window() = default;
|
||||
|
||||
virtual void OnUpdate() = 0;
|
||||
|
||||
virtual unsigned int GetWidth() const = 0;
|
||||
virtual unsigned int GetHeight() const = 0;
|
||||
|
||||
virtual void SetVSync(bool enabled) = 0;
|
||||
virtual bool IsVSync() const = 0;
|
||||
virtual void SetEventCallback(const EventCallbackFn& callback) = 0;
|
||||
|
||||
virtual bool Close() const = 0;
|
||||
virtual void* GetNativeWindow() const = 0;
|
||||
|
||||
static std::unique_ptr<Window> Create(const WindowProps& props = WindowProps());
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Event/Event.h"
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class WindowResizeEvent : public Event
|
||||
{
|
||||
public:
|
||||
WindowResizeEvent(unsigned int width, unsigned int height)
|
||||
: m_Width(width), m_Height(height) {}
|
||||
|
||||
unsigned int GetWidth() const { return m_Width; }
|
||||
unsigned int GetHeight() const { return m_Height; }
|
||||
|
||||
static EventType GetStaticType() { return EventType::WindowResize; }
|
||||
virtual EventType GetEventType() const override { return GetStaticType(); }
|
||||
virtual const char* GetName() const override { return "WindowResize"; }
|
||||
virtual int GetCategoryFlags() const override { return EventCategory::EventCategoryApplication; }
|
||||
|
||||
private:
|
||||
unsigned int m_Width, m_Height;
|
||||
};
|
||||
|
||||
class WindowCloseEvent : public Event
|
||||
{
|
||||
public:
|
||||
WindowCloseEvent() = default;
|
||||
static EventType GetStaticType() { return EventType::WindowClose; }
|
||||
virtual EventType GetEventType() const override { return GetStaticType(); }
|
||||
virtual const char* GetName() const override { return "WindowClose"; }
|
||||
virtual int GetCategoryFlags() const override { return EventCategory::EventCategoryApplication; }
|
||||
};
|
||||
|
||||
class WindowFileDropEvent : public Event
|
||||
{
|
||||
public:
|
||||
WindowFileDropEvent(unsigned int count, const char* paths[])
|
||||
: m_Count(count), m_Paths(paths) {}
|
||||
|
||||
unsigned int GetCount() const { return m_Count; }
|
||||
const char** GetPaths() const { return m_Paths; }
|
||||
|
||||
static EventType GetStaticType() { return EventType::FileDroped; }
|
||||
virtual EventType GetEventType() const override { return GetStaticType(); }
|
||||
virtual const char* GetName() const override { return "FileDroped"; }
|
||||
virtual int GetCategoryFlags() const override { return EventCategory::EventCategoryApplication; }
|
||||
|
||||
private:
|
||||
int m_Count;
|
||||
const char** m_Paths;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Core/Core.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
enum class EventType
|
||||
{
|
||||
None = 0,
|
||||
WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMove, FileDroped,
|
||||
KeyPressed, KeyReleased, KeyTyped,
|
||||
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
|
||||
};
|
||||
|
||||
enum EventCategory
|
||||
{
|
||||
None = 0,
|
||||
EventCategoryApplication = BIT(0),
|
||||
EventCategoryInput = BIT(1),
|
||||
EventCategoryKeyboard = BIT(2),
|
||||
EventCategoryMouse = BIT(3),
|
||||
EventCategoryMouseButton = BIT(4)
|
||||
};
|
||||
|
||||
/*#define EVENT_CLASS_TYPE(type) static EventType GetStaticType(){return EventType::type;}\
|
||||
virtual EventType GetEventType() const override { return GetStaticType(); }\
|
||||
virtual const char* GetName() const override { return #type; }*/
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
bool Handled = false;
|
||||
virtual EventType GetEventType() const = 0;
|
||||
virtual const char* GetName() const = 0;
|
||||
virtual int GetCategoryFlags() const = 0;
|
||||
virtual std::string ToString() const { return GetName(); }
|
||||
|
||||
bool IsInCategory(EventCategory category)
|
||||
{
|
||||
if (GetCategoryFlags() & category)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string stringify(const T& x) {
|
||||
std::ostringstream o;
|
||||
o << x;
|
||||
return o.str();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class EventDispatcher
|
||||
{
|
||||
public:
|
||||
EventDispatcher(Event& event)
|
||||
: m_Event(event)
|
||||
{
|
||||
}
|
||||
|
||||
// F will be deduced by the compiler
|
||||
template<typename T, typename F>
|
||||
bool Dispatch(const F& func)
|
||||
{
|
||||
if (m_Event.GetEventType() == T::GetStaticType())
|
||||
{
|
||||
m_Event.Handled = func(static_cast<T&>(m_Event));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
Event& m_Event;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const Event& e)
|
||||
{
|
||||
return os << e.ToString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#include "pch.h"
|
||||
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||
//#define IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||
#include "FlipScope/ImGui/imgui_impl_opengl3.cpp"
|
||||
#include "FlipScope/ImGui/imgui_impl_glfw.cpp"
|
||||
|
|
@ -0,0 +1,358 @@
|
|||
#include "pch.h"
|
||||
#include "FlipScope/Core/Core.h"
|
||||
#include "FlipScope/Core/AppController.h"
|
||||
#include "FlipScope/ImGui/ImGuiLayer.h"
|
||||
#include "FlipScope/Renderer/RenderCommand.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
#include <icons_font_awesome5.h>
|
||||
|
||||
#include "FlipScope/Core/Application.h"
|
||||
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
static ImGuiDockNodeFlags opt_flags = ImGuiDockNodeFlags_PassthruCentralNode;
|
||||
ImFont* ImGuiLayer::m_NormalFont;
|
||||
ImFont* ImGuiLayer::m_SmallFont;
|
||||
ImFont* ImGuiLayer::m_IconFont;
|
||||
|
||||
//Project* ImGuiLayer::m_CurrentProject;
|
||||
std::string ImGuiLayer::m_CurrentProjectName;
|
||||
std::string ImGuiLayer::m_CurrentEpisodeName;
|
||||
|
||||
static bool show_timeline = false;
|
||||
static bool show_stageview = false;
|
||||
static bool show_viewport = false;
|
||||
static bool show_property = false;
|
||||
static bool show_shotview = false;
|
||||
|
||||
ImGuiLayer::ImGuiLayer()
|
||||
{
|
||||
}
|
||||
|
||||
void ImGuiLayer::OnAttach()
|
||||
{
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigDockingWithShift = true;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||
ImFontConfig config;
|
||||
config.FontDataOwnedByAtlas = false;
|
||||
|
||||
m_NormalFont = io.Fonts->AddFontFromFileTTF("resources/fonts/Roboto-Regular.ttf", 16.0, &config);
|
||||
config.MergeMode = true;
|
||||
|
||||
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
||||
io.Fonts->AddFontFromFileTTF("resources/fonts/fa-solid-900.ttf", 14.0, &config, icon_ranges);
|
||||
|
||||
m_SmallFont = io.Fonts->AddFontFromFileTTF("resources/fonts/Roboto-Regular.ttf", 14.0, &config);
|
||||
|
||||
io.FontDefault = m_NormalFont;
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
Application& app = Application::Get();
|
||||
GLFWwindow* window = static_cast<GLFWwindow*>(app.GetWindow().GetNativeWindow());
|
||||
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
ImGui_ImplOpenGL3_Init("#version 410");
|
||||
|
||||
m_Texture = Texture::Create("C:/Test.png");
|
||||
|
||||
// Build framebuffer
|
||||
//FramebufferSpecification fbspec;
|
||||
//fbspec.Width = 1280;
|
||||
//fbspec.Height = 720;
|
||||
//m_Framebuffer = Framebuffer::Create(fbspec);
|
||||
|
||||
// Initialize Renderer
|
||||
//m_HydraRenderer = std::make_shared<HydraRenderer>(1280, 720);
|
||||
//m_HydraRenderer->Init(1280, 720);
|
||||
|
||||
m_Viewport = std::make_shared<Viewport>(1280, 720);
|
||||
m_StageView = std::make_shared<StageView>();
|
||||
m_ShotView = std::make_shared<ShotView>();
|
||||
}
|
||||
|
||||
void ImGuiLayer::OnUpdate()
|
||||
{
|
||||
Application& app = Application::Get();
|
||||
AppController& controller = app.GetController();
|
||||
|
||||
if (controller.IsStageChanged())
|
||||
{
|
||||
m_Viewport->Update();
|
||||
controller.SetStageChanged(false);
|
||||
}
|
||||
//m_Framebuffer->Bind();
|
||||
// Renderer Draw Code
|
||||
//RenderCommand::SetClearColor(glm::vec4(1.0f, 0.1f, 0.1f, 1));
|
||||
//RenderCommand::Clear();
|
||||
|
||||
//m_HydraRenderer->OnDraw();
|
||||
m_Viewport->GetRenderer()->OnRender();
|
||||
//m_HydraRenderer->OnRender();
|
||||
|
||||
//m_Framebuffer->Unbind();
|
||||
}
|
||||
|
||||
void ImGuiLayer::OnDetach()
|
||||
{
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
void ImGuiLayer::Begin()
|
||||
{
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
/*void ImGuiLayer::BeginDockSpace()
|
||||
{
|
||||
static bool opt_fullscreen_persistant = true;
|
||||
ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
|
||||
if (ImGui::GetIO().DisplaySize.y > 0)
|
||||
{
|
||||
|
||||
bool opt_fullscreen = opt_fullscreen_persistant;
|
||||
|
||||
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent
|
||||
// window not dockable into, because it would be confusing to have two
|
||||
// docking targets within each others.
|
||||
ImGuiWindowFlags window_flags =
|
||||
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
|
||||
if (opt_fullscreen) {
|
||||
auto dockSpaceSize = viewport->Size;
|
||||
dockSpaceSize.y -= m_StatusBarSize; // remove the status bar
|
||||
ImGui::SetNextWindowPos(viewport->Pos);
|
||||
ImGui::SetNextWindowSize(dockSpaceSize);
|
||||
ImGui::SetNextWindowViewport(viewport->ID);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
|
||||
window_flags |= ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoMove;
|
||||
window_flags |=
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
||||
}
|
||||
|
||||
// When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render
|
||||
// our background and handle the pass-thru hole, so we ask Begin() to not
|
||||
// render a background.
|
||||
if (opt_flags & ImGuiDockNodeFlags_PassthruCentralNode)
|
||||
window_flags |= ImGuiWindowFlags_NoBackground;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
static bool alwaysOpened = true;
|
||||
ImGui::Begin("DockSpace", &alwaysOpened, window_flags);
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (opt_fullscreen) ImGui::PopStyleVar(2);
|
||||
|
||||
// Dockspace
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) {
|
||||
ImGuiID dockspace_id = ImGui::GetID("FsDockspace");
|
||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), opt_flags);
|
||||
}
|
||||
else {
|
||||
// TODO: emit a log message
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ImGui::End();
|
||||
}*/
|
||||
void ImGuiLayer::BeginDockSpace()
|
||||
{
|
||||
static bool alwaysOpened = true;
|
||||
static ImGuiDockNodeFlags dockFlags = ImGuiDockNodeFlags_PassthruCentralNode;
|
||||
static ImGuiWindowFlags windowFlags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
windowFlags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
||||
windowFlags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
||||
windowFlags |= ImGuiWindowFlags_NoBackground;
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->Pos);
|
||||
ImGui::SetNextWindowSize(viewport->Size);
|
||||
ImGui::SetNextWindowViewport(viewport->ID);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::Begin("DockSpace", &alwaysOpened, windowFlags);
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
ImGuiID dockspaceid = ImGui::GetID("dockspace");
|
||||
ImGui::DockSpace(dockspaceid, ImVec2(0.0f, 0.0f), dockFlags);
|
||||
|
||||
EndDockSpace();
|
||||
}
|
||||
|
||||
void ImGuiLayer::EndDockSpace()
|
||||
{
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
float ImGuiLayer::DrawMenuBar()
|
||||
{
|
||||
auto menu_height = 0.0f;
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
ImGui::MenuItem("New", "Ctrl+N", nullptr);
|
||||
if (ImGui::MenuItem("Open", "Ctrl+O", nullptr))
|
||||
{
|
||||
AppController::OpenStageDialog();
|
||||
}
|
||||
ImGui::MenuItem("Close", "Ctrl+W", nullptr);
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Save", "Ctrl+S", nullptr))
|
||||
{
|
||||
AppController::SaveStage();
|
||||
}
|
||||
ImGui::Separator();
|
||||
ImGui::MenuItem("Export", "Ctrl+E", nullptr);
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Exit", "Ctrl+Q", nullptr))
|
||||
{
|
||||
Application& app = Application::Get();
|
||||
app.GetWindow().Close();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("View"))
|
||||
{
|
||||
ImGui::MenuItem("Shots", "Alt+P", &show_shotview);
|
||||
ImGui::MenuItem("Timeline", "Alt+T", &show_timeline);
|
||||
ImGui::MenuItem("Stage", "Alt+O", &show_stageview);
|
||||
ImGui::MenuItem("Viewport", "Alt+V", &show_viewport);
|
||||
ImGui::MenuItem("Property", "Alt+P", &show_property);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Help"))
|
||||
{
|
||||
ImGui::MenuItem("About", "", nullptr);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
menu_height = ImGui::GetWindowSize().y;
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
return menu_height;
|
||||
}
|
||||
|
||||
void ImGuiLayer::DrawStatusBar()
|
||||
{
|
||||
ImGuiContext& g = *ImGui::GetCurrentContext();
|
||||
ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
|
||||
// Draw status bar(no docking)
|
||||
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, m_StatusBarSize));
|
||||
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + viewport->Size.y - m_StatusBarSize));
|
||||
//ImGui::SetNextWindowPos(ImVec2(0.0f, g.IO.DisplaySize.y - mFooterHeight));
|
||||
//ImGui::SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, mFooterHeight));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0.0f, 20.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(2.0f, 2.0f));
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDocking;
|
||||
|
||||
if (!ImGui::Begin("##statusbar", nullptr, window_flags))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
// Draw the common stuff
|
||||
ImGui::SameLine(viewport->Size.x - 100.f);
|
||||
ImFont *font = ImGui::GetFont();
|
||||
font->Scale = 0.875;
|
||||
ImGui::PushFont(font);
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui::Text("FPS: (%.1f FPS)", io.Framerate);
|
||||
font->Scale = 1.0;
|
||||
ImGui::PopFont();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ImGuiLayer::Render()
|
||||
{
|
||||
static bool show = true;
|
||||
auto menu_height = DrawMenuBar();
|
||||
BeginDockSpace();
|
||||
DrawStatusBar();
|
||||
ImGui::ShowDemoWindow(&show);
|
||||
if (show_timeline) ShowTimeline(&show_timeline);
|
||||
if (show_property) ShowProperty(&show_property);
|
||||
if (show_shotview) m_ShotView->Show(&show_shotview);
|
||||
if (show_viewport) m_Viewport->Show(&show_viewport);
|
||||
if (show_stageview) m_StageView->Show(&show_stageview);
|
||||
}
|
||||
|
||||
void ImGuiLayer::ShowTimeline(bool* p_open)
|
||||
{
|
||||
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
if (!ImGui::Begin("Timeline", p_open))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ImGuiLayer::ShowProperty(bool* p_open)
|
||||
{
|
||||
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
if (!ImGui::Begin("Property", p_open))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
void ImGuiLayer::End()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
Application& app = Application::Get();
|
||||
io.DisplaySize = ImVec2((float)app.GetWindow().GetWidth(), (float)app.GetWindow().GetHeight());
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
GLFWwindow* backup_current_context = glfwGetCurrentContext();
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
glfwMakeContextCurrent(backup_current_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Pipeline/Project.h"
|
||||
|
||||
#include "FlipScope/Renderer/FrameBuffer.h"
|
||||
#include "FlipScope/Renderer/Texture.h"
|
||||
|
||||
//#include "FlipScope/Usd/HydraRenderer.h"
|
||||
#include "FlipScope/Widgets/Viewport.h"
|
||||
#include "FlipScope/Widgets/StageView.h"
|
||||
#include "FlipScope/Widgets/ShotView.h"
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class ImGuiLayer
|
||||
{
|
||||
public:
|
||||
ImGuiLayer();
|
||||
~ImGuiLayer() = default;
|
||||
void OnAttach();
|
||||
void OnDetach();
|
||||
|
||||
void OnUpdate();
|
||||
|
||||
void Render();
|
||||
void Begin();
|
||||
void End();
|
||||
public:
|
||||
void BeginDockSpace();
|
||||
void EndDockSpace();
|
||||
float DrawMenuBar();
|
||||
void DrawStatusBar();
|
||||
void ShowViewport(bool *p_open);
|
||||
void ShowShotList(bool *p_open);
|
||||
void ShowTimeline(bool *p_open);
|
||||
void ShowProperty(bool *p_open);
|
||||
|
||||
ImFont* GetNormalFont() { return m_NormalFont; }
|
||||
ImFont* GetSmallFont() { return m_SmallFont; }
|
||||
ImFont* GetIconFont() { return m_IconFont; }
|
||||
|
||||
private:
|
||||
float m_Time = 0.0f;
|
||||
float m_StatusBarSize = 20.0f;
|
||||
|
||||
glm::vec2 m_ViewportSize = { 0.0f, 0.0f };
|
||||
|
||||
std::shared_ptr<Texture> m_Texture;
|
||||
std::shared_ptr<Framebuffer> m_Framebuffer;
|
||||
|
||||
//std::shared_ptr<HydraRenderer> m_HydraRenderer;
|
||||
|
||||
static ImFont* m_NormalFont;
|
||||
static ImFont* m_SmallFont;
|
||||
static ImFont* m_IconFont;
|
||||
|
||||
static std::string m_CurrentProjectName;
|
||||
static std::string m_CurrentEpisodeName;
|
||||
|
||||
static bool m_IsViewportFocused;
|
||||
static bool m_IsViewportHovered;
|
||||
|
||||
std::shared_ptr<Viewport> m_Viewport;
|
||||
std::shared_ptr<StageView> m_StageView;
|
||||
std::shared_ptr<ShotView> m_ShotView;
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,726 @@
|
|||
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||
// - Desktop GL: 2.x 3.x 4.x
|
||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||
// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
||||
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
||||
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
||||
// 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility.
|
||||
// 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call.
|
||||
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
||||
// 2019-03-15: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
||||
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
||||
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
|
||||
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||
// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT) / GL_CLIP_ORIGIN.
|
||||
// 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used.
|
||||
// 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES".
|
||||
// 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation.
|
||||
// 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples.
|
||||
// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state.
|
||||
// 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a NULL pointer.
|
||||
// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
|
||||
// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
|
||||
// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
|
||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||
// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
|
||||
|
||||
//----------------------------------------
|
||||
// OpenGL GLSL GLSL
|
||||
// version version string
|
||||
//----------------------------------------
|
||||
// 2.0 110 "#version 110"
|
||||
// 2.1 120 "#version 120"
|
||||
// 3.0 130 "#version 130"
|
||||
// 3.1 140 "#version 140"
|
||||
// 3.2 150 "#version 150"
|
||||
// 3.3 330 "#version 330 core"
|
||||
// 4.0 400 "#version 400 core"
|
||||
// 4.1 410 "#version 410 core"
|
||||
// 4.2 420 "#version 410 core"
|
||||
// 4.3 430 "#version 430 core"
|
||||
// ES 2.0 100 "#version 100" = WebGL 1.0
|
||||
// ES 3.0 300 "#version 300 es" = WebGL 2.0
|
||||
//----------------------------------------
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#endif
|
||||
|
||||
// Auto-enable GLES on matching platforms
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
|
||||
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
#undef IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
|
||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
|
||||
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||
#endif
|
||||
|
||||
// GL includes
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
#include <GLES2/gl2.h>
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||||
#include <OpenGLES/ES3/gl.h> // Use GL ES 3
|
||||
#else
|
||||
#include <GLES3/gl3.h> // Use GL ES 3
|
||||
#endif
|
||||
#else
|
||||
// About Desktop OpenGL function loaders:
|
||||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||
#include <GL/gl3w.h> // Needs to be initialized with gl3wInit() in user's code
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#include <glbinding/Binding.h> // Needs to be initialized with glbinding::Binding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#include <glbinding/glbinding.h>// Needs to be initialized with glbinding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
#else
|
||||
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0
|
||||
#else
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1
|
||||
#endif
|
||||
|
||||
// OpenGL Data
|
||||
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries.
|
||||
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
||||
static GLuint g_FontTexture = 0;
|
||||
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||
static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
|
||||
static int g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
|
||||
static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
|
||||
|
||||
// Forward Declarations
|
||||
static void ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||
|
||||
// Functions
|
||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
{
|
||||
// Query for GL version
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
GLint major, minor;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||
g_GlVersion = major * 1000 + minor;
|
||||
#else
|
||||
g_GlVersion = 2000; // GLES 2
|
||||
#endif
|
||||
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendRendererName = "imgui_impl_opengl3";
|
||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (g_GlVersion >= 3200)
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
#endif
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||
|
||||
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
||||
// Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 100";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 300 es";
|
||||
#else
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 130";
|
||||
#endif
|
||||
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
|
||||
strcpy(g_GlslVersionString, glsl_version);
|
||||
strcat(g_GlslVersionString, "\n");
|
||||
|
||||
// Dummy construct to make it easily visible in the IDE and debugger which GL loader has been selected.
|
||||
// The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
|
||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||
// you are likely to get a crash below.
|
||||
// You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||
const char* gl_loader = "Unknown";
|
||||
IM_UNUSED(gl_loader);
|
||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||
gl_loader = "GL3W";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||
gl_loader = "GLEW";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
gl_loader = "GLAD";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||
gl_loader = "glbinding2";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||
gl_loader = "glbinding3";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||
gl_loader = "custom";
|
||||
#else
|
||||
gl_loader = "none";
|
||||
#endif
|
||||
|
||||
// Make a dummy GL call (we don't actually need the result)
|
||||
// IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
|
||||
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
|
||||
GLint current_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
||||
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_Shutdown()
|
||||
{
|
||||
ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_NewFrame()
|
||||
{
|
||||
if (!g_ShaderHandle)
|
||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
|
||||
{
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
#ifdef GL_POLYGON_MODE
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
#endif
|
||||
|
||||
// Setup viewport, orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||
float L = draw_data->DisplayPos.x;
|
||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||
float T = draw_data->DisplayPos.y;
|
||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||
const float ortho_projection[4][4] =
|
||||
{
|
||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, -1.0f, 0.0f },
|
||||
{ (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
|
||||
};
|
||||
glUseProgram(g_ShaderHandle);
|
||||
glUniform1i(g_AttribLocationTex, 0);
|
||||
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
||||
#endif
|
||||
|
||||
(void)vertex_array_object;
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(vertex_array_object);
|
||||
#endif
|
||||
|
||||
// Bind vertex/index buffers and setup attributes for ImDrawVert
|
||||
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxPos);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxUV);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxColor);
|
||||
glVertexAttribPointer(g_AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
|
||||
glVertexAttribPointer(g_AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
|
||||
glVertexAttribPointer(g_AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
|
||||
}
|
||||
|
||||
// OpenGL3 Render function.
|
||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||
if (fb_width <= 0 || fb_height <= 0)
|
||||
return;
|
||||
|
||||
// Backup GL state
|
||||
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
||||
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
|
||||
#endif
|
||||
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
GLint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array_object);
|
||||
#endif
|
||||
#ifdef GL_POLYGON_MODE
|
||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||
#endif
|
||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
||||
GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
|
||||
GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
|
||||
GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
|
||||
GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
|
||||
GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
|
||||
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
|
||||
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
bool clip_origin_lower_left = true;
|
||||
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
|
||||
GLenum last_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&last_clip_origin); // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
|
||||
if (last_clip_origin == GL_UPPER_LEFT)
|
||||
clip_origin_lower_left = false;
|
||||
#endif
|
||||
|
||||
// Setup desired GL state
|
||||
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
|
||||
// The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
|
||||
GLuint vertex_array_object = 0;
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glGenVertexArrays(1, &vertex_array_object);
|
||||
#endif
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
|
||||
// Will project scissor/clipping rectangles into framebuffer space
|
||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||
|
||||
// Render command lists
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
|
||||
// Upload vertex/index buffers
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
|
||||
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback != NULL)
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
else
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Project scissor/clipping rectangles into framebuffer space
|
||||
ImVec4 clip_rect;
|
||||
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
||||
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
||||
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
||||
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
||||
|
||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||
{
|
||||
// Apply scissor/clipping rectangle
|
||||
if (clip_origin_lower_left)
|
||||
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
||||
else
|
||||
glScissor((int)clip_rect.x, (int)clip_rect.y, (int)clip_rect.z, (int)clip_rect.w); // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||
|
||||
// Bind texture, Draw
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (g_GlVersion >= 3200)
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
||||
else
|
||||
#endif
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the temporary VAO
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glDeleteVertexArrays(1, &vertex_array_object);
|
||||
#endif
|
||||
|
||||
// Restore modified GL state
|
||||
glUseProgram(last_program);
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
glBindSampler(0, last_sampler);
|
||||
#endif
|
||||
glActiveTexture(last_active_texture);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(last_vertex_array_object);
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
|
||||
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
|
||||
if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
|
||||
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
||||
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
||||
#ifdef GL_POLYGON_MODE
|
||||
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||
#endif
|
||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
||||
|
||||
// Upload texture to graphics system
|
||||
GLint last_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGenTextures(1, &g_FontTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
#ifdef GL_UNPACK_ROW_LENGTH
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
|
||||
|
||||
// Restore state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyFontsTexture()
|
||||
{
|
||||
if (g_FontTexture)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
glDeleteTextures(1, &g_FontTexture);
|
||||
io.Fonts->TexID = 0;
|
||||
g_FontTexture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
|
||||
static bool CheckShader(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
|
||||
glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
|
||||
static bool CheckProgram(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetProgramiv(handle, GL_LINK_STATUS, &status);
|
||||
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||
{
|
||||
// Backup GL state
|
||||
GLint last_texture, last_array_buffer;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
GLint last_vertex_array;
|
||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||
#endif
|
||||
|
||||
// Parse GLSL version string
|
||||
int glsl_version = 130;
|
||||
sscanf(g_GlslVersionString, "#version %d", &glsl_version);
|
||||
|
||||
const GLchar* vertex_shader_glsl_120 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"attribute vec2 Position;\n"
|
||||
"attribute vec2 UV;\n"
|
||||
"attribute vec4 Color;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_130 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"in vec2 Position;\n"
|
||||
"in vec2 UV;\n"
|
||||
"in vec4 Color;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_300_es =
|
||||
"precision mediump float;\n"
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_410_core =
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_120 =
|
||||
"#ifdef GL_ES\n"
|
||||
" precision mediump float;\n"
|
||||
"#endif\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_130 =
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_300_es =
|
||||
"precision mediump float;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_410_core =
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
// Select shaders matching our GLSL versions
|
||||
const GLchar* vertex_shader = NULL;
|
||||
const GLchar* fragment_shader = NULL;
|
||||
if (glsl_version < 130)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_120;
|
||||
fragment_shader = fragment_shader_glsl_120;
|
||||
}
|
||||
else if (glsl_version >= 410)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_410_core;
|
||||
fragment_shader = fragment_shader_glsl_410_core;
|
||||
}
|
||||
else if (glsl_version == 300)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_300_es;
|
||||
fragment_shader = fragment_shader_glsl_300_es;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_130;
|
||||
fragment_shader = fragment_shader_glsl_130;
|
||||
}
|
||||
|
||||
// Create shaders
|
||||
const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
|
||||
g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
|
||||
glCompileShader(g_VertHandle);
|
||||
CheckShader(g_VertHandle, "vertex shader");
|
||||
|
||||
const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader };
|
||||
g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL);
|
||||
glCompileShader(g_FragHandle);
|
||||
CheckShader(g_FragHandle, "fragment shader");
|
||||
|
||||
g_ShaderHandle = glCreateProgram();
|
||||
glAttachShader(g_ShaderHandle, g_VertHandle);
|
||||
glAttachShader(g_ShaderHandle, g_FragHandle);
|
||||
glLinkProgram(g_ShaderHandle);
|
||||
CheckProgram(g_ShaderHandle, "shader program");
|
||||
|
||||
g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
|
||||
g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
|
||||
g_AttribLocationVtxPos = glGetAttribLocation(g_ShaderHandle, "Position");
|
||||
g_AttribLocationVtxUV = glGetAttribLocation(g_ShaderHandle, "UV");
|
||||
g_AttribLocationVtxColor = glGetAttribLocation(g_ShaderHandle, "Color");
|
||||
|
||||
// Create buffers
|
||||
glGenBuffers(1, &g_VboHandle);
|
||||
glGenBuffers(1, &g_ElementsHandle);
|
||||
|
||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
|
||||
// Restore modified GL state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(last_vertex_array);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
||||
{
|
||||
if (g_VboHandle) { glDeleteBuffers(1, &g_VboHandle); g_VboHandle = 0; }
|
||||
if (g_ElementsHandle) { glDeleteBuffers(1, &g_ElementsHandle); g_ElementsHandle = 0; }
|
||||
if (g_ShaderHandle && g_VertHandle) { glDetachShader(g_ShaderHandle, g_VertHandle); }
|
||||
if (g_ShaderHandle && g_FragHandle) { glDetachShader(g_ShaderHandle, g_FragHandle); }
|
||||
if (g_VertHandle) { glDeleteShader(g_VertHandle); g_VertHandle = 0; }
|
||||
if (g_FragHandle) { glDeleteShader(g_FragHandle); g_FragHandle = 0; }
|
||||
if (g_ShaderHandle) { glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; }
|
||||
|
||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||
// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously.
|
||||
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport, void*)
|
||||
{
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
{
|
||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
ImGui_ImplOpenGL3_RenderDrawData(viewport->DrawData);
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_InitPlatformInterface()
|
||||
{
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGui::DestroyPlatformWindows();
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Pipeline/Episode.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
Episode::Episode(Project *project, std::string name)
|
||||
: m_Project(project),
|
||||
m_Name(name)
|
||||
{
|
||||
}
|
||||
|
||||
Episode::~Episode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Episode::AddShot(Shot &shot)
|
||||
{
|
||||
m_ShotList.push_back(shot);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Pipeline/Project.h"
|
||||
#include "FlipScope/Pipeline/Shot.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class Episode
|
||||
{
|
||||
public:
|
||||
Episode(Project *project, const std::string name);
|
||||
~Episode();
|
||||
|
||||
std::string GetName() { return m_Name; }
|
||||
ShotList GetShotList() { return m_ShotList; }
|
||||
|
||||
void AddShot(Shot &shot);
|
||||
|
||||
private:
|
||||
std::string m_Name;
|
||||
Project* m_Project;
|
||||
ShotList m_ShotList;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Pipeline/Project.h"
|
||||
#include "FlipScope/Pipeline/Episode.h"
|
||||
#include "FlipScope/Pipeline/Shot.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
|
||||
Project::Project(const std::string name,
|
||||
const std::string aliasname,
|
||||
const std::string type,
|
||||
const std::string location,
|
||||
const std::string ntPath,
|
||||
const std::string unixPath,
|
||||
const StringList users) :
|
||||
m_Name(name),
|
||||
m_AliasName(aliasname),
|
||||
m_Type(type),
|
||||
m_Location(location),
|
||||
m_NtPath(ntPath),
|
||||
m_UnixPath(unixPath),
|
||||
m_Users(users)
|
||||
{
|
||||
FS_INFO("Init ProjectData : {0}", aliasname);
|
||||
const std::string ddtProjectDataRoot = "//ren/render/WEB/ddt2/" + aliasname;
|
||||
|
||||
m_ShotLastReviewConfigPath = ddtProjectDataRoot + "/" + "shot_lastest_review_file.tbs";
|
||||
m_ShotInfomationConfigPath = ddtProjectDataRoot + "/" + "shot_information.tbs";
|
||||
m_ShotTaskReviewConfigPath = ddtProjectDataRoot + "/" + "shottask_information.tbs";
|
||||
|
||||
}
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
m_Users.clear();
|
||||
}
|
||||
|
||||
void Project::ShotLastReviewConfigInit()
|
||||
{
|
||||
if (!m_ShotLastReviewConfigRoot.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::ifstream config_doc(m_ShotLastReviewConfigPath, std::ifstream::binary);
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
std::string errs;
|
||||
|
||||
if (!Json::parseFromStream(rbuilder, config_doc, &m_ShotLastReviewConfigRoot, &errs))
|
||||
{
|
||||
FS_ERROR(errs);
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize Episode List
|
||||
if (m_EpisodeNameList.size() == 0)
|
||||
{
|
||||
for (auto &info : m_ShotLastReviewConfigRoot)
|
||||
{
|
||||
std::string episodeName = info["name"].asString();
|
||||
m_EpisodeNameList.push_back(episodeName);
|
||||
FS_INFO("GetEpisodeList() : {0} : {1}", m_AliasName, info["name"].asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Project::ShotInfomationConfigInit()
|
||||
{
|
||||
if (!m_ShotInfomationConfigRoot.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::ifstream config_doc(m_ShotInfomationConfigPath, std::ifstream::binary);
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
std::string errs;
|
||||
|
||||
if (!Json::parseFromStream(rbuilder, config_doc, &m_ShotInfomationConfigRoot, &errs))
|
||||
{
|
||||
FS_ERROR(errs);
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &info : m_ShotInfomationConfigRoot)
|
||||
{
|
||||
for (unsigned int n = 1; n < info["table"].size(); n++)
|
||||
{
|
||||
std::string name = info["table"][n][2].asString();
|
||||
std::string act = info["table"][n][3].asString();
|
||||
std::string sequence = info["table"][n][4].asString();
|
||||
int frameStart = info["table"][n][5].asInt();
|
||||
int frameEnd = info["table"][n][6].asInt();
|
||||
int duration = info["table"][n][7].asInt();
|
||||
int handleLeft = info["table"][n][8].asInt();
|
||||
int handleRight = info["table"][n][9].asInt();
|
||||
std::string shotType = info["table"][n][11].asString();
|
||||
std::string episodeName = info["table"][n][12].asString();
|
||||
Shot shot(name, act, sequence,
|
||||
frameStart, frameEnd, duration, handleLeft, handleRight,
|
||||
shotType, m_AliasName, episodeName);
|
||||
m_ShotList.push_back(shot);
|
||||
}
|
||||
|
||||
FS_INFO("Init {0} Shots", info["table"].size());
|
||||
}
|
||||
}
|
||||
|
||||
bool Project::IsProjectUser(std::string userName)
|
||||
{
|
||||
for (auto &user : m_Users)
|
||||
{
|
||||
if (user == userName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
StringList Project::GetEpisodeNameList()
|
||||
{
|
||||
ShotLastReviewConfigInit();
|
||||
|
||||
if (m_EpisodeNameList.size() == 0)
|
||||
{
|
||||
for (auto &info : m_ShotLastReviewConfigRoot)
|
||||
{
|
||||
std::string episodeName = info["name"].asString();
|
||||
m_EpisodeNameList.push_back(episodeName);
|
||||
FS_INFO("GetEpisodeList() : {0} : {1}", m_AliasName, info["name"].asString());
|
||||
}
|
||||
}
|
||||
return m_EpisodeNameList;
|
||||
}
|
||||
|
||||
ShotList Project::GetShotListByEpisode(std::string episodeName)
|
||||
{
|
||||
ShotInfomationConfigInit();
|
||||
|
||||
ShotList shotList;
|
||||
if (m_ShotList.size() == 0)
|
||||
return shotList;
|
||||
|
||||
for (auto &shot : m_ShotList)
|
||||
{
|
||||
if (shot.GetEpisodeName() == episodeName)
|
||||
{
|
||||
shotList.push_back(shot);
|
||||
}
|
||||
}
|
||||
return shotList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#pragma once
|
||||
|
||||
#include <json/json.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "FlipScope/Pipeline/Shot.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
typedef std::vector<std::string> StringList;
|
||||
//typedef std::vector<Episode> EpisodeList;
|
||||
typedef std::vector<Shot> ShotList;
|
||||
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
Project(const std::string name,
|
||||
const std::string aliasname,
|
||||
const std::string type,
|
||||
const std::string location,
|
||||
const std::string ntPath,
|
||||
const std::string unixPath,
|
||||
const StringList users = StringList());
|
||||
~Project();
|
||||
|
||||
public:
|
||||
bool IsEmpty() { return m_Name.length() <= 0; }
|
||||
std::string GetName() { return m_Name; }
|
||||
std::string GetAliasName() { return m_AliasName; }
|
||||
std::string GetType() { return m_AliasName; }
|
||||
std::string GetLocation() { return m_Location; }
|
||||
std::string GetNtPath() { return m_NtPath; }
|
||||
std::string GetUnixPath() { return m_UnixPath; }
|
||||
StringList GetUsers() { return m_Users; }
|
||||
|
||||
public:
|
||||
bool IsProjectUser(std::string userName);
|
||||
|
||||
void ShotLastReviewConfigInit();
|
||||
void ShotInfomationConfigInit();
|
||||
|
||||
std::string GetShotLastReviewConfigPath() { return m_ShotLastReviewConfigPath; }
|
||||
std::string GetShotInfomationConfigPath() { return m_ShotInfomationConfigPath; }
|
||||
std::string GetShotTaskReviewConfigPath() { return m_ShotTaskReviewConfigPath; }
|
||||
|
||||
StringList GetEpisodeNameList();
|
||||
//EpisodeList GetEpisodeList() { return m_EpisodeList; }
|
||||
ShotList GetShotList() { return m_ShotList; }
|
||||
ShotList GetShotListByEpisode(std::string episodeName);
|
||||
|
||||
private:
|
||||
std::string m_Name;
|
||||
std::string m_AliasName;
|
||||
std::string m_Type;
|
||||
std::string m_Location;
|
||||
std::string m_NtPath;
|
||||
std::string m_UnixPath;
|
||||
|
||||
StringList m_Users;
|
||||
|
||||
std::string m_ShotLastReviewConfigPath;
|
||||
std::string m_ShotInfomationConfigPath;
|
||||
std::string m_ShotTaskReviewConfigPath;
|
||||
|
||||
Json::Value m_ShotLastReviewConfigRoot;
|
||||
Json::Value m_ShotInfomationConfigRoot;
|
||||
Json::Value m_ShotTaskReviewConfigRoot;
|
||||
|
||||
StringList m_EpisodeNameList;
|
||||
//EpisodeList m_EpisodeList;
|
||||
ShotList m_ShotList;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Pipeline/ProjectInfo.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
const char* projectConfigPath = "//ren/render/spider/project.json";
|
||||
|
||||
ProjectInfo::ProjectInfo()
|
||||
{
|
||||
//if(!m_Initialized)
|
||||
// Init();
|
||||
}
|
||||
|
||||
ProjectInfo::~ProjectInfo()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
std::string ProjectInfo::GetCurrentLocation()
|
||||
{
|
||||
const char* domain = getenv("USERDOMAIN");
|
||||
if (strcmp(domain, "CG") == 0)
|
||||
return "cgtp";
|
||||
if (strcmp(domain, "CGCG") == 0)
|
||||
return "cgks";
|
||||
if (strcmp(domain, "CGXM") == 0)
|
||||
return "cgxm";
|
||||
if (strcmp(domain, "GLOWINGSTUDIOS") == 0)
|
||||
return "bgs";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
std::string ProjectInfo::GetCurrentUser()
|
||||
{
|
||||
return getenv("USERNAME");
|
||||
}
|
||||
|
||||
Project ProjectInfo::GetCurrentProjectByName(std::string projectName)
|
||||
{
|
||||
for (auto &p : m_UserProjectList)
|
||||
{
|
||||
if (p.GetAliasName() == projectName)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return Project("", "", "", "", "", "");
|
||||
}
|
||||
|
||||
ProjectList ProjectInfo::GetUserProjects()
|
||||
{
|
||||
Init();
|
||||
return m_UserProjectList;
|
||||
}
|
||||
|
||||
void ProjectInfo::Reload()
|
||||
{
|
||||
m_UserProjectList.clear();
|
||||
m_Initialized = false;
|
||||
Init();
|
||||
}
|
||||
|
||||
void ProjectInfo::Init()
|
||||
{
|
||||
if (m_Initialized)
|
||||
return;
|
||||
|
||||
std::ifstream config_doc(projectConfigPath, std::ifstream::binary);
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
|
||||
std::string errs;
|
||||
Json::Value root;
|
||||
|
||||
if (!Json::parseFromStream(rbuilder, config_doc, &root, &errs))
|
||||
{
|
||||
FS_ERROR("{0}", errs.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
std::string currentUser = GetCurrentUser();
|
||||
auto projectNames = root.getMemberNames();
|
||||
|
||||
std::sort(projectNames.begin(), projectNames.end());
|
||||
|
||||
for(auto &name: projectNames)
|
||||
{
|
||||
std::string type = root[name]["Type"].asString();
|
||||
|
||||
if (type == "data")
|
||||
{
|
||||
std::string aliasName = root[name]["AliasName"].asString();
|
||||
std::string location = root[name]["Location"].asString();
|
||||
std::string ntPath = root[name]["NT"].asString();
|
||||
std::string unixPath = root[name]["UNIX"].asString();
|
||||
StringList users;
|
||||
bool isProjectMember = false;
|
||||
if (!root[name]["USER"].isNull())
|
||||
{
|
||||
for (auto& user : root[name]["USER"])
|
||||
{
|
||||
users.push_back(user.asString());
|
||||
}
|
||||
}
|
||||
std::string currentLocation = GetCurrentLocation();
|
||||
if (currentLocation == location)
|
||||
{
|
||||
// Current User Name in Project Users
|
||||
if (std::find(users.begin(), users.end(), currentUser) != users.end())
|
||||
{
|
||||
Project p(name, aliasName, type, location, ntPath, unixPath, users);
|
||||
m_UserProjectList.push_back(p);
|
||||
FS_INFO("Project :{0}", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For debug only
|
||||
/*for (auto &p : m_CurrentProjectList)
|
||||
{
|
||||
FS_INFO("Check {0}", p.GetName());
|
||||
ProjectData data = p.GetProjectData();
|
||||
FS_INFO("Check {0}", data.GetShotLastReviewConfigPath());
|
||||
for (auto&e : p.GetProjectData().GetEpisodeList())
|
||||
{
|
||||
FS_INFO("{0}", e.c_str());
|
||||
}
|
||||
}*/
|
||||
|
||||
//std::sort(m_ProjectNames.begin(), m_ProjectNames.end());
|
||||
}
|
||||
|
||||
void ProjectInfo::Shutdown()
|
||||
{
|
||||
m_UserProjectList.clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <json/json.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
#include "FlipScope/Pipeline/Project.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
typedef std::vector<Project> ProjectList;
|
||||
|
||||
class ProjectInfo
|
||||
{
|
||||
public:
|
||||
|
||||
ProjectInfo();
|
||||
~ProjectInfo();
|
||||
|
||||
void Init();
|
||||
void Reload();
|
||||
void Shutdown();
|
||||
|
||||
public:
|
||||
static std::string GetCurrentLocation();
|
||||
static std::string GetCurrentUser();
|
||||
|
||||
Project GetCurrentProjectByName(std::string projectName);
|
||||
ProjectList GetUserProjects();
|
||||
|
||||
private:
|
||||
bool m_Initialized = false;
|
||||
ProjectList m_UserProjectList;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Pipeline/Shot.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
Shot::Shot( const std::string name,
|
||||
const std::string act,
|
||||
const std::string sequence,
|
||||
const int frameStart,
|
||||
const int frameEnd,
|
||||
const int duration,
|
||||
const int handleLeft,
|
||||
const int handleRight,
|
||||
const std::string shotType,
|
||||
const std::string projectName,
|
||||
const std::string episodeName)
|
||||
: m_Name(name),
|
||||
m_Act(act),
|
||||
m_Sequence(sequence),
|
||||
m_FrameStart(frameStart),
|
||||
m_FrameEnd(frameEnd),
|
||||
m_Duration(duration),
|
||||
m_HandleLeft(handleLeft),
|
||||
m_HandleRight(handleRight),
|
||||
m_ShotType(shotType),
|
||||
m_ProjectName(projectName),
|
||||
m_EpisodeName(episodeName)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
|
||||
class Shot
|
||||
{
|
||||
public:
|
||||
|
||||
Shot( const std::string name,
|
||||
const std::string act,
|
||||
const std::string sequence,
|
||||
const int frameStart,
|
||||
const int frameEnd,
|
||||
const int duration,
|
||||
const int handleLeft,
|
||||
const int handleRight,
|
||||
const std::string shotType,
|
||||
const std::string projectName,
|
||||
const std::string episodeName);
|
||||
~Shot(){};
|
||||
|
||||
std::string GetName() { return m_Name; }
|
||||
std::string GetAct() { return m_Act; }
|
||||
std::string GetSequence() { return m_Sequence; }
|
||||
int GetFrameStart() { return m_FrameStart; }
|
||||
int GetFrameEnd() { return m_FrameEnd; }
|
||||
std::string GetProjectName() { return m_ProjectName; }
|
||||
std::string GetEpisodeName() { return m_EpisodeName; }
|
||||
|
||||
private:
|
||||
std::string m_Name;
|
||||
std::string m_Act;
|
||||
std::string m_Sequence;
|
||||
int m_FrameStart = 0;
|
||||
int m_FrameEnd = 0;
|
||||
int m_Duration = 0;
|
||||
int m_HandleLeft = 0;
|
||||
int m_HandleRight = 0;
|
||||
std::string m_ShotType;
|
||||
|
||||
std::string m_ProjectName;
|
||||
std::string m_EpisodeName;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Renderer/FrameBuffer.h"
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
#include "Platform/OpenGL/OpenGLFramebuffer.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::shared_ptr<Framebuffer> Framebuffer::Create(const FramebufferSpecification& spec)
|
||||
{
|
||||
switch (Renderer::GetAPI())
|
||||
{
|
||||
case RendererAPI::API::None:
|
||||
return nullptr;
|
||||
case RendererAPI::API::OpenGL:
|
||||
return std::make_shared<OpenGLFramebuffer>(spec);
|
||||
}
|
||||
|
||||
FS_ERROR("Unknown RendererAPI!");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <memory>
|
||||
namespace FSV
|
||||
{
|
||||
struct FramebufferSpecification
|
||||
{
|
||||
uint32_t Width, Height;
|
||||
uint32_t Sample = 1;
|
||||
bool SwapChainTarget = false;
|
||||
};
|
||||
|
||||
class Framebuffer
|
||||
{
|
||||
public:
|
||||
virtual void Bind() = 0;
|
||||
virtual void Unbind() = 0;
|
||||
|
||||
virtual void Resize(uint32_t width, uint32_t height) = 0;
|
||||
|
||||
virtual uint32_t GetColorAttachmentRendererID() const = 0;
|
||||
|
||||
virtual const FramebufferSpecification& GetSpecification() const = 0;
|
||||
|
||||
static std::shared_ptr<Framebuffer> Create(const FramebufferSpecification& spec);
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Renderer/GraphicsContext.h"
|
||||
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
#include "Platform/OpenGL/OpenGLContext.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::unique_ptr<GraphicsContext> GraphicsContext::Create(void* window)
|
||||
{
|
||||
switch (Renderer::GetAPI())
|
||||
{
|
||||
case RendererAPI::API::None:
|
||||
return nullptr;
|
||||
case RendererAPI::API::OpenGL:
|
||||
return std::make_unique<OpenGLContext>(static_cast<GLFWwindow*>(window));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class GraphicsContext
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void SwapBuffers() = 0;
|
||||
|
||||
static std::unique_ptr<GraphicsContext> Create(void* window);
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Renderer/RenderCommand.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::unique_ptr<RendererAPI> RenderCommand::s_RendererAPI = RendererAPI::Create();
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Renderer/RendererAPI.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class RenderCommand
|
||||
{
|
||||
public:
|
||||
static void Init()
|
||||
{
|
||||
s_RendererAPI->Init();
|
||||
}
|
||||
|
||||
static void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
|
||||
{
|
||||
s_RendererAPI->SetViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
static void SetClearColor(glm::vec4& color)
|
||||
{
|
||||
s_RendererAPI->SetClearColor(color);
|
||||
}
|
||||
static void Clear()
|
||||
{
|
||||
s_RendererAPI->Clear();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::unique_ptr<RendererAPI> s_RendererAPI;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
void Renderer::Init()
|
||||
{
|
||||
RenderCommand::Init();
|
||||
}
|
||||
|
||||
void Renderer::BeginScene()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Renderer::EndScene()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Renderer::OnWindowResize(uint32_t width, uint32_t height)
|
||||
{
|
||||
RenderCommand::SetViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
void Renderer::Shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#include "FlipScope/Renderer/RenderCommand.h"
|
||||
#include "FlipScope/Renderer/RendererAPI.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
static void Shutdown();
|
||||
|
||||
static void OnWindowResize(uint32_t width, uint32_t height);
|
||||
|
||||
static void BeginScene();
|
||||
static void EndScene();
|
||||
|
||||
inline static RendererAPI::API GetAPI() { return RendererAPI::GetAPI(); }
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Renderer/RendererAPI.h"
|
||||
#include "Platform/OpenGL/OpenGLRendererAPI.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
RendererAPI::API RendererAPI::s_API = RendererAPI::API::OpenGL;
|
||||
std::unique_ptr<RendererAPI> RendererAPI::Create()
|
||||
{
|
||||
switch (s_API)
|
||||
{
|
||||
case RendererAPI::API::OpenGL: return std::make_unique<OpenGLRendererAPI>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class RendererAPI
|
||||
{
|
||||
public:
|
||||
enum class API
|
||||
{
|
||||
None = 0, OpenGL = 1
|
||||
};
|
||||
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) = 0;
|
||||
virtual void SetClearColor(const glm::vec4& color) = 0;
|
||||
|
||||
virtual void Clear() = 0;
|
||||
|
||||
inline static API GetAPI() { return s_API; }
|
||||
|
||||
static std::unique_ptr<RendererAPI> Create();
|
||||
|
||||
private:
|
||||
static API s_API;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Renderer/Texture.h"
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
#include "Platform/OpenGL/OpenGLTexture.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::shared_ptr<Texture> Texture::Create(uint32_t width, uint32_t height)
|
||||
{
|
||||
switch (Renderer::GetAPI())
|
||||
{
|
||||
case RendererAPI::API::None:
|
||||
{
|
||||
FS_ERROR("RendererAPI::None is currently not supported!");
|
||||
return nullptr;
|
||||
}
|
||||
case RendererAPI::API::OpenGL:
|
||||
return std::make_shared<OpenGLTexture>(width, height);
|
||||
}
|
||||
|
||||
FS_ERROR("Unknown RendererAPI");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Texture> Texture::Create(const std::string& path)
|
||||
{
|
||||
switch (Renderer::GetAPI())
|
||||
{
|
||||
case RendererAPI::API::None:
|
||||
{
|
||||
FS_ERROR("RendererAPI::None is currently not supported!");
|
||||
return nullptr;
|
||||
}
|
||||
case RendererAPI::API::OpenGL:
|
||||
return std::make_shared<OpenGLTexture>(path);
|
||||
}
|
||||
|
||||
FS_ERROR("Unknown RendererAPI");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
~Texture() = default;
|
||||
|
||||
virtual uint32_t GetWidth() const = 0;
|
||||
virtual uint32_t GetHeight() const = 0;
|
||||
virtual uint32_t GetRendererID() const = 0;
|
||||
|
||||
virtual void SetData(void* data, uint32_t size) const = 0;
|
||||
|
||||
|
||||
virtual void Bind(uint32_t slot = 0) const = 0;
|
||||
virtual bool operator==(const Texture& other) const = 0;
|
||||
|
||||
static std::shared_ptr<Texture> Create(uint32_t width, uint32_t height);
|
||||
static std::shared_ptr<Texture> Create(const std::string& path);
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Renderer/ViewportRenderer.h"
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
#include "Platform/OpenGL/OpenGLViewportRenderer.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
std::shared_ptr<ViewportRenderer> ViewportRenderer::Create()
|
||||
{
|
||||
switch (Renderer::GetAPI())
|
||||
{
|
||||
case RendererAPI::API::None:
|
||||
return nullptr;
|
||||
case RendererAPI::API::OpenGL:
|
||||
return std::make_shared<OpenGLViewportRenderer>();
|
||||
}
|
||||
|
||||
FS_ERROR("Unknown RendererAPI");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class ViewportRenderer
|
||||
{
|
||||
public:
|
||||
ViewportRenderer() = default;
|
||||
~ViewportRenderer() = default;
|
||||
|
||||
static std::shared_ptr<ViewportRenderer> Create();
|
||||
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual uint32_t GetWidth() const = 0;
|
||||
virtual uint32_t GetHeight() const = 0;
|
||||
|
||||
virtual void OnWindowResize(uint32_t width, uint32_t height) = 0;
|
||||
|
||||
virtual void OnRender() = 0;
|
||||
|
||||
inline static RendererAPI::API GetAPI() { return RendererAPI::GetAPI(); }
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,300 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Usd/FreeCamera.h"
|
||||
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
FreeCamera::FreeCamera(CameraOptions option, bool isZUp, float fov=60.0)
|
||||
: m_Options(option)
|
||||
{
|
||||
m_Camera = GfCamera();
|
||||
m_Camera.SetPerspectiveFromAspectRatioAndFieldOfView(1.0, fov, GfCamera::FOVVertical);
|
||||
|
||||
ResetClipingPlanes();
|
||||
|
||||
m_IsZUp = isZUp;
|
||||
m_CameraTransformDirty = true;
|
||||
|
||||
m_RotTheta = 0;
|
||||
m_RotPhi = 0;
|
||||
m_RotPsi = 0;
|
||||
m_Center = GfVec3d(0, 0, 0);
|
||||
m_Dist = 100;
|
||||
m_Camera.SetFocusDistance(m_Dist);
|
||||
m_SelSize = 10;
|
||||
|
||||
if (isZUp)
|
||||
{
|
||||
m_YZUpMatrix = GfMatrix4d().SetRotate(GfRotation(GfVec3d().XAxis(), -90));
|
||||
m_YZUpInvMatrix = m_YZUpMatrix.GetInverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_YZUpMatrix = GfMatrix4d(1.0);
|
||||
m_YZUpInvMatrix = GfMatrix4d(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
FreeCamera::~FreeCamera()
|
||||
{
|
||||
}
|
||||
|
||||
float FreeCamera::GetFov()
|
||||
{
|
||||
// The vertical field of view, in degrees, for perspective cameras.
|
||||
// For orthographic cameras fov is the height of the view frustum, in
|
||||
// world units.
|
||||
//
|
||||
if (m_Camera.GetProjection() == GfCamera::Projection::Perspective)
|
||||
{
|
||||
return m_Camera.GetFieldOfView(GfCamera::FOVVertical);
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_Camera.GetVerticalAperture() * GfCamera::APERTURE_UNIT;
|
||||
}
|
||||
}
|
||||
|
||||
void FreeCamera::SetFov(float value)
|
||||
{
|
||||
if (m_Camera.GetProjection() == GfCamera::Projection::Perspective)
|
||||
{
|
||||
m_Camera.SetPerspectiveFromAspectRatioAndFieldOfView(
|
||||
m_Camera.GetAspectRatio(), value, GfCamera::FOVVertical);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Camera.SetOrthographicFromAspectRatioAndSize(
|
||||
m_Camera.GetAspectRatio(), value, GfCamera::FOVVertical);
|
||||
}
|
||||
}
|
||||
|
||||
float FreeCamera::GetNearClip()
|
||||
{
|
||||
return m_Camera.GetClippingRange().GetMin();
|
||||
}
|
||||
|
||||
float FreeCamera::GetFarClip()
|
||||
{
|
||||
return m_Camera.GetClippingRange().GetMax();
|
||||
}
|
||||
|
||||
void FreeCamera::ResetClipingPlanes()
|
||||
{
|
||||
double _near = m_OverrideNear || m_Options.DefaultNear;
|
||||
double _far = m_OverrideFar || m_Options.DefaultFar;
|
||||
m_Camera.SetClippingRange(GfRange1f(_near, _far));
|
||||
}
|
||||
|
||||
void FreeCamera::FrameSelection(GfBBox3d selBBox, float frameFit)
|
||||
{
|
||||
m_ClosestVisibleDist = -1;
|
||||
m_Center = selBBox.ComputeCentroid();
|
||||
GfRange3d selRange = selBBox.ComputeAlignedRange();
|
||||
GfVec3d selSize = selRange.GetSize();
|
||||
m_SelSize = std::max(std::max(selSize[0], selSize[1]), selSize[2]);
|
||||
if (IsOrthographic())
|
||||
{
|
||||
//m_Fov = m_SelSize * frameFit;
|
||||
SetFov(m_SelSize * frameFit);
|
||||
m_Dist = m_SelSize + m_Options.DefaultNear;
|
||||
}
|
||||
else
|
||||
{
|
||||
float fov = GetFov();
|
||||
float halfFov = fov * 0.5 || 0.5;
|
||||
float lengthToFit = m_SelSize * frameFit * 0.5;
|
||||
m_Dist = lengthToFit / atan(((halfFov * M_PI) / 180.0));
|
||||
|
||||
if (m_Dist < (m_Options.DefaultNear + m_SelSize * 0.5))
|
||||
{
|
||||
m_Dist = m_Options.DefaultNear + lengthToFit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FreeCamera::SetClosestVisibleDistFromPoint(GfVec3d point)
|
||||
{
|
||||
GfFrustum frustum = m_Camera.GetFrustum();
|
||||
GfVec3d camPos = frustum.GetPosition();
|
||||
GfRay camRay = GfRay(camPos, frustum.ComputeViewDirection());
|
||||
m_ClosestVisibleDist = camRay.FindClosestPoint(point)[1];
|
||||
m_LastFramedDist = m_Dist;
|
||||
m_LastFramedClosestDist = m_ClosestVisibleDist;
|
||||
}
|
||||
|
||||
float FreeCamera::ComputePixelsToWorldFactor(int viewportHeight)
|
||||
{
|
||||
PushToCameraTransform();
|
||||
if (IsOrthographic())
|
||||
{
|
||||
return GetFov() / viewportHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
float frustumHeight = m_Camera.GetFrustum().GetWindow().GetSize()[1];
|
||||
return frustumHeight * m_Dist / viewportHeight;
|
||||
}
|
||||
}
|
||||
|
||||
bool FreeCamera::IsOrthographic()
|
||||
{
|
||||
return m_Camera.GetProjection() == GfCamera::Projection::Orthographic;
|
||||
}
|
||||
|
||||
void FreeCamera::SetProjection(GfCamera::Projection projection)
|
||||
{
|
||||
m_Camera.SetProjection(projection);
|
||||
}
|
||||
|
||||
GfCamera::Projection FreeCamera::GetProjection()
|
||||
{
|
||||
return m_Camera.GetProjection();
|
||||
}
|
||||
|
||||
void FreeCamera::SetClippingPlanes(GfBBox3d stageBBox)
|
||||
{
|
||||
//TfDebug::IsDebugSymbolNameEnabled();
|
||||
|
||||
double computedNear, computedFar = 0;
|
||||
if (stageBBox.GetRange().IsEmpty() || (m_OverrideNear && m_OverrideFar))
|
||||
{
|
||||
computedNear = m_Options.DefaultNear;
|
||||
computedFar = m_Options.DefaultFar;
|
||||
}
|
||||
else
|
||||
{
|
||||
GfFrustum frustum = m_Camera.GetFrustum();
|
||||
GfVec3d camPos = frustum.GetPosition();
|
||||
GfRay camRay = GfRay(camPos, frustum.ComputeViewDirection());
|
||||
|
||||
RangeOfBoxAlongRay(computedNear, computedFar, camRay, stageBBox);
|
||||
double precisionNear = computedFar / m_Options.MaxGoodZResolution;
|
||||
|
||||
if (m_ClosestVisibleDist)
|
||||
{
|
||||
double halfClose = m_ClosestVisibleDist / 2.0;
|
||||
if (m_ClosestVisibleDist < m_LastFramedClosestDist)
|
||||
{
|
||||
halfClose = std::max(std::max(precisionNear, halfClose), computedNear);
|
||||
}
|
||||
|
||||
if (halfClose < computedNear)
|
||||
{
|
||||
computedNear = halfClose;
|
||||
}
|
||||
else if (precisionNear > computedNear)
|
||||
{
|
||||
computedNear = std::min(((precisionNear + halfClose) / 2.0), halfClose);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double _near = m_OverrideNear || computedNear;
|
||||
double _far = m_OverrideFar || computedFar;
|
||||
|
||||
_far = std::max(_near + 1, _far);
|
||||
m_Camera.SetClippingRange(GfRange1f(_near, _far));
|
||||
|
||||
}
|
||||
|
||||
GfCamera FreeCamera::ComputeGfCamera(GfBBox3d stageBBox, bool autoClip=true)
|
||||
{
|
||||
PushToCameraTransform();
|
||||
|
||||
if (autoClip)
|
||||
SetClippingPlanes(stageBBox);
|
||||
else
|
||||
ResetClipingPlanes();
|
||||
|
||||
return m_Camera;
|
||||
}
|
||||
|
||||
GfMatrix4d FreeCamera::RotMatrix(GfVec3d &vec, double angle)
|
||||
{
|
||||
return GfMatrix4d(1.0).SetRotate(GfRotation(vec, angle));
|
||||
}
|
||||
|
||||
void FreeCamera::RangeOfBoxAlongRay(double &minDist, double &maxDist, GfRay camRay, GfBBox3d stageBBox)
|
||||
{
|
||||
minDist = -1 * std::numeric_limits<float>::min();
|
||||
maxDist = 1 * std::numeric_limits<float>::max();
|
||||
|
||||
GfRange3d boxRange = stageBBox.GetRange();
|
||||
GfMatrix4d boxXform = stageBBox.GetMatrix();
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
GfVec3d point = boxXform.Transform(boxRange.GetCorner(i));
|
||||
double pointDist = camRay.FindClosestPoint(point)[1];
|
||||
if (pointDist > maxDist)
|
||||
maxDist = pointDist;
|
||||
if (pointDist < minDist)
|
||||
minDist = pointDist;
|
||||
}
|
||||
if (minDist < m_Options.DefaultNear)
|
||||
minDist = m_Options.DefaultNear;
|
||||
else
|
||||
minDist *= 0.99;
|
||||
|
||||
maxDist *= 1.01;
|
||||
}
|
||||
|
||||
void FreeCamera::PushToCameraTransform()
|
||||
{
|
||||
// Updates the camera's transform matrix, that is, the matrix that brings
|
||||
// the camera to the origin, with the camera view pointing down:
|
||||
// +Y if this is a Zup camera, or
|
||||
// -Z if this is a Yup camera .
|
||||
|
||||
if (!m_CameraTransformDirty)
|
||||
return;
|
||||
|
||||
m_Camera.SetTransform(GfMatrix4d().SetTranslate(GfVec3d().ZAxis() * m_Dist) *
|
||||
RotMatrix(GfVec3d().ZAxis(), -m_RotPsi) *
|
||||
RotMatrix(GfVec3d().XAxis(), -m_RotPhi) *
|
||||
RotMatrix(GfVec3d().YAxis(), -m_RotTheta) *
|
||||
m_YZUpInvMatrix *
|
||||
GfMatrix4d().SetTranslate(m_Center)
|
||||
);
|
||||
|
||||
m_Camera.SetFocusDistance(m_Dist);
|
||||
m_CameraTransformDirty = false;
|
||||
}
|
||||
|
||||
void FreeCamera::PullFromCameraTransform()
|
||||
{
|
||||
// Updates parameters (center, rotTheta, etc.) from the camera transform.
|
||||
//
|
||||
// reads the transform set on the camera and updates all the other
|
||||
// parameters.This is the inverse of _pushToCameraTransform
|
||||
|
||||
GfMatrix4d camTransfrom = m_Camera.GetTransform();
|
||||
float dist = m_Camera.GetFocusDistance();
|
||||
GfFrustum frustum = m_Camera.GetFrustum();
|
||||
GfVec3d camPos = frustum.GetPosition();
|
||||
GfVec3d camAxis = frustum.ComputeViewDirection();
|
||||
|
||||
// Compute translational parts
|
||||
m_Dist = dist;
|
||||
m_SelSize = dist / 10.0;
|
||||
m_Center = camPos + dist * camAxis;
|
||||
|
||||
// Compute rotational part
|
||||
GfMatrix4d transform = camTransfrom * m_YZUpMatrix;
|
||||
transform.Orthonormalize();
|
||||
GfRotation rotation = transform.ExtractRotation();
|
||||
|
||||
// Decompose and set angles
|
||||
GfVec3d _decompose = -rotation.Decompose(GfVec3d().YAxis(), GfVec3d().XAxis(), GfVec3d().ZAxis());
|
||||
m_RotTheta = _decompose[0];
|
||||
m_RotPhi = _decompose[1];
|
||||
m_RotPsi = _decompose[2];
|
||||
|
||||
m_CameraTransformDirty = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
#pragma once
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/base/gf/camera.h"
|
||||
#include "pxr/base/gf/bbox3d.h"
|
||||
#include "pxr/base/gf/frustum.h"
|
||||
#include "pxr/base/tf/debug.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
struct CameraOptions
|
||||
{
|
||||
float DefaultNear = 1;
|
||||
float DefaultFar = 2000000;
|
||||
float MaxSafeZResolution = 1e6;
|
||||
float MaxGoodZResolution = 5e4;
|
||||
};
|
||||
|
||||
class FreeCamera
|
||||
{
|
||||
public:
|
||||
|
||||
FreeCamera(CameraOptions option, bool isZUp, float fov);
|
||||
~FreeCamera();
|
||||
CameraOptions GetOption() { return m_Options; }
|
||||
|
||||
GfCamera ComputeGfCamera(GfBBox3d stageBBox, bool autoClip);
|
||||
void SetClippingPlanes(GfBBox3d stageBBox);
|
||||
void ResetClipingPlanes();
|
||||
|
||||
void FrameSelection(GfBBox3d selBBox, float frameFit);
|
||||
void SetClosestVisibleDistFromPoint(GfVec3d point);
|
||||
|
||||
float ComputePixelsToWorldFactor(int viewportHeight);
|
||||
|
||||
bool IsOrthographic();
|
||||
void SetProjection(GfCamera::Projection projection);
|
||||
GfCamera::Projection GetProjection();
|
||||
|
||||
GfMatrix4d RotMatrix(GfVec3d &vec, double angle);
|
||||
bool IsZUp() { return m_IsZUp; }
|
||||
|
||||
float GetFov();
|
||||
void SetFov(float value);
|
||||
|
||||
float GetNearClip();
|
||||
float GetFarClip();
|
||||
|
||||
private:
|
||||
|
||||
void RangeOfBoxAlongRay(double &minDist, double &maxDist, GfRay camRay, GfBBox3d stageBBox);
|
||||
void PushToCameraTransform();
|
||||
void PullFromCameraTransform();
|
||||
|
||||
CameraOptions m_Options;
|
||||
GfCamera m_Camera;
|
||||
|
||||
bool m_IsZUp;
|
||||
float m_RotTheta;
|
||||
float m_RotPhi;
|
||||
float m_RotPsi;
|
||||
|
||||
GfVec3d m_Center;
|
||||
GfMatrix4d m_YZUpMatrix;
|
||||
GfMatrix4d m_YZUpInvMatrix;
|
||||
|
||||
float m_Dist;
|
||||
float m_OverrideNear = -1;
|
||||
float m_OverrideFar = -1;
|
||||
|
||||
float m_ClosestVisibleDist = -1;
|
||||
float m_LastFramedDist = -1;
|
||||
float m_LastFramedClosestDist = -1;
|
||||
|
||||
float m_Fov;
|
||||
float m_SelSize;
|
||||
|
||||
bool m_CameraTransformDirty = false;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "pch.h"
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/imaging/glf/drawTarget.h"
|
||||
#include "pxr/imaging/hd/engine.h"
|
||||
#include "pxr/imaging/hd/renderIndex.h"
|
||||
#include "pxr/imaging/hd/rendererPlugin.h"
|
||||
#include "pxr/imaging/hd/rprimCollection.h"
|
||||
#include "pxr/imaging/hdSt/renderDelegate.h"
|
||||
#include "pxr/imaging/hdx/taskController.h"
|
||||
|
||||
#include "pxr/usdImaging/usdImagingGL/engine.h"
|
||||
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
using HgiUniquePtr = std::unique_ptr<class Hgi>;
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class HdRenderer
|
||||
{
|
||||
public:
|
||||
HdRenderer(uint32_t width, uint32_t height);
|
||||
~HdRenderer();
|
||||
private:
|
||||
uint32_t _width, _height;
|
||||
|
||||
GlfDrawTargetRefPtr _drawTarget;
|
||||
|
||||
HgiUniquePtr _hgi;
|
||||
HdEngine _engine;
|
||||
HdRendererPlugin* _renderPlugin = nullptr;
|
||||
HdxTaskController* _taskController = nullptr;
|
||||
HdRenderIndex* _renderIndex = nullptr;
|
||||
HdxSelectionTrackerSharedPtr _selectionTracker;
|
||||
HdRprimCollection _renderCollection
|
||||
{
|
||||
HdTokens->geometry,
|
||||
HdReprSelector(HdReprTokens->refined),
|
||||
SdfPath::AbsoluteRootPath()
|
||||
};
|
||||
HdRprimCollection _selectionCollection{ HdReprTokens->wire,
|
||||
HdReprSelector(HdReprTokens->wire) };
|
||||
HdRprimCollection _pointSnappingCollection{
|
||||
HdTokens->geometry,
|
||||
HdReprSelector(HdReprTokens->refined, TfToken(), HdReprTokens->points),
|
||||
SdfPath::AbsoluteRootPath()
|
||||
};
|
||||
|
||||
GlfSimpleLight _defaultLight;
|
||||
GfVec4d _viewport;
|
||||
|
||||
const bool _isUsingHdSt = false;
|
||||
bool _initializationAttempted = false;
|
||||
bool _initializationSucceeded = false;
|
||||
bool _hasDefaultLighting = false;
|
||||
bool _selectionChanged = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,488 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
//#include <GL/glew.h>
|
||||
#include <imgui.h>
|
||||
|
||||
#include "FlipScope/Core/Application.h"
|
||||
#include "FlipScope/Usd/HydraRenderer.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usdGeom/metrics.h"
|
||||
#include "pxr/usd/usdGeom/bboxCache.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
#include "pxr/imaging/glf/contextCaps.h"
|
||||
#include "pxr/imaging/glf/simpleLightingContext.h"
|
||||
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
HydraRenderer::HydraRenderer(uint32_t width, uint32_t height)
|
||||
:m_Width(width), m_Height(height)
|
||||
{
|
||||
m_Translate[0] = 0.0;
|
||||
m_Translate[1] = 1000.0;
|
||||
m_Translate[2] = 2500.0;
|
||||
|
||||
}
|
||||
|
||||
HydraRenderer::~HydraRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HydraRenderer::Init(uint32_t width, uint32_t height)
|
||||
{
|
||||
GlfContextCaps::InitInstance();
|
||||
|
||||
// Build render target
|
||||
m_DrawTarget = GlfDrawTarget::New(GfVec2i(GetWidth(), GetHeight()));
|
||||
|
||||
m_DrawTarget->Bind();
|
||||
|
||||
m_DrawTarget->AddAttachment("color", GL_RGBA, GL_FLOAT, GL_RGBA);
|
||||
m_DrawTarget->AddAttachment("depth", GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F);
|
||||
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
|
||||
SetupRenderer(true);
|
||||
|
||||
m_DrawTarget->Unbind();
|
||||
}
|
||||
|
||||
void HydraRenderer::SetupRenderer(bool IsInit=false)
|
||||
{
|
||||
FS_INFO("SetupRenderer() : Setp UsdImagingGLEngine.");
|
||||
|
||||
AppController& controller = Application::GetController();
|
||||
m_Stage = controller.GetStageDataModel()->GetStage();
|
||||
|
||||
//m_Stage = UsdStage::Open("C:/TEMP/Kitchen_set/Kitchen_set.usd");
|
||||
//m_Stage = UsdStage::CreateInMemory("");
|
||||
|
||||
SdfPathVector excludedPaths;
|
||||
|
||||
if (UsdImagingGLEngine::IsHydraEnabled()) {
|
||||
|
||||
FS_INFO("Using HD Renderer");
|
||||
m_Renderer.reset(new UsdImagingGLEngine(m_Stage->GetPseudoRoot().GetPath(), excludedPaths));
|
||||
if (!m_CurrentRenderer.empty())
|
||||
{
|
||||
if (!m_Renderer->SetRendererPlugin(TfToken(m_CurrentRenderer)))
|
||||
{
|
||||
FS_ERROR("Couldn't set renderer plugin: {0}", m_CurrentRenderer);
|
||||
}
|
||||
else {
|
||||
FS_INFO("Renderer plugin: {0}", m_CurrentRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
FS_INFO("Using Reference Renderer");
|
||||
m_Renderer.reset(new UsdImagingGLEngine(m_Stage->GetPseudoRoot().GetPath(), excludedPaths));
|
||||
}
|
||||
|
||||
if (controller.IsStageChanged() || IsInit)
|
||||
{
|
||||
m_ShouldFrameAll = true;
|
||||
|
||||
if (m_ShouldFrameAll)
|
||||
{
|
||||
TfTokenVector purposes;
|
||||
purposes.push_back(UsdGeomTokens->default_);
|
||||
purposes.push_back(UsdGeomTokens->proxy);
|
||||
|
||||
bool useExtentHints = true;
|
||||
UsdGeomBBoxCache bboxCache(UsdTimeCode::Default(), purposes, useExtentHints);
|
||||
|
||||
GfBBox3d bbox = bboxCache.ComputeWorldBound(m_Stage->GetPseudoRoot());
|
||||
GfRange3d world = bbox.ComputeAlignedRange();
|
||||
|
||||
GfVec3d worldCenter = (world.GetMin() + world.GetMax()) / 2.0;
|
||||
double worldSize = world.GetSize().GetLength();
|
||||
|
||||
if (UsdGeomGetStageUpAxis(m_Stage) == UsdGeomTokens->z)
|
||||
{
|
||||
m_Translate[0] = -worldCenter[0];
|
||||
m_Translate[1] = -worldCenter[2];
|
||||
m_Translate[2] = -worldCenter[1] - worldSize;
|
||||
}
|
||||
else {
|
||||
m_Translate[0] = -worldCenter[0];
|
||||
m_Translate[1] = -worldCenter[1];
|
||||
m_Translate[2] = -worldCenter[2] - worldSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsEnabledLighting())
|
||||
{
|
||||
if (UsdImagingGLEngine::IsHydraEnabled()) {
|
||||
m_LightingContext = GlfSimpleLightingContext::New();
|
||||
GlfSimpleLight light;
|
||||
|
||||
if (IsEnabledCameraLight()) {
|
||||
|
||||
light.SetPosition(GfVec4f(m_Translate[0], m_Translate[2], m_Translate[1], 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
light.SetPosition(GfVec4f(0, -.5, .5, 0));
|
||||
}
|
||||
light.SetDiffuse(GfVec4f(1, 1, 1, 1));
|
||||
light.SetAmbient(GfVec4f(0, 0, 0, 1));
|
||||
light.SetSpecular(GfVec4f(1, 1, 1, 1));
|
||||
GlfSimpleLightVector lights;
|
||||
lights.push_back(light);
|
||||
m_LightingContext->SetLights(lights);
|
||||
|
||||
GlfSimpleMaterial material;
|
||||
material.SetAmbient(GfVec4f(0.2, 0.2, 0.2, 1.0));
|
||||
material.SetDiffuse(GfVec4f(0.8, 0.8, 0.8, 1.0));
|
||||
material.SetSpecular(GfVec4f(0, 0, 0, 1));
|
||||
material.SetShininess(0.0001f);
|
||||
m_LightingContext->SetMaterial(material);
|
||||
m_LightingContext->SetSceneAmbient(GfVec4f(0.2, 0.2, 0.2, 1.0));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
if (IsEnabledCameraLight())
|
||||
{
|
||||
float position[4] = { m_Translate[0], m_Translate[2], m_Translate[1], 0 };
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, position);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
float position[4] = { 0,-.5,.5,0 };
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint32_t HydraRenderer::GetRendererID()
|
||||
{
|
||||
return m_DrawTarget->GetAttachment("color")->GetGlTextureName();
|
||||
}
|
||||
|
||||
void HydraRenderer::Shutdown()
|
||||
{
|
||||
m_DrawTarget = GlfDrawTargetRefPtr();
|
||||
FS_INFO("Shutdown HydraEngine");
|
||||
m_Renderer->InvalidateBuffers();
|
||||
}
|
||||
|
||||
void HydraRenderer::OnWindowResize(uint32_t width, uint32_t height)
|
||||
{
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
//FS_INFO("OnWindowResize :: {}, {}", width, height);
|
||||
OnRender();
|
||||
}
|
||||
|
||||
void HydraRenderer::OnRender()
|
||||
{
|
||||
int width = GetWidth();
|
||||
int height = GetHeight();
|
||||
|
||||
//FS_INFO("OnRender :: {}, {}", width, height);
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
m_DrawTarget->Bind();
|
||||
m_DrawTarget->SetSize(GfVec2i(width, height));
|
||||
|
||||
// Draw Code Here
|
||||
OnDraw();
|
||||
|
||||
m_DrawTarget->Unbind();
|
||||
|
||||
/*
|
||||
//Blit color framebuffer to screen
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_DrawTarget->GetFramebufferId());
|
||||
|
||||
glBlitFramebuffer(0, 0, width, height,
|
||||
0, 0, width, height,
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
*/
|
||||
}
|
||||
|
||||
void HydraRenderer::OnDraw()
|
||||
{
|
||||
int width = GetWidth();
|
||||
int height = GetHeight();
|
||||
//m_DrawTarget->SetSize(GfVec2i(width, height));
|
||||
//FS_INFO("HydraRenderer::Draw : {0}, {1}", width, height);
|
||||
//m_DrawTarget->Bind();
|
||||
|
||||
|
||||
GfVec4d viewport(0, 0, width, height);
|
||||
|
||||
if (GetCameraPath().empty())
|
||||
{
|
||||
//FS_INFO("CameraPath Empty");
|
||||
|
||||
GfMatrix4d viewMatrix(1.0);
|
||||
viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(0, 1, 0), m_Rotate[0]));
|
||||
viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(1, 0, 0), m_Rotate[1]));
|
||||
viewMatrix *= GfMatrix4d().SetTranslate(GfVec3d(m_Translate[0], m_Translate[1], m_Translate[2]));
|
||||
|
||||
//FS_INFO("Camera Rotate [{0}, {1}]", m_Rotate[0], m_Rotate[1]);
|
||||
//FS_INFO("Camera Translate [{0}, {1}, {2}]", m_Translate[0], m_Translate[1], m_Translate[2]);
|
||||
|
||||
GfMatrix4d modelViewMatrix = viewMatrix;
|
||||
if (UsdGeomGetStageUpAxis(m_Stage) == UsdGeomTokens->z) {
|
||||
// rotate from z-up to y-up
|
||||
modelViewMatrix =
|
||||
GfMatrix4d().SetRotate(GfRotation(GfVec3d(1.0, 0.0, 0.0), -90.0)) *
|
||||
modelViewMatrix;
|
||||
}
|
||||
|
||||
const double aspectRatio = double(width) / height;
|
||||
GfFrustum frustum;
|
||||
frustum.SetPerspective(60.0, aspectRatio, 1, 100000.0);
|
||||
const GfMatrix4d projMatrix = frustum.ComputeProjectionMatrix();
|
||||
|
||||
m_Renderer->SetCameraState(modelViewMatrix, projMatrix);
|
||||
|
||||
} else {
|
||||
m_Renderer->SetCameraPath(SdfPath(GetCameraPath()));
|
||||
}
|
||||
|
||||
GfVec4f const &clearColor = GfVec4f(0.12f, 0.12f, 0.12f, 1.0f);
|
||||
|
||||
m_Renderer->SetRenderViewport(viewport);
|
||||
|
||||
m_RenderParams = UsdImagingGLRenderParams();
|
||||
m_RenderParams.enableLighting = true;
|
||||
m_RenderParams.showGuides = true;
|
||||
m_RenderParams.showRender = false;
|
||||
m_RenderParams.showProxy = true;
|
||||
m_RenderParams.clearColor = clearColor;
|
||||
m_RenderParams.forceRefresh = true;
|
||||
m_RenderParams.drawMode = UsdImagingGLDrawMode::DRAW_SHADED_SMOOTH;
|
||||
//m_RenderParams.clipPlanes =
|
||||
glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
|
||||
|
||||
if (GetCurrentRendererName() == "GL")
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
m_Renderer->SetRendererAov(TfToken("color"));
|
||||
|
||||
if (IsEnabledLighting())
|
||||
{
|
||||
if (UsdImagingGLEngine::IsHydraEnabled())
|
||||
{
|
||||
m_Renderer->SetLightingState(m_LightingContext);
|
||||
} else {
|
||||
m_Renderer->SetLightingStateFromOpenGL();
|
||||
}
|
||||
}
|
||||
/*
|
||||
bool const clearOnlyOnce = true;
|
||||
bool cleared = false;
|
||||
int convergenceIterations = 0;
|
||||
GLfloat clearDepth[1] = { 1.0f };
|
||||
|
||||
do {
|
||||
convergenceIterations++;
|
||||
|
||||
if (cleared && clearOnlyOnce)
|
||||
{
|
||||
// Don't clear the FBO
|
||||
} else {
|
||||
glClearBufferfv(GL_COLOR, 0, clearColor.data());
|
||||
glClearBufferfv(GL_DEPTH, 0, clearDepth);
|
||||
cleared = true;
|
||||
}
|
||||
|
||||
m_Engine->Render(m_Stage->GetPseudoRoot(), m_RenderParams);
|
||||
//m_Engine->InvalidateBuffers();
|
||||
|
||||
} while (!m_Engine->IsConverged());*/
|
||||
|
||||
m_Renderer->Render(m_Stage->GetPseudoRoot(), m_RenderParams);
|
||||
|
||||
//glFinish();
|
||||
//m_DrawTarget->Unbind();
|
||||
//FS_INFO("Iterations to convergence: {}", convergenceIterations);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void DrawAxis()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TfTokenVector HydraRenderer::GetRendererPlugins()
|
||||
{
|
||||
TfTokenVector rendererPlugins = m_Renderer->GetRendererPlugins();
|
||||
return rendererPlugins;
|
||||
}
|
||||
|
||||
std::vector<std::string> HydraRenderer::GetRendererPluginsNames()
|
||||
{
|
||||
std::vector<std::string> rendererPluginNames;
|
||||
for (auto &plugin : GetRendererPlugins())
|
||||
{
|
||||
rendererPluginNames.push_back(GetRenderer()->GetRendererDisplayName(plugin));
|
||||
}
|
||||
return rendererPluginNames;
|
||||
}
|
||||
|
||||
TfToken HydraRenderer::GetCurrentRenderer()
|
||||
{
|
||||
return GetRenderer()->GetCurrentRendererId();
|
||||
}
|
||||
|
||||
std::string HydraRenderer::GetCurrentRendererName()
|
||||
{
|
||||
//FS_INFO("GetCurrentRendererName : {}", GetCurrentRenderer().GetText());
|
||||
return GetRenderer()->GetRendererDisplayName(GetCurrentRenderer());
|
||||
}
|
||||
|
||||
void HydraRenderer::SetCurrentRenderer(std::string rendererName)
|
||||
{
|
||||
TfToken rendererId;
|
||||
for (auto &plugin : GetRendererPlugins())
|
||||
{
|
||||
if (GetRenderer()->GetRendererDisplayName(plugin) == rendererName)
|
||||
{
|
||||
rendererId = plugin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rendererId.IsEmpty())
|
||||
{
|
||||
FS_WARN("Renderer name : \"{}\" not in register renderer plugin list, skip...", rendererName);
|
||||
return;
|
||||
}
|
||||
m_CurrentRenderer = rendererId;
|
||||
SetupRenderer();
|
||||
//GetEngine()->SetRendererPlugin(rendererId);
|
||||
//GetEngine()->SetRendererAov(TfToken("color"));
|
||||
}
|
||||
|
||||
void HydraRenderer::SetCurrentRenderer(TfToken rendererId)
|
||||
{
|
||||
TfTokenVector rendererPlugins = GetRendererPlugins();
|
||||
auto it = std::find(rendererPlugins.begin(), rendererPlugins.end(), rendererId);
|
||||
if (it == rendererPlugins.end())
|
||||
{
|
||||
FS_WARN("Renderer plugin : \"{}\" not in register renderer plugin list, skip...", rendererId.GetString());
|
||||
return;
|
||||
}
|
||||
GetRenderer()->SetRendererPlugin(rendererId);
|
||||
}
|
||||
|
||||
bool HydraRenderer::WriteToFile(std::string const & attachment, std::string const & filename)
|
||||
{
|
||||
if (m_DrawTarget->IsBound())
|
||||
m_DrawTarget->Unbind();
|
||||
|
||||
bool result = m_DrawTarget->WriteToFile(attachment, filename);
|
||||
|
||||
if (m_DrawTarget->IsBound())
|
||||
m_DrawTarget->Bind();
|
||||
|
||||
FS_INFO("Write {0} attachment to {1}", attachment, filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
void HydraRenderer::OnMousePress(bool button[], int x, int y, const int& modKeys)
|
||||
{
|
||||
FS_INFO("Mouse Press ({}, {}, {}) : {} : {}", button[0], button[1], button[2], x, y);
|
||||
|
||||
m_MouseButton[0] = button[0];
|
||||
m_MouseButton[1] = button[1];
|
||||
m_MouseButton[2] = button[2];
|
||||
|
||||
if (modKeys & ImGuiKeyModFlags_Alt)
|
||||
{
|
||||
m_MousePos[0] = x;
|
||||
m_MousePos[1] = y;
|
||||
}
|
||||
}
|
||||
|
||||
void HydraRenderer::OnMouseRelease(bool button[], int x, int y, const int& modKeys)
|
||||
{
|
||||
FS_INFO("Mouse Release ({}, {}, {}) : {} : {}", button[0], button[1], button[2], x, y);
|
||||
|
||||
m_MouseButton[0] = button[0];
|
||||
m_MouseButton[1] = button[1];
|
||||
m_MouseButton[2] = button[2];
|
||||
}
|
||||
|
||||
void HydraRenderer::OnMouseMove(bool button[], int x, int y, const int& modKeys)
|
||||
{
|
||||
FS_INFO("Mouse Move Buttons : {0}, {1}, {2}", m_MouseButton[0], m_MouseButton[1], m_MouseButton[2]);
|
||||
|
||||
int dx = x - m_MousePos[0];
|
||||
int dy = y - m_MousePos[1];
|
||||
|
||||
if (modKeys & ImGuiKeyModFlags_Alt)
|
||||
{
|
||||
if (m_MouseButton[0]) {
|
||||
m_Rotate[0] += dx;
|
||||
m_Rotate[1] += dy;
|
||||
}
|
||||
else if (m_MouseButton[2]) {
|
||||
m_Translate[0] += dx;
|
||||
m_Translate[1] -= dy;
|
||||
}
|
||||
else if (m_MouseButton[1]) {
|
||||
m_Translate[2] += dx;
|
||||
}
|
||||
|
||||
m_MousePos[0] = x;
|
||||
m_MousePos[1] = y;
|
||||
}
|
||||
}
|
||||
|
||||
void HydraRenderer::ResolveCamera()
|
||||
{
|
||||
}
|
||||
|
||||
void HydraRenderer::ComputePickFrustum(int x, int y)
|
||||
{
|
||||
}
|
||||
|
||||
void HydraRenderer::PickObject(int x, int y, bool button[], const int & modKeys)
|
||||
{
|
||||
}
|
||||
|
||||
void HydraRenderer::UpdateSelection()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Core/AppController.h"
|
||||
#include "FlipScope/Renderer/ViewportRenderer.h"
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/imaging/glf/drawTarget.h"
|
||||
#include "pxr/usdImaging/usdImagingGL/engine.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class HydraRenderer
|
||||
{
|
||||
public:
|
||||
HydraRenderer(uint32_t width, uint32_t height);
|
||||
~HydraRenderer();
|
||||
|
||||
virtual void Init(uint32_t width, uint32_t height);
|
||||
virtual void SetupRenderer(bool IsInit);
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual uint32_t GetWidth() { return m_Width; }
|
||||
virtual uint32_t GetHeight() { return m_Height; }
|
||||
|
||||
UsdStageRefPtr GetStage() { return m_Stage; }
|
||||
std::shared_ptr<UsdImagingGLEngine> GetRenderer() { return m_Renderer; }
|
||||
|
||||
virtual void OnWindowResize(uint32_t width, uint32_t height);
|
||||
|
||||
virtual void OnRender();
|
||||
virtual void OnDraw();
|
||||
|
||||
void DrawAxis();
|
||||
|
||||
std::string GetCameraPath() { return m_CameraPath; }
|
||||
|
||||
TfTokenVector GetRendererPlugins();
|
||||
std::vector<std::string> GetRendererPluginsNames();
|
||||
TfToken GetCurrentRenderer();
|
||||
std::string GetCurrentRendererName();
|
||||
|
||||
void SetCurrentRenderer(std::string rendererName);
|
||||
void SetCurrentRenderer(TfToken renderer);
|
||||
|
||||
// Lighting Settings
|
||||
bool IsEnabledLighting() { return m_EnabledLighting; }
|
||||
void SetEnabledLighting(bool enabled) { m_EnabledLighting = enabled; }
|
||||
bool IsEnabledCameraLight() { return m_EnabledCameraLight; }
|
||||
void SetEnabledCameraLight(bool enabled) { m_EnabledCameraLight = enabled; }
|
||||
|
||||
uint32_t GetRendererID();
|
||||
|
||||
bool WriteToFile(std::string const & attachment, std::string const & filename);
|
||||
|
||||
void OnMousePress(bool button[], int x, int y, const int& modKeys);
|
||||
void OnMouseRelease(bool button[], int x, int y, const int& modKeys);
|
||||
void OnMouseMove(bool button[], int x, int y, const int& modKeys);
|
||||
|
||||
void ResolveCamera();
|
||||
void ComputePickFrustum(int x, int y);
|
||||
void PickObject(int x, int y, bool button[], const int& modKeys);
|
||||
void UpdateSelection();
|
||||
|
||||
private:
|
||||
uint32_t m_Width, m_Height = 0;
|
||||
AppController *m_Controller;
|
||||
|
||||
UsdStageRefPtr m_Stage;
|
||||
|
||||
std::string m_CurrentRenderer;
|
||||
std::shared_ptr<UsdImagingGLEngine> m_Renderer;
|
||||
|
||||
GlfDrawTargetRefPtr m_DrawTarget;
|
||||
|
||||
UsdImagingGLRenderParams m_RenderParams;
|
||||
|
||||
bool m_ShouldFrameAll = false;
|
||||
|
||||
GlfSimpleLightingContextRefPtr m_LightingContext;
|
||||
bool m_EnabledLighting = true;
|
||||
bool m_EnabledCameraLight = false;
|
||||
|
||||
// For Camera manipulate transform
|
||||
std::string m_CameraPath;
|
||||
|
||||
float m_Translate[3];
|
||||
float m_Rotate[2];
|
||||
|
||||
int m_MousePos[2];
|
||||
bool m_MouseButton[3];
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
#include "FlipScope/Usd/SelectionModel.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <pxr/pxr.h>
|
||||
#include <pxr/usd/usd/prim.h>
|
||||
|
||||
FSV::SelectionModel::SelectionModel()
|
||||
{
|
||||
}
|
||||
|
||||
FSV::SelectionModel::~SelectionModel()
|
||||
{
|
||||
}
|
||||
|
||||
bool FSV::SelectionModel::IsSelected(UsdPrim& prim)
|
||||
{
|
||||
if(HasPrim(prim))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void FSV::SelectionModel::AddSelection(UsdPrim& prim)
|
||||
{
|
||||
Clear();
|
||||
//m_SelectionData.push_back(prim.GetPrimPath().GetString());
|
||||
AppendSelection(prim);
|
||||
//FS_INFO("Add to Selection : {}, HasPrim : {}", prim.GetPrimPath().GetString(), HasPrim(prim));
|
||||
}
|
||||
|
||||
void FSV::SelectionModel::AppendSelection(UsdPrim & prim)
|
||||
{
|
||||
if (IsSelected(prim))
|
||||
return;
|
||||
m_SelectionData.push_back(prim.GetPrimPath().GetString());
|
||||
m_SelectionPrimData.push_back(prim);
|
||||
//FS_INFO("Append to Selection : {}", prim.GetPrimPath().GetString());
|
||||
}
|
||||
|
||||
void FSV::SelectionModel::Clear()
|
||||
{
|
||||
m_SelectionData.clear();
|
||||
m_SelectionPrimData.clear();
|
||||
}
|
||||
|
||||
bool FSV::SelectionModel::HasPrim(UsdPrim & prim)
|
||||
{
|
||||
return std::find(m_SelectionData.begin(), m_SelectionData.end(), prim.GetPrimPath().GetString()) != m_SelectionData.end();
|
||||
}
|
||||
|
||||
UsdPrim& FSV::SelectionModel::CurrentSelection()
|
||||
{
|
||||
return UsdPrim();
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <pxr/pxr.h>
|
||||
#include <pxr/usd/usd/prim.h>
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
typedef std::vector<std::string> SelectionData;
|
||||
typedef std::vector<UsdPrim> SelectionPrimData;
|
||||
class SelectionModel
|
||||
{
|
||||
public:
|
||||
SelectionModel();
|
||||
~SelectionModel();
|
||||
|
||||
bool IsSelected(UsdPrim& prim);
|
||||
|
||||
void AddSelection(UsdPrim& prim);
|
||||
void AppendSelection(UsdPrim& prim);
|
||||
SelectionData GetSelection() { return m_SelectionData; };
|
||||
UsdPrim& CurrentSelection();
|
||||
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
bool HasPrim(UsdPrim& prim);
|
||||
|
||||
SelectionData m_SelectionData;
|
||||
SelectionPrimData m_SelectionPrimData;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Usd/StageDataModel.h"
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
#include "pxr/usd/usd/notice.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
StageDataModel::StageDataModel()
|
||||
{
|
||||
TfTokenVector includedPurposes;
|
||||
includedPurposes.push_back(UsdGeomTokens->default_);
|
||||
includedPurposes.push_back(UsdGeomTokens->proxy);
|
||||
m_BboxCache = std::make_shared<UsdGeomBBoxCache>(GetCurrentFrame(), includedPurposes);
|
||||
|
||||
m_XformCache = std::make_shared<UsdGeomXformCache>();
|
||||
//m_Stage = UsdStage::CreateNew("C:/Temp/Test.usd");
|
||||
//m_Stage = UsdStage::Open("C:/TEMP/Kitchen_set/Kitchen_set.usd");
|
||||
//SetStage(UsdStage::Open("C:/TEMP/Kitchen_set/Kitchen_set.usd"));
|
||||
}
|
||||
|
||||
StageDataModel::~StageDataModel()
|
||||
{
|
||||
}
|
||||
|
||||
void StageDataModel::SetStage(UsdStageRefPtr stage)
|
||||
{
|
||||
m_StageNoticeListener.SetStage(UsdStageWeakPtr());
|
||||
m_StageNoticeListener.SetStageContentsChangedCallback(nullptr);
|
||||
m_StageNoticeListener.SetStageObjectsChangedCallback(nullptr);
|
||||
|
||||
m_Stage = stage;
|
||||
|
||||
m_StageNoticeListener.SetStage(stage);
|
||||
m_StageNoticeListener.SetStageContentsChangedCallback(
|
||||
std::bind(&StageDataModel::OnStageContentChanged,
|
||||
this,
|
||||
std::placeholders::_1));
|
||||
|
||||
m_StageNoticeListener.SetStageObjectsChangedCallback(
|
||||
std::bind(&StageDataModel::OnStageObjectChanged,
|
||||
this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
void StageDataModel::GetStageCamera()
|
||||
{
|
||||
}
|
||||
|
||||
void StageDataModel::SetCurrentFrame(double value)
|
||||
{
|
||||
m_CurrentFrame = UsdTimeCode(value);
|
||||
m_BboxCache->SetTime(m_CurrentFrame);
|
||||
m_XformCache->SetTime(m_CurrentFrame);
|
||||
}
|
||||
|
||||
TfTokenVector StageDataModel::GetIncludedPurposes()
|
||||
{
|
||||
return m_BboxCache->GetIncludedPurposes();
|
||||
}
|
||||
|
||||
void StageDataModel::SetIncludedPurposes(TfTokenVector includedPurposes)
|
||||
{
|
||||
m_BboxCache->SetIncludedPurposes(includedPurposes);
|
||||
}
|
||||
|
||||
GfBBox3d StageDataModel::ComputeWorldBound(const UsdPrim & prim)
|
||||
{
|
||||
return m_BboxCache->ComputeWorldBound(prim);
|
||||
}
|
||||
|
||||
GfMatrix4d StageDataModel::GetLocalToWorldTransform(const UsdPrim & prim)
|
||||
{
|
||||
return m_XformCache->GetLocalToWorldTransform(prim);
|
||||
}
|
||||
|
||||
UsdShadeMaterial StageDataModel::ComputeBoundMaterial(const UsdPrim & prim)
|
||||
{
|
||||
return UsdShadeMaterialBindingAPI(prim).ComputeBoundMaterial();
|
||||
}
|
||||
|
||||
void StageDataModel::OnStageContentChanged(const UsdNotice::StageContentsChanged & notice)
|
||||
{
|
||||
}
|
||||
|
||||
void StageDataModel::OnStageObjectChanged(const UsdNotice::ObjectsChanged & notice)
|
||||
{
|
||||
/*for (auto i : notice.GetResyncedPaths()) {
|
||||
}*/
|
||||
}
|
||||
|
||||
void StageDataModel::ClearCaches()
|
||||
{
|
||||
m_BboxCache->Clear();
|
||||
m_XformCache->Clear();
|
||||
}
|
||||
std::unique_ptr<StageDataModel> StageDataModel::Create()
|
||||
{
|
||||
return std::make_unique<StageDataModel>();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usd/timecode.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/bboxCache.h"
|
||||
#include "pxr/usd/usdGeom/xformCache.h"
|
||||
#include "pxr/base/tf/notice.h"
|
||||
#include "pxr/usd/usdShade/materialBindingAPI.h"
|
||||
|
||||
#include "FlipScope/Usd/StageNoticeListener.h"
|
||||
#include "FlipScope/Usd/SelectionModel.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class StageDataModel
|
||||
{
|
||||
public:
|
||||
StageDataModel();
|
||||
~StageDataModel();
|
||||
|
||||
UsdStageRefPtr GetStage() { return m_Stage; };
|
||||
void SetStage(UsdStageRefPtr stage);
|
||||
|
||||
std::string GetStageFilePath() { return m_StageFilePath; }
|
||||
void SetStageFilePath(std::string filePath) { m_StageFilePath = filePath; }
|
||||
|
||||
void GetStageCamera();
|
||||
|
||||
UsdTimeCode GetCurrentFrame() { return m_CurrentFrame; };
|
||||
void SetCurrentFrame(double value);
|
||||
|
||||
TfTokenVector GetIncludedPurposes();
|
||||
void SetIncludedPurposes(TfTokenVector includedPurposes);
|
||||
//void OnPrimChanged(UsdNotice::ObjectsChanged ¬ice, UsdStageWeakPtr &stage);
|
||||
|
||||
GfBBox3d ComputeWorldBound(const UsdPrim& prim) ;
|
||||
GfMatrix4d GetLocalToWorldTransform(const UsdPrim& prim);
|
||||
UsdShadeMaterial ComputeBoundMaterial(const UsdPrim& prim);
|
||||
|
||||
void OnStageContentChanged(const UsdNotice::StageContentsChanged& notice);
|
||||
void OnStageObjectChanged(const UsdNotice::ObjectsChanged& notice);
|
||||
|
||||
bool IsPlaying() { return m_Playing; };
|
||||
void SetPlaying(bool playing) { m_Playing = playing; };
|
||||
|
||||
void ClearCaches();
|
||||
|
||||
static std::unique_ptr<StageDataModel> Create();
|
||||
|
||||
SelectionModel& GetSelectionModel() { return m_SelectionModel; }
|
||||
|
||||
private:
|
||||
UsdTimeCode m_CurrentFrame = UsdTimeCode::Default();
|
||||
UsdStageRefPtr m_Stage;
|
||||
|
||||
std::string m_StageFilePath;
|
||||
|
||||
std::shared_ptr<UsdGeomBBoxCache> m_BboxCache;
|
||||
std::shared_ptr<UsdGeomXformCache> m_XformCache;
|
||||
|
||||
StageNoticeListener m_StageNoticeListener;
|
||||
|
||||
SelectionModel m_SelectionModel;
|
||||
|
||||
bool m_Playing;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Usd/StageNoticeListener.h"
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/base/tf/notice.h"
|
||||
#include "pxr/base/tf/weakBase.h"
|
||||
#include "pxr/usd/usd/notice.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
StageNoticeListener::~StageNoticeListener()
|
||||
{
|
||||
if (m_StageContentsChangedKey.IsValid()) {
|
||||
TfNotice::Revoke(m_StageContentsChangedKey);
|
||||
}
|
||||
if (m_StageObjectsChangedKey.IsValid()) {
|
||||
TfNotice::Revoke(m_StageObjectsChangedKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StageNoticeListener::SetStage(const UsdStageWeakPtr & stage)
|
||||
{
|
||||
m_Stage = stage;
|
||||
UpdateStageContentsChangedRegistration();
|
||||
}
|
||||
|
||||
void StageNoticeListener::SetStageContentsChangedCallback(const StageContentsChangedCallback & callback)
|
||||
{
|
||||
m_StageContentsChangedCallback = callback;
|
||||
UpdateStageContentsChangedRegistration();
|
||||
}
|
||||
|
||||
void StageNoticeListener::SetStageObjectsChangedCallback(const StageObjectsChangedCallback & callback)
|
||||
{
|
||||
m_StageObjectsChangedCallback = callback;
|
||||
}
|
||||
|
||||
void StageNoticeListener::UpdateStageContentsChangedRegistration()
|
||||
{
|
||||
if (m_Stage && m_StageContentsChangedCallback) {
|
||||
// Register for notices if we're not already listening.
|
||||
if (!m_StageContentsChangedKey.IsValid()) {
|
||||
m_StageContentsChangedKey = TfNotice::Register( TfCreateWeakPtr(this), &StageNoticeListener::OnStageContentsChanged);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// Either the stage or the callback is invalid, so stop listening for
|
||||
// notices.
|
||||
if (m_StageContentsChangedKey.IsValid()) {
|
||||
TfNotice::Revoke(m_StageContentsChangedKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Stage && m_StageObjectsChangedCallback) {
|
||||
|
||||
// Register for notices if we're not already listening.
|
||||
if (!m_StageObjectsChangedKey.IsValid()) {
|
||||
m_StageObjectsChangedKey =
|
||||
TfNotice::Register(TfCreateWeakPtr(this), &StageNoticeListener::OnStageObjectsChanged, m_Stage);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_StageObjectsChangedKey.IsValid()) {
|
||||
TfNotice::Revoke(m_StageObjectsChangedKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StageNoticeListener::OnStageContentsChanged(const UsdNotice::StageContentsChanged & notice) const
|
||||
{
|
||||
if (notice.GetStage() == m_Stage && m_StageContentsChangedCallback)
|
||||
{
|
||||
m_StageContentsChangedCallback(notice);
|
||||
}
|
||||
}
|
||||
|
||||
void StageNoticeListener::OnStageObjectsChanged(const UsdNotice::ObjectsChanged & notice, const UsdStageWeakPtr & sender) const
|
||||
{
|
||||
if (notice.GetStage() == m_Stage && m_StageObjectsChangedCallback)
|
||||
{
|
||||
m_StageObjectsChangedCallback(notice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/base/tf/notice.h"
|
||||
#include "pxr/base/tf/weakBase.h"
|
||||
#include "pxr/usd/usd/notice.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class StageNoticeListener : public TfWeakBase
|
||||
{
|
||||
public:
|
||||
StageNoticeListener() = default;
|
||||
virtual ~StageNoticeListener();
|
||||
|
||||
void SetStage(const UsdStageWeakPtr& stage);
|
||||
|
||||
using StageContentsChangedCallback = std::function<void(const UsdNotice::StageContentsChanged& notice)>;
|
||||
using StageObjectsChangedCallback = std::function<void(const UsdNotice::ObjectsChanged& notice)>;
|
||||
|
||||
void SetStageContentsChangedCallback( const StageContentsChangedCallback& callback );
|
||||
void SetStageObjectsChangedCallback( const StageObjectsChangedCallback& callback );
|
||||
|
||||
|
||||
private:
|
||||
UsdStageWeakPtr m_Stage;
|
||||
StageNoticeListener(const StageNoticeListener&) = delete;
|
||||
|
||||
TfNotice::Key m_StageContentsChangedKey{};
|
||||
StageContentsChangedCallback m_StageContentsChangedCallback{};
|
||||
|
||||
TfNotice::Key m_StageObjectsChangedKey{};
|
||||
StageObjectsChangedCallback m_StageObjectsChangedCallback{};
|
||||
|
||||
void UpdateStageContentsChangedRegistration();
|
||||
void OnStageContentsChanged( const UsdNotice::StageContentsChanged& notice) const;
|
||||
void OnStageObjectsChanged( const UsdNotice::ObjectsChanged& notice, const UsdStageWeakPtr& sender) const;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "ViewSettings.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
ViewSettings::ViewSettings(Settings settings)
|
||||
{
|
||||
}
|
||||
|
||||
ViewSettings::~ViewSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool ViewSettings::SaveSettings()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewSettings::LoadSettings()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
#pragma once
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/base/gf/vec4f.h"
|
||||
#include "pxr/usdImaging/usdImagingGL/renderParams.h"
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
const char* colorCorrectModes[] = { "disabled", "sRGB", "openColorIO" };
|
||||
enum ColorCorrectModes
|
||||
{
|
||||
DISABLE,
|
||||
SRGB,
|
||||
OPENCOLORIO
|
||||
};
|
||||
const char* pickModes[] = {"Prims", "Models", "Instances", "Prototypes"};
|
||||
enum PickModes
|
||||
{
|
||||
PRIMS,
|
||||
MODELS,
|
||||
INSTANCES,
|
||||
PROTOTYPES
|
||||
};
|
||||
const char* selectionHightlightModes[] = { "Never", "Only when paused", "Always" };
|
||||
struct Settings
|
||||
{
|
||||
UsdImagingGLDrawMode renderMode = UsdImagingGLDrawMode::DRAW_SHADED_SMOOTH;
|
||||
float freeCameraFOV = 60.0;
|
||||
TfToken colorCorrectionMode = TfToken(colorCorrectModes[ColorCorrectModes::SRGB]);
|
||||
GfVec4f highlightColor = { 1.0, 1.0, 0.0, 0.5 };
|
||||
GfVec4f backgroundColor = {};
|
||||
bool cameraLightEnabled = true;
|
||||
bool domeLightEnabled = false;
|
||||
bool ambientLightOnly = true;
|
||||
TfToken pickMode = TfToken(pickModes[PickModes::PRIMS]);
|
||||
bool showBBoxes = true;
|
||||
bool showAABBoxes = true;
|
||||
bool displayGuide = false;
|
||||
bool displayProxy = true;
|
||||
bool displayRender = false;
|
||||
bool enableSceneMaterials = true;
|
||||
bool showInactivePrims = true;
|
||||
bool showMasterPrims = false;
|
||||
bool showUndefinedPrims = false;
|
||||
bool showAbstractPrims = false;
|
||||
bool showHUD = true;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class ViewSettings
|
||||
{
|
||||
public:
|
||||
ViewSettings(Settings settings);
|
||||
~ViewSettings();
|
||||
|
||||
Settings Get() { return m_Settings; }
|
||||
void Set(Settings settings) { m_Settings = settings; }
|
||||
|
||||
bool SaveSettings();
|
||||
bool LoadSettings();
|
||||
|
||||
private:
|
||||
Settings m_Settings;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "ShotView.h"
|
||||
|
||||
#include "FlipScope/Core/Application.h"
|
||||
|
||||
#include "FlipScope/Pipeline/ProjectInfo.h"
|
||||
#include "FlipScope/Pipeline/Project.h"
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
ShotView::ShotView()
|
||||
{
|
||||
}
|
||||
ShotView::~ShotView()
|
||||
{
|
||||
}
|
||||
void ShotView::Show(bool * p_open)
|
||||
{
|
||||
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
if (!ImGui::Begin("Shots", p_open))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ProjectInfo projectInfo = Application::GetProjectInfo();
|
||||
static ProjectList projectList = projectInfo.GetUserProjects();
|
||||
|
||||
static Project* currentProject = nullptr;
|
||||
|
||||
static std::string currentEpisodeName;
|
||||
static StringList episodeNameList;
|
||||
|
||||
static std::string currentShotName;
|
||||
static ShotList shotList;
|
||||
|
||||
if (currentProject == nullptr && projectList.size())
|
||||
{
|
||||
currentProject = &projectList[0];
|
||||
episodeNameList = currentProject->GetEpisodeNameList();
|
||||
if (episodeNameList.size() && !currentEpisodeName.length())
|
||||
{
|
||||
currentEpisodeName = episodeNameList[0];
|
||||
shotList = currentProject->GetShotListByEpisode(currentEpisodeName);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginCombo("Project", currentProject->GetAliasName().c_str(), (ImGuiComboFlags)projectList.size()))
|
||||
{
|
||||
for (int n = 0; n < projectList.size(); n++)
|
||||
{
|
||||
bool is_selected = (currentProject->GetAliasName() == projectList[n].GetAliasName());
|
||||
if (ImGui::Selectable(projectList[n].GetAliasName().c_str(), is_selected))
|
||||
{
|
||||
currentProject = &projectList[n];
|
||||
|
||||
// Reload Episode List
|
||||
episodeNameList = currentProject->GetEpisodeNameList();
|
||||
currentEpisodeName = "";
|
||||
currentShotName = "";
|
||||
if (episodeNameList.size() && !currentEpisodeName.length())
|
||||
{
|
||||
currentEpisodeName = episodeNameList[0];
|
||||
|
||||
// Reload Shot List
|
||||
shotList = currentProject->GetShotListByEpisode(currentEpisodeName);
|
||||
if (shotList.size() && !currentShotName.length())
|
||||
{
|
||||
currentShotName = shotList[0].GetName();
|
||||
}
|
||||
}
|
||||
FS_INFO("{0}", projectList[n].GetAliasName().c_str());
|
||||
}
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
if (ImGui::BeginCombo("Episode", currentEpisodeName.c_str(), (ImGuiComboFlags)episodeNameList.size()))
|
||||
{
|
||||
for (int n = 0; n < episodeNameList.size(); n++)
|
||||
{
|
||||
bool is_selected = (currentEpisodeName == episodeNameList[n]);
|
||||
if (ImGui::Selectable(episodeNameList[n].c_str(), is_selected))
|
||||
{
|
||||
currentEpisodeName = episodeNameList[n];
|
||||
shotList = currentProject->GetShotListByEpisode(currentEpisodeName);
|
||||
// Reload Shot List
|
||||
currentShotName = "";
|
||||
shotList = currentProject->GetShotListByEpisode(currentEpisodeName);
|
||||
if (shotList.size() && !currentShotName.length())
|
||||
{
|
||||
currentShotName = shotList[0].GetName();
|
||||
}
|
||||
FS_INFO("Current Episode : {0}", currentEpisodeName);
|
||||
}
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
/*for (int n = 0; n < shotList.size(); n++)
|
||||
{
|
||||
FS_INFO("{0} : Shot : {1}", currentEpisodeName, shotList[n].GetName());
|
||||
}*/
|
||||
/*if (ImGui::BeginCombo("Shot", currentShotName.c_str(), shotList.size()))
|
||||
{
|
||||
for (int n = 0; n < shotList.size(); n++)
|
||||
{
|
||||
bool is_selected = (currentShotName == shotList[n].GetName());
|
||||
if (ImGui::Selectable(shotList[n].GetName().c_str(), is_selected))
|
||||
{
|
||||
currentShotName = shotList[n].GetName();
|
||||
}
|
||||
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}*/
|
||||
|
||||
ImGui::ListBoxHeader("Shots");
|
||||
for (auto shot : shotList)
|
||||
{
|
||||
bool is_selected = (currentShotName == shot.GetName());
|
||||
if (ImGui::Selectable(shot.GetName().c_str(), is_selected))
|
||||
{
|
||||
currentShotName = shot.GetName();
|
||||
}
|
||||
}
|
||||
ImGui::ListBoxFooter();
|
||||
|
||||
const char* stage_items[] = { "Lay", "Ani", "Lgt", "Sim" };
|
||||
static const char* stage_item_current = stage_items[0];
|
||||
if (ImGui::BeginCombo("Stage", stage_item_current, IM_ARRAYSIZE(stage_items)))
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(stage_items); n++)
|
||||
{
|
||||
bool is_selected = (stage_item_current == stage_items[n]);
|
||||
if (ImGui::Selectable(stage_items[n], is_selected))
|
||||
stage_item_current = stage_items[n];
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
/*StringList shotNames = current_project.GetProjectData().GetEpisodeShotNameList(episode_item_current);
|
||||
FS_INFO("{0} : {1}", episode_item_current, shotNames.size());
|
||||
std::string shot_item_current = shotNames.size() ? shotNames[0] : "";
|
||||
if (ImGui::BeginCombo("Shots", shot_item_current.c_str(), shotNames.size()))
|
||||
{
|
||||
for (int n = 0; n < shotNames.size(); n++)
|
||||
{
|
||||
bool is_selected = (shot_item_current == shotNames[n]);
|
||||
if (ImGui::Selectable(shotNames[n].c_str(), is_selected))
|
||||
{
|
||||
shot_item_current = shotNames[n];
|
||||
FS_INFO("Current Shot : {0}", shot_item_current);
|
||||
}
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
|
||||
}*/
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class ShotView
|
||||
{
|
||||
public:
|
||||
ShotView();
|
||||
~ShotView();
|
||||
|
||||
void Show(bool *p_open);
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,358 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <icons_font_awesome5.h>
|
||||
|
||||
#include "FlipScope/Core/Application.h"
|
||||
#include "FlipScope/Core/AppController.h"
|
||||
#include "FlipScope/Widgets/StageView.h"
|
||||
|
||||
#include <pxr/pxr.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
StageView::StageView()
|
||||
{
|
||||
}
|
||||
|
||||
StageView::~StageView()
|
||||
{
|
||||
}
|
||||
|
||||
void StageView::InitToolBar()
|
||||
{
|
||||
AppController& controller = Application::GetController();
|
||||
|
||||
if (ImGui::Button(ICON_FA_PLUS, ImVec2(26.0f, 24.0f)))
|
||||
{
|
||||
ImGui::OpenPopup("Create Prim");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("Create Prim", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
static char primName[128] = "";
|
||||
static char primTypeName[64] = "";
|
||||
static bool useOverPrim = false;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::InputTextWithHint("Path", "Prim path start with /", primName, IM_ARRAYSIZE(primName));
|
||||
ImGui::Checkbox("Override", &useOverPrim);
|
||||
const char* stage_items[] = { "Xform", "Mesh", "Light", "Camera" };
|
||||
static const char* stage_item_current = stage_items[0];
|
||||
|
||||
if (useOverPrim)
|
||||
{
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
|
||||
}
|
||||
|
||||
if (ImGui::BeginCombo("Type", stage_item_current, IM_ARRAYSIZE(stage_items)))
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(stage_items); n++)
|
||||
{
|
||||
bool is_selected = (stage_item_current == stage_items[n]);
|
||||
if (ImGui::Selectable(stage_items[n], is_selected))
|
||||
stage_item_current = stage_items[n];
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
if (useOverPrim)
|
||||
{
|
||||
ImGui::PopItemFlag();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
if (ImGui::Button("OK", ImVec2(120, 0))) {
|
||||
controller.CreatePrim(primName, stage_item_current);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SetItemDefaultFocus();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel", ImVec2(120, 0))) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
/*if (ImGui::MenuItem("Override Prim", "Alt+O", false, true))
|
||||
{
|
||||
controller.CreateOverridePrim("/refPath");
|
||||
}*/
|
||||
|
||||
ImGui::SameLine(0.0, 2.0);
|
||||
ImGui::Button(ICON_FA_MINUS, ImVec2(26.0f, 24.0f));
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
void StageView::BuildTreeNode(UsdPrim &prim)
|
||||
{
|
||||
/*if (prim.GetChildren().empty())
|
||||
{
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Selectable(prim.GetName().GetText());
|
||||
//ImGui::Selectable(ICON_FA_HOME);
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(prim.GetTypeName().GetText());
|
||||
ImGui::NextColumn();
|
||||
}*/
|
||||
ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth;
|
||||
AppController& controller = Application::GetController();
|
||||
static SelectionModel selectionModel = controller.GetStageDataModel()->GetSelectionModel();
|
||||
|
||||
for (auto &p : prim.GetChildren())
|
||||
{
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGuiTreeNodeFlags node_flags = base_flags;
|
||||
|
||||
if (!p.GetChildren()) {
|
||||
node_flags = ImGuiTreeNodeFlags_Leaf;
|
||||
}
|
||||
|
||||
//const bool is_selected = selectionModel.HasPrim(p);
|
||||
|
||||
if (selectionModel.IsSelected(p)){
|
||||
node_flags |= ImGuiTreeNodeFlags_Selected;
|
||||
}
|
||||
|
||||
//bool p_open = ImGui::TreeNodeEx(ICON_FA_CUBE + p.GetName().GetText(), node_flags);
|
||||
char treeText[1024];
|
||||
//sprintf(treeText, "%s %s", ICON_FA_CUBE, p.GetName().GetText());
|
||||
//sprintf(treeText, "%sXX", p.GetName().GetText());
|
||||
//bool p_open = ImGui::TreeNodeEx(treeText, node_flags);
|
||||
|
||||
bool p_open = ImGui::TreeNodeEx(p.GetName().GetText(), node_flags);
|
||||
/*ImGui::SameLine();
|
||||
if (p.GetTypeName().GetString() == "Xform") {
|
||||
ImGui::TextColored(ImVec4(0.0, 1.0, 0.5, 1.0), ICON_FA_ASTERISK);
|
||||
}
|
||||
else if (p.GetTypeName().GetString() == "Mesh") {
|
||||
//ImGui::Text(ICON_FA_SHAPES);
|
||||
ImGui::TextColored(ImVec4(0.0, 0.5, 0.8, 1.0), ICON_FA_CUBE);
|
||||
}
|
||||
else if (p.GetTypeName().GetString() == "Camera") {
|
||||
ImGui::TextColored(ImVec4(0.0, 0.5, 0.8, 1.0), ICON_FA_CAMERA);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text(p.GetName().GetText());
|
||||
*/
|
||||
//ImGui::SameLine();
|
||||
//bool p_open = ImGui::TreeNodeEx(&p, node_flags, p.GetName().GetText());
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
if (ImGui::GetIO().KeyCtrl) {
|
||||
selectionModel.AppendSelection(p); // Append selection
|
||||
} else {
|
||||
selectionModel.AddSelection(p); // Add selection
|
||||
}
|
||||
}
|
||||
|
||||
// Some usaful icon
|
||||
// ICON_FA_SHAPES -
|
||||
// ICON_FA_LINK - Reference
|
||||
/*ImGui::AlignTextToFramePadding();
|
||||
if (p.GetTypeName().GetString() == "Xform") {
|
||||
ImGui::TextColored(ImVec4(0.0, 1.0, 0.5, 1.0), ICON_FA_ASTERISK);
|
||||
}
|
||||
else if (p.GetTypeName().GetString() == "Mesh") {
|
||||
//ImGui::Text(ICON_FA_SHAPES);
|
||||
ImGui::TextColored(ImVec4(0.0, 0.5, 0.8, 1.0), ICON_FA_CUBE);
|
||||
}
|
||||
else if (p.GetTypeName().GetString() == "Camera") {
|
||||
ImGui::TextColored(ImVec4(0.0, 0.5, 0.8, 1.0), ICON_FA_CAMERA);
|
||||
}*/
|
||||
/*node_flags = ImGuiTreeNodeFlags_Leaf;
|
||||
|
||||
if (selectionModel.IsSelected(p)) {
|
||||
node_flags |= ImGuiTreeNodeFlags_Selected;
|
||||
}*/
|
||||
//ImGui::TreeNodeEx(p.GetTypeName().GetText(), node_flags);
|
||||
|
||||
/*ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_None;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
float font_size = ImGui::GetFontSize();
|
||||
//ImGui::AlignTextToFramePadding();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.0, 0.5));
|
||||
ImGui::Selectable(p.GetTypeName().GetText(), selectionModel.IsSelected(p), selectable_flags, ImVec2(ImGui::GetColumnWidth(), font_size+ (style.FramePadding.y * 2) - 2));
|
||||
ImGui::PopStyleVar();
|
||||
//ImGui::SameLine();*/
|
||||
ImGui::AlignTextToFramePadding();
|
||||
char PrimTypeText[1024];
|
||||
auto PrimTypeColor = ImVec4(1.0, 1.0, 1.5, 1.0);
|
||||
if (p.GetTypeName().GetString() == "Xform")
|
||||
{
|
||||
PrimTypeColor = ImVec4(0.0, 1.0, 0.5, 1.0);
|
||||
sprintf(PrimTypeText, "%s %s", ICON_FA_ASTERISK, p.GetTypeName().GetText());
|
||||
}
|
||||
else if (p.GetTypeName().GetString() == "Mesh")
|
||||
{
|
||||
PrimTypeColor = ImVec4(0.0, 0.5, 0.8, 1.0);
|
||||
sprintf(PrimTypeText, "%s %s", ICON_FA_CUBE, p.GetTypeName().GetText());
|
||||
}
|
||||
else if (p.GetTypeName().GetString() == "Camera")
|
||||
{
|
||||
PrimTypeColor = ImVec4(0.0, 0.5, 0.8, 1.0);
|
||||
sprintf(PrimTypeText, "%s %s", ICON_FA_CAMERA, p.GetTypeName().GetText());
|
||||
}
|
||||
else {
|
||||
sprintf(PrimTypeText, "%s", p.GetTypeName().GetText());
|
||||
}
|
||||
|
||||
//ImGui::TextColored(PrimTypeColor, PrimTypeText);
|
||||
ImGui::SetItemAllowOverlap();
|
||||
//ImGui::Selectable(PrimTypeText, selectionModel.IsSelected(p), ImGuiSelectableFlags_SpanAllColumns);
|
||||
ImGui::Selectable(PrimTypeText, selectionModel.IsSelected(p));
|
||||
|
||||
//ImGui::Text(p.GetTypeName().GetText());
|
||||
ImGui::NextColumn();
|
||||
//ImGui::SetItemAllowOverlap();
|
||||
|
||||
/*auto primSpec = p.GetPrimDefinition();
|
||||
static bool isChecked = !primSpec->GetHidden();
|
||||
char chk_name[1024];
|
||||
sprintf(chk_name, "%s", p.GetPath().GetText());
|
||||
if (ImGui::Checkbox(chk_name, &isChecked))
|
||||
{
|
||||
FS_INFO("Changed {}:{}", p.GetPath().GetText(), isChecked);
|
||||
//isChecked ? p.SetHidden(true) : p.SetHidden(false);
|
||||
isChecked ? primSpec->SetHidden(true) : primSpec->SetHidden(false);
|
||||
}*/
|
||||
|
||||
constexpr const char* inheritedIcon = ICON_FA_EYE;
|
||||
UsdGeomImageable imageable(prim);
|
||||
|
||||
if (imageable) {
|
||||
VtValue visibleValue;
|
||||
auto attr = imageable.GetVisibilityAttr();
|
||||
if (attr.HasAuthoredValue()) {
|
||||
attr.Get(&visibleValue);
|
||||
const TfToken& visibilityToken = visibleValue.Get<TfToken>();
|
||||
const char* icon = visibilityToken == UsdGeomTokens->invisible
|
||||
? ICON_FA_EYE_SLASH : inheritedIcon;
|
||||
if (ImGui::SmallButton(icon)) {
|
||||
UsdTimeCode tc = UsdTimeCode::Default();
|
||||
if (visibilityToken == UsdGeomTokens->inherited) {
|
||||
attr.Set(VtValue(UsdGeomTokens->invisible), tc);
|
||||
}
|
||||
else if (visibilityToken == UsdGeomTokens->invisible)
|
||||
{
|
||||
prim.RemoveProperty(attr.GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ImGui::SmallButton(inheritedIcon)) {
|
||||
UsdTimeCode tc = UsdTimeCode::Default();
|
||||
attr.Set(VtValue(UsdGeomTokens->inherited), tc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ImGui::SmallButton("")
|
||||
ImGui::NextColumn();
|
||||
|
||||
if(p_open){
|
||||
BuildTreeNode(p);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StageView::BuildOutliner()
|
||||
{
|
||||
AppController& controller = Application::GetController();
|
||||
constexpr ImGuiTableFlags tableFlags = ImGuiTableFlags_SizingFixedFit | /*ImGuiTableFlags_RowBg |*/ ImGuiTableFlags_ScrollY | ImGuiTableFlags_Resizable;
|
||||
/*if (ImGui::BeginTable("##DrawStageOutliner", 3, tableFlags)) {
|
||||
ImGui::TableSetupScrollFreeze(3, 1); // Freeze the root node of the tree (the layer)
|
||||
ImGui::TableSetupColumn("Hierarchy");
|
||||
ImGui::TableSetupColumn("V", ImGuiTableColumnFlags_WidthFixed, 40);
|
||||
ImGui::TableSetupColumn("Type");
|
||||
|
||||
UsdPrim rootPrim = controller.GetStageDataModel()->GetStage()->GetPseudoRoot();
|
||||
SdfLayerHandle layer = controller.GetStageDataModel()->GetStage()->GetSessionLayer();
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGuiTreeNodeFlags nodeflags = ImGuiTreeNodeFlags_OpenOnArrow;
|
||||
|
||||
ImGuiListClipper clipper;
|
||||
|
||||
|
||||
ImGui::EndTable();
|
||||
}*/
|
||||
if (ImGui::BeginTable("split2", 3, ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody))
|
||||
{
|
||||
//ImGui::TableSetupScrollFreeze(3, 1); // Freeze the root node of the tree (the layer)
|
||||
ImGui::TableSetupColumn("Hierarchy", ImGuiTableColumnFlags_NoHide);
|
||||
ImGui::TableSetupColumn("V", ImGuiTableColumnFlags_WidthFixed, 40);
|
||||
ImGui::TableSetupColumn("Type");
|
||||
ImGui::TableHeadersRow();
|
||||
static bool selected[10] = {};
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
char label[32];
|
||||
sprintf(label, "Item %d", i);
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(label, &selected[i], ImGuiSelectableFlags_SpanAllColumns);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Some other contents");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("123456");
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
void StageView::BuildTreeItem(UsdPrim& prim)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StageView::Show(bool *p_open)
|
||||
{
|
||||
AppController& controller = Application::GetController();
|
||||
controller.GetStageDataModel()->GetStage();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 2));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 4));
|
||||
|
||||
if (!ImGui::Begin("Stage", p_open))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
//InitToolBar();
|
||||
|
||||
BuildOutliner();
|
||||
/*ImGui::Columns(3, "tree", true);
|
||||
ImGui::Text("Path");
|
||||
ImGui::NextColumn();
|
||||
|
||||
ImGui::Text("Type");
|
||||
ImGui::NextColumn();
|
||||
|
||||
ImGui::Text(ICON_FA_EYE);
|
||||
ImGui::NextColumn();
|
||||
|
||||
BuildTreeNode(controller.GetStageDataModel()->GetStage()->GetPseudoRoot());
|
||||
*/
|
||||
//ImGui::Columns(1);
|
||||
ImGui::PopStyleVar(3);
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Usd/StageDataModel.h"
|
||||
|
||||
|
||||
#include <pxr/pxr.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
|
||||
PXR_NAMESPACE_USING_DIRECTIVE
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class StageView
|
||||
{
|
||||
public:
|
||||
StageView();
|
||||
~StageView();
|
||||
void InitToolBar();
|
||||
|
||||
//StageDataModel* GetModel() { return m_StageDataModel; };
|
||||
//void SetModel(StageDataModel *model);
|
||||
void BuildTreeNode(UsdPrim &prim);
|
||||
void BuildOutliner();
|
||||
void BuildTreeItem(UsdPrim &prim);
|
||||
void Show(bool *p_open);
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <icons_font_awesome5.h>
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
#include "FlipScope/Widgets/Viewport.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
|
||||
Viewport::Viewport(uint32_t width, uint32_t height)
|
||||
:m_Width(width), m_Height(height)
|
||||
{
|
||||
m_HydraRenderer = std::make_shared<HydraRenderer>(width, height);
|
||||
m_HydraRenderer->Init(width, height);
|
||||
}
|
||||
|
||||
Viewport::~Viewport()
|
||||
{
|
||||
}
|
||||
|
||||
void Viewport::Update()
|
||||
{
|
||||
// Re-initialize Renderer
|
||||
m_HydraRenderer->SetupRenderer(false);
|
||||
}
|
||||
|
||||
void Viewport::Show(bool *p_open)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
/*#ifdef IMGUI_HAS_VIEWPORT
|
||||
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size);
|
||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Pos);
|
||||
#else
|
||||
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
||||
#endif*/
|
||||
ImGui::SetNextWindowSize(io.DisplaySize, ImGuiCond_Once);
|
||||
//ImGui::SetNextWindowSize(ImVec2(430, 450));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(1.0f, 1.0f));
|
||||
//ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 3.0f);
|
||||
std::string viewportName = "Viewport - (" + GetRenderer()->GetCurrentRendererName() + ")";
|
||||
|
||||
if (!ImGui::Begin(viewportName.c_str(), p_open))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
//InitToolBar();
|
||||
|
||||
ImVec2 viewportPos = ImGui::GetCursorScreenPos();
|
||||
ImVec2 viewportPanelSize = ImGui::GetContentRegionAvail();
|
||||
ImVec2 mousePosInViewport = ImVec2(io.MousePos.x - viewportPos.x, io.MousePos.y - viewportPos.y);
|
||||
|
||||
// FS_INFO("viewportPanelSize {}, {}", viewportPanelSize.x, viewportPanelSize.y);
|
||||
|
||||
/*bool IsMouseInViewport = false;
|
||||
if (mousePosInViewport.x > 0 && mousePosInViewport.x < viewportPanelSize.x &&
|
||||
mousePosInViewport.y > 0 && mousePosInViewport.y < viewportPanelSize.y)
|
||||
{
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NoMouse;
|
||||
IsMouseInViewport = true;
|
||||
// FS_INFO("{} {}", mousePosInViewport.x, mousePosInViewport.y);
|
||||
} else {
|
||||
io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse;
|
||||
IsMouseInViewport = true;
|
||||
}*/
|
||||
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
|
||||
const ImRect bb(window->DC.CursorPos, ImVec2(window->DC.CursorPos.x+ viewportPanelSize.x, window->DC.CursorPos.y + viewportPanelSize.y));
|
||||
|
||||
uint64_t rendererID = m_HydraRenderer->GetRendererID();
|
||||
|
||||
ImGui::PushID((void*)(intptr_t)rendererID);
|
||||
const ImGuiID id = window->GetID("#image");
|
||||
ImGui::PopID();
|
||||
|
||||
bool hovered, held;
|
||||
bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held);
|
||||
|
||||
if (hovered)
|
||||
{
|
||||
|
||||
//if (ImGui::GetMergedKeyModFlags() & ImGuiKeyModFlags_Alt)
|
||||
if (io.KeyMods & ImGuiKeyModFlags_Alt)
|
||||
{
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Arrow);
|
||||
if (ImGui::IsAnyMouseDown())
|
||||
{
|
||||
if (io.MouseClicked[0] || io.MouseClicked[1] || io.MouseClicked[2])
|
||||
m_HydraRenderer->OnMousePress(io.MouseClicked, io.MousePos.x, io.MousePos.y, io.KeyMods);
|
||||
|
||||
m_HydraRenderer->OnMouseMove(io.MouseDown, io.MousePos.x, io.MousePos.y, io.KeyMods);
|
||||
}
|
||||
|
||||
if (io.MouseReleased[0] || io.MouseReleased[1] || io.MouseReleased[2])
|
||||
{
|
||||
m_HydraRenderer->OnMouseRelease(io.MouseReleased, io.MousePos.x, io.MousePos.y, io.KeyMods);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Update renderer
|
||||
m_HydraRenderer->OnWindowResize(viewportPanelSize.x, viewportPanelSize.y);
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::Image((void*)rendererID, ImVec2{ viewportPanelSize.x, viewportPanelSize.y }, ImVec2{ 0, 1 }, ImVec2{ 1, 0 });
|
||||
|
||||
//if (ImGui::IsItemHovered()){}
|
||||
|
||||
ImVec2 work_area_pos = viewportPos;
|
||||
ImVec2 work_area_size = viewportPanelSize;
|
||||
ImVec2 window_pos = ImVec2(work_area_pos.x + 10, work_area_pos.y + 10);
|
||||
ImVec2 window_pos_pivot = ImVec2(0, 0);
|
||||
/*ImGui::SetNextWindowFocus();
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
ImGui::SetNextWindowViewport(window->ViewportId);
|
||||
ImGui::SetNextWindowBgAlpha(0.35f);
|
||||
int corner = -1;
|
||||
if (ImGui::Begin("Example: Simple overlay", p_open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNav))
|
||||
{
|
||||
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
|
||||
ImGui::Separator();
|
||||
if (ImGui::IsMousePosValid())
|
||||
ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
|
||||
else
|
||||
ImGui::Text("Mouse Position: <invalid>");
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
|
||||
if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
|
||||
if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
|
||||
if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
*/
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
|
||||
ImGui::PushClipRect(window_pos, ImVec2(window_pos.x + work_area_size.x, window_pos.y + work_area_size.y), true);
|
||||
|
||||
ImGui::BeginChild("#ViewportWidgets", ImVec2(work_area_size.x, 100), false);
|
||||
ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
|
||||
ImGui::Button(ICON_FA_HOME, ImVec2(22.0f, 22.0f));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_FA_HOME, ImVec2(22.0f, 22.0f));
|
||||
ImGui::SameLine();
|
||||
static std::string currentRendererName = GetRenderer()->GetCurrentRendererName();
|
||||
std::vector<std::string> rendererPluginNames = GetRenderer()->GetRendererPluginsNames();
|
||||
//FS_INFO("### currentRendererName : {}", currentRendererName);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, IM_COL32(0, 0, 0, 150));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f);
|
||||
|
||||
if (ImGui::BeginCombo("", currentRendererName.c_str(), (ImGuiComboFlags)rendererPluginNames.size()))
|
||||
{
|
||||
for (int n = 0; n < rendererPluginNames.size(); n++)
|
||||
{
|
||||
bool is_selected = (currentRendererName == rendererPluginNames[n]);
|
||||
|
||||
if (ImGui::Selectable(rendererPluginNames[n].c_str(), is_selected))
|
||||
{
|
||||
currentRendererName = rendererPluginNames[n];
|
||||
GetRenderer()->SetCurrentRenderer(currentRendererName);
|
||||
}
|
||||
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::EndChild();
|
||||
ImGui::PopClipRect();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void Viewport::InitToolBar()
|
||||
{
|
||||
|
||||
ImGui::Button(ICON_FA_HOME, ImVec2(22.0f, 22.0f));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_FA_HOME, ImVec2(22.0f, 22.0f));
|
||||
ImGui::SameLine();
|
||||
static std::string currentRendererName = GetRenderer()->GetCurrentRendererName();
|
||||
std::vector<std::string> rendererPluginNames = GetRenderer()->GetRendererPluginsNames();
|
||||
//FS_INFO("### currentRendererName : {}", currentRendererName);
|
||||
|
||||
if (ImGui::BeginCombo("Renderer", currentRendererName.c_str(), (ImGuiComboFlags)rendererPluginNames.size()))
|
||||
{
|
||||
for (int n = 0; n < rendererPluginNames.size(); n++)
|
||||
{
|
||||
bool is_selected = (currentRendererName == rendererPluginNames[n]);
|
||||
|
||||
if (ImGui::Selectable(rendererPluginNames[n].c_str(), is_selected))
|
||||
{
|
||||
currentRendererName = rendererPluginNames[n];
|
||||
GetRenderer()->SetCurrentRenderer(currentRendererName);
|
||||
}
|
||||
|
||||
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::BeginCombo("Camera", "Free Camera"))
|
||||
{
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewport::OnMousePress(bool button[], int x, int y, int modKeys)
|
||||
{
|
||||
}
|
||||
void Viewport::OnMouseRelease(bool button[], int x, int y, int modKeys)
|
||||
{
|
||||
}
|
||||
void Viewport::OnMouseMove(int x, int y, int modKeys)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include "FlipScope/Usd/StageDataModel.h"
|
||||
#include "FlipScope/Usd/HydraRenderer.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class Viewport
|
||||
{
|
||||
public:
|
||||
|
||||
Viewport(uint32_t width, uint32_t height);
|
||||
virtual ~Viewport();
|
||||
|
||||
void Update();
|
||||
|
||||
void Show(bool *p_open);
|
||||
|
||||
std::shared_ptr<HydraRenderer> GetRenderer() { return m_HydraRenderer; };
|
||||
void InitToolBar();
|
||||
|
||||
int GetWidth() { return m_Width; };
|
||||
int GetHeight() { return m_Height; };
|
||||
|
||||
void OnMousePress(bool button[], int x, int y, int modKeys);
|
||||
void OnMouseRelease(bool button[], int x, int y, int modKeys);
|
||||
void OnMouseMove(int x, int y, int modKeys);
|
||||
|
||||
private:
|
||||
uint32_t m_Width, m_Height;
|
||||
std::shared_ptr<HydraRenderer> m_HydraRenderer;
|
||||
std::shared_ptr<StageDataModel> m_StageDataModel;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Core.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
#include "Platform/OpenGL/OpenGLContext.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
OpenGLContext::OpenGLContext(GLFWwindow* windowHandle)
|
||||
: m_WindowHandle(windowHandle)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OpenGLContext::Init()
|
||||
{
|
||||
glfwMakeContextCurrent(m_WindowHandle);
|
||||
|
||||
int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||
//GLenum status = glewInit();
|
||||
if (!status) {
|
||||
//if(GLEW_OK != status)
|
||||
//{
|
||||
//FS_ERROR("OpenGLContext::Init() : Fail initialize OpenGL.");
|
||||
FS_ERROR("OpenGLContext::Init() : Fail initialize OpenGL. {0}", status);
|
||||
}
|
||||
else {
|
||||
FS_INFO("OpenGLContext.Init(): {0}", status);
|
||||
}
|
||||
|
||||
FS_INFO("OpenGL Info:");
|
||||
FS_INFO(" Vendor: {0}", glGetString(GL_VENDOR));
|
||||
FS_INFO(" Renderer: {0}", glGetString(GL_RENDERER));
|
||||
FS_INFO(" Version: {0}", glGetString(GL_VERSION));
|
||||
}
|
||||
|
||||
void OpenGLContext::SwapBuffers()
|
||||
{
|
||||
glfwSwapBuffers(m_WindowHandle);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Renderer/GraphicsContext.h"
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class OpenGLContext :public GraphicsContext
|
||||
{
|
||||
public:
|
||||
OpenGLContext(GLFWwindow* windowHandle);
|
||||
|
||||
virtual void Init() override;
|
||||
virtual void SwapBuffers() override;
|
||||
|
||||
private:
|
||||
GLFWwindow* m_WindowHandle;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
#include "Platform/OpenGL/OpenGLFramebuffer.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
//#include <GL/glew.h>
|
||||
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
OpenGLFramebuffer::OpenGLFramebuffer(const FramebufferSpecification& spec)
|
||||
:m_Specification(spec)
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
OpenGLFramebuffer::~OpenGLFramebuffer()
|
||||
{
|
||||
glDeleteFramebuffers(1, &m_RendererID);
|
||||
glDeleteTextures(1, &m_ColorAttachment);
|
||||
glDeleteTextures(1, &m_DepthAttachment);
|
||||
}
|
||||
|
||||
void OpenGLFramebuffer::Invalidate()
|
||||
{
|
||||
|
||||
if (m_RendererID)
|
||||
{
|
||||
glDeleteFramebuffers(1, &m_RendererID);
|
||||
glDeleteTextures(1, &m_ColorAttachment);
|
||||
glDeleteTextures(1, &m_DepthAttachment);
|
||||
}
|
||||
|
||||
glCreateFramebuffers(1, &m_RendererID);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_RendererID);
|
||||
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_ColorAttachment);
|
||||
glBindTexture(GL_TEXTURE_2D, m_ColorAttachment);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Specification.Width, m_Specification.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_ColorAttachment, 0);
|
||||
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_DepthAttachment);
|
||||
glBindTexture(GL_TEXTURE_2D, m_DepthAttachment);
|
||||
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, m_Specification.Width, m_Specification.Height);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthAttachment, 0);
|
||||
|
||||
if (!(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE))
|
||||
FS_ERROR("Framebuffer is incomplete!");
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
void OpenGLFramebuffer::Bind()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_RendererID);
|
||||
}
|
||||
|
||||
void OpenGLFramebuffer::Unbind()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
void OpenGLFramebuffer::Resize(uint32_t width, uint32_t height)
|
||||
{
|
||||
m_Specification.Width = width;
|
||||
m_Specification.Height = height;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Renderer/FrameBuffer.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class OpenGLFramebuffer :public Framebuffer
|
||||
{
|
||||
public:
|
||||
OpenGLFramebuffer(const FramebufferSpecification& spec);
|
||||
virtual ~OpenGLFramebuffer();
|
||||
|
||||
virtual void Bind() override;
|
||||
virtual void Unbind() override;
|
||||
|
||||
void Invalidate();
|
||||
|
||||
virtual void Resize(uint32_t width, uint32_t height) override;
|
||||
|
||||
|
||||
virtual uint32_t GetColorAttachmentRendererID() const override { return m_ColorAttachment; }
|
||||
|
||||
virtual const FramebufferSpecification& GetSpecification() const override { return m_Specification; }
|
||||
private:
|
||||
uint32_t m_RendererID = 0;
|
||||
uint32_t m_ColorAttachment = 0, m_DepthAttachment = 0;
|
||||
FramebufferSpecification m_Specification;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "OpenGLRendererAPI.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
//#include <GL/glew.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
void OpenGLRendererAPI::Init()
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void OpenGLRendererAPI::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
|
||||
{
|
||||
glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
void OpenGLRendererAPI::SetClearColor(const glm::vec4& color)
|
||||
{
|
||||
glClearColor(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void OpenGLRendererAPI::Clear()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Renderer/RendererAPI.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class OpenGLRendererAPI : public RendererAPI
|
||||
{
|
||||
public:
|
||||
virtual void Init() override;
|
||||
virtual void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override;
|
||||
|
||||
virtual void SetClearColor(const glm::vec4& color) override;
|
||||
virtual void Clear() override;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
#include "Platform/OpenGL/OpenGLTexture.h"
|
||||
|
||||
#include <stb_image.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
OpenGLTexture::OpenGLTexture(uint32_t width, uint32_t height)
|
||||
:m_Width(width), m_Height(height)
|
||||
{
|
||||
m_InternalFormat = GL_RGBA8;
|
||||
m_DataFormat = GL_RGBA;
|
||||
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_RendererID);
|
||||
glTextureStorage2D(m_RendererID, 1, m_InternalFormat, m_Width, m_Height);
|
||||
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
}
|
||||
|
||||
OpenGLTexture::OpenGLTexture(const std::string path)
|
||||
:m_Path(path)
|
||||
{
|
||||
int width, height, channels;
|
||||
stbi_uc *data;
|
||||
stbi_set_flip_vertically_on_load(1);
|
||||
{
|
||||
FS_INFO("stbi_load - OpenGLTexture2D::OpenGLTexture2D(const std:string&)");
|
||||
data = stbi_load(path.c_str(), &width, &height, &channels, 0);
|
||||
}
|
||||
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
|
||||
GLenum internalFormat = 0, dataFormat = 0;
|
||||
if (channels == 4)
|
||||
{
|
||||
internalFormat = GL_RGBA8;
|
||||
dataFormat = GL_RGBA;
|
||||
}
|
||||
else if (channels == 3)
|
||||
{
|
||||
internalFormat = GL_RGB8;
|
||||
dataFormat = GL_RGB;
|
||||
}
|
||||
|
||||
m_InternalFormat = internalFormat;
|
||||
m_DataFormat = dataFormat;
|
||||
|
||||
if (!(internalFormat & dataFormat))
|
||||
{
|
||||
FS_ERROR("Format not supported!");
|
||||
return;
|
||||
}
|
||||
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_RendererID);
|
||||
glTextureStorage2D(m_RendererID, 1, internalFormat, m_Width, m_Height);
|
||||
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glTextureSubImage2D(m_RendererID, 0, 0, 0, m_Width, m_Height, dataFormat, GL_UNSIGNED_BYTE, data);
|
||||
|
||||
stbi_image_free(data);
|
||||
}
|
||||
|
||||
OpenGLTexture::~OpenGLTexture()
|
||||
{
|
||||
glDeleteTextures(1, &m_RendererID);
|
||||
}
|
||||
|
||||
void OpenGLTexture::SetData(void *data, uint32_t size) const
|
||||
{
|
||||
uint32_t bpp = m_DataFormat == GL_RGBA ? 4 : 3;
|
||||
glTextureSubImage2D(m_RendererID, 0, 0, 0, m_Width, m_Height, m_DataFormat, GL_UNSIGNED_BYTE, data);
|
||||
}
|
||||
|
||||
void OpenGLTexture::Bind(uint32_t slot) const
|
||||
{
|
||||
glBindTextureUnit(slot, m_RendererID);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Renderer/Texture.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
//#include <GL/glew.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class OpenGLTexture :public Texture
|
||||
{
|
||||
public:
|
||||
|
||||
OpenGLTexture(uint32_t width, uint32_t height);
|
||||
OpenGLTexture(const std::string path);
|
||||
|
||||
virtual ~OpenGLTexture();
|
||||
|
||||
virtual uint32_t GetWidth() const override { return m_Width; }
|
||||
virtual uint32_t GetHeight() const override { return m_Height; }
|
||||
virtual uint32_t GetRendererID() const override { return m_RendererID; }
|
||||
|
||||
virtual void SetData(void* data, uint32_t size) const override;
|
||||
|
||||
virtual void Bind(uint32_t slot = 0) const override;
|
||||
|
||||
virtual bool operator==(const Texture& other) const override
|
||||
{
|
||||
return m_RendererID == ((OpenGLTexture&)other).m_RendererID;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_Path;
|
||||
uint32_t m_Width, m_Height;
|
||||
uint32_t m_RendererID;
|
||||
GLenum m_InternalFormat, m_DataFormat;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "Platform/OpenGL/OpenGLViewportRenderer.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
OpenGLViewportRenderer::OpenGLViewportRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
OpenGLViewportRenderer::~OpenGLViewportRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
void OpenGLViewportRenderer::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OpenGLViewportRenderer::Shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OpenGLViewportRenderer::OnWindowResize(uint32_t width, uint32_t height)
|
||||
{
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
}
|
||||
|
||||
void OpenGLViewportRenderer::OnRender()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include "FlipScope/Renderer/ViewportRenderer.h"
|
||||
#include <glad/glad.h>
|
||||
//#include <GL/glew.h>
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class OpenGLViewportRenderer :public ViewportRenderer
|
||||
{
|
||||
public:
|
||||
OpenGLViewportRenderer();
|
||||
virtual ~OpenGLViewportRenderer();
|
||||
virtual void Init() override;
|
||||
virtual void Shutdown() override;
|
||||
|
||||
virtual uint32_t GetWidth() const override { return m_Width; }
|
||||
virtual uint32_t GetHeight() const override { return m_Height; }
|
||||
|
||||
virtual void OnWindowResize(uint32_t width, uint32_t height);
|
||||
|
||||
virtual void OnRender();
|
||||
|
||||
private:
|
||||
uint32_t m_Width, m_Height;
|
||||
GLenum m_DrawTarget;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "Platform/Windows/WindowsWindow.h"
|
||||
|
||||
#include "FlipScope/Core/Log.h"
|
||||
#include "FlipScope/Event/ApplicationEvent.h"
|
||||
|
||||
#include "FlipScope/Renderer/Renderer.h"
|
||||
|
||||
#include "Platform/OpenGL/OpenGLContext.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
static uint8_t s_GLFWWindowCount = 0;
|
||||
|
||||
static void GLFWErrorCallback(int error, const char* description)
|
||||
{
|
||||
FS_ERROR("GLFW Error : {0} , {1}", error, description);
|
||||
}
|
||||
|
||||
WindowsWindow::WindowsWindow(const WindowProps& props)
|
||||
{
|
||||
Init(props);
|
||||
}
|
||||
|
||||
WindowsWindow::~WindowsWindow()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void WindowsWindow::Init(const WindowProps& props)
|
||||
{
|
||||
FS_INFO("WindowsWindow::Init()");
|
||||
m_Data.Title = props.Title;
|
||||
m_Data.Width = props.Width;
|
||||
m_Data.Height = props.Height;
|
||||
|
||||
if (s_GLFWWindowCount == 0)
|
||||
{
|
||||
int success = glfwInit();
|
||||
FS_INFO("WindowsWindow::Init() : glfwInit() : {0}", success);
|
||||
glfwSetErrorCallback(GLFWErrorCallback);
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
||||
m_Window = glfwCreateWindow((int)props.Width, (int)props.Height, m_Data.Title.c_str(), nullptr, nullptr);
|
||||
++s_GLFWWindowCount;
|
||||
|
||||
m_Context = GraphicsContext::Create(m_Window);
|
||||
m_Context->Init();
|
||||
|
||||
//glfwSetWindowUserPointer(m_Window, &m_Data);
|
||||
glfwSetWindowUserPointer(m_Window, this);
|
||||
SetVSync(true);
|
||||
|
||||
glfwSetWindowSizeCallback(m_Window, WindowResizeCallback);
|
||||
glfwSetWindowCloseCallback(m_Window, WindowCloseCallback);
|
||||
glfwSetMouseButtonCallback(m_Window, MouseButtonCallback);
|
||||
glfwSetCursorPosCallback(m_Window, CursorPosCallback);
|
||||
glfwSetDropCallback(m_Window, FileDropCallback);
|
||||
glfwSetScrollCallback(m_Window, ScrollCallback);
|
||||
}
|
||||
|
||||
void WindowsWindow::Shutdown()
|
||||
{
|
||||
glfwDestroyWindow(m_Window);
|
||||
--s_GLFWWindowCount;
|
||||
|
||||
if (s_GLFWWindowCount == 0)
|
||||
{
|
||||
glfwTerminate();
|
||||
}
|
||||
FS_INFO("WindowsWindow::Shutdown()");
|
||||
}
|
||||
|
||||
void WindowsWindow::OnUpdate()
|
||||
{
|
||||
glfwPollEvents();
|
||||
//Renderer
|
||||
|
||||
m_Context->SwapBuffers();
|
||||
}
|
||||
|
||||
void WindowsWindow::SetVSync(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
glfwSwapInterval(1);
|
||||
else
|
||||
glfwSwapInterval(0);
|
||||
m_Data.VSync = enabled;
|
||||
}
|
||||
|
||||
bool WindowsWindow::IsVSync() const
|
||||
{
|
||||
return m_Data.VSync;
|
||||
}
|
||||
|
||||
bool WindowsWindow::Close() const
|
||||
{
|
||||
if (glfwWindowShouldClose(m_Window))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void WindowsWindow::OnWindowResize(unsigned int width, unsigned int height)
|
||||
{
|
||||
m_Data.Width = width;
|
||||
m_Data.Height = height;
|
||||
FS_INFO("WindowsWindow::OnWindowResize() : Resize {0} {1}", width, height);
|
||||
Renderer::OnWindowResize(width, height);
|
||||
}
|
||||
|
||||
void WindowsWindow::OnWindowClose()
|
||||
{
|
||||
FS_INFO("WindowsWindow::OnWindowClose() : Close");
|
||||
}
|
||||
|
||||
void WindowsWindow::OnFileDrop(unsigned int count, const char *paths[])
|
||||
{
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
const std::string &filepath = paths[i];
|
||||
FS_INFO("WindowsWindow::OnFileDrop() : {0} : {1}", i, filepath);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsWindow::OnScroll(double xOffset, double yOffset)
|
||||
{
|
||||
FS_INFO("WindowsWindow::OnScroll() : {0} {1}", xOffset, yOffset);
|
||||
}
|
||||
|
||||
void WindowsWindow::OnCursorPos(double xPos, double yPos)
|
||||
{
|
||||
//FS_INFO("WindowsWindow::OnCursorPos() : {0} {1}", xPos, yPos);
|
||||
}
|
||||
|
||||
void WindowsWindow::OnMousePress(int button, int mods)
|
||||
{
|
||||
FS_INFO("WindowsWindow::OnMousePress() : {0} {1}", button, mods);
|
||||
}
|
||||
|
||||
void WindowsWindow::OnMouseRelease(int button, int mods)
|
||||
{
|
||||
FS_INFO("WindowsWindow::OnMouseRelease() : {0} {1}", button, mods);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
#pragma once
|
||||
#include "FlipScope/Core/Core.h"
|
||||
|
||||
#include "FlipScope/Core/Window.h"
|
||||
#include "FlipScope/Renderer/GraphicsContext.h"
|
||||
|
||||
namespace FSV
|
||||
{
|
||||
class WindowsWindow : public Window
|
||||
{
|
||||
public:
|
||||
WindowsWindow(const WindowProps& props);
|
||||
virtual ~WindowsWindow();
|
||||
|
||||
void OnUpdate() override;
|
||||
|
||||
inline unsigned int GetWidth() const override { return m_Data.Width; }
|
||||
inline unsigned int GetHeight() const override { return m_Data.Height; }
|
||||
|
||||
void SetEventCallback(const EventCallbackFn& callback) override { m_Data.EventCallback = callback; }
|
||||
void SetVSync(bool enabled) override;
|
||||
bool IsVSync() const override;
|
||||
bool Close() const;
|
||||
|
||||
void OnWindowResize(unsigned int width, unsigned int height);
|
||||
void OnWindowClose();
|
||||
void OnFileDrop(unsigned int count, const char* paths[]);
|
||||
void OnScroll(double xOffset, double yOffset);
|
||||
void OnCursorPos(double xPos, double yPos);
|
||||
void OnMousePress(int button, int mods);
|
||||
void OnMouseRelease(int button, int mods);
|
||||
|
||||
inline virtual void* GetNativeWindow() const { return m_Window; }
|
||||
|
||||
private:
|
||||
virtual void Init(const WindowProps& props);
|
||||
virtual void Shutdown();
|
||||
|
||||
private:
|
||||
GLFWwindow* m_Window;
|
||||
std::unique_ptr<GraphicsContext> m_Context;
|
||||
bool m_Running;
|
||||
|
||||
struct WindowData
|
||||
{
|
||||
std::string Title;
|
||||
unsigned int Width, Height;
|
||||
bool VSync;
|
||||
EventCallbackFn EventCallback;
|
||||
};
|
||||
|
||||
WindowData m_Data;
|
||||
|
||||
inline static auto WindowResizeCallback(GLFWwindow *win, int width, int height) -> void {
|
||||
WindowsWindow *window = static_cast<WindowsWindow*>(glfwGetWindowUserPointer(win));
|
||||
window->OnWindowResize(width, height);
|
||||
}
|
||||
|
||||
inline static auto WindowCloseCallback(GLFWwindow *win) -> void {
|
||||
WindowsWindow *window = static_cast<WindowsWindow*>(glfwGetWindowUserPointer(win));
|
||||
window->OnWindowClose();
|
||||
}
|
||||
|
||||
inline static auto FileDropCallback(GLFWwindow *win, int count, const char* paths[]) -> void {
|
||||
WindowsWindow *window = static_cast<WindowsWindow*>(glfwGetWindowUserPointer(win));
|
||||
window->OnFileDrop(count, paths);
|
||||
}
|
||||
|
||||
inline static auto ScrollCallback(GLFWwindow *win, double xOffset, double yOffset) -> void {
|
||||
WindowsWindow *window = static_cast<WindowsWindow*>(glfwGetWindowUserPointer(win));
|
||||
window->OnScroll(xOffset, yOffset);
|
||||
}
|
||||
|
||||
inline static auto CursorPosCallback(GLFWwindow *win, double xPos, double yPos) -> void {
|
||||
WindowsWindow *window = static_cast<WindowsWindow*>(glfwGetWindowUserPointer(win));
|
||||
window->OnCursorPos(xPos, yPos);
|
||||
}
|
||||
|
||||
|
||||
inline static auto MouseButtonCallback(GLFWwindow *win, int button, int action, int mods) -> void {
|
||||
WindowsWindow *window = static_cast<WindowsWindow*>(glfwGetWindowUserPointer(win));
|
||||
switch (action)
|
||||
{
|
||||
case GLFW_PRESS:
|
||||
window->OnMousePress(button, mods);
|
||||
break;
|
||||
case GLFW_RELEASE:
|
||||
window->OnMouseRelease(button, mods);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "FlipScope/Core/Application.h"
|
||||
#include "FlipScope/Core/Log.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
FSV::Log::Init();
|
||||
auto *app = FSV::CreateApplication();
|
||||
app->Run();
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "pch.h"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include <thread>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <Windows.h>
|
||||
Loading…
Reference in New Issue