From 1fa6fb699419dc850d279da99003063d2487137b Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 13 Jun 2011 19:35:52 +0000 Subject: [PATCH] debug: convert debug quad shaders to GLSL 1.30. --- src/debugquad.cpp | 56 +++++++++++++++++++++++++++-------------------- src/video.cpp | 15 +------------ 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/debugquad.cpp b/src/debugquad.cpp index a6f11113..c0e61a84 100644 --- a/src/debugquad.cpp +++ b/src/debugquad.cpp @@ -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);" "}"); diff --git a/src/video.cpp b/src/video.cpp index 9773a2f5..2c8f974c 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -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