diff --git a/includes/graphics.h b/includes/graphics.h index b9d39bb2d..f86158a59 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -224,21 +224,24 @@ void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale); #ifdef INCLUDE_SHADERS #ifndef SHADERS_H #define SHADERS_H -const char * fireFragment = "uniform sampler2D fireAlpha;\ +const char * fireFragment = "#version 120\n\ +uniform sampler2D fireAlpha;\ void main () {\ vec4 texColor = texture2D(fireAlpha, gl_PointCoord);\ gl_FragColor = vec4(gl_Color.rgb, texColor.a*gl_Color.a);\ }"; -const char * fireVertex = "void main(void)\ +const char * fireVertex = "#version 120\n\ +void main(void)\ {\ gl_Position = ftransform();;\ gl_FrontColor = gl_Color;\ }"; -const char * lensFragment = "uniform sampler2D pTex;\ +const char * lensFragment = "#version 120\n\ +uniform sampler2D pTex;\ uniform sampler2D tfX;\ uniform sampler2D tfY;\ -uniform float xres = 612.0;\ -uniform float yres = 384.0;\ +uniform float xres;\ +uniform float yres;\ void main () {\ vec4 transformX = texture2D(tfX, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\ vec4 transformY = -texture2D(tfY, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\ @@ -252,13 +255,15 @@ void main () {\ );\ gl_FragColor = texColor;\ }"; -const char * lensVertex = "void main(void)\ +const char * lensVertex = "#version 120\n\ +void main(void)\ {\ gl_TexCoord[0] = gl_MultiTexCoord0;\ gl_Position = ftransform();;\ gl_FrontColor = gl_Color;\ }"; -const char * airVFragment = "uniform sampler2D airX;\ +const char * airVFragment = "#version 120\n\ +uniform sampler2D airX;\ uniform sampler2D airY;\ uniform sampler2D airP;\ void main () {\ @@ -267,26 +272,30 @@ void main () {\ vec4 texP = texture2D(airP, gl_TexCoord[0].st);\ gl_FragColor = vec4(abs(texX.r)/2.0, texP.b/2.0, abs(texY.g)/2.0, 1.0);\ }"; -const char * airVVertex = "void main(void)\ +const char * airVVertex = "#version 120\n\ +void main(void)\ {\ gl_TexCoord[0] = gl_MultiTexCoord0;\ gl_Position = ftransform();;\ gl_FrontColor = gl_Color;\ }"; -const char * airPFragment = "uniform sampler2D airX;\ +const char * airPFragment = "#version 120\n\ +uniform sampler2D airX;\ uniform sampler2D airY;\ uniform sampler2D airP;\ void main () {\ vec4 texP = texture2D(airP, gl_TexCoord[0].st);\ gl_FragColor = vec4(max(texP.b/2.0, 0), 0, abs(min(texP.b/2.0, 0)), 1.0);\ }"; -const char * airPVertex = "void main(void)\ +const char * airPVertex = "#version 120\n\ +void main(void)\ {\ gl_TexCoord[0] = gl_MultiTexCoord0;\ gl_Position = ftransform();;\ gl_FrontColor = gl_Color;\ }"; -const char * airCFragment = "uniform sampler2D airX;\ +const char * airCFragment = "#version 120\n\ +uniform sampler2D airX;\ uniform sampler2D airY;\ uniform sampler2D airP;\ void main () {\ @@ -295,7 +304,8 @@ void main () {\ vec4 texP = texture2D(airP, gl_TexCoord[0].st);\ gl_FragColor = vec4(max(texP.b/2.0, 0), 0, abs(min(texP.b/2.0, 0)), 1.0) + vec4(abs(texX.r)/8.0, abs(texX.r)/8.0, abs(texX.r)/8.0, 1.0) + vec4(abs(texY.g)/8.0, abs(texY.g)/8.0, abs(texY.g)/8.0, 1.0);\ }"; -const char * airCVertex = "void main(void)\ +const char * airCVertex = "#version 120\n\ +void main(void)\ {\ gl_TexCoord[0] = gl_MultiTexCoord0;\ gl_Position = ftransform();;\ diff --git a/src/graphics.c b/src/graphics.c index 8f5fe8c62..2409b98de 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2515,6 +2515,7 @@ void render_parts(pixel *vid) glEnable( GL_TEXTURE_2D ); if(cmode==CM_FANCY) { + float xres = XRES, yres = YRES; glUseProgram(lensProg); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, partsFboTex); @@ -2528,8 +2529,8 @@ void render_parts(pixel *vid) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES, YRES, GL_GREEN, GL_FLOAT, gravyf); glUniform1i(glGetUniformLocation(lensProg, "tfY"), 2); glActiveTexture(GL_TEXTURE0); - //glUniform1f(glGetUniformLocation(lensProg, "xres"), (float)XRES); - //glUniform1f(glGetUniformLocation(lensProg, "yres"), (float)YRES); + glUniform1fv(glGetUniformLocation(lensProg, "xres"), 1, &xres); + glUniform1fv(glGetUniformLocation(lensProg, "yres"), 1, &yres); } else {