]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_backend.c
Added strlcat and strlcpy, from OpenBSD. They are smart replacements for strncat...
[xonotic/darkplaces.git] / gl_backend.c
index 3a15f7a586edd39a78aa1d8ecb529742ac5434f3..c3eef34081e835296f1a08800b37a1663fa55521 100644 (file)
@@ -74,7 +74,6 @@ void SCR_ScreenShot_f (void);
 
 // these are externally accessible
 int r_lightmapscalebit;
-float r_colorscale;
 
 static matrix4x4_t backend_viewmatrix;
 static matrix4x4_t backend_modelmatrix;
@@ -91,6 +90,7 @@ note: here's strip order for a terrain row:
 |\ |\ |\ |\ |
 | \| \| \| \|
 A--B--C--D--E
+clockwise
 
 A0B, 01B, B1C, 12C, C2D, 23D, D3E, 34E
 
@@ -100,6 +100,42 @@ A0B, 01B, B1C, 12C, C2D, 23D, D3E, 34E
 *elements++ = i;
 *elements++ = i + 1;
 *elements++ = i + row + 1;
+
+
+for (y = 0;y < rows - 1;y++)
+{
+       for (x = 0;x < columns - 1;x++)
+       {
+               i = y * rows + x;
+               *elements++ = i + columns;
+               *elements++ = i;
+               *elements++ = i + columns + 1;
+               *elements++ = i;
+               *elements++ = i + 1;
+               *elements++ = i + columns + 1;
+       }
+}
+
+alternative:
+0--1--2--3--4
+| /| /|\ | /|
+|/ |/ | \|/ |
+A--B--C--D--E
+counterclockwise
+
+for (y = 0;y < rows - 1;y++)
+{
+       for (x = 0;x < columns - 1;x++)
+       {
+               i = y * rows + x;
+               *elements++ = i;
+               *elements++ = i + columns;
+               *elements++ = i + columns + 1;
+               *elements++ = i + columns;
+               *elements++ = i + columns + 1;
+               *elements++ = i + 1;
+       }
+}
 */
 
 int polygonelements[768];
@@ -121,7 +157,7 @@ void GL_Backend_FreeArrays(void)
 
 static void gl_backend_start(void)
 {
-       Con_Printf("OpenGL Backend started\n");
+       Con_DPrintf("OpenGL Backend started\n");
        if (qglDrawRangeElements != NULL)
        {
                CHECKGLERROR
@@ -129,7 +165,7 @@ static void gl_backend_start(void)
                CHECKGLERROR
                qglGetIntegerv(GL_MAX_ELEMENTS_INDICES, &gl_maxdrawrangeelementsindices);
                CHECKGLERROR
-               Con_Printf("glDrawRangeElements detected (max vertices %i, max indices %i)\n", gl_maxdrawrangeelementsvertices, gl_maxdrawrangeelementsindices);
+               Con_DPrintf("glDrawRangeElements detected (max vertices %i, max indices %i)\n", gl_maxdrawrangeelementsvertices, gl_maxdrawrangeelementsindices);
        }
 
        backendunits = min(MAX_TEXTUREUNITS, gl_textureunits);
@@ -144,7 +180,7 @@ static void gl_backend_shutdown(void)
        backendunits = 0;
        backendactive = false;
 
-       Con_Printf("OpenGL Backend shutting down\n");
+       Con_DPrintf("OpenGL Backend shutting down\n");
 
        GL_Backend_FreeArrays();
 }
@@ -957,7 +993,6 @@ void R_Mesh_State_Texture(const rmeshstate_t *m)
 qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qboolean jpeg)
 {
        qboolean ret;
-       int i, j;
        qbyte *buffer;
 
        if (!r_render.integer)
@@ -967,16 +1002,6 @@ qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qbo
        qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer);
        CHECKGLERROR
 
-       // LordHavoc: compensate for v_overbrightbits when using hardware gamma
-       if (v_hwgamma.integer)
-       {
-               for (i = 0;i < width * height * 3;i++)
-               {
-                       j = buffer[i] << v_overbrightbits.integer;
-                       buffer[i] = (qbyte) (bound(0, j, 255));
-               }
-       }
-
        if (jpeg)
                ret = JPEG_SaveImage_preflipped (filename, width, height, buffer);
        else
@@ -1041,11 +1066,8 @@ void SCR_UpdateScreen (void)
        if (gl_combine.integer && (!gl_combine_extension || r_textureunits.integer < 2))
                Cvar_SetValueQuick(&gl_combine, 0);
 
-       // lighting scale
-       r_colorscale = 1.0f / (float) (1 << v_overbrightbits.integer);
-
        // lightmaps only
-       r_lightmapscalebit = v_overbrightbits.integer;
+       r_lightmapscalebit = 0;
        if (gl_combine.integer && r_textureunits.integer > 1)
                r_lightmapscalebit += 2;
 
@@ -1085,6 +1107,7 @@ float varray_color4f[65536*4];
 float varray_texcoord2f[4][65536*2];
 float varray_texcoord3f[4][65536*3];
 float varray_normal3f[65536*3];
+int earray_element3i[65536];
 
 //===========================================================================
 // vertex array caching subsystem