cvar_t gl_dither = {CVAR_SAVE, "gl_dither", "1", "enables OpenGL dithering (16bit looks bad with this off)"};
cvar_t gl_lockarrays = {0, "gl_lockarrays", "0", "enables use of glLockArraysEXT, may cause glitches with some broken drivers, and may be slower than normal"};
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 gl_vbo = {CVAR_SAVE, "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;
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));
}
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);
int colormask; // stored as bottom 4 bits: r g b a (3 2 1 0 order)
int depthtest;
float depthrange[2];
+ float polygonoffset[2];
int alphatest;
int scissortest;
unsigned int unit;
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;
+ gl_state.polygonoffset[0] = 0;
+ gl_state.polygonoffset[1] = 0;
CHECKGLERROR
qglDepthFunc(GL_LEQUAL);CHECKGLERROR
qglEnable(GL_DEPTH_TEST);CHECKGLERROR
qglDepthMask(gl_state.depthmask);CHECKGLERROR
+ qglPolygonOffset(gl_state.polygonoffset[0], gl_state.polygonoffset[1]);
if (gl_support_arb_vertex_buffer_object)
{
}
}
+void GL_PolygonOffset(float planeoffset, float depthoffset)
+{
+ if (gl_state.polygonoffset[0] != planeoffset || gl_state.polygonoffset[1] != depthoffset)
+ {
+ gl_state.polygonoffset[0] = planeoffset;
+ gl_state.polygonoffset[1] = depthoffset;
+ qglPolygonOffset(planeoffset, depthoffset);
+ }
+}
+
+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