damn, committed the old version of my patch... this now is the REAL v_flipped
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 May 2007 00:23:30 +0000 (00:23 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 May 2007 00:23:30 +0000 (00:23 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7343 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_rmain.c
model_sprite.c
r_sprites.c

index 8b4dbdc..4dbdc8c 100644 (file)
@@ -16,7 +16,7 @@ cvar_t gl_lockarrays = {0, "gl_lockarrays", "0", "enables use of glLockArraysEXT
 cvar_t gl_lockarrays_minimumvertices = {0, "gl_lockarrays_minimumvertices", "1", "minimum number of vertices required for use of glLockArraysEXT, setting this too low may reduce performance"};
 cvar_t gl_vbo = {0, "gl_vbo", "1", "make use of GL_ARB_vertex_buffer_object extension to store static geometry in video memory for faster rendering"};
 
-cvar_t v_flipped = {0, "v_flipped", "0", "mirror the screen (poor man's left handed mode"};
+cvar_t v_flipped = {0, "v_flipped", "0", "mirror the screen (poor man's left handed mode)"};
 qboolean v_flipped_state = false;
 
 int gl_maxdrawrangeelementsvertices;
@@ -270,10 +270,12 @@ void gl_backend_init(void)
        R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
 }
 
+void GL_SetMirrorState(qboolean state);
+
 void GL_SetupView_Orientation_Identity (void)
 {
        backend_viewmatrix = identitymatrix;
-       v_flipped_state = false;
+       GL_SetMirrorState(false);
        memset(&backend_modelmatrix, 0, sizeof(backend_modelmatrix));
 }
 
@@ -285,7 +287,7 @@ void GL_SetupView_Orientation_FromEntity(const matrix4x4_t *matrix)
        Matrix4x4_ConcatRotate(&basematrix, 90, 0, 0, 1);
        Matrix4x4_Concat(&backend_viewmatrix, &basematrix, &tempmatrix);
 
-       v_flipped_state = v_flipped.integer;
+       GL_SetMirrorState(v_flipped.integer);
        if(v_flipped_state)
        {
                Matrix4x4_Transpose(&basematrix, &backend_viewmatrix);
@@ -544,7 +546,7 @@ void GL_Backend_ResetState(void)
        gl_state.color4f[0] = gl_state.color4f[1] = gl_state.color4f[2] = gl_state.color4f[3] = 1;
        gl_state.lockrange_first = 0;
        gl_state.lockrange_count = 0;
-       gl_state.cullface = GL_FRONT; // quake is backwards, this culls back faces
+       gl_state.cullface = v_flipped_state ? GL_BACK : GL_FRONT; // quake is backwards, this culls back faces
        gl_state.cullfaceenable = true;
 
        CHECKGLERROR
@@ -678,6 +680,19 @@ void GL_DepthRange(float nearfrac, float farfrac)
        }
 }
 
+void GL_SetMirrorState(qboolean state)
+{
+       if(!state != !v_flipped_state)
+       {
+               // change cull face mode!
+               if(gl_state.cullface == GL_BACK)
+                       qglCullFace((gl_state.cullface = GL_FRONT));
+               else if(gl_state.cullface == GL_FRONT)
+                       qglCullFace((gl_state.cullface = GL_BACK));
+       }
+       v_flipped_state = state;
+}
+
 void GL_CullFace(int state)
 {
        CHECKGLERROR
index a4f7e69..c233bc0 100644 (file)
@@ -104,6 +104,8 @@ cvar_t gl_lightmaps = {0, "gl_lightmaps", "0", "draws only lightmaps, no texture
 cvar_t r_test = {0, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"};
 cvar_t r_batchmode = {0, "r_batchmode", "1", "selects method of rendering multiple surfaces with one driver call (values are 0, 1, 2, etc...)"};
 
+extern qboolean v_flipped_state;
+
 typedef struct r_glsl_bloomshader_s
 {
        int program;
@@ -2952,6 +2954,16 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
 
        R_Mesh_Matrix(&identitymatrix);
        GL_BlendFunc(blendfunc1, blendfunc2);
+
+       if(v_flipped_state)
+       {
+               scalex1 = -scalex1;
+               scalex2 = -scalex2;
+               GL_CullFace(GL_BACK);
+       }
+       else
+               GL_CullFace(GL_FRONT);
+
        GL_DepthMask(false);
        GL_DepthRange(0, depthshort ? 0.0625 : 1);
        GL_DepthTest(!depthdisable);
index 49c7933..623243d 100644 (file)
@@ -43,7 +43,7 @@ static void Mod_SpriteSetupTexture(texture_t *texture, skinframe_t *skinframe, q
 {
        if (!skinframe)
                skinframe = R_SkinFrame_LoadMissing();
-       texture->basematerialflags = MATERIALFLAG_WALL | MATERIALFLAG_NOCULLFACE;
+       texture->basematerialflags = MATERIALFLAG_WALL;
        if (fullbright)
                texture->basematerialflags |= MATERIALFLAG_FULLBRIGHT;
        if (additive)
index 0683b73..ae19bde 100644 (file)
@@ -2,8 +2,6 @@
 #include "quakedef.h"
 #include "r_shadow.h"
 
-extern cvar_t v_flipped;
-
 void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 {
        int i;
@@ -66,12 +64,6 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                break;
        }
 
-       if(v_flipped.integer)
-       {
-               left[0] = -left[0];
-               left[1] = -left[1];
-       }
-
        R_Mesh_Matrix(&identitymatrix);
 
        // LordHavoc: interpolated sprite rendering