Fix shader compilation for ATi and Intel

This commit is contained in:
Simon Robertshaw 2011-11-04 20:07:51 +00:00
parent 85c638bf71
commit 6615fbca03
2 changed files with 25 additions and 14 deletions

View File

@ -224,21 +224,24 @@ void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale);
#ifdef INCLUDE_SHADERS #ifdef INCLUDE_SHADERS
#ifndef SHADERS_H #ifndef SHADERS_H
#define SHADERS_H #define SHADERS_H
const char * fireFragment = "uniform sampler2D fireAlpha;\ const char * fireFragment = "#version 120\n\
uniform sampler2D fireAlpha;\
void main () {\ void main () {\
vec4 texColor = texture2D(fireAlpha, gl_PointCoord);\ vec4 texColor = texture2D(fireAlpha, gl_PointCoord);\
gl_FragColor = vec4(gl_Color.rgb, texColor.a*gl_Color.a);\ 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_Position = ftransform();;\
gl_FrontColor = gl_Color;\ gl_FrontColor = gl_Color;\
}"; }";
const char * lensFragment = "uniform sampler2D pTex;\ const char * lensFragment = "#version 120\n\
uniform sampler2D pTex;\
uniform sampler2D tfX;\ uniform sampler2D tfX;\
uniform sampler2D tfY;\ uniform sampler2D tfY;\
uniform float xres = 612.0;\ uniform float xres;\
uniform float yres = 384.0;\ uniform float yres;\
void main () {\ void main () {\
vec4 transformX = texture2D(tfX, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\ 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));\ vec4 transformY = -texture2D(tfY, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\
@ -252,13 +255,15 @@ void main () {\
);\ );\
gl_FragColor = texColor;\ gl_FragColor = texColor;\
}"; }";
const char * lensVertex = "void main(void)\ const char * lensVertex = "#version 120\n\
void main(void)\
{\ {\
gl_TexCoord[0] = gl_MultiTexCoord0;\ gl_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\ gl_Position = ftransform();;\
gl_FrontColor = gl_Color;\ gl_FrontColor = gl_Color;\
}"; }";
const char * airVFragment = "uniform sampler2D airX;\ const char * airVFragment = "#version 120\n\
uniform sampler2D airX;\
uniform sampler2D airY;\ uniform sampler2D airY;\
uniform sampler2D airP;\ uniform sampler2D airP;\
void main () {\ void main () {\
@ -267,26 +272,30 @@ void main () {\
vec4 texP = texture2D(airP, gl_TexCoord[0].st);\ 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);\ 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_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\ gl_Position = ftransform();;\
gl_FrontColor = gl_Color;\ gl_FrontColor = gl_Color;\
}"; }";
const char * airPFragment = "uniform sampler2D airX;\ const char * airPFragment = "#version 120\n\
uniform sampler2D airX;\
uniform sampler2D airY;\ uniform sampler2D airY;\
uniform sampler2D airP;\ uniform sampler2D airP;\
void main () {\ void main () {\
vec4 texP = texture2D(airP, gl_TexCoord[0].st);\ 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);\ 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_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\ gl_Position = ftransform();;\
gl_FrontColor = gl_Color;\ gl_FrontColor = gl_Color;\
}"; }";
const char * airCFragment = "uniform sampler2D airX;\ const char * airCFragment = "#version 120\n\
uniform sampler2D airX;\
uniform sampler2D airY;\ uniform sampler2D airY;\
uniform sampler2D airP;\ uniform sampler2D airP;\
void main () {\ void main () {\
@ -295,7 +304,8 @@ void main () {\
vec4 texP = texture2D(airP, gl_TexCoord[0].st);\ 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);\ 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_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\ gl_Position = ftransform();;\

View File

@ -2515,6 +2515,7 @@ void render_parts(pixel *vid)
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
if(cmode==CM_FANCY) if(cmode==CM_FANCY)
{ {
float xres = XRES, yres = YRES;
glUseProgram(lensProg); glUseProgram(lensProg);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, partsFboTex); 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); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES, YRES, GL_GREEN, GL_FLOAT, gravyf);
glUniform1i(glGetUniformLocation(lensProg, "tfY"), 2); glUniform1i(glGetUniformLocation(lensProg, "tfY"), 2);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
//glUniform1f(glGetUniformLocation(lensProg, "xres"), (float)XRES); glUniform1fv(glGetUniformLocation(lensProg, "xres"), 1, &xres);
//glUniform1f(glGetUniformLocation(lensProg, "yres"), (float)YRES); glUniform1fv(glGetUniformLocation(lensProg, "yres"), 1, &yres);
} }
else else
{ {