From e5ffcfb43231c55c1cdd71566e622de7583160a9 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 31 Oct 2021 19:47:57 +0800 Subject: * glsl compiler --- Data/Resources/Shaders/Editor-Text.glsl | 2 +- Projects/VisualStudio/Editor/Editor.vcxproj | 1 + Projects/VisualStudio/Editor/Editor.vcxproj.filters | 3 +++ Runtime/Graphics/RenderCommands.cpp | 9 +++++++++ Runtime/Graphics/RenderCommands.h | 1 + Runtime/Graphics/Shader.cpp | 1 + Runtime/Graphics/ShaderCompiler.cpp | 4 ++-- 7 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 Runtime/Graphics/RenderCommands.cpp diff --git a/Data/Resources/Shaders/Editor-Text.glsl b/Data/Resources/Shaders/Editor-Text.glsl index 1624c0e..f589e07 100644 --- a/Data/Resources/Shaders/Editor-Text.glsl +++ b/Data/Resources/Shaders/Editor-Text.glsl @@ -2,8 +2,8 @@ CMD_BEGIN +Cull Both Blend SrcAlpha OneMinusSrcAlpha -Cull Both DepthTest Off CMD_END diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj b/Projects/VisualStudio/Editor/Editor.vcxproj index e6c8aee..3dda150 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj +++ b/Projects/VisualStudio/Editor/Editor.vcxproj @@ -191,6 +191,7 @@ + diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters index 78f759a..32f64ac 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters +++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters @@ -390,6 +390,9 @@ Runtime\Rendering + + Runtime\Graphics + diff --git a/Runtime/Graphics/RenderCommands.cpp b/Runtime/Graphics/RenderCommands.cpp new file mode 100644 index 0000000..336bf20 --- /dev/null +++ b/Runtime/Graphics/RenderCommands.cpp @@ -0,0 +1,9 @@ +#include "RenderCommands.h" + +void ReleaseRenderCommandGroup(RenderCommandGroup& group) +{ + for (int i = 0; i < group.size(); ++i) + { + delete group[i]; + } +} diff --git a/Runtime/Graphics/RenderCommands.h b/Runtime/Graphics/RenderCommands.h index cbffdd0..8dc2dbe 100644 --- a/Runtime/Graphics/RenderCommands.h +++ b/Runtime/Graphics/RenderCommands.h @@ -8,6 +8,7 @@ struct RenderCommand }; typedef std::vector RenderCommandGroup; +void ReleaseRenderCommandGroup(RenderCommandGroup& group); // Cull Off|Front|Back|Both struct Cmd_Cull : RenderCommand diff --git a/Runtime/Graphics/Shader.cpp b/Runtime/Graphics/Shader.cpp index 67bbe01..ca5a572 100644 --- a/Runtime/Graphics/Shader.cpp +++ b/Runtime/Graphics/Shader.cpp @@ -58,6 +58,7 @@ Shader::Shader(LuaBind::VM*vm, std::string& glslShader) } catch (GLSLCompileException& e) { + ReleaseRenderCommandGroup(cmd); throw ShaderCompileExecption(e.what()); } CompileProgram(vsh.c_str(), fsh.c_str()); diff --git a/Runtime/Graphics/ShaderCompiler.cpp b/Runtime/Graphics/ShaderCompiler.cpp index 06ad7b0..637fd59 100644 --- a/Runtime/Graphics/ShaderCompiler.cpp +++ b/Runtime/Graphics/ShaderCompiler.cpp @@ -314,7 +314,7 @@ void GLSLCompiler::GetParams(const char* cmdName, std::string& params, std::stri s_CompileError = string("Compile Shader Error: Invalid parameter count of ") + cmdName +" : " + params; throw GLSLCompileException(s_CompileError.c_str()); } - if(!IsSeperator(params[i])) + if(!IsSeperator(params[j])) out[index++] = params.substr(i, j - i + 1); else out[index++] = params.substr(i, j - i); @@ -332,4 +332,4 @@ void GLSLCompiler::GetParams(const char* cmdName, std::string& params, std::stri } i = j; } -} \ No newline at end of file +} -- cgit v1.1-26-g67d0