added VertexColor2DMaterial at MaterialCreaterTest.cpp

This commit is contained in:
2023-03-15 17:50:33 +08:00
parent 5ba705cd6b
commit 31b5bb6d4f
4 changed files with 65 additions and 11 deletions

View File

@@ -63,12 +63,65 @@ void main()
mc.CreateShader();
return(false);
return(true);
}
bool VertexColor2DMaterial()
{
MaterialCreater mc(1,false);
//vertex部分
{
ShaderCreaterVertex *vsc=mc.GetVS();
vsc->AddInput("vec2","Position");
vsc->AddInput("vec4","Color");
vsc->AddOutput("vec4","Color");
vsc->SetShaderCodes(R"(
void main()
{
Output.Color=Color;
gl_Position=vec4(Position,0,1);
})");
}
//fragment部分
{
ShaderCreaterFragment *fsc=mc.GetFS();
fsc->AddOutput("vec4","Color");
fsc->SetShaderCodes(R"(
void main()
{
Color=Input.Color;
}
)");
}
mc.CreateShader();
return(true);
}
namespace glsl_compiler
{
bool Init();
void Close();
}//namespace glsl_compiler
int main()
{
if(!glsl_compiler::Init())
return -1;
PureColor2DMaterial();
VertexColor2DMaterial();
glsl_compiler::Close();
return 0;
}