Compare commits

...

10 commits

7 changed files with 156 additions and 152 deletions

View file

@ -496,7 +496,8 @@ void R_DrawWorldBumped() {
R_DrawMeshBumped((mesh_t *)currentshadowlight->lightCmdsMesh[i].asVoid); R_DrawMeshBumped((mesh_t *)currentshadowlight->lightCmdsMesh[i].asVoid);
} }
lastShader = ((msurface_t *)currentshadowlight->lightCmds[0].asVoid)->shader->shader; if ( (msurface_t *)currentshadowlight->lightCmds[0].asVoid)
lastShader = ((msurface_t *)currentshadowlight->lightCmds[0].asVoid)->shader->shader;
freeIndex = 0; freeIndex = 0;
for (i=0; i<currentshadowlight->numlightcmds-1; i++) { for (i=0; i<currentshadowlight->numlightcmds-1; i++) {
s = (msurface_t *)currentshadowlight->lightCmds[i].asVoid; s = (msurface_t *)currentshadowlight->lightCmds[i].asVoid;

View file

@ -162,7 +162,8 @@ typedef char GLcharARB;
#define GL_ARB_vertex_shader 1 #define GL_ARB_vertex_shader 1
// Taken from ARB_vertex_program // Taken from ARB_vertex_program
#if !defined(__FreeBSD__) #ifndef GL_ARB_vertex_program
#define GL_ARB_vertex_program 1
typedef void (APIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
typedef void (APIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
typedef void (APIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
@ -206,6 +207,12 @@ typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLu
typedef void (APIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalize, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalize, GLsizei stride, const GLvoid *pointer);
typedef void (APIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (APIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
typedef void (APIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (APIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer);
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
#endif #endif
typedef void (APIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); typedef void (APIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
typedef void (APIENTRY * PFNGLBINDARRAYGL2PROC) (GLhandleARB shaderObject, GLenum array, const GLcharARB *name, GLint length); typedef void (APIENTRY * PFNGLBINDARRAYGL2PROC) (GLhandleARB shaderObject, GLenum array, const GLcharARB *name, GLint length);
@ -235,8 +242,6 @@ typedef void (APIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint
typedef void (APIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (APIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
typedef void (APIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (APIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
typedef void (APIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, GLfloat *value); typedef void (APIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, GLfloat *value);
typedef void (APIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, GLfloat *value); typedef void (APIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, GLfloat *value);
typedef void (APIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, GLfloat *value); typedef void (APIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, GLfloat *value);
@ -247,7 +252,6 @@ typedef void (APIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count,
typedef void (APIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, GLint *value); typedef void (APIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, GLint *value);
typedef void (APIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, GLint *value); typedef void (APIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, GLint *value);
typedef void (APIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLuint count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLuint count, GLboolean transpose, const GLfloat *value);
typedef void (APIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLuint count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLuint count, GLboolean transpose, const GLfloat *value);
typedef void (APIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLuint count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLuint count, GLboolean transpose, const GLfloat *value);
@ -260,17 +264,9 @@ typedef void (APIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLin
typedef void (APIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); typedef void (APIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
typedef void (APIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); typedef void (APIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
typedef void (APIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); typedef void (APIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
#if !defined (__FreeBSD__)
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer);
#endif
typedef void (APIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC)(GLhandleARB obj, GLenum pname, GLfloat *params); typedef void (APIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC)(GLhandleARB obj, GLenum pname, GLfloat *params);
typedef void (APIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC)(GLhandleARB obj, GLenum pname, GLint *params); typedef void (APIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC)(GLhandleARB obj, GLenum pname, GLint *params);
#if !defined (__FreeBSD__)
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
typedef void (APIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
#endif
typedef GLhandleARB (APIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); typedef GLhandleARB (APIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname);
typedef GLhandleARB (APIENTRY * PFNGLCREATEVERTEXARRAYOBJECTGL2PROC) (GLhandleARB formatObject, GLsizei count); typedef GLhandleARB (APIENTRY * PFNGLCREATEVERTEXARRAYOBJECTGL2PROC) (GLhandleARB formatObject, GLsizei count);
typedef void (APIENTRY * PFNGLLOADVERTEXARRAYDATAGL2PROC) (GLhandleARB object, GLuint start, GLsizei count, GLvoid *data, GLenum preserve); typedef void (APIENTRY * PFNGLLOADVERTEXARRAYDATAGL2PROC) (GLhandleARB object, GLuint start, GLsizei count, GLvoid *data, GLenum preserve);
@ -479,7 +475,7 @@ void GL2_CreateShaders()
} }
len = strlen(shader); len = strlen(shader);
qglShaderSourceARB(vertex_shaders[i], 1, &shader, &len); qglShaderSourceARB(vertex_shaders[i], 1, (const GLcharARB **)&shader, &len);
GL2_checkerror(); GL2_checkerror();
shader = COM_LoadTempFile(fragment_programs[i]); shader = COM_LoadTempFile(fragment_programs[i]);
@ -489,7 +485,7 @@ void GL2_CreateShaders()
Sys_Error("GL2: %s not found\n", fragment_programs[i]); Sys_Error("GL2: %s not found\n", fragment_programs[i]);
} }
len = strlen(shader); len = strlen(shader);
qglShaderSourceARB(fragment_shaders[i], 1, &shader, &len); qglShaderSourceARB(fragment_shaders[i], 1, (const GLcharARB **)&shader, &len);
GL2_checkerror(); GL2_checkerror();
qglCompileShaderARB(vertex_shaders[i]); qglCompileShaderARB(vertex_shaders[i]);

View file

@ -60,9 +60,9 @@ typedef void (APIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsize
typedef void (APIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); typedef void (APIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
typedef void (APIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); typedef void (APIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
#endif
typedef void (APIENTRY * glProgramLocalParameter4fARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRY * glProgramLocalParameter4fARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
glProgramLocalParameter4fARBPROC qglProgramLocalParameter4fARB; glProgramLocalParameter4fARBPROC qglProgramLocalParameter4fARB;
#endif
static char bump_vertex_program[] = static char bump_vertex_program[] =
"!!VP1.1\n" "!!VP1.1\n"
@ -279,67 +279,70 @@ static char bump_fragment_program3_colored[] =
"END"; "END";
static char delux_fragment_program[] = static char delux_fragment_program[] =
"!!FP1.0\n" "!!FP1.0\n"
"TEX R0, f[TEX1], TEX1, 2D;\n" "TEX R0.xyz, f[TEX1], TEX1, 2D;\n"
"TEX R1, f[TEX0], TEX2, 2D;\n" "TEX R1, f[TEX0], TEX2, 2D;\n"
"MADR R0.xyz, R0, 2, -1;\n" "MADR R0.xyz, 2, R0, -1;\n"
"ADDR R3.xyz, p[0], -f[TEX5];\n" "DP3X H0.x, R0, f[TEX2];\n"
"DP3R R2.x, R0, f[TEX2];\n" "DP3X H0.y, R0, f[TEX3];\n"
"DP3R R2.y, R0, f[TEX3];\n" "DP3X H0.z, R0, f[TEX4];\n"
"DP3R R2.z, R0, f[TEX4];\n" "DP3H H0.w, H0, H0;\n"
"DP3R R4.x, R3, f[TEX2];\n" "RSQH H0.w, H0.w;\n"
"DP3R R4.y, R3, f[TEX3];\n" "MULH H0.xyz, H0.w, H0;\n"
"DP3R R4.z, R3, f[TEX4];\n" "MOVR H1.w, R1.w;\n"
"DP3R R0.x, R2, R2;\n" "MADX H2.xyz, 2, R1, -1;\n"
"RSQR R0.x, R0.x;\n" "MOVX H1.xyz, H2;\n"
"MULR R2.xyz, R0.x, R2;\n" "DP3H_SAT H0.w, H0, H1;\n"
"DP3R R0.x, R4, R4;\n" "ADDR R0.xyz, p[0], -f[TEX5];\n"
"RSQR R0.x, R0.x;\n" "DP3R R1.x, R0, f[TEX2];\n"
"MADR R4.xyz, R0.x, R4, R2;\n" "DP3R R1.y, R0, f[TEX3];\n"
"MULR R4.xyz, R4, 0.5;\n" "DP3R R1.z, R0, f[TEX4];\n"
"MOVR R0.w, R1.w;\n" "DP3R R0.x, R1, R1.xyzx;\n"
"MADR R0.xyz, R1, 2, -1;\n" "RSQR R0.x, R0.x;\n"
"DP3R_SAT R1.x, R4, R0;\n" "MADR R0.xyz, R0.x, R1, H0;\n"
"POWR R1.x, R1.x, 16;\n" "MULR R0.xyz, R0, 0.5;\n"
"MULR R1.x, R1.x, R0.w;\n" "DP3H_SAT H0.x, R0, H1;\n"
"DP3R_SAT R0.x, R2, R0;\n" "POWH H0.x, H0.x, 16;\n"
"TEX R2, f[TEX0], TEX3, 2D;\n" "MULH H0.x, H0.x, H1.w;\n"
"TEX R3, f[TEX1], TEX0, 2D;\n" "TEX R0, f[TEX0], TEX3, 2D;\n"
"MADR R0, R2, R0.x, R1.x;\n" "TEX R1, f[TEX1], TEX0, 2D;\n"
"MULR o[COLR], R0, R3;\n" "MADH H0, R0, H0.w, H0.x;\n"
"END"; "MULH o[COLR].xyz, H0, R1;\n"
"MOVH o[COLR].w, R0.w;\n"
"END";
static char delux_fragment_program_colored[] = static char delux_fragment_program_colored[] =
"!!FP1.0\n" "!!FP1.0\n"
"TEX R0, f[TEX1], TEX1, 2D;\n" "TEX R0, f[TEX1], TEX1, 2D;\n"
"TEX R1, f[TEX0], TEX2, 2D;\n" "TEX R1, f[TEX0], TEX2, 2D;\n"
"MADR R0.xyz, R0, 2, -1;\n" "MADR R0.xyz, 2, R0, -1;\n"
"ADDR R3.xyz, p[0], -f[TEX5];\n" "MADX H0.xyz, 2, R1, -1;\n"
"DP3R R2.x, R0, f[TEX2];\n" "DP3X H1.x, R0, f[TEX2];\n"
"DP3R R2.y, R0, f[TEX3];\n" "DP3X H1.y, R0, f[TEX3];\n"
"DP3R R2.z, R0, f[TEX4];\n" "DP3X H1.z, R0, f[TEX4];\n"
"DP3R R4.x, R3, f[TEX2];\n" "DP3H H0.w, H1, H1;\n"
"DP3R R4.y, R3, f[TEX3];\n" "RSQH H0.w, H0.w;\n"
"DP3R R4.z, R3, f[TEX4];\n" "MULH H1.xyz, H0.w, H1;\n"
"DP3R R0.x, R2, R2;\n" "DP3H_SAT H0.w, H1, H0;\n"
"RSQR R0.x, R0.x;\n" "ADDR R0.xyz, p[0], -f[TEX5];\n"
"MULR R2.xyz, R0.x, R2;\n" "DP3R R1.x, R0, f[TEX2];\n"
"DP3R R0.x, R4, R4;\n" "DP3R R1.y, R0, f[TEX3];\n"
"RSQR R0.x, R0.x;\n" "DP3R R1.z, R0, f[TEX4];\n"
"MADR R4.xyz, R0.x, R4, R2;\n" "DP3R R0.x, R1, R1;\n"
"MULR R4.xyz, R4, 0.5;\n" "RSQR R0.x, R0.x;\n"
"MOVR R0.w, R1.w;\n" "MADR R0.xyz, R0.x, R1, H1;\n"
"MADR R0.xyz, R1, 2, -1;\n" "MULR R0.xyz, R0, 0.5;\n"
"DP3R_SAT R1.x, R4, R0;\n" "DP3H_SAT H0.x, R0, H0;\n"
"POWR R1.x, R1.x, 16;\n" "POWH H0.x, H0.x, 16;\n"
"TEX R0, f[TEX0], TEX4, 2D;\n" "TEX R0, f[TEX0], TEX4, 2D;\n"
"MULR R1, R1.x, R0;\n" "TEX R1, f[TEX0], TEX3, 2D;\n"
"DP3R_SAT R0.x, R2, R0;\n" "MULH H1, R0, H0.x;\n"
"TEX R2, f[TEX0], TEX3, 2D;\n" "MADH H1, R1, H0.w, H1;\n"
"TEX R3, f[TEX1], TEX0, 2D;\n" "TEX R0, f[TEX1], TEX0, 2D;\n"
"MADR R0, R2, R0.x, R1;\n" "MULH o[COLR].xyz, H1, R0;\n"
"MULR o[COLR], R0, R3;\n" "MOVH o[COLR].w, R1.w;\n"
"END"; "END";
typedef enum typedef enum

View file

@ -46,12 +46,12 @@ GL3DFXSETPALETTEEXTPFN qgl3DfxSetPaletteEXT;
PFNBLENDCOLORPROC qglBlendColorEXT; PFNBLENDCOLORPROC qglBlendColorEXT;
// EXT_stencil_two_side // EXT_stencil_two_side
PFNGLACTIVESTENCILFACEEXTPROC qglActiveStencilFaceEXT; PFNGLACTIVESTENCILFACEEXTPROC qglActiveStencilFaceEXT;
// ATI_separate_stencil // ATI_separate_stencil
PFNGLSTENCILOPSEPARATEATIPROC qglStencilOpSeparateATI; PFNGLSTENCILOPSEPARATEATIPROC qglStencilOpSeparateATI;
PFNGLSTENCILFUNCSEPARATEATIPROC qglStencilFuncSeparateATI; PFNGLSTENCILFUNCSEPARATEATIPROC qglStencilFuncSeparateATI;
//int texture_mode = GL_NEAREST; //int texture_mode = GL_NEAREST;
@ -79,9 +79,9 @@ GLfloat gl_textureanisotropylevel = 2.0f;
//cvar_t gl_anisotropic = { "gl_anisotropic", "0", 1 }; //cvar_t gl_anisotropic = { "gl_anisotropic", "0", 1 };
qboolean gl_occlusiontest = false; qboolean gl_occlusiontest = false;
occlusion_cut_meshes; int occlusion_cut_meshes;
occlusion_cut_entities; int occlusion_cut_entities;
occlusion_cut_lights; int occlusion_cut_lights;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -406,74 +406,74 @@ void CheckGL2FragmentExtensions(void)
void CheckAnisotropicExtension(void) void CheckAnisotropicExtension(void)
{ {
if (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic") && if (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic") &&
( COM_CheckParm ("-anisotropic") || COM_CheckParm ("-anisotropy")) ) ( COM_CheckParm ("-anisotropic") || COM_CheckParm ("-anisotropy")) )
{ {
GLfloat maxanisotropy; GLfloat maxanisotropy;
if ( COM_CheckParm ("-anisotropy")) if ( COM_CheckParm ("-anisotropy"))
gl_textureanisotropylevel = Q_atoi(com_argv[COM_CheckParm("-anisotropy")+1]); gl_textureanisotropylevel = Q_atoi(com_argv[COM_CheckParm("-anisotropy")+1]);
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxanisotropy); glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxanisotropy);
if ( gl_textureanisotropylevel > maxanisotropy ) if ( gl_textureanisotropylevel > maxanisotropy )
gl_textureanisotropylevel = maxanisotropy; gl_textureanisotropylevel = maxanisotropy;
if ( gl_textureanisotropylevel < 1.0f ) if ( gl_textureanisotropylevel < 1.0f )
gl_textureanisotropylevel = 1.0f; gl_textureanisotropylevel = 1.0f;
Con_Printf("Anisotropic texture filter level %.0f\n", Con_Printf("Anisotropic texture filter level %.0f\n",
gl_textureanisotropylevel); gl_textureanisotropylevel);
gl_texturefilteranisotropic = true; gl_texturefilteranisotropic = true;
} }
} }
void CheckTextureCompressionExtension(void) void CheckTextureCompressionExtension(void)
{ {
if (strstr(gl_extensions, "GL_ARB_texture_compression") ) if (strstr(gl_extensions, "GL_ARB_texture_compression") )
{ {
Con_Printf("Texture compression available\n"); Con_Printf("Texture compression available\n");
gl_texcomp = true; gl_texcomp = true;
} }
} }
void CheckOcclusionTest(void) void CheckOcclusionTest(void)
{ {
if (strstr(gl_extensions, "GL_HP_occlusion_test") ) if (strstr(gl_extensions, "GL_HP_occlusion_test") )
{ {
Con_Printf("Occlusion test available\n"); Con_Printf("Occlusion test available\n");
gl_occlusiontest = true; gl_occlusiontest = true;
} }
} }
void CheckMirrorOnce(void) void CheckMirrorOnce(void)
{ {
if (COM_CheckParm ("-nomirroronce")) return; if (COM_CheckParm ("-nomirroronce")) return;
if (strstr(gl_extensions, "GL_ATI_texture_mirror_once") ) if (strstr(gl_extensions, "GL_ATI_texture_mirror_once") )
{ {
Con_Printf("Mirror once available\n"); Con_Printf("Mirror once available\n");
gl_mirroronce = true; gl_mirroronce = true;
} }
} }
void CheckTwoSidedStencil(void) void CheckTwoSidedStencil(void)
{ {
if (COM_CheckParm ("-notwosidedstencil")) if (COM_CheckParm ("-notwosidedstencil"))
return; return;
if (strstr(gl_extensions, "GL_EXT_stencil_two_side")) if (strstr(gl_extensions, "GL_EXT_stencil_two_side"))
{ {
SAFE_GET_PROC( qglActiveStencilFaceEXT, PFNGLACTIVESTENCILFACEEXTPROC, "glActiveStencilFaceEXT"); SAFE_GET_PROC( qglActiveStencilFaceEXT, PFNGLACTIVESTENCILFACEEXTPROC, "glActiveStencilFaceEXT");
gl_twosidedstencil = 1; gl_twosidedstencil = 1;
Con_Printf("Using EXT_stencil_two_side\n"); Con_Printf("Using EXT_stencil_two_side\n");
} }
else if (strstr(gl_extensions, "GL_ATI_separate_stencil")) else if (strstr(gl_extensions, "GL_ATI_separate_stencil"))
{ {
SAFE_GET_PROC( qglStencilOpSeparateATI, PFNGLSTENCILOPSEPARATEATIPROC, "glStencilOpSeparateATI"); SAFE_GET_PROC( qglStencilOpSeparateATI, PFNGLSTENCILOPSEPARATEATIPROC, "glStencilOpSeparateATI");
SAFE_GET_PROC( qglStencilFuncSeparateATI, PFNGLSTENCILFUNCSEPARATEATIPROC, "glStencilFuncSeparateATI"); SAFE_GET_PROC( qglStencilFuncSeparateATI, PFNGLSTENCILFUNCSEPARATEATIPROC, "glStencilFuncSeparateATI");
gl_twosidedstencil = 2; gl_twosidedstencil = 2;
Con_Printf("Using ATI_separate_stencil\n"); Con_Printf("Using ATI_separate_stencil\n");
} }
} }
static int supportedTmu; static int supportedTmu;
/* /*
@ -540,8 +540,8 @@ void GL_Init (void)
CheckOcclusionTest(); CheckOcclusionTest();
Con_Printf ("Checking MO\n"); Con_Printf ("Checking MO\n");
CheckMirrorOnce(); CheckMirrorOnce();
Con_Printf ("Checking two-sided stencil\n"); Con_Printf ("Checking two-sided stencil\n");
CheckTwoSidedStencil(); CheckTwoSidedStencil();
//if something goes wrong here throw an sys_error as we don't want to end up //if something goes wrong here throw an sys_error as we don't want to end up
//having invalid function pointers called... //having invalid function pointers called...

View file

@ -669,23 +669,24 @@ void R_DrawAliasSurfaceShadowVolume (aliashdr_t *paliashdr, aliasframeinstant_t
case 1: case 1:
// EXT_stencil_two_side // EXT_stencil_two_side
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
qglActiveStencilFaceEXT(GL_BACK); qglActiveStencilFaceEXT(GL_BACK);
glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP); glStencilOp(GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP);
glStencilFunc(GL_ALWAYS, 0, ~0); glStencilFunc(GL_ALWAYS, 0, ~0);
qglActiveStencilFaceEXT(GL_FRONT); qglActiveStencilFaceEXT(GL_FRONT);
glStencilOp(GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP); glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);
glStencilFunc(GL_ALWAYS, 0, ~0); glStencilFunc(GL_ALWAYS, 0, ~0);
R_DrawAliasFrameShadowVolume2 (paliashdr, aliasframeinstant); R_DrawAliasFrameShadowVolume2 (paliashdr, aliasframeinstant);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
break; break;
case 2: case 2:
// ATI_separate_stencil // ATI_separate_stencil
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);
qglStencilFuncSeparateATI(GL_ALWAYS, GL_ALWAYS, 0, ~0); qglStencilFuncSeparateATI(GL_ALWAYS, GL_ALWAYS, 0, ~0);
qglStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP); qglStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);
qglStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP); qglStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP);
R_DrawAliasFrameShadowVolume2 (paliashdr, aliasframeinstant); R_DrawAliasFrameShadowVolume2 (paliashdr, aliasframeinstant);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
break; break;
@ -2170,6 +2171,7 @@ void R_RenderScene (void)
case 1: case 1:
// EXT_stencil_two_side // EXT_stencil_two_side
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
qglActiveStencilFaceEXT(GL_BACK); qglActiveStencilFaceEXT(GL_BACK);
glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP); glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);
glStencilFunc(GL_ALWAYS, 0, ~0); glStencilFunc(GL_ALWAYS, 0, ~0);
@ -2182,13 +2184,12 @@ void R_RenderScene (void)
//Pass 1 increase //Pass 1 increase
if (sh_entityshadows.value) R_DrawEntitiesShadowVolumes(mod_brush); if (sh_entityshadows.value) R_DrawEntitiesShadowVolumes(mod_brush);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
qglActiveStencilFaceEXT(GL_FRONT_AND_BACK); glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
break; break;
case 2: case 2:
// ATI_separate_stencil // ATI_separate_stencil
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);
qglStencilFuncSeparateATI(GL_ALWAYS, GL_ALWAYS, 0, ~0); qglStencilFuncSeparateATI(GL_ALWAYS, GL_ALWAYS, 0, ~0);
qglStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP); qglStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP);
qglStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP); qglStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);

View file

@ -1986,7 +1986,8 @@ void StencilMeshVolumes()
case 1: case 1:
// EXT_stencil_two_side // EXT_stencil_two_side
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
qglActiveStencilFaceEXT(GL_BACK); glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
qglActiveStencilFaceEXT(GL_BACK);
glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP); glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);
glStencilFunc(GL_ALWAYS, 0, ~0); glStencilFunc(GL_ALWAYS, 0, ~0);
qglActiveStencilFaceEXT(GL_FRONT); qglActiveStencilFaceEXT(GL_FRONT);
@ -1996,7 +1997,7 @@ void StencilMeshVolumes()
for (i=0; i<currentshadowlight->numlightcmdsmesh-1; i++) for (i=0; i<currentshadowlight->numlightcmdsmesh-1; i++)
StencilMeshVolume2((mesh_t *)currentshadowlight->lightCmdsMesh[i].asVoid); StencilMeshVolume2((mesh_t *)currentshadowlight->lightCmdsMesh[i].asVoid);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
qglActiveStencilFaceEXT(GL_FRONT_AND_BACK); glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
break; break;
case 2: case 2:

View file

@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
func = (type) SDL_GL_GetProcAddress (name) func = (type) SDL_GL_GetProcAddress (name)
#elif defined (__glx__) #elif defined (__glx__)
#define SAFE_GET_PROC( func, type, name) \ #define SAFE_GET_PROC( func, type, name) \
func = (type) glXGetProcAddressARB (name) func = (type)(unsigned long)glXGetProcAddressARB (name)
#else #else
#define SAFE_GET_PROC( func, type, name) \ #define SAFE_GET_PROC( func, type, name) \
func = (type) wglGetProcAddress(name); \ func = (type) wglGetProcAddress(name); \
@ -490,17 +490,16 @@ extern int occlusion_cut_lights;
#define GL_DECR_WRAP_EXT 0x8508 #define GL_DECR_WRAP_EXT 0x8508
#ifndef GL_EXT_stencil_two_side #ifndef GL_EXT_stencil_two_side
#define GL_EXT_stencil_two_side 1
#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 #define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910
#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 #define GL_ACTIVE_STENCIL_FACE_EXT 0x8911
#endif
#ifndef GL_EXT_stencil_two_side
#define GL_EXT_stencil_two_side 1
typedef void (APIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); typedef void (APIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
#endif #endif
extern PFNGLACTIVESTENCILFACEEXTPROC qglActiveStencilFaceEXT; extern PFNGLACTIVESTENCILFACEEXTPROC qglActiveStencilFaceEXT;
// ATI_separate_stencil // ATI_separate_stencil
#ifndef GL_ATI_separate_stencil
#define GL_ATI_separate_stencil 1
#define GL_STENCIL_BACK_FUNC_ATI 0x8800 #define GL_STENCIL_BACK_FUNC_ATI 0x8800
#define GL_STENCIL_BACK_FAIL_ATI 0x8801 #define GL_STENCIL_BACK_FAIL_ATI 0x8801
#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
@ -508,6 +507,7 @@ extern PFNGLACTIVESTENCILFACEEXTPROC qglActiveStencilFaceEXT;
typedef void (APIENTRY *PFNGLSTENCILOPSEPARATEATIPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (APIENTRY *PFNGLSTENCILOPSEPARATEATIPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
typedef void (APIENTRY *PFNGLSTENCILFUNCSEPARATEATIPROC)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); typedef void (APIENTRY *PFNGLSTENCILFUNCSEPARATEATIPROC)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
#endif
extern PFNGLSTENCILOPSEPARATEATIPROC qglStencilOpSeparateATI; extern PFNGLSTENCILOPSEPARATEATIPROC qglStencilOpSeparateATI;
extern PFNGLSTENCILFUNCSEPARATEATIPROC qglStencilFuncSeparateATI; extern PFNGLSTENCILFUNCSEPARATEATIPROC qglStencilFuncSeparateATI;
@ -1005,7 +1005,8 @@ extern PFNGLVERTEXATTRIBS4SVNVPROC qglVertexAttribs4svNV ;
extern PFNGLVERTEXATTRIBS4UBVNVPROC qglVertexAttribs4ubvNV ; extern PFNGLVERTEXATTRIBS4UBVNVPROC qglVertexAttribs4ubvNV ;
/* GL_ARB_vertex_buffer_object */ /* GL_ARB_vertex_buffer_object */
#ifndef GL_ARB_vertex_buffer_object
#define GL_ARB_vertex_buffer_object 1
#define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_SIZE_ARB 0x8764
#define GL_BUFFER_USAGE_ARB 0x8765 #define GL_BUFFER_USAGE_ARB 0x8765
#define GL_ARRAY_BUFFER_ARB 0x8892 #define GL_ARRAY_BUFFER_ARB 0x8892
@ -1052,6 +1053,7 @@ typedef GLvoid* (APIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access
typedef GLboolean (APIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); typedef GLboolean (APIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target);
typedef void (APIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (APIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); typedef void (APIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
#endif
extern PFNGLBINDBUFFERARBPROC qglBindBufferARB; extern PFNGLBINDBUFFERARBPROC qglBindBufferARB;
extern PFNGLDELETEBUFFERSARBPROC qglDeleteBuffersARB; extern PFNGLDELETEBUFFERSARBPROC qglDeleteBuffersARB;
@ -1075,7 +1077,7 @@ extern PFNGLGETBUFFERPOINTERVARBPROC qglGetBufferPointervARB;
extern qboolean gl_mtexable; extern qboolean gl_mtexable;
extern qboolean gl_texturefilteranisotropic; // <AWE> true if anisotropic texture filtering available. extern qboolean gl_texturefilteranisotropic; // <AWE> true if anisotropic texture filtering available.
extern int gl_twosidedstencil; extern int gl_twosidedstencil;
typedef enum typedef enum
{ {