From b215d811a1981e20f35bb31df4e6cd2a74146193 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 4 Nov 2021 10:00:00 +0800 Subject: *misc --- Data/DefaultContent/Libraries/GameLab/Debug.lua | 6 +++ Data/Libraries/GameLab/Editor/EditorWindow.lua | 23 +++++++++++ Data/Libraries/GameLab/Editor/GUI/EditorWindow.lua | 23 ----------- Data/Libraries/GameLab/Editor/GUI/init.lua | 2 - Data/Libraries/GameLab/Editor/init.lua | 1 + Data/Resources/Shaders/BaseColor.gls | 43 -------------------- Data/Resources/Shaders/BaseColor.glsl | 43 ++++++++++++++++++++ Data/Resources/Shaders/Editor-Shape.glsl | 47 ++++++++++++++++++++++ Data/Resources/Shaders/Editor-Text.gls | 47 ---------------------- Data/Resources/Shaders/Editor-Text.glsl | 45 +++++++++++++++++++++ Data/Resources/Shaders/Editor-UI.gls | 45 --------------------- Data/Resources/Shaders/Editor-UI.glsl | 45 +++++++++++++++++++++ Data/Scripts/Editor/AssetBrowser.lua | 9 ++--- Data/Scripts/EditorGUI/EditorWindowManager.lua | 2 +- Runtime/Graphics/Shader.cpp | 6 +-- Runtime/Graphics/Shader.h | 2 +- Runtime/Graphics/ShaderCompiler.cpp | 46 ++++++++++----------- Runtime/Graphics/ShaderCompiler.h | 14 +++---- 18 files changed, 249 insertions(+), 200 deletions(-) create mode 100644 Data/DefaultContent/Libraries/GameLab/Debug.lua create mode 100644 Data/Libraries/GameLab/Editor/EditorWindow.lua delete mode 100644 Data/Libraries/GameLab/Editor/GUI/EditorWindow.lua delete mode 100644 Data/Resources/Shaders/BaseColor.gls create mode 100644 Data/Resources/Shaders/BaseColor.glsl create mode 100644 Data/Resources/Shaders/Editor-Shape.glsl delete mode 100644 Data/Resources/Shaders/Editor-Text.gls create mode 100644 Data/Resources/Shaders/Editor-Text.glsl delete mode 100644 Data/Resources/Shaders/Editor-UI.gls create mode 100644 Data/Resources/Shaders/Editor-UI.glsl diff --git a/Data/DefaultContent/Libraries/GameLab/Debug.lua b/Data/DefaultContent/Libraries/GameLab/Debug.lua new file mode 100644 index 0000000..9f68160 --- /dev/null +++ b/Data/DefaultContent/Libraries/GameLab/Debug.lua @@ -0,0 +1,6 @@ + +local c_log = GameLab.Debug.Log +local c_log_editor = GameLab.Debug.LogEditor +local c_log_warning = GameLab.Debug.LogWarning +local c_log_error = GameLab.Debug.LogError + diff --git a/Data/Libraries/GameLab/Editor/EditorWindow.lua b/Data/Libraries/GameLab/Editor/EditorWindow.lua new file mode 100644 index 0000000..af79771 --- /dev/null +++ b/Data/Libraries/GameLab/Editor/EditorWindow.lua @@ -0,0 +1,23 @@ +local EditorWindow = GameLab.Class("GameLab.Editor.EditorWindow") + +EditorWindow.Ctor = function(self, title) + self.title = title -- 编辑器名称 + self.guiWindow = nil -- 绑定的GUIWindow +end + +EditorWindow.OnGUI = function(self) +end + +EditorWindow.OnUpdate = function(self) +end + +EditorWindow.OnStart = function(self) +end + +EditorWindow.OnStop = function(self) +end + +EditorWindow.OnFocus = function(self) +end + +return EditorWindow \ No newline at end of file diff --git a/Data/Libraries/GameLab/Editor/GUI/EditorWindow.lua b/Data/Libraries/GameLab/Editor/GUI/EditorWindow.lua deleted file mode 100644 index 4f0525f..0000000 --- a/Data/Libraries/GameLab/Editor/GUI/EditorWindow.lua +++ /dev/null @@ -1,23 +0,0 @@ -local EditorWindow = GameLab.Class("GameLab.Editor.GUI.EditorWindow") - -EditorWindow.Ctor = function(self, title) - self.title = title -- 编辑器名称 - self.guiWindow = nil -- 绑定的GUIWindow -end - -EditorWindow.OnGUI = function(self) -end - -EditorWindow.OnUpdate = function(self) -end - -EditorWindow.OnStart = function(self) -end - -EditorWindow.OnStop = function(self) -end - -EditorWindow.OnFocus = function(self) -end - -return EditorWindow \ No newline at end of file diff --git a/Data/Libraries/GameLab/Editor/GUI/init.lua b/Data/Libraries/GameLab/Editor/GUI/init.lua index def4237..a1ccb7c 100644 --- a/Data/Libraries/GameLab/Editor/GUI/init.lua +++ b/Data/Libraries/GameLab/Editor/GUI/init.lua @@ -3,8 +3,6 @@ local m = GameLab.Editor.GUI local import = GameLab.import(...) -m.EditorWindow = import("EditorWindow") - import("Functions") return m \ No newline at end of file diff --git a/Data/Libraries/GameLab/Editor/init.lua b/Data/Libraries/GameLab/Editor/init.lua index 97b4b2e..c151aab 100644 --- a/Data/Libraries/GameLab/Editor/init.lua +++ b/Data/Libraries/GameLab/Editor/init.lua @@ -4,5 +4,6 @@ GameLab.Editor = m local import = GameLab.import(...) m.AssetManager = import("AssetManager") +m.EditorWindow = import("EditorWindow") return m \ No newline at end of file diff --git a/Data/Resources/Shaders/BaseColor.gls b/Data/Resources/Shaders/BaseColor.gls deleted file mode 100644 index b1aed17..0000000 --- a/Data/Resources/Shaders/BaseColor.gls +++ /dev/null @@ -1,43 +0,0 @@ -#version 330 core - -VSH_BEGIN - -vec3 vPos; -vec3 vNormal; -vec4 vTangent; -vec4 vColor; -vec2 vUV; -vec2 vUV2; -vec2 vUV3; -vec2 vUV4; - -uniform mat4 gamelab_mat_model; -uniform mat4 gamelab_mat_vp; -uniform vec4 gamelab_screen; -uniform vec4 gamelab_time; - -uniform mat4 mvp; - -out vec2 uv; - -void main() -{ - vec4 clip = mvp * vec4(vPos, -1, 1.0); - gl_Position = clip; - uv = vUV; -} - -VSH_END - -FSH_BEGIN -uniform sampler2D uiTex; - -in vec2 uv; - -out vec4 FragColor; - -void main() -{ - FragColor = texture(uiTex, uv); -} -FSH_END diff --git a/Data/Resources/Shaders/BaseColor.glsl b/Data/Resources/Shaders/BaseColor.glsl new file mode 100644 index 0000000..b1aed17 --- /dev/null +++ b/Data/Resources/Shaders/BaseColor.glsl @@ -0,0 +1,43 @@ +#version 330 core + +VSH_BEGIN + +vec3 vPos; +vec3 vNormal; +vec4 vTangent; +vec4 vColor; +vec2 vUV; +vec2 vUV2; +vec2 vUV3; +vec2 vUV4; + +uniform mat4 gamelab_mat_model; +uniform mat4 gamelab_mat_vp; +uniform vec4 gamelab_screen; +uniform vec4 gamelab_time; + +uniform mat4 mvp; + +out vec2 uv; + +void main() +{ + vec4 clip = mvp * vec4(vPos, -1, 1.0); + gl_Position = clip; + uv = vUV; +} + +VSH_END + +FSH_BEGIN +uniform sampler2D uiTex; + +in vec2 uv; + +out vec4 FragColor; + +void main() +{ + FragColor = texture(uiTex, uv); +} +FSH_END diff --git a/Data/Resources/Shaders/Editor-Shape.glsl b/Data/Resources/Shaders/Editor-Shape.glsl new file mode 100644 index 0000000..7548507 --- /dev/null +++ b/Data/Resources/Shaders/Editor-Shape.glsl @@ -0,0 +1,47 @@ +// 渲染编辑器文字 + +#version 330 core + +CMD_BEGIN +Cull Off +Blend SrcAlpha OneMinusSrcAlpha +DepthTest Off +CMD_END + +uniform mat4 gamelab_mat_mvp; +uniform sampler2D gamelab_main_tex; +uniform vec2 gamelab_ui_position; + +VSH_BEGIN +layout (location = 0) in vec2 vPos; +layout (location = 1) in vec2 vUV; +layout (location = 2) in vec4 vColor; + +out vec2 uv; +out vec4 color; + +void main() +{ + vec2 pos = vPos + gamelab_ui_position; + vec4 clip = gamelab_mat_mvp * vec4(pos, -1, 1.0); + gl_Position = clip; + uv = vUV; + color = vColor; +} +VSH_END + +FSH_BEGIN +in vec2 uv; +in vec4 color; + +out vec4 FragColor; + +void main() +{ + //vec2 uv = vec2(uv.x, 1 - uv.y); + vec4 sampled = vec4(0.8,0.8,0.8,texture(gamelab_main_tex, uv).r); + sampled *= color; + //sampled = vec4(1,1,1,1); + FragColor = sampled; +} +FSH_END diff --git a/Data/Resources/Shaders/Editor-Text.gls b/Data/Resources/Shaders/Editor-Text.gls deleted file mode 100644 index 7548507..0000000 --- a/Data/Resources/Shaders/Editor-Text.gls +++ /dev/null @@ -1,47 +0,0 @@ -// 渲染编辑器文字 - -#version 330 core - -CMD_BEGIN -Cull Off -Blend SrcAlpha OneMinusSrcAlpha -DepthTest Off -CMD_END - -uniform mat4 gamelab_mat_mvp; -uniform sampler2D gamelab_main_tex; -uniform vec2 gamelab_ui_position; - -VSH_BEGIN -layout (location = 0) in vec2 vPos; -layout (location = 1) in vec2 vUV; -layout (location = 2) in vec4 vColor; - -out vec2 uv; -out vec4 color; - -void main() -{ - vec2 pos = vPos + gamelab_ui_position; - vec4 clip = gamelab_mat_mvp * vec4(pos, -1, 1.0); - gl_Position = clip; - uv = vUV; - color = vColor; -} -VSH_END - -FSH_BEGIN -in vec2 uv; -in vec4 color; - -out vec4 FragColor; - -void main() -{ - //vec2 uv = vec2(uv.x, 1 - uv.y); - vec4 sampled = vec4(0.8,0.8,0.8,texture(gamelab_main_tex, uv).r); - sampled *= color; - //sampled = vec4(1,1,1,1); - FragColor = sampled; -} -FSH_END diff --git a/Data/Resources/Shaders/Editor-Text.glsl b/Data/Resources/Shaders/Editor-Text.glsl new file mode 100644 index 0000000..03ec5a7 --- /dev/null +++ b/Data/Resources/Shaders/Editor-Text.glsl @@ -0,0 +1,45 @@ +#version 330 core + +CMD_BEGIN +Cull Off +Blend SrcAlpha OneMinusSrcAlpha +DepthTest Off +CMD_END + +uniform mat4 gamelab_mat_mvp; +uniform sampler2D gamelab_main_tex; +uniform vec2 gamelab_ui_position; + +VSH_BEGIN +layout (location = 0) in vec2 vPos; +layout (location = 1) in vec2 vUV; +layout (location = 2) in vec4 vColor; + +out vec2 uv; +out vec4 color; + +void main() +{ + vec2 pos = vPos + gamelab_ui_position; + vec4 clip = gamelab_mat_mvp * vec4(pos, -1, 1.0); + gl_Position = clip; + uv = vUV; + color = vColor; +} +VSH_END + +FSH_BEGIN +in vec2 uv; +in vec4 color; + +out vec4 FragColor; + +void main() +{ + //vec2 uv = vec2(uv.x, 1 - uv.y); + vec4 sampled = vec4(0.8,0.8,0.8,texture(gamelab_main_tex, uv).r); + sampled *= color; + //sampled = vec4(1,1,1,1); + FragColor = sampled; +} +FSH_END diff --git a/Data/Resources/Shaders/Editor-UI.gls b/Data/Resources/Shaders/Editor-UI.gls deleted file mode 100644 index b2b348b..0000000 --- a/Data/Resources/Shaders/Editor-UI.gls +++ /dev/null @@ -1,45 +0,0 @@ -#version 330 core - -CMD_BEGIN -Cull Off -Blend SrcAlpha OneMinusSrcAlpha -DepthTest Off -CMD_END - -uniform mat4 gamelab_mat_mvp; -uniform sampler2D gamelab_main_tex; -uniform vec2 gamelab_ui_position; - -VSH_BEGIN -layout (location = 0) in vec2 vPos; -layout (location = 1) in vec2 vUV; -layout (location = 2) in vec4 vColor; - -out vec2 uv; -out vec4 color; - -void main() -{ - vec2 pos = vPos + gamelab_ui_position; - vec4 clip = gamelab_mat_mvp * vec4(pos, -1, 1.0); - gl_Position = clip; - uv = vUV; - color = vColor; -} -VSH_END - -FSH_BEGIN -in vec2 uv; -in vec4 color; - -out vec4 FragColor; - -void main() -{ - //vec2 uv = vec2(uv.x, 1 - uv.y); - vec4 sampled = texture(gamelab_main_tex, uv); - // sampled *= color; - //sampled = vec4(1,1,1,1); - FragColor = sampled; -} -FSH_END diff --git a/Data/Resources/Shaders/Editor-UI.glsl b/Data/Resources/Shaders/Editor-UI.glsl new file mode 100644 index 0000000..b2b348b --- /dev/null +++ b/Data/Resources/Shaders/Editor-UI.glsl @@ -0,0 +1,45 @@ +#version 330 core + +CMD_BEGIN +Cull Off +Blend SrcAlpha OneMinusSrcAlpha +DepthTest Off +CMD_END + +uniform mat4 gamelab_mat_mvp; +uniform sampler2D gamelab_main_tex; +uniform vec2 gamelab_ui_position; + +VSH_BEGIN +layout (location = 0) in vec2 vPos; +layout (location = 1) in vec2 vUV; +layout (location = 2) in vec4 vColor; + +out vec2 uv; +out vec4 color; + +void main() +{ + vec2 pos = vPos + gamelab_ui_position; + vec4 clip = gamelab_mat_mvp * vec4(pos, -1, 1.0); + gl_Position = clip; + uv = vUV; + color = vColor; +} +VSH_END + +FSH_BEGIN +in vec2 uv; +in vec4 color; + +out vec4 FragColor; + +void main() +{ + //vec2 uv = vec2(uv.x, 1 - uv.y); + vec4 sampled = texture(gamelab_main_tex, uv); + // sampled *= color; + //sampled = vec4(1,1,1,1); + FragColor = sampled; +} +FSH_END diff --git a/Data/Scripts/Editor/AssetBrowser.lua b/Data/Scripts/Editor/AssetBrowser.lua index a0cb295..89d4eba 100644 --- a/Data/Scripts/Editor/AssetBrowser.lua +++ b/Data/Scripts/Editor/AssetBrowser.lua @@ -1,5 +1,5 @@ local Debug = GameLab.Debug -local AssetBrowser = GameLab.Editor.GUI.EditorWindow.Extend("GameLab.Editor.AssetBrowser") +local AssetBrowser = GameLab.Editor.EditorWindow.Extend("GameLab.Editor.AssetBrowser") local GL = GameLab.Engine.GL local Matrix44 = GameLab.Engine.Math.Matrix44 local Engine = GameLab.Engine @@ -15,7 +15,6 @@ local shader = nil local tex AssetBrowser.OnGUI = function(self) - if tex == nil then tex = Engine.Resource.LoadTexture("./Resources/Images/tile.png") --tex = Engine.Resource.LoadTexture("./Resources/Images/brickwall_small.jpg") @@ -24,7 +23,7 @@ AssetBrowser.OnGUI = function(self) if shader == nil then -- 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.gls") + shader = Engine.Rendering.Shader.CreateFromFile("./Resources/Shaders/Editor-Text.glsl") end local ortho = Matrix44.New() @@ -36,11 +35,11 @@ AssetBrowser.OnGUI = function(self) Engine.Rendering.UseShader(shader) Engine.Rendering.SetMatrix44("gamelab_mat_mvp", ortho) - Engine.Rendering.SetVector2("gamelab_ui_position", {0, 0}) + Engine.Rendering.SetVector2("gamelab_ui_position", {0, 30}) --Engine.Rendering.SetTexture("gamelab_main_tex", tex) --Engine.Rendering.DrawUIQuad({0, 0, 200, 200}) _G["default_font"]:GetCharacters("你好世界!Hello,World! Project Window Properties", 12) - --Engine.Rendering.DrawUI9Slicing(1, {25, 25}, {25, 25}, {80, 80}, {200, 200} ) + --Engine.Rendering.DrawUI9Slicing(1, {25, 25}, {25, 25}, {80, 80}, {400, 50} ) Engine.Rendering.ResetUniformState() end diff --git a/Data/Scripts/EditorGUI/EditorWindowManager.lua b/Data/Scripts/EditorGUI/EditorWindowManager.lua index 707038b..e3595ae 100644 --- a/Data/Scripts/EditorGUI/EditorWindowManager.lua +++ b/Data/Scripts/EditorGUI/EditorWindowManager.lua @@ -2,4 +2,4 @@ local EditorWindowManager = {} EditorWindowManager.name = "asd" -return EditorWindowManager \ No newline at end of file +return EditorWindowManager \ No newline at end of file diff --git a/Runtime/Graphics/Shader.cpp b/Runtime/Graphics/Shader.cpp index 8df3624..d1fe78e 100644 --- a/Runtime/Graphics/Shader.cpp +++ b/Runtime/Graphics/Shader.cpp @@ -45,7 +45,7 @@ Shader::Shader(LuaBind::VM*vm) { } -Shader::Shader(LuaBind::VM*vm, std::string& glslShader) +Shader::Shader(LuaBind::VM*vm, std::string& glsllShader) : NativeClass(vm) { // stlstringڴСֵջ䣬RAII֤ͷ @@ -53,9 +53,9 @@ Shader::Shader(LuaBind::VM*vm, std::string& glslShader) std::string fsh ; try { - GLSCompiler::Compile(glslShader, vsh, fsh, m_Commands); + GLSLCompiler::Compile(glsllShader, vsh, fsh, m_Commands); } - catch (GLSCompileException& e) + catch (GLSLCompileException& e) { ReleaseRenderCommandGroup(m_Commands); throw ShaderCompileExecption(e.what()); diff --git a/Runtime/Graphics/Shader.h b/Runtime/Graphics/Shader.h index 6b2b1bc..14d022b 100644 --- a/Runtime/Graphics/Shader.h +++ b/Runtime/Graphics/Shader.h @@ -14,7 +14,7 @@ class Shader : public LuaBind::NativeClass public: Shader()/*throw(ShaderCompileExecption)*/; Shader(LuaBind::VM*vm)/*throw(ShaderCompileExecption)*/; - Shader(LuaBind::VM*vm, std::string& glslShader)/*throw(ShaderCompileExecption)*/; + Shader(LuaBind::VM*vm, std::string& glsllShader)/*throw(ShaderCompileExecption)*/; Shader(LuaBind::VM*vm, const char* vert, const char* frag)/*throw(ShaderCompileExecption)*/; ~Shader(); diff --git a/Runtime/Graphics/ShaderCompiler.cpp b/Runtime/Graphics/ShaderCompiler.cpp index ddd21a6..20b19f5 100644 --- a/Runtime/Graphics/ShaderCompiler.cpp +++ b/Runtime/Graphics/ShaderCompiler.cpp @@ -13,18 +13,18 @@ static const char* CMD_END = "CMD_END"; std::string s_CompileError = ""; -// GLSΪIJ +// GLSLΪIJ // * CMD_BEGIN CMD_END ֮ // * VERTEX_SHADER_BEGIN VERTEX_SHADER_END֮Ķɫ // * FRAGMENT_SHADER_BEGIN FRAGMENT_SHADER_END֮Ƭɫ // * ֮Ĺ -void GLSCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& group)/*throw GLSCompileException*/ +void GLSLCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& group)/*throw GLSLCompileException*/ { #define CheckLabel(label) {\ int pos = src.find(label);\ if(pos == string::npos || !IsLabelActive(src, label)) {\ s_CompileError = std::string("Compile Shader Error: No ") + #label + " label";\ - throw GLSCompileException(s_CompileError.c_str());\ + throw GLSLCompileException(s_CompileError.c_str());\ }} CheckLabel(VSH_BEGIN); @@ -59,7 +59,7 @@ if(pos == string::npos || !IsLabelActive(src, label)) {\ fsh = common + fsh; } -std::string GLSCompiler::GetContent(std::string& src, const char* from, const char* to) +std::string GLSLCompiler::GetContent(std::string& src, const char* from, const char* to) { int begin = src.find(from); int end = src.find(to); @@ -71,7 +71,7 @@ std::string GLSCompiler::GetContent(std::string& src, const char* from, const ch return content; } -std::string GLSCompiler::TrimContent(std::string& src, const char* from, const char* to) +std::string GLSLCompiler::TrimContent(std::string& src, const char* from, const char* to) { int begin = src.find(from); int end = src.find(to); @@ -79,7 +79,7 @@ std::string GLSCompiler::TrimContent(std::string& src, const char* from, const c return result; } -bool GLSCompiler::IsLabelActive(std::string& src, const char* label) +bool GLSLCompiler::IsLabelActive(std::string& src, const char* label) { int pos = src.find(label); if (pos == string::npos) @@ -98,7 +98,7 @@ bool GLSCompiler::IsLabelActive(std::string& src, const char* label) return true; } -bool GLSCompiler::IsCommandActive(std::string& src, const char* label) +bool GLSLCompiler::IsCommandActive(std::string& src, const char* label) { int pos = src.find(label); if (pos == string::npos) @@ -117,7 +117,7 @@ bool GLSCompiler::IsCommandActive(std::string& src, const char* label) return true; } -void GLSCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) +void GLSLCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) { istringstream ss = istringstream(cmds); string line; @@ -139,7 +139,7 @@ void GLSCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) else { s_CompileError = string("Unknown command " + cmdName); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } } } @@ -147,7 +147,7 @@ void GLSCompiler::ParseCmd(std::string& cmds, RenderCommandGroup& group) #define IsSeperator(c) (c == ' ' || c == '\r' || c == '\n' || c == /*tab*/9) // ҵڵĵһʣΪ -bool GLSCompiler::FindCmdPos(std::string& line, int* start, int* end) +bool GLSLCompiler::FindCmdPos(std::string& line, int* start, int* end) { for (int i = 0; i < line.size(); ++i) { @@ -166,7 +166,7 @@ bool GLSCompiler::FindCmdPos(std::string& line, int* start, int* end) return false; } -bool GLSCompiler::IsLineCommentd(std::string& line) +bool GLSLCompiler::IsLineCommentd(std::string& line) { for (int i = 0; i < line.size(); ++i) { @@ -185,7 +185,7 @@ bool GLSCompiler::IsLineCommentd(std::string& line) #define MAX_PARAM 2 -void GLSCompiler::CommandCull(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandCull(std::string& p, RenderCommandGroup& group) { std::string params[1]; GetParams("Cull", p, params, 1); @@ -200,12 +200,12 @@ void GLSCompiler::CommandCull(std::string& p, RenderCommandGroup& group) { delete pCull; s_CompileError = string("Compile Shader Error: Invalid parameter of Cull: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pCull); } -void GLSCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) { std::string params[2]; GetParams("Blend", p, params, 2); @@ -239,7 +239,7 @@ void GLSCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) { delete pblend; s_CompileError = string("Compile Shader Error: Invalid parameter of Blend: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } if (params[1] == "Zero") blend.dstFac = Cmd_Blend::Blend_Zero; @@ -260,13 +260,13 @@ void GLSCompiler::CommandBlend(std::string& p, RenderCommandGroup& group) { delete pblend; s_CompileError = string("Compile Shader Error: Invalid parameter of Blend: " + params[1]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pblend); } -void GLSCompiler::CommandDepthTest(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandDepthTest(std::string& p, RenderCommandGroup& group) { std::string params[1]; GetParams("DepthTest", p, params, 1); @@ -286,12 +286,12 @@ void GLSCompiler::CommandDepthTest(std::string& p, RenderCommandGroup& group) { delete pTest; s_CompileError = string("Compile Shader Error: Invalid parameter of DepthTest: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pTest); } -void GLSCompiler::CommandDepthWrite(std::string& p, RenderCommandGroup& group) +void GLSLCompiler::CommandDepthWrite(std::string& p, RenderCommandGroup& group) { std::string params[1]; GetParams("DepthWrite", p, params, 1); @@ -304,12 +304,12 @@ void GLSCompiler::CommandDepthWrite(std::string& p, RenderCommandGroup& group) { delete pwrite; s_CompileError = string("Compile Shader Error: Invalid parameter of DepthWrite: " + params[0]); - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } group.push_back(pwrite); } -void GLSCompiler::GetParams(const char* cmdName, std::string& params, std::string* out, int n) +void GLSLCompiler::GetParams(const char* cmdName, std::string& params, std::string* out, int n) { int index = 0; for (int i = 0; i < params.size(); ++i) @@ -324,7 +324,7 @@ void GLSCompiler::GetParams(const char* cmdName, std::string& params, std::strin if (index >= n) { s_CompileError = string("Compile Shader Error: Invalid parameter count of ") + cmdName +" : " + params; - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } if(!IsSeperator(params[j])) out[index++] = params.substr(i, j - i + 1); @@ -337,7 +337,7 @@ void GLSCompiler::GetParams(const char* cmdName, std::string& params, std::strin if (index >= n) { s_CompileError = string("Compile Shader Error: Invalid parameter count of ") + cmdName + " : " + params; - throw GLSCompileException(s_CompileError.c_str()); + throw GLSLCompileException(s_CompileError.c_str()); } out[index++] = params.substr(i, j - i); break; diff --git a/Runtime/Graphics/ShaderCompiler.h b/Runtime/Graphics/ShaderCompiler.h index 2d48bb0..a9d174b 100644 --- a/Runtime/Graphics/ShaderCompiler.h +++ b/Runtime/Graphics/ShaderCompiler.h @@ -6,36 +6,36 @@ #include "Runtime/Threading/Job.h" #include "Runtime/Graphics/RenderCommands.h" -// GLS(GameLab Shader) +// GLSL(GameLab Shader) // in: .glsl path // out: vsh & fsh -class CompileGLSJob : public Job +class CompileGLSLJob : public Job { }; // in: glsl shader // out: vsh & fsh -class CompileGLSShaderJob : public Job +class CompileGLSLShaderJob : public Job { }; -class GLSCompileException : public std::exception +class GLSLCompileException : public std::exception { public: - GLSCompileException(const char* what) + GLSLCompileException(const char* what) : std::exception(what) { } }; -class GLSCompiler +class GLSLCompiler { public: - static void Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& cmd)/*throw GLSCompileException*/; + static void Compile(std::string& src, std::string& vsh, std::string& fsh, RenderCommandGroup& cmd)/*throw GLSLCompileException*/; private: static std::string GetContent(std::string& src, const char* from, const char* to); -- cgit v1.1-26-g67d0