From 1437cbec91ef410b740f3733519eb8135d996d40 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 3 Jan 2012 18:06:26 +0900 Subject: [PATCH] Make the face culling a little more sensible. GL Quake was weird, culling front faces. Partly understandable, since Quake's front order is clockwise and GL's default order is counter-clockwise. However, since the order can be specified, that should be done instead. Thus, specify the winding order as clockwise (for quake's data), set culling for back-face removal, and then mess with the winding direction in the mirror and fish-eye code. --- include/QF/GL/qf_funcs_list.h | 2 +- libs/video/renderer/gl/gl_rmain.c | 8 ++++---- libs/video/targets/vid_common_gl.c | 3 ++- libs/video/targets/vid_common_glsl.c | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/QF/GL/qf_funcs_list.h b/include/QF/GL/qf_funcs_list.h index ddb0156a9..4814b289d 100644 --- a/include/QF/GL/qf_funcs_list.h +++ b/include/QF/GL/qf_funcs_list.h @@ -154,7 +154,7 @@ QFGL_NEED (void, glFogf, (GLenum pname, GLfloat param)) QFGL_NEED (void, glFogfv, (GLenum pname, const GLfloat * params)) QFGL_NEED (void, glFogi, (GLenum pname, GLint param)) QFGL_DONT_NEED (void, glFogiv, (GLenum pname, const GLint * params)) -QFGL_DONT_NEED (void, glFrontFace, (GLenum mode)) +QFGL_NEED (void, glFrontFace, (GLenum mode)) QFGL_NEED (void, glFrustum, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)) QFGL_NEED (GLuint, glGenLists, (GLsizei range)) QFGL_NEED (void, glGenTextures, (GLsizei n, GLuint * textures)) diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 8d0f5ec89..0aee1d291 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -469,9 +469,9 @@ R_SetupGL (void) qfglScalef (1, -1, 1); else qfglScalef (-1, 1, 1); - qfglCullFace (GL_BACK); + qfglFrontFace (GL_CCW); } else - qfglCullFace (GL_FRONT); + qfglFrontFace (GL_CW); qfglMatrixMode (GL_MODELVIEW); qfglLoadIdentity (); @@ -576,7 +576,7 @@ R_Mirror (void) qfglScalef (1, -1, 1); else qfglScalef (-1, 1, 1); - qfglCullFace (GL_FRONT); + qfglFrontFace (GL_CW); qfglMatrixMode (GL_MODELVIEW); qfglLoadMatrixf (r_base_world_matrix); @@ -883,7 +883,7 @@ R_InitFishEye (void) -gl_cube_map_size / 2); qfglDisable (GL_DEPTH_TEST); - qfglCullFace (GL_BACK); + qfglFrontFace (GL_CCW); qfglClear (GL_COLOR_BUFFER_BIT); qfglEnable (GL_TEXTURE_CUBE_MAP_ARB); diff --git a/libs/video/targets/vid_common_gl.c b/libs/video/targets/vid_common_gl.c index 9fcb6d90e..ca15eba89 100644 --- a/libs/video/targets/vid_common_gl.c +++ b/libs/video/targets/vid_common_gl.c @@ -615,7 +615,8 @@ GL_Init_Common (void) qfglClearColor (0, 0, 0, 0); qfglEnable (GL_TEXTURE_2D); - qfglCullFace (GL_FRONT); + qfglFrontFace (GL_CW); + qfglCullFace (GL_BACK); qfglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); qfglShadeModel (GL_FLAT); diff --git a/libs/video/targets/vid_common_glsl.c b/libs/video/targets/vid_common_glsl.c index 6f372cc73..3278824b1 100644 --- a/libs/video/targets/vid_common_glsl.c +++ b/libs/video/targets/vid_common_glsl.c @@ -140,7 +140,8 @@ GL_Init_Common (void) qfglClearColor (0, 0, 0, 0); qfglEnable (GL_TEXTURE_2D); - qfglCullFace (GL_FRONT); + qfglFrontFace (GL_CW); + qfglCullFace (GL_BACK); qfglEnable (GL_BLEND); qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);