Quellcode durchsuchen

debug: convert debug quad shaders to GLSL 1.30.

legacy
Sam Hocevar sam vor 13 Jahren
Ursprung
Commit
1fa6fb6994
2 geänderte Dateien mit 33 neuen und 38 gelöschten Zeilen
  1. +32
    -24
      src/debugquad.cpp
  2. +1
    -14
      src/video.cpp

+ 32
- 24
src/debugquad.cpp Datei anzeigen

@@ -122,13 +122,14 @@ void DebugQuad::TickDraw(float deltams)

/* Quad #4: create texture in fragment shader */
data->shader[0] = Shader::Create(
"#version 120\n"
"#version 130\n"
"in vec2 in_Vertex;"
"void main()"
"{"
" gl_Position = gl_Vertex;"
" gl_Position = vec4(in_Vertex, 0.0, 1.0);"
"}",

"#version 120\n"
"#version 130\n"
"void main()"
"{"
" float dx = mod(gl_FragCoord.x * gl_FragCoord.y, 2.0);"
@@ -139,33 +140,37 @@ void DebugQuad::TickDraw(float deltams)

/* Quad #5: pass color from vertex shader to fragment shader */
data->shader[1] = Shader::Create(
"#version 120\n"
"varying vec4 color;"
"#version 130\n"
"in vec2 in_Vertex;"
"in vec2 in_MultiTexCoord0;"
"varying vec4 pass_Color;"
"void main()"
"{"
" float r = gl_MultiTexCoord0.x;"
" float g = gl_MultiTexCoord0.y;"
" color = vec4(1.0 - r, 1.0 - g, r, 1.0);"
" gl_Position = gl_Vertex;"
" float r = in_MultiTexCoord0.x;"
" float g = in_MultiTexCoord0.y;"
" pass_Color = vec4(1.0 - r, 1.0 - g, r, 1.0);"
" gl_Position = vec4(in_Vertex, 0.0, 1.0);"
"}",

"#version 120\n"
"varying vec4 color;"
"#version 130\n"
"varying vec4 pass_Color;"
"void main()"
"{"
" gl_FragColor = color;"
" gl_FragColor = pass_Color;"
"}");

/* Quad #6: apply texture in fragment shader */
data->shader[2] = Shader::Create(
"#version 120\n"
"#version 130\n"
"in vec2 in_Vertex;"
"in vec2 in_MultiTexCoord0;"
"void main()"
"{"
" gl_TexCoord[0] = gl_MultiTexCoord0;"
" gl_Position = gl_Vertex;"
" gl_TexCoord[0] = vec4(in_MultiTexCoord0, 0.0, 0.0);"
" gl_Position = vec4(in_Vertex, 0.0, 1.0);"
"}",

"#version 120\n"
"#version 130\n"
"uniform sampler2D tex;"
"void main()"
"{"
@@ -174,22 +179,25 @@ void DebugQuad::TickDraw(float deltams)

/* Quad #8: vertex buffer, apply texture in fragment shader */
data->shader[3] = Shader::Create(
"#version 120\n"
"varying vec4 color;"
"#version 130\n"
"in vec2 in_Vertex;"
"in vec2 in_MultiTexCoord0;"
"in vec4 in_Color;"
"varying vec4 pass_Color;"
"void main()"
"{"
" gl_TexCoord[0] = gl_MultiTexCoord0;"
" color = gl_Color;"
" gl_Position = gl_Vertex;"
" gl_TexCoord[0] = vec4(in_MultiTexCoord0, 0.0, 0.0);"
" pass_Color = in_Color;"
" gl_Position = vec4(in_Vertex, 0.0, 1.0);"
"}",

"#version 120\n"
"varying vec4 color;"
"#version 130\n"
"varying vec4 pass_Color;"
"uniform sampler2D tex;"
"void main()"
"{"
" vec4 tmp = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
" gl_FragColor = vec4(abs(tmp.xyz - color.xyz), 1.0);"
" gl_FragColor = vec4(abs(tmp.xyz - pass_Color.xyz), 1.0);"
"}");




+ 1
- 14
src/video.cpp Datei anzeigen

@@ -37,33 +37,24 @@ mat4 proj_matrix, view_matrix, model_matrix;
#define OLD

static char const *vertexshader =
#if !defined OLD
"#version 130\n"
#endif
"\n"
#if defined HAVE_GLES_2X
"attribute vec3 in_Position;\n"
"attribute vec2 in_TexCoord;\n"
"varying vec2 pass_TexCoord;\n"
#elif !defined OLD
#else
"in vec3 in_Position;\n"
"in vec2 in_TexCoord;\n"
#endif
//"in vec3 in_Color;\n"
//"out vec3 pass_Color;\n"
"uniform mat4 proj_matrix;\n"
"uniform mat4 view_matrix;\n"
"uniform mat4 model_matrix;\n"
"\n"
"void main()\n"
"{\n"
#if defined OLD
" vec3 in_Position = gl_Vertex.xyz;\n"
" vec2 in_TexCoord = gl_MultiTexCoord0.xy;\n"
#endif
" gl_Position = proj_matrix * view_matrix * model_matrix"
" * vec4(in_Position, 1.0);\n"
//" pass_Color = in_Color;\n"
#if defined HAVE_GLES_2X
" pass_TexCoord = in_TexCoord;\n"
#else
@@ -72,13 +63,9 @@ static char const *vertexshader =
"}\n";

static char const *fragmentshader =
#if !defined OLD
"#version 130\n"
#endif
"\n"
"uniform sampler2D in_Texture;\n"
//"in vec3 pass_Color;\n"
//"out vec4 out_Color;\n"
#if defined HAVE_GLES_2X
"varying vec2 pass_TexCoord;\n"
#endif


Laden…
Abbrechen
Speichern