X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=gl_backend.c;h=56518855485b052fbd0b88d64e2ae7911ae77624;hb=cbab7e9c0c8031f6dd459b786ed2be326b632660;hp=833bdb1bd45279b873d8fbbd435945e62094e91f;hpb=5cf8eacc9621cf85f9d0474e59289b13d083260f;p=xonotic%2Fdarkplaces.git diff --git a/gl_backend.c b/gl_backend.c index 833bdb1b..56518855 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -72,10 +72,6 @@ int c_meshs, c_meshelements; 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; static matrix4x4_t backend_modelviewmatrix; @@ -91,6 +87,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 +97,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]; @@ -308,6 +341,7 @@ static struct int blend; GLboolean depthmask; int depthtest; + int scissortest; int unit; int clientunit; gltextureunit_t units[MAX_TEXTUREUNITS]; @@ -569,6 +603,26 @@ void GL_LockArrays(int first, int count) } } +void GL_Scissor (int x, int y, int width, int height) +{ + CHECKGLERROR + qglScissor(x, vid.realheight - (y + height),width,height); + CHECKGLERROR +} + +void GL_ScissorTest(int state) +{ + if(gl_state.scissortest == state) + return; + + CHECKGLERROR + if((gl_state.scissortest = state)) + qglEnable(GL_SCISSOR_TEST); + else + qglDisable(GL_SCISSOR_TEST); + CHECKGLERROR +} + void GL_TransformToScreen(const vec4_t in, vec4_t out) { vec4_t temp; @@ -946,6 +1000,19 @@ void R_Mesh_State_Texture(const rmeshstate_t *m) } } +void R_Mesh_Draw_ShowTris(int numverts, int numtriangles, int *elements) +{ + qglBegin(GL_LINES); + for (;numtriangles;numtriangles--, elements += 3) + { + qglArrayElement(elements[0]);qglArrayElement(elements[1]); + qglArrayElement(elements[1]);qglArrayElement(elements[2]); + qglArrayElement(elements[2]);qglArrayElement(elements[0]); + } + qglEnd(); + CHECKGLERROR +} + /* ============================================================================== @@ -957,7 +1024,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 +1033,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,14 +1097,6 @@ 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; - if (gl_combine.integer && r_textureunits.integer > 1) - r_lightmapscalebit += 2; - R_TimeReport("setup"); R_ClearScreen(); @@ -1085,6 +1133,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