sv_http/sv_ftp paranoia, add gl_menutint_shader cvar, use shaders for r_menutint rendering on GL
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2118 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
2f26e1d12a
commit
62462f3b5d
5 changed files with 161 additions and 29 deletions
|
@ -247,6 +247,7 @@ cvar_t gl_schematics = SCVAR("gl_schematics","0");
|
|||
cvar_t gl_ztrick = SCVAR("gl_ztrick","0");
|
||||
cvar_t gl_lerpimages = SCVAR("gl_lerpimages", "1");
|
||||
cvar_t gl_lightmap_shift = SCVARF("gl_lightmap_shift", "0", CVAR_ARCHIVE | CVAR_LATCH);
|
||||
cvar_t gl_menutint_shader = SCVAR("gl_menutint_shader", "1");
|
||||
extern cvar_t r_waterlayers;
|
||||
cvar_t gl_triplebuffer = SCVARF("gl_triplebuffer", "1", CVAR_ARCHIVE);
|
||||
cvar_t vid_hardwaregamma = SCVARF("vid_hardwaregamma", "1", CVAR_ARCHIVE);
|
||||
|
@ -367,6 +368,8 @@ void GLRenderer_Init(void)
|
|||
|
||||
Cvar_Register (&gl_lightmap_shift, GLRENDEREROPTIONS);
|
||||
|
||||
Cvar_Register (&gl_menutint_shader, GLRENDEREROPTIONS);
|
||||
|
||||
R_BloomRegister();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2007,12 +2007,14 @@ Draw_FadeScreen
|
|||
================
|
||||
*/
|
||||
vec3_t fadecolor;
|
||||
vec3_t fadecolorreal;
|
||||
int faderender;
|
||||
int fademodified;
|
||||
|
||||
void GLDraw_FadeScreen (void)
|
||||
{
|
||||
extern cvar_t r_menutint;
|
||||
extern cvar_t r_menutint, gl_menutint_shader;
|
||||
extern int scenepp_texture, scenepp_mt_program, scenepp_mt_parm_colorf, scenepp_mt_parm_inverti;
|
||||
|
||||
if (fademodified != r_menutint.modified)
|
||||
{
|
||||
|
@ -2032,24 +2034,16 @@ void GLDraw_FadeScreen (void)
|
|||
faderender = GL_ONE_MINUS_DST_COLOR;
|
||||
fadecolor[0] = -(fadecolor[0]);
|
||||
}
|
||||
if (fadecolor[0] > 1)
|
||||
fadecolor[0] = 1;
|
||||
|
||||
if (fadecolor[1] < 0)
|
||||
{
|
||||
faderender = GL_ONE_MINUS_DST_COLOR;
|
||||
fadecolor[1] = -(fadecolor[1]);
|
||||
}
|
||||
if (fadecolor[1] > 1)
|
||||
fadecolor[1] = 1;
|
||||
|
||||
if (fadecolor[2] < 0)
|
||||
{
|
||||
faderender = GL_ONE_MINUS_DST_COLOR;
|
||||
fadecolor[2] = -(fadecolor[2]);
|
||||
}
|
||||
if (fadecolor[2] > 1)
|
||||
fadecolor[2] = 1;
|
||||
}
|
||||
|
||||
fademodified = r_menutint.modified;
|
||||
|
@ -2058,24 +2052,103 @@ void GLDraw_FadeScreen (void)
|
|||
if (!faderender)
|
||||
return;
|
||||
|
||||
qglEnable (GL_BLEND);
|
||||
qglBlendFunc(faderender, GL_ZERO);
|
||||
qglDisable(GL_ALPHA_TEST);
|
||||
qglDisable (GL_TEXTURE_2D);
|
||||
qglColor4f (fadecolor[0], fadecolor[1], fadecolor[2], 1);
|
||||
qglBegin (GL_QUADS);
|
||||
if (scenepp_mt_program && gl_menutint_shader.value)
|
||||
{
|
||||
float vwidth = 1, vheight = 1;
|
||||
float vs, vt;
|
||||
|
||||
qglVertex2f (0,0);
|
||||
qglVertex2f (vid.width, 0);
|
||||
qglVertex2f (vid.width, vid.height);
|
||||
qglVertex2f (0, vid.height);
|
||||
// get the powers of 2 for the size of the texture that will hold the scene
|
||||
while (vwidth < glwidth)
|
||||
vwidth *= 2;
|
||||
while (vheight < glheight)
|
||||
vheight *= 2;
|
||||
|
||||
qglEnd ();
|
||||
qglColor4f (1,1,1,1);
|
||||
qglEnable (GL_TEXTURE_2D);
|
||||
qglDisable (GL_BLEND);
|
||||
qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
qglEnable(GL_ALPHA_TEST);
|
||||
// get the maxtexcoords while we're at it (cache this or just use largest?)
|
||||
vs = glwidth / vwidth;
|
||||
vt = glheight / vheight;
|
||||
|
||||
// 2d mode, but upside down to quake's normal 2d drawing
|
||||
// this makes grabbing the sreen a lot easier
|
||||
qglViewport (glx, gly, glwidth, glheight);
|
||||
|
||||
qglMatrixMode(GL_PROJECTION);
|
||||
// Push the matrices to go into 2d mode, that matches opengl's mode
|
||||
qglPushMatrix();
|
||||
qglLoadIdentity ();
|
||||
// TODO: use actual window width and height
|
||||
qglOrtho (0, glwidth, 0, glheight, -99999, 99999);
|
||||
|
||||
qglMatrixMode(GL_MODELVIEW);
|
||||
qglPushMatrix();
|
||||
qglLoadIdentity ();
|
||||
|
||||
GL_Bind(scenepp_texture);
|
||||
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(S_ERROR "GL Error after qglCopyTexImage2D\n");
|
||||
|
||||
GLSlang_UseProgram(scenepp_mt_program);
|
||||
qglUniform3fvARB(scenepp_mt_parm_colorf, 1, fadecolor);
|
||||
if (faderender == GL_ONE_MINUS_DST_COLOR)
|
||||
qglUniform1iARB(scenepp_mt_parm_inverti, 1);
|
||||
else
|
||||
qglUniform1iARB(scenepp_mt_parm_inverti, 0);
|
||||
|
||||
if (qglGetError())
|
||||
Con_Printf(S_ERROR "GL Error after GLSlang_UseProgram\n");
|
||||
|
||||
qglEnable(GL_TEXTURE_2D);
|
||||
GL_Bind(scenepp_texture);
|
||||
|
||||
qglBegin(GL_QUADS);
|
||||
|
||||
qglTexCoord2f (0, 0);
|
||||
qglVertex2f(0, 0);
|
||||
qglTexCoord2f (vs, 0);
|
||||
qglVertex2f(glwidth, 0);
|
||||
qglTexCoord2f (vs, vt);
|
||||
qglVertex2f(glwidth, glheight);
|
||||
qglTexCoord2f (0, vt);
|
||||
qglVertex2f(0, glheight);
|
||||
|
||||
qglEnd();
|
||||
|
||||
GLSlang_UseProgram(0);
|
||||
|
||||
// After all the post processing, pop the matrices
|
||||
qglMatrixMode(GL_PROJECTION);
|
||||
qglPopMatrix();
|
||||
qglMatrixMode(GL_MODELVIEW);
|
||||
qglPopMatrix();
|
||||
|
||||
if (qglGetError())
|
||||
Con_Printf(S_ERROR "GL Error after drawing with shaderobjects\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// shaderless way
|
||||
qglEnable (GL_BLEND);
|
||||
qglBlendFunc(faderender, GL_ZERO);
|
||||
qglDisable(GL_ALPHA_TEST);
|
||||
qglDisable (GL_TEXTURE_2D);
|
||||
qglColor4f (fadecolor[0], fadecolor[1], fadecolor[2], 1);
|
||||
qglBegin (GL_QUADS);
|
||||
|
||||
qglVertex2f (0,0);
|
||||
qglVertex2f (vid.width, 0);
|
||||
qglVertex2f (vid.width, vid.height);
|
||||
qglVertex2f (0, vid.height);
|
||||
|
||||
qglEnd ();
|
||||
qglColor4f (1,1,1,1);
|
||||
qglEnable (GL_TEXTURE_2D);
|
||||
qglDisable (GL_BLEND);
|
||||
qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
qglEnable(GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
Sbar_Changed();
|
||||
}
|
||||
|
|
|
@ -155,6 +155,11 @@ int scenepp_ww_parm_texture1i;
|
|||
int scenepp_ww_parm_texture2i;
|
||||
int scenepp_ww_parm_ampscalef;
|
||||
|
||||
int scenepp_mt_program;
|
||||
int scenepp_mt_parm_texture0i;
|
||||
int scenepp_mt_parm_colorf;
|
||||
int scenepp_mt_parm_inverti;
|
||||
|
||||
// KrimZon - init post processing - called in GL_CheckExtensions, when they're called
|
||||
// I put it here so that only this file need be changed when messing with the post
|
||||
// processing shaders
|
||||
|
@ -221,11 +226,62 @@ void GL_InitSceneProcessingShaders_WaterWarp (void)
|
|||
GLSlang_UseProgram(0);
|
||||
|
||||
if (qglGetError())
|
||||
Con_Printf("GL Error initing shader object\n");
|
||||
Con_Printf(S_ERROR "GL Error initing shader object\n");
|
||||
}
|
||||
|
||||
void GL_InitSceneProcessingShaders_MenuTint(void)
|
||||
{
|
||||
static vec3_t defaultcolor = {1, 1, 1};
|
||||
|
||||
char *vshader = "\
|
||||
varying vec2 texcoord;\
|
||||
void main(void)\
|
||||
{\
|
||||
texcoord = gl_MultiTexCoord0.xy;\
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\
|
||||
}";
|
||||
char *fshader = "\
|
||||
varying vec2 texcoord;\
|
||||
uniform vec3 colorparam;\
|
||||
uniform sampler2D source;\
|
||||
uniform int invert;\
|
||||
const vec3 lumfactors = vec3(0.299, 0.587, 0.114);\
|
||||
const vec3 invertvec = vec3(1.0, 1.0, 1.0);\
|
||||
void main(void)\
|
||||
{\
|
||||
vec3 texcolor = texture2D(source, texcoord).rgb;\
|
||||
float luminance = dot(lumfactors, texcolor);\
|
||||
texcolor = vec3(luminance, luminance, luminance);\
|
||||
texcolor *= colorparam;\
|
||||
texcolor = invert > 0 ? (invertvec - texcolor) : texcolor;\
|
||||
gl_FragColor = vec4(texcolor, 1.0);\
|
||||
}";
|
||||
|
||||
if (qglGetError())
|
||||
Con_Printf("GL Error before initing shader object\n");
|
||||
|
||||
scenepp_mt_program = GLSlang_CreateProgram(NULL, vshader, fshader);
|
||||
|
||||
if (!scenepp_mt_program)
|
||||
return;
|
||||
|
||||
scenepp_mt_parm_texture0i = GLSlang_GetUniformLocation(scenepp_mt_program, "source");
|
||||
scenepp_mt_parm_colorf = GLSlang_GetUniformLocation(scenepp_mt_program, "colorparam");
|
||||
scenepp_mt_parm_inverti = GLSlang_GetUniformLocation(scenepp_mt_program, "invert");
|
||||
|
||||
GLSlang_UseProgram(scenepp_mt_program);
|
||||
GLSlang_SetUniform1i(scenepp_mt_parm_texture0i, 0);
|
||||
|
||||
GLSlang_UseProgram(0);
|
||||
|
||||
if (qglGetError())
|
||||
Con_Printf(S_ERROR "GL Error initing shader object\n");
|
||||
}
|
||||
|
||||
void GL_InitSceneProcessingShaders (void)
|
||||
{
|
||||
GL_InitSceneProcessingShaders_WaterWarp();
|
||||
GL_InitSceneProcessingShaders_MenuTint();
|
||||
}
|
||||
|
||||
#define PP_WARP_TEX_SIZE 64
|
||||
|
@ -1862,7 +1918,7 @@ void GLR_RenderView (void)
|
|||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if (qglGetError())
|
||||
Con_Printf("GL Error after qglCopyTexImage2D\n");
|
||||
Con_Printf(S_ERROR "GL Error after qglCopyTexImage2D\n");
|
||||
|
||||
// Here we apply the shaders - currently just waterwarp
|
||||
GLSlang_UseProgram(scenepp_ww_program);
|
||||
|
|
|
@ -91,7 +91,7 @@ qboolean FTP_ServerInit(void)
|
|||
listen(ftpserversocket, 3);
|
||||
|
||||
ftpserverinitied = true;
|
||||
|
||||
ftpserverfailed = false;
|
||||
|
||||
IWebPrintf("FTP server is running\n");
|
||||
return true;
|
||||
|
|
|
@ -64,7 +64,7 @@ qboolean HTTP_ServerInit(void)
|
|||
listen(httpserversocket, 3);
|
||||
|
||||
httpserverinitied = true;
|
||||
|
||||
httpserverfailed = false;
|
||||
|
||||
IWebPrintf("HTTP server is running\n");
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue