]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_backend.c
made deformvertexes autosprite2 work properly
[xonotic/darkplaces.git] / gl_backend.c
index 4dbdc8ce25c969eb720cd8cad63927fbadd3b187..8d3a8c3fdad82b981086048e1844b89e1360de60 100644 (file)
@@ -14,7 +14,7 @@ cvar_t gl_polyblend = {CVAR_SAVE, "gl_polyblend", "1", "tints view while underwa
 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)"};
 qboolean v_flipped_state = false;
@@ -396,6 +396,7 @@ static struct gl_state_s
        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;
@@ -548,6 +549,8 @@ void GL_Backend_ResetState(void)
        gl_state.lockrange_count = 0;
        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
 
@@ -561,6 +564,7 @@ void GL_Backend_ResetState(void)
        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)
        {
@@ -680,6 +684,16 @@ void GL_DepthRange(float nearfrac, float farfrac)
        }
 }
 
+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)