diff options
Diffstat (limited to 'Runtime/Graphics')
-rw-r--r-- | Runtime/Graphics/Shader.cpp | 6 | ||||
-rw-r--r-- | Runtime/Graphics/Shader.h | 2 | ||||
-rw-r--r-- | Runtime/Graphics/ShaderCompiler.cpp | 46 | ||||
-rw-r--r-- | Runtime/Graphics/ShaderCompiler.h | 14 |
4 files changed, 34 insertions, 34 deletions
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<Shader>(vm) { // stl的string会在大小超过阈值的情况下在栈里分配,并用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<Shader> 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分为四部分
+// GLSL分为四部分
// * 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);
|