From 98d05c5030ba1c35ddfe402790702b3f44c63134 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 31 Oct 2021 17:29:32 +0800 Subject: - Runtime Proj + Runner Proj --- .../GameLab/Engine/Rendering/Material.lua | 8 + .../Libraries/GameLab/Engine/Rendering/Shader.lua | 10 +- .../Libraries/GameLab/Engine/Rendering/init.lua | 1 + Data/Resources/Shaders/Editor-Text.glsl | 10 +- Data/Scripts/Editor/AssetBrowser.lua | 6 +- Projects/VisualStudio/GameLab.sln | 20 +- Projects/VisualStudio/Runner/Runner.vcxproj | 134 ++++++++++ .../VisualStudio/Runner/Runner.vcxproj.filters | 9 + Projects/VisualStudio/Runner/Runner.vcxproj.user | 4 + Projects/VisualStudio/Runtime/Runtime.vcxproj | 231 ------------------ .../VisualStudio/Runtime/Runtime.vcxproj.filters | 269 --------------------- Projects/VisualStudio/Runtime/Runtime.vcxproj.user | 4 - Runner/Runner.cpp | 0 Runner/Runner.h | 0 Runtime/Graphics/Shader.cpp | 3 +- Runtime/Graphics/ShaderCompiler.cpp | 5 +- Runtime/Graphics/ShaderCompiler.h | 3 +- Runtime/Runner.cpp | 0 Runtime/Runner.h | 0 19 files changed, 186 insertions(+), 531 deletions(-) create mode 100644 Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Material.lua create mode 100644 Projects/VisualStudio/Runner/Runner.vcxproj create mode 100644 Projects/VisualStudio/Runner/Runner.vcxproj.filters create mode 100644 Projects/VisualStudio/Runner/Runner.vcxproj.user delete mode 100644 Projects/VisualStudio/Runtime/Runtime.vcxproj delete mode 100644 Projects/VisualStudio/Runtime/Runtime.vcxproj.filters delete mode 100644 Projects/VisualStudio/Runtime/Runtime.vcxproj.user create mode 100644 Runner/Runner.cpp create mode 100644 Runner/Runner.h delete mode 100644 Runtime/Runner.cpp delete mode 100644 Runtime/Runner.h diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Material.lua b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Material.lua new file mode 100644 index 0000000..872d7e1 --- /dev/null +++ b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Material.lua @@ -0,0 +1,8 @@ +local Material = GameLab.Class("GameLab.Engine.Rendering.Material") + +Material.Ctor = function(self) + self.shader = nil -- 绑定的shader + self.uniforms = {} -- {name, value} +end + +return Material \ No newline at end of file diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Shader.lua b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Shader.lua index c64d526..b3c8aeb 100644 --- a/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Shader.lua +++ b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Shader.lua @@ -1,11 +1,11 @@ local Shader = GameLab.Engine.Rendering.Shader or {} --- @Shader.CreateFromFile --- 从文件中创建Shader --- @param path:string 路径 --- @return shader 创建的shader Shader.CreateFromFile = function( path ) - + local glsl = GameLab.IO.ReadFile(path, GameLab.IO.EFileMode.Text) + if glsl ~= nil then + local shader = Shader.New(glsl) + return shader + end end return Shader \ No newline at end of file diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua index caefccf..5469297 100644 --- a/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua +++ b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua @@ -7,6 +7,7 @@ local Shader = GameLab.Engine.Rendering.Shader m.Color = import("Color") m.Color32 = import("Color32") +m.Shader = import("Shader") m.LoadTexture = function(path) diff --git a/Data/Resources/Shaders/Editor-Text.glsl b/Data/Resources/Shaders/Editor-Text.glsl index af76555..3566b28 100644 --- a/Data/Resources/Shaders/Editor-Text.glsl +++ b/Data/Resources/Shaders/Editor-Text.glsl @@ -1,12 +1,12 @@ #version 330 core -CMD_BEGIN +// CMD_BEGIN -Cull Both -DepthTest Off -Blend SrcAlpha OneMinusSrcAlpha +// Cull Both +// DepthTest Off +// Blend SrcAlpha OneMinusSrcAlpha -CMD_END +// CMD_END uniform mat4 gamelab_mat_mvp; uniform sampler2D uiTex; diff --git a/Data/Scripts/Editor/AssetBrowser.lua b/Data/Scripts/Editor/AssetBrowser.lua index 7c73ec3..d726654 100644 --- a/Data/Scripts/Editor/AssetBrowser.lua +++ b/Data/Scripts/Editor/AssetBrowser.lua @@ -16,14 +16,14 @@ local tex AssetBrowser.OnGUI = function(self) - if tex == nil then tex = Engine.Resource.LoadTexture("./Resources/Images/brickwall.jpg") end if shader == nil then - local glsl = IO.ReadFile("./Resources/Shaders/Editor-Text.glsl", IO.EFileMode.Text) - shader = Engine.Rendering.Shader.New(glsl) + -- local glsl = IO.ReadFile("./Resources/Shaders/Editor-Text.glsl", IO.EFileMode.Text) + -- shader = Engine.Rendering.Shader.New(glsl) + shader = Engine.Rendering.Shader.CreateFromFile("./Resources/Shaders/Editor-Text.glsl") end local ortho = Matrix44.New() diff --git a/Projects/VisualStudio/GameLab.sln b/Projects/VisualStudio/GameLab.sln index 9a7496c..8013406 100644 --- a/Projects/VisualStudio/GameLab.sln +++ b/Projects/VisualStudio/GameLab.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28307.1022 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Runtime", "Runtime\Runtime.vcxproj", "{4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "SDL2\SDL2.vcxproj", "{8658F91C-9AAE-4819-9005-77D09C61D97F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ThirdParty", "ThirdParty", "{0F6EE105-E1FF-4770-8314-06F9F98FB68F}" @@ -31,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AsyncTask", "AsyncTask\Asyn EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hash-library", "hash-library\hash-library.vcxproj", "{F5341260-AFF4-4F99-9182-C8A0673E3B14}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Runner", "Runner\Runner.vcxproj", "{0168C539-D3F8-48AD-BBB0-259B87786D1F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -39,14 +39,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Debug|x64.ActiveCfg = Debug|x64 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Debug|x64.Build.0 = Debug|x64 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Debug|x86.ActiveCfg = Debug|Win32 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Debug|x86.Build.0 = Debug|Win32 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Release|x64.ActiveCfg = Release|x64 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Release|x64.Build.0 = Release|x64 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Release|x86.ActiveCfg = Release|Win32 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD}.Release|x86.Build.0 = Release|Win32 {8658F91C-9AAE-4819-9005-77D09C61D97F}.Debug|x64.ActiveCfg = Debug|x64 {8658F91C-9AAE-4819-9005-77D09C61D97F}.Debug|x64.Build.0 = Debug|x64 {8658F91C-9AAE-4819-9005-77D09C61D97F}.Debug|x86.ActiveCfg = Debug|Win32 @@ -135,6 +127,14 @@ Global {F5341260-AFF4-4F99-9182-C8A0673E3B14}.Release|x64.Build.0 = Release|x64 {F5341260-AFF4-4F99-9182-C8A0673E3B14}.Release|x86.ActiveCfg = Release|Win32 {F5341260-AFF4-4F99-9182-C8A0673E3B14}.Release|x86.Build.0 = Release|Win32 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Debug|x64.ActiveCfg = Debug|x64 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Debug|x64.Build.0 = Debug|x64 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Debug|x86.ActiveCfg = Debug|Win32 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Debug|x86.Build.0 = Debug|Win32 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Release|x64.ActiveCfg = Release|x64 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Release|x64.Build.0 = Release|x64 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Release|x86.ActiveCfg = Release|Win32 + {0168C539-D3F8-48AD-BBB0-259B87786D1F}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Projects/VisualStudio/Runner/Runner.vcxproj b/Projects/VisualStudio/Runner/Runner.vcxproj new file mode 100644 index 0000000..f66f423 --- /dev/null +++ b/Projects/VisualStudio/Runner/Runner.vcxproj @@ -0,0 +1,134 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {0168C539-D3F8-48AD-BBB0-259B87786D1F} + Runner + 10.0.17763.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + Console + + + + + Level3 + Disabled + true + true + + + Console + + + + + Level3 + MaxSpeed + true + true + true + true + + + Console + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + Console + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/Projects/VisualStudio/Runner/Runner.vcxproj.filters b/Projects/VisualStudio/Runner/Runner.vcxproj.filters new file mode 100644 index 0000000..0a0cafd --- /dev/null +++ b/Projects/VisualStudio/Runner/Runner.vcxproj.filters @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Projects/VisualStudio/Runner/Runner.vcxproj.user b/Projects/VisualStudio/Runner/Runner.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/Projects/VisualStudio/Runner/Runner.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Projects/VisualStudio/Runtime/Runtime.vcxproj b/Projects/VisualStudio/Runtime/Runtime.vcxproj deleted file mode 100644 index 27a06a0..0000000 --- a/Projects/VisualStudio/Runtime/Runtime.vcxproj +++ /dev/null @@ -1,231 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {12759f92-73f9-48bc-8808-9fe709dcd134} - - - {9b542e6d-8677-4ad6-9a69-4650103906c5} - - - {12b7b0f8-6581-4321-9627-3ee601100463} - - - - 15.0 - {4C26BDCC-CA08-4C43-8EFF-B62A204D5FBD} - Runtime - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(SolutionDir)..\..\Build - - - $(SolutionDir)..\..\Build - - - $(SolutionDir)..\..\Build - - - $(SolutionDir)..\..\Build - - - - Level3 - Disabled - true - true - $(SolutionDir)..\..\ThirdParty\;$(SolutionDir)..\..\ThirdParty\SDL2\include;%(AdditionalIncludeDirectories) - - - Console - - - - - Level3 - Disabled - true - true - $(SolutionDir)..\..\ThirdParty\;$(SolutionDir)..\..\ThirdParty\SDL2\include;%(AdditionalIncludeDirectories) - - - Console - - - - - Level3 - MaxSpeed - true - true - true - true - $(SolutionDir)..\..\ThirdParty\;$(SolutionDir)..\..\ThirdParty\SDL2\include;%(AdditionalIncludeDirectories) - - - Console - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - $(SolutionDir)..\..\ThirdParty\;$(SolutionDir)..\..\ThirdParty\SDL2\include;%(AdditionalIncludeDirectories) - - - Console - true - true - - - - - - \ No newline at end of file diff --git a/Projects/VisualStudio/Runtime/Runtime.vcxproj.filters b/Projects/VisualStudio/Runtime/Runtime.vcxproj.filters deleted file mode 100644 index c25be44..0000000 --- a/Projects/VisualStudio/Runtime/Runtime.vcxproj.filters +++ /dev/null @@ -1,269 +0,0 @@ - - - - - {e789ad2d-945c-482e-8316-1dd0ccdfc465} - - - {9ad1872a-2d30-43f7-be83-f30d53e57970} - - - {c7bba1da-cea1-43fa-b344-17a3d4abc615} - - - {d0c5cd2c-bc7a-437a-86ce-903b6891c0dd} - - - {93deee15-5efc-4231-ab54-56f471ab701f} - - - {088f2ab7-cbf6-4338-b43a-652fde8d0b4b} - - - {ec69ceaf-4fa8-4296-827e-fd4c537ec5ea} - - - {bfc9838c-ddde-4d86-8da3-4ccebd976cde} - - - {5bbfbd7d-379a-43e9-b05a-8f97b7f3fa3a} - - - {e53ba507-aa27-4d67-9da4-42752bc84dc8} - - - {158d8348-2b65-4ff1-b313-ba9f7bcfde32} - - - {fb970ccc-e9aa-4f61-854c-0b852503a375} - - - {4478c64f-e27a-4be6-a189-8d99e0fc6b15} - - - {c865b35b-5537-4757-927d-7476009f4de2} - - - {e53b1cb1-9d81-47a0-8d40-566d4fd0ef80} - - - - - Utilities - - - Utilities - - - Graphics - - - Mesh - - - Mesh - - - Mesh - - - Profiler - - - Utilities - - - Graphics - - - Graphics - - - Math - - - Graphics - - - Mesh - - - Math - - - Graphics - - - Input - - - Graphics - - - Graphics - - - Graphics - - - Utilities - - - Utilities - - - FileSystem - - - Utilities - - - Utilities - - - Graphics - - - FileSystem - - - Graphics - - - Mesh - - - Graphics - - - Utilities - - - Graphics - - - Graphics - - - Math - - - Shaders - - - Shaders - - - Shaders - - - Utilities - - - Profiler - - - Mesh - - - Graphics - - - Physics - - - ImGUI - - - ImGUI - - - - - - Mesh - - - Graphics - - - Math - - - Graphics\Scripting - - - Graphics - - - Graphics - - - Graphics - - - Math - - - Graphics - - - Physics\Scripting - - - Input - - - Graphics - - - Graphics - - - Graphics\Scripting - - - Graphics - - - FileSystem - - - Utilities - - - Utilities - - - Graphics - - - FileSystem - - - Graphics - - - Graphics\Scripting - - - Mesh - - - Graphics - - - Shaders - - - Graphics - - - ImGUI - - - ImGUI - - - - \ No newline at end of file diff --git a/Projects/VisualStudio/Runtime/Runtime.vcxproj.user b/Projects/VisualStudio/Runtime/Runtime.vcxproj.user deleted file mode 100644 index be25078..0000000 --- a/Projects/VisualStudio/Runtime/Runtime.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Runner/Runner.cpp b/Runner/Runner.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Runner/Runner.h b/Runner/Runner.h new file mode 100644 index 0000000..e69de29 diff --git a/Runtime/Graphics/Shader.cpp b/Runtime/Graphics/Shader.cpp index 4c41d6b..67bbe01 100644 --- a/Runtime/Graphics/Shader.cpp +++ b/Runtime/Graphics/Shader.cpp @@ -51,9 +51,10 @@ Shader::Shader(LuaBind::VM*vm, std::string& glslShader) // stlµÄstring»áÔÚ´óС³¬¹ýãÐÖµµÄÇé¿öÏÂÔÚÕ»Àï·ÖÅ䣬²¢ÓÃRAII±£Ö¤ÊÍ·Å std::string vsh ; std::string fsh ; + RenderCommandGroup cmd; try { - GLSLCompiler::Compile(glslShader, vsh, fsh); + GLSLCompiler::Compile(glslShader, vsh, fsh, cmd); } catch (GLSLCompileException& e) { diff --git a/Runtime/Graphics/ShaderCompiler.cpp b/Runtime/Graphics/ShaderCompiler.cpp index ba69313..809c375 100644 --- a/Runtime/Graphics/ShaderCompiler.cpp +++ b/Runtime/Graphics/ShaderCompiler.cpp @@ -7,11 +7,12 @@ const char* VSH_END = "VSH_END"; const char* FSH_BEGIN = "FSH_BEGIN"; const char* FSH_END = "FSH_END"; -// GLSL·ÖΪÈý²¿·Ö +// GLSL·ÖΪËIJ¿·Ö +// * CMD_BEGIN ºÍ CMD_END Ö®¼äµÄÃüÁî // * VERTEX_SHADER_BEGIN ºÍ VERTEX_SHADER_ENDÖ®¼äµÄ¶¥µã×ÅÉ«Æ÷ // * FRAGMENT_SHADER_BEGIN ºÍ FRAGMENT_SHADER_ENDÖ®¼äµÄƬ¶Î×ÅÉ«Æ÷ // * Á½ÕßÖ®ÍâµÄ¹«¹²²¿·Ö -void GLSLCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh)/*throw GLSLCompileException*/ +void GLSLCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& cmd)/*throw GLSLCompileException*/ { int vsh_begin = src.find(VSH_BEGIN); if (vsh_begin == string::npos) diff --git a/Runtime/Graphics/ShaderCompiler.h b/Runtime/Graphics/ShaderCompiler.h index 4e276c1..56ddb45 100644 --- a/Runtime/Graphics/ShaderCompiler.h +++ b/Runtime/Graphics/ShaderCompiler.h @@ -4,6 +4,7 @@ #include #include "Runtime/Threading/Mutex.h" #include "Runtime/Threading/Job.h" +#include "Runtime/Graphics/RenderCommands.h" // ±àÒëGLSL(GameLab Shading Language) @@ -34,6 +35,6 @@ public: class GLSLCompiler { public: - static void Compile(std::string& src, std::string& vsh, std::string& fsh)/*throw GLSLCompileException*/; + static void Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& cmd)/*throw GLSLCompileException*/; }; diff --git a/Runtime/Runner.cpp b/Runtime/Runner.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Runtime/Runner.h b/Runtime/Runner.h deleted file mode 100644 index e69de29..0000000 -- cgit v1.1-26-g67d0