mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-23 04:11:53 +00:00
KrimZon's water warp code works a bit better with this instead.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@771 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
75c31d7223
commit
decefcb1ab
1 changed files with 63 additions and 23 deletions
|
@ -171,24 +171,49 @@ void GL_InitSceneProcessingShaders (void)
|
||||||
uniform float ampscale;\
|
uniform float ampscale;\
|
||||||
void main (void)\
|
void main (void)\
|
||||||
{\
|
{\
|
||||||
v_texCoord.x = v_texCoord.x + sin((v_texCoord.y * xscale) + time) * ampscale;\
|
vec2 temp;\
|
||||||
v_texCoord.y = v_texCoord.y + cos((v_texCoord.x * yscale) + time) * ampscale;\
|
temp.x = v_texCoord.x + sin((v_texCoord.y * xscale) + time) * ampscale;\
|
||||||
gl_FragColor = texture2D( texture, v_texCoord );\
|
temp.y = v_texCoord.y + cos((v_texCoord.x * yscale) + time) * ampscale;\
|
||||||
|
gl_FragColor = texture2D( texture, temp );\
|
||||||
}\
|
}\
|
||||||
";
|
";
|
||||||
|
|
||||||
vert = GLSlang_CreateShader(genericvert, 1);
|
if (qglGetError())
|
||||||
frag = GLSlang_CreateShader(wwfrag, 0);
|
Con_Printf("GL Error before initing shader object\n");
|
||||||
|
|
||||||
|
vert = GLSlang_CreateShader(genericvert, 1);//GL_VERTEX_SHADER_ARB);
|
||||||
|
frag = GLSlang_CreateShader(wwfrag, 0);//GL_FRAGMENT_SHADER_ARB);
|
||||||
|
|
||||||
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after initing shader object\n");
|
||||||
|
|
||||||
scenepp_ww_program = GLSlang_CreateProgram(vert, frag);
|
scenepp_ww_program = GLSlang_CreateProgram(vert, frag);
|
||||||
scenepp_ww_parm_texturei = GLSlang_GetUniformLocation(scenepp_ww_program, "texture");
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after initing shader object\n");
|
||||||
|
|
||||||
|
// scenepp_ww_parm_texturei = GLSlang_GetUniformLocation(scenepp_ww_program, "texture");
|
||||||
scenepp_ww_parm_timef = GLSlang_GetUniformLocation(scenepp_ww_program, "time");
|
scenepp_ww_parm_timef = GLSlang_GetUniformLocation(scenepp_ww_program, "time");
|
||||||
scenepp_ww_parm_xscalef = GLSlang_GetUniformLocation(scenepp_ww_program, "xscale");
|
scenepp_ww_parm_xscalef = GLSlang_GetUniformLocation(scenepp_ww_program, "xscale");
|
||||||
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after initing shader object\n");
|
||||||
scenepp_ww_parm_yscalef = GLSlang_GetUniformLocation(scenepp_ww_program, "yscale");
|
scenepp_ww_parm_yscalef = GLSlang_GetUniformLocation(scenepp_ww_program, "yscale");
|
||||||
scenepp_ww_parm_ampscalef = GLSlang_GetUniformLocation(scenepp_ww_program, "ampscale");
|
scenepp_ww_parm_ampscalef = GLSlang_GetUniformLocation(scenepp_ww_program, "ampscale");
|
||||||
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after initing shader object\n");
|
||||||
|
|
||||||
GLSlang_SetUniform1i(scenepp_ww_parm_texturei, 0);
|
GLSlang_UseProgram(scenepp_ww_program);
|
||||||
GLSlang_SetUniform1f(scenepp_ww_parm_ampscalef, 0.08);
|
|
||||||
|
// GLSlang_SetUniform1i(scenepp_ww_parm_texturei, 0);
|
||||||
|
|
||||||
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after initing shader object\n");
|
||||||
|
|
||||||
|
GLSlang_SetUniform1f(scenepp_ww_parm_ampscalef, 0.02);
|
||||||
|
|
||||||
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after initing shader object\n");
|
||||||
|
|
||||||
|
GLSlang_UseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1749,6 +1774,7 @@ void GLR_RenderView (void)
|
||||||
// we check if we need to use any shaders - currently it's just waterwarp
|
// we check if we need to use any shaders - currently it's just waterwarp
|
||||||
if ((gl_config.arb_shader_objects) && (r_waterwarp.value /*&& r_viewleaf->contents <= Q1CONTENTS_WATER*/))
|
if ((gl_config.arb_shader_objects) && (r_waterwarp.value /*&& r_viewleaf->contents <= Q1CONTENTS_WATER*/))
|
||||||
{
|
{
|
||||||
|
extern int char_texture;
|
||||||
float vwidth = 1, vheight = 1;
|
float vwidth = 1, vheight = 1;
|
||||||
float vs, vt;
|
float vs, vt;
|
||||||
|
|
||||||
|
@ -1762,9 +1788,12 @@ void GLR_RenderView (void)
|
||||||
vheight *= 2;
|
vheight *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the texcoords while we're at it
|
if (qglGetError())
|
||||||
vs = glwidth - vwidth;
|
Con_Printf("GL Error before drawing with shaderobjects\n");
|
||||||
vt = glheight - vheight;
|
|
||||||
|
// get the maxtexcoords while we're at it
|
||||||
|
vs = glwidth / vwidth;
|
||||||
|
vt = glheight / vheight;
|
||||||
|
|
||||||
// 2d mode, but upside down to quake's normal 2d drawing
|
// 2d mode, but upside down to quake's normal 2d drawing
|
||||||
// this makes grabbing the sreen a lot easier
|
// this makes grabbing the sreen a lot easier
|
||||||
|
@ -1775,7 +1804,7 @@ void GLR_RenderView (void)
|
||||||
qglPushMatrix();
|
qglPushMatrix();
|
||||||
qglLoadIdentity ();
|
qglLoadIdentity ();
|
||||||
// TODO: use actual window width and height
|
// TODO: use actual window width and height
|
||||||
qglOrtho (0, vid.width, 0, vid.height, -99999, 99999);
|
qglOrtho (0, glwidth, 0, glheight, -99999, 99999);
|
||||||
|
|
||||||
qglMatrixMode(GL_MODELVIEW);
|
qglMatrixMode(GL_MODELVIEW);
|
||||||
qglPushMatrix();
|
qglPushMatrix();
|
||||||
|
@ -1789,6 +1818,11 @@ void GLR_RenderView (void)
|
||||||
// copy the scene to texture
|
// copy the scene to texture
|
||||||
GL_Bind(scenepp_texture);
|
GL_Bind(scenepp_texture);
|
||||||
qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, glx, gly, vwidth, vheight, 0);
|
qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, glx, gly, vwidth, vheight, 0);
|
||||||
|
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after qglCopyTexImage2D\n");
|
||||||
|
|
||||||
// Here we apply the shaders - currently just waterwarp
|
// Here we apply the shaders - currently just waterwarp
|
||||||
GLSlang_UseProgram(scenepp_ww_program);
|
GLSlang_UseProgram(scenepp_ww_program);
|
||||||
|
@ -1796,30 +1830,36 @@ void GLR_RenderView (void)
|
||||||
GLSlang_SetUniform1f(scenepp_ww_parm_xscalef, glheight / 32.0f);
|
GLSlang_SetUniform1f(scenepp_ww_parm_xscalef, glheight / 32.0f);
|
||||||
GLSlang_SetUniform1f(scenepp_ww_parm_timef, cl.time);
|
GLSlang_SetUniform1f(scenepp_ww_parm_timef, cl.time);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after GLSlang_UseProgram\n");
|
||||||
|
|
||||||
glTexCoord2f(0, 0);
|
qglBegin(GL_QUADS);
|
||||||
glVertex2f(0, 0);
|
|
||||||
|
|
||||||
glTexCoord2f(vs, 0);
|
qglTexCoord2f(0, 0);
|
||||||
glVertex2f(vwidth, 0);
|
qglVertex2f(0, 0);
|
||||||
|
|
||||||
glTexCoord2f(vs, vt);
|
qglTexCoord2f(vs, 0);
|
||||||
glVertex2f(vwidth, vheight);
|
qglVertex2f(glwidth, 0);
|
||||||
|
|
||||||
glTexCoord2f(0, vt);
|
qglTexCoord2f(vs, vt);
|
||||||
glVertex2f(0, vheight);
|
qglVertex2f(glwidth, glheight);
|
||||||
|
|
||||||
|
qglTexCoord2f(0, vt);
|
||||||
|
qglVertex2f(0, glheight);
|
||||||
|
|
||||||
glEnd();
|
qglEnd();
|
||||||
|
|
||||||
// Disable shaders
|
// Disable shaders
|
||||||
GLSlang_UseProgram(NULL);
|
GLSlang_UseProgram(0);
|
||||||
|
|
||||||
// After all the post processing, pop the matrices
|
// After all the post processing, pop the matrices
|
||||||
qglMatrixMode(GL_PROJECTION);
|
qglMatrixMode(GL_PROJECTION);
|
||||||
qglPopMatrix();
|
qglPopMatrix();
|
||||||
qglMatrixMode(GL_MODELVIEW);
|
qglMatrixMode(GL_MODELVIEW);
|
||||||
qglPopMatrix();
|
qglPopMatrix();
|
||||||
|
|
||||||
|
if (qglGetError())
|
||||||
|
Con_Printf("GL Error after drawing with shaderobjects\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue