mirror of https://github.com/buggins/dlangui.git
refactor shaders code
This commit is contained in:
parent
3b4e98b024
commit
20f6488694
|
@ -211,26 +211,28 @@ immutable string MEDIUMP = "";
|
||||||
|
|
||||||
class SolidFillProgram : GLProgram {
|
class SolidFillProgram : GLProgram {
|
||||||
@property override string vertexSource() {
|
@property override string vertexSource() {
|
||||||
return
|
return q{
|
||||||
"in " ~ HIGHP ~ " vec4 vertex;\n"
|
in vec4 vertex;
|
||||||
"in " ~ LOWP ~ " vec4 colAttr;\n"
|
in vec4 colAttr;
|
||||||
"out " ~ LOWP ~ " vec4 col;\n"
|
out vec4 col;
|
||||||
"uniform " ~ MEDIUMP ~ " mat4 matrix;\n"
|
uniform mat4 matrix;
|
||||||
"void main(void)\n"
|
void main(void)
|
||||||
"{\n"
|
{
|
||||||
" gl_Position = matrix * vertex;\n"
|
gl_Position = matrix * vertex;
|
||||||
" col = colAttr;\n"
|
col = colAttr;
|
||||||
"}\n";
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@property override string fragmentSource() {
|
@property override string fragmentSource() {
|
||||||
return
|
return q{
|
||||||
"in " ~ LOWP ~ " vec4 col;\n"
|
in vec4 col;
|
||||||
"out " ~ LOWP ~ " vec4 outColor;\n"
|
out vec4 outColor;
|
||||||
"void main(void)\n"
|
void main(void)
|
||||||
"{\n"
|
{
|
||||||
" outColor = col;\n"
|
outColor = col;
|
||||||
"}\n";
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void beforeExecute() {
|
void beforeExecute() {
|
||||||
|
@ -336,31 +338,33 @@ class SolidFillProgram : GLProgram {
|
||||||
|
|
||||||
class TextureProgram : SolidFillProgram {
|
class TextureProgram : SolidFillProgram {
|
||||||
@property override string vertexSource() {
|
@property override string vertexSource() {
|
||||||
return
|
return q{
|
||||||
"in " ~ HIGHP ~ " vec4 vertex;\n"
|
in vec4 vertex;
|
||||||
"in " ~ LOWP ~ " vec4 colAttr;\n"
|
in vec4 colAttr;
|
||||||
"in " ~ MEDIUMP ~ " vec4 texCoord;\n"
|
in vec4 texCoord;
|
||||||
"out " ~ LOWP ~ " vec4 col;\n"
|
out vec4 col;
|
||||||
"out " ~ MEDIUMP ~ " vec4 texc;\n"
|
out vec4 texc;
|
||||||
"uniform " ~ MEDIUMP ~ " mat4 matrix;\n"
|
uniform mat4 matrix;
|
||||||
"void main(void)\n"
|
void main(void)
|
||||||
"{\n"
|
{
|
||||||
" gl_Position = matrix * vertex;\n"
|
gl_Position = matrix * vertex;
|
||||||
" col = colAttr;\n"
|
col = colAttr;
|
||||||
" texc = texCoord;\n"
|
texc = texCoord;
|
||||||
"}\n";
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@property override string fragmentSource() {
|
@property override string fragmentSource() {
|
||||||
return
|
return q{
|
||||||
"uniform sampler2D texture;\n"
|
uniform sampler2D texture;
|
||||||
"in " ~ LOWP ~ " vec4 col;\n"
|
in vec4 col;
|
||||||
"in " ~ MEDIUMP ~ " vec4 texc;\n"
|
in vec4 texc;
|
||||||
"out " ~ LOWP ~ " vec4 outColor;\n"
|
out vec4 outColor;
|
||||||
"void main(void)\n"
|
void main(void)
|
||||||
"{\n"
|
{
|
||||||
" outColor = texture(texture, texc.st) * col;\n" //texture2D
|
outColor = texture(texture, texc.st) * col;
|
||||||
"}\n";
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint texCoordLocation;
|
GLint texCoordLocation;
|
||||||
|
@ -447,31 +451,33 @@ class TextureProgram : SolidFillProgram {
|
||||||
|
|
||||||
class FontProgram : SolidFillProgram {
|
class FontProgram : SolidFillProgram {
|
||||||
@property override string vertexSource() {
|
@property override string vertexSource() {
|
||||||
return
|
return q{
|
||||||
"in " ~ HIGHP ~ " vec4 vertex;\n"
|
in vec4 vertex;
|
||||||
"in " ~ LOWP ~ " vec4 colAttr;\n"
|
in vec4 colAttr;
|
||||||
"in " ~ MEDIUMP ~ " vec4 texCoord;\n"
|
in vec4 texCoord;
|
||||||
"out " ~ LOWP ~ " vec4 col;\n"
|
out vec4 col;
|
||||||
"out " ~ MEDIUMP ~ " vec4 texc;\n"
|
out vec4 texc;
|
||||||
"uniform " ~ MEDIUMP ~ " mat4 matrix;\n"
|
uniform mat4 matrix;
|
||||||
"void main(void)\n"
|
void main(void)
|
||||||
"{\n"
|
{
|
||||||
" gl_Position = matrix * vertex;\n"
|
gl_Position = matrix * vertex;
|
||||||
" col = colAttr;\n"
|
col = colAttr;
|
||||||
" texc = texCoord;\n"
|
texc = texCoord;
|
||||||
"}\n";
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@property override string fragmentSource() {
|
@property override string fragmentSource() {
|
||||||
return
|
return q{
|
||||||
"uniform sampler2D texture;\n"
|
uniform sampler2D texture;
|
||||||
"in " ~ LOWP ~ " vec4 col;\n"
|
in vec4 col;
|
||||||
"in " ~ MEDIUMP ~ " vec4 texc;\n"
|
in vec4 texc;
|
||||||
"out " ~ LOWP ~ " vec4 outColor;\n"
|
out vec4 outColor;
|
||||||
"void main(void)\n"
|
void main(void)
|
||||||
"{\n"
|
{
|
||||||
" outColor = texture(texture, texc.st) * col;\n"//texture2D
|
outColor = texture(texture, texc.st) * col;
|
||||||
"}\n";
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint texCoordLocation;
|
GLint texCoordLocation;
|
||||||
|
|
Loading…
Reference in New Issue