]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_backend.c
fix really stupid typo in SV_Move code, this cures the 'monsters walking through...
[xonotic/darkplaces.git] / gl_backend.c
index 11d3ac09fd03157a5ee6783eaa7a21969d1f4941..aa1f23c3c5f73f9a6ada06e7b2bdc2b12a1aa262 100644 (file)
@@ -135,22 +135,12 @@ for (y = 0;y < rows - 1;y++)
 int polygonelements[(POLYGONELEMENTS_MAXPOINTS-2)*3];
 int quadelements[QUADELEMENTS_MAXQUADS*6];
 
-#if 0
-static void R_Mesh_CacheArray_Startup(void);
-static void R_Mesh_CacheArray_Shutdown(void);
-#endif
 void GL_Backend_AllocArrays(void)
 {
-#if 0
-       R_Mesh_CacheArray_Startup();
-#endif
 }
 
 void GL_Backend_FreeArrays(void)
 {
-#if 0
-       R_Mesh_CacheArray_Shutdown();
-#endif
 }
 
 static void gl_backend_start(void)
@@ -389,7 +379,7 @@ typedef struct gltextureunit_s
        int arrayenabled;
        unsigned int arraycomponents;
        const void *pointer_texcoord;
-       float rgbscale, alphascale;
+       int rgbscale, alphascale;
        int combinergb, combinealpha;
        // FIXME: add more combine stuff
        // texmatrixenabled exists only to avoid unnecessary texmatrix compares
@@ -576,8 +566,6 @@ void GL_BlendFunc(int blendfunc1, int blendfunc2)
 {
        if (gl_state.blendfunc1 != blendfunc1 || gl_state.blendfunc2 != blendfunc2)
        {
-               if (r_showtrispass)
-                       return;
                qglBlendFunc(gl_state.blendfunc1 = blendfunc1, gl_state.blendfunc2 = blendfunc2);CHECKGLERROR
                if (gl_state.blendfunc2 == GL_ZERO)
                {
@@ -613,8 +601,6 @@ void GL_DepthMask(int state)
 {
        if (gl_state.depthmask != state)
        {
-               if (r_showtrispass)
-                       return;
                qglDepthMask(gl_state.depthmask = state);CHECKGLERROR
        }
 }
@@ -623,8 +609,6 @@ void GL_DepthTest(int state)
 {
        if (gl_state.depthtest != state)
        {
-               if (r_showtrispass && r_showdisabledepthtest.integer)
-                       return;
                gl_state.depthtest = state;
                if (gl_state.depthtest)
                {
@@ -651,8 +635,6 @@ void GL_Color(float cr, float cg, float cb, float ca)
 {
        if (gl_state.pointer_color || gl_state.color4f[0] != cr || gl_state.color4f[1] != cg || gl_state.color4f[2] != cb || gl_state.color4f[3] != ca)
        {
-               if (r_showtrispass)
-                       return;
                gl_state.color4f[0] = cr;
                gl_state.color4f[1] = cg;
                gl_state.color4f[2] = cb;
@@ -663,16 +645,6 @@ void GL_Color(float cr, float cg, float cb, float ca)
        }
 }
 
-void GL_ShowTrisColor(float cr, float cg, float cb, float ca)
-{
-       if (!r_showtrispass)
-               return;
-       r_showtrispass = 0;
-       GL_Color(cr * r_showtris.value, cg * r_showtris.value, cb * r_showtris.value, ca);
-       r_showtrispass = 1;
-}
-
-
 void GL_LockArrays(int first, int count)
 {
        if (gl_state.lockrange_count != count || gl_state.lockrange_first != first)
@@ -717,10 +689,6 @@ void GL_ScissorTest(int state)
 
 void GL_Clear(int mask)
 {
-       // in showtris rendering, don't clear the color buffer as that would hide
-       // the accumulated lines
-       if (r_showtrispass)
-               mask &= ~GL_COLOR_BUFFER_BIT;
        qglClear(mask);CHECKGLERROR
 }
 
@@ -756,6 +724,26 @@ unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **ver
        if (!programobject)
                return 0;
 
+       if (developer.integer >= 100)
+       {
+               int i;
+               Con_Printf("Compiling shader:\n");
+               if (vertexstrings_count)
+               {
+                       Con_Printf("------ VERTEX SHADER ------\n");
+                       for (i = 0;i < vertexstrings_count;i++)
+                               Con_Print(vertexstrings_list[i]);
+                       Con_Print("\n");
+               }
+               if (fragmentstrings_count)
+               {
+                       Con_Printf("------ FRAGMENT SHADER ------\n");
+                       for (i = 0;i < fragmentstrings_count;i++)
+                               Con_Print(fragmentstrings_list[i]);
+                       Con_Print("\n");
+               }
+       }
+
        if (vertexstrings_count)
        {
                CHECKGLERROR
@@ -872,11 +860,6 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int *
                return;
        }
        //CHECKGLERROR
-       if (r_showtrispass)
-       {
-               R_Mesh_Draw_ShowTris(firstvertex, numvertices, numtriangles, elements);
-               return;
-       }
        renderstats.meshes++;
        renderstats.meshes_elements += numelements;
        if (gl_paranoid.integer)
@@ -1093,8 +1076,6 @@ void R_Mesh_VertexPointer(const float *vertex3f)
 
 void R_Mesh_ColorPointer(const float *color4f)
 {
-       if (r_showtrispass)
-               return;
        if (gl_state.pointer_color != color4f)
        {
                CHECKGLERROR
@@ -1120,8 +1101,6 @@ void R_Mesh_ColorPointer(const float *color4f)
 void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, const float *texcoord)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (r_showtrispass)
-               return;
        // update array settings
        if (texcoord)
        {
@@ -1159,8 +1138,6 @@ void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, in
        gltextureunit_t *unit = gl_state.units + unitnum;
        if (unitnum >= backendimageunits)
                return;
-       if (r_showtrispass)
-               return;
        // update 1d texture binding
        if (unit->t1d != tex1d)
        {
@@ -1252,8 +1229,6 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
        gltextureunit_t *unit = gl_state.units + unitnum;
        if (unitnum >= backendimageunits)
                return;
-       if (r_showtrispass)
-               return;
        // update 1d texture binding
        if (unit->t1d != texnum)
        {
@@ -1321,8 +1296,6 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
        gltextureunit_t *unit = gl_state.units + unitnum;
        if (unitnum >= backendimageunits)
                return;
-       if (r_showtrispass)
-               return;
        // update 1d texture binding
        if (unit->t1d)
        {
@@ -1390,8 +1363,6 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
        gltextureunit_t *unit = gl_state.units + unitnum;
        if (unitnum >= backendimageunits)
                return;
-       if (r_showtrispass)
-               return;
        // update 1d texture binding
        if (unit->t1d)
        {
@@ -1459,8 +1430,6 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
        gltextureunit_t *unit = gl_state.units + unitnum;
        if (unitnum >= backendimageunits)
                return;
-       if (r_showtrispass)
-               return;
        // update 1d texture binding
        if (unit->t1d)
        {
@@ -1526,8 +1495,6 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
 void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (r_showtrispass)
-               return;
        if (matrix->m[3][3])
        {
                // texmatrix specified, check if it is different
@@ -1560,8 +1527,6 @@ void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
 void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, int rgbscale, int alphascale)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (r_showtrispass)
-               return;
        if (gl_combine.integer)
        {
                // GL_ARB_texture_env_combine
@@ -1653,268 +1618,3 @@ void R_Mesh_Draw_ShowTris(int firstvertex, int numvertices, int numtriangles, co
        qglEnd();
        CHECKGLERROR
 }
-
-//===========================================================================
-// dynamic vertex array buffer subsystem
-//===========================================================================
-
-// FIXME: someday this should be dynamically allocated and resized?
-float varray_vertex3f[65536*3];
-float varray_svector3f[65536*3];
-float varray_tvector3f[65536*3];
-float varray_normal3f[65536*3];
-float varray_color4f[65536*4];
-float varray_texcoord2f[4][65536*2];
-float varray_texcoord3f[4][65536*3];
-int earray_element3i[65536];
-float varray_vertex3f2[65536*3];
-
-#if 0
-//===========================================================================
-// vertex array caching subsystem
-//===========================================================================
-
-typedef struct rcachearraylink_s
-{
-       struct rcachearraylink_s *next, *prev;
-       struct rcachearrayitem_s *data;
-}
-rcachearraylink_t;
-
-typedef struct rcachearrayitem_s
-{
-       // the original request structure
-       rcachearrayrequest_t request;
-       // active
-       int active;
-       // offset into r_mesh_rcachedata
-       int offset;
-       // for linking this into the sequential list
-       rcachearraylink_t sequentiallink;
-       // for linking this into the lookup list
-       rcachearraylink_t hashlink;
-}
-rcachearrayitem_t;
-
-#define RCACHEARRAY_HASHSIZE 65536
-#define RCACHEARRAY_ITEMS 4096
-#define RCACHEARRAY_DEFAULTSIZE (4 << 20)
-
-// all active items are linked into this chain in sorted order
-static rcachearraylink_t r_mesh_rcachesequentialchain;
-// all inactive items are linked into this chain in unknown order
-static rcachearraylink_t r_mesh_rcachefreechain;
-// all active items are also linked into these chains (using their hashlink)
-static rcachearraylink_t r_mesh_rcachechain[RCACHEARRAY_HASHSIZE];
-
-// all items are stored here, whether active or inactive
-static rcachearrayitem_t r_mesh_rcacheitems[RCACHEARRAY_ITEMS];
-
-// size of data buffer
-static int r_mesh_rcachedata_size = RCACHEARRAY_DEFAULTSIZE;
-// data buffer
-static unsigned char r_mesh_rcachedata[RCACHEARRAY_DEFAULTSIZE];
-
-// current state
-static int r_mesh_rcachedata_offset;
-static rcachearraylink_t *r_mesh_rcachesequentialchain_current;
-
-static void R_Mesh_CacheArray_Startup(void)
-{
-       int i;
-       rcachearraylink_t *l;
-       // prepare all the linked lists
-       l = &r_mesh_rcachesequentialchain;l->next = l->prev = l;l->data = NULL;
-       l = &r_mesh_rcachefreechain;l->next = l->prev = l;l->data = NULL;
-       memset(&r_mesh_rcachechain, 0, sizeof(r_mesh_rcachechain));
-       for (i = 0;i < RCACHEARRAY_HASHSIZE;i++)
-       {
-               l = &r_mesh_rcachechain[i];
-               l->next = l->prev = l;
-               l->data = NULL;
-       }
-       memset(&r_mesh_rcacheitems, 0, sizeof(r_mesh_rcacheitems));
-       for (i = 0;i < RCACHEARRAY_ITEMS;i++)
-       {
-               r_mesh_rcacheitems[i].hashlink.data = r_mesh_rcacheitems[i].sequentiallink.data = &r_mesh_rcacheitems[i];
-               l = &r_mesh_rcacheitems[i].sequentiallink;
-               l->next = &r_mesh_rcachefreechain;
-               l->prev = l->next->prev;
-               l->next->prev = l->prev->next = l;
-       }
-       // clear other state
-       r_mesh_rcachedata_offset = 0;
-       r_mesh_rcachesequentialchain_current = &r_mesh_rcachesequentialchain;
-}
-
-static void R_Mesh_CacheArray_Shutdown(void)
-{
-}
-
-/*
-static void R_Mesh_CacheArray_ValidateState(int num)
-{
-       rcachearraylink_t *l, *lhead;
-       lhead = &r_mesh_rcachesequentialchain;
-       if (r_mesh_rcachesequentialchain_current == lhead)
-               return;
-       for (l = lhead->next;l != lhead;l = l->next)
-               if (r_mesh_rcachesequentialchain_current == l)
-                       return;
-       Sys_Error("%i", num);
-}
-*/
-
-int R_Mesh_CacheArray(rcachearrayrequest_t *r)
-{
-       rcachearraylink_t *l, *lhead, *lnext;
-       rcachearrayitem_t *d;
-       int hashindex, offset, offsetend;
-
-       //R_Mesh_CacheArray_ValidateState(3);
-       // calculate a hashindex to choose a cache chain
-       r->data = NULL;
-       hashindex = CRC_Block((unsigned char *)r, sizeof(*r)) % RCACHEARRAY_HASHSIZE;
-
-       // is it already cached?
-       for (lhead = &r_mesh_rcachechain[hashindex], l = lhead->next;l != lhead;l = l->next)
-       {
-               if (!memcmp(&l->data->request, r, sizeof(l->data->request)))
-               {
-                       // we have it cached already
-                       r->data = r_mesh_rcachedata + l->data->offset;
-                       return false;
-               }
-       }
-
-       // we need to add a new cache item, this means finding a place for the new
-       // data and making sure we have a free item available, lots of work...
-
-       // check if buffer needs to wrap
-       if (r_mesh_rcachedata_offset + r->data_size > r_mesh_rcachedata_size)
-       {
-               /*
-               if (r->data_size * 10 > r_mesh_rcachedata_size)
-               {
-                       // realloc whole cache
-               }
-               */
-               // reset back to start
-               r_mesh_rcachedata_offset = 0;
-               r_mesh_rcachesequentialchain_current = &r_mesh_rcachesequentialchain;
-       }
-       offset = r_mesh_rcachedata_offset;
-       r_mesh_rcachedata_offset += r->data_size;
-       offsetend = r_mesh_rcachedata_offset;
-       //R_Mesh_CacheArray_ValidateState(4);
-
-       /*
-       {
-               int n;
-               for (lhead = &r_mesh_rcachesequentialchain, l = lhead->next, n = 0;l != lhead;l = l->next, n++);
-               Con_Printf("R_Mesh_CacheArray: new data range %i:%i, %i items are already linked\n", offset, offsetend, n);
-       }
-       */
-
-       // make room for the new data (remove old items)
-       lhead = &r_mesh_rcachesequentialchain;
-       l = r_mesh_rcachesequentialchain_current;
-       if (l == lhead)
-               l = l->next;
-       while (l != lhead && l->data->offset < offsetend && l->data->offset + l->data->request.data_size > offset)
-       {
-       //r_mesh_rcachesequentialchain_current = l;
-       //R_Mesh_CacheArray_ValidateState(8);
-               lnext = l->next;
-               // if at the end of the chain, wrap around
-               if (lnext == lhead)
-                       lnext = lnext->next;
-       //r_mesh_rcachesequentialchain_current = lnext;
-       //R_Mesh_CacheArray_ValidateState(10);
-
-               // unlink from sequential chain
-               l->next->prev = l->prev;
-               l->prev->next = l->next;
-       //R_Mesh_CacheArray_ValidateState(11);
-               // link into free chain
-               l->next = &r_mesh_rcachefreechain;
-               l->prev = l->next->prev;
-               l->next->prev = l->prev->next = l;
-       //R_Mesh_CacheArray_ValidateState(12);
-
-               l = &l->data->hashlink;
-               // unlink from hash chain
-               l->next->prev = l->prev;
-               l->prev->next = l->next;
-
-               l = lnext;
-       //r_mesh_rcachesequentialchain_current = l;
-       //R_Mesh_CacheArray_ValidateState(9);
-       }
-       //r_mesh_rcachesequentialchain_current = l;
-       //R_Mesh_CacheArray_ValidateState(5);
-       // gobble an extra item if we have no free items available
-       if (r_mesh_rcachefreechain.next == &r_mesh_rcachefreechain)
-       {
-               lnext = l->next;
-
-               // unlink from sequential chain
-               l->next->prev = l->prev;
-               l->prev->next = l->next;
-               // link into free chain
-               l->next = &r_mesh_rcachefreechain;
-               l->prev = l->next->prev;
-               l->next->prev = l->prev->next = l;
-
-               l = &l->data->hashlink;
-               // unlink from hash chain
-               l->next->prev = l->prev;
-               l->prev->next = l->next;
-
-               l = lnext;
-       }
-       r_mesh_rcachesequentialchain_current = l;
-       //R_Mesh_CacheArray_ValidateState(6);
-
-       // now take an item from the free chain
-       l = r_mesh_rcachefreechain.next;
-       // set it up
-       d = l->data;
-       d->request = *r;
-       d->offset = offset;
-       // unlink
-       l->next->prev = l->prev;
-       l->prev->next = l->next;
-       // relink to sequential
-       l->next = r_mesh_rcachesequentialchain_current->prev;
-       l->prev = l->next->prev;
-       while (l->next->data && l->data && l->next->data->offset <= d->offset)
-       {
-               //Con_Print(">\n");
-               l->next = l->next->next;
-               l->prev = l->prev->next;
-       }
-       while (l->prev->data && l->data && l->prev->data->offset >= d->offset)
-       {
-               //Con_Print("<\n");
-               l->prev = l->prev->prev;
-               l->next = l->next->prev;
-       }
-       l->next->prev = l->prev->next = l;
-       // also link into hash chain
-       l = &l->data->hashlink;
-       l->next = &r_mesh_rcachechain[hashindex];
-       l->prev = l->next->prev;
-       l->prev->next = l;
-       l->next->prev = l->prev->next = l;
-
-
-       //r_mesh_rcachesequentialchain_current = d->sequentiallink.next;
-
-       //R_Mesh_CacheArray_ValidateState(7);
-       // and finally set the data pointer
-       r->data = r_mesh_rcachedata + d->offset;
-       // and tell the caller to fill the array
-       return true;
-}
-#endif