]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
manually inlined GL_LockArray and GL_UnlockArray in the only places they were used
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 12 Sep 2002 14:55:25 +0000 (14:55 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 12 Sep 2002 14:55:25 +0000 (14:55 +0000)
RGB fragment textures are no longer aligned on 3 pixel boundaries, changed UNPACK_ALIGNMENT to allow this

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2371 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_backend.h
gl_draw.c
gl_textures.c
glquake.h
render.h
vid_shared.c

index ad6f24c9189819f201f11d59b498dbcaa3aee925..10acf3f093de5576005ded1a3100d2eadefa2627 100644 (file)
@@ -213,28 +213,6 @@ void gl_backend_init(void)
        R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
 }
 
-int arraylocked = false;
-
-void GL_LockArray(int first, int count)
-{
-       if (!arraylocked && gl_supportslockarrays && gl_lockarrays.integer && gl_mesh_drawmode.integer > 0)
-       {
-               qglLockArraysEXT(first, count);
-               CHECKGLERROR
-               arraylocked = true;
-       }
-}
-
-void GL_UnlockArray(void)
-{
-       if (arraylocked)
-       {
-               qglUnlockArraysEXT();
-               CHECKGLERROR
-               arraylocked = false;
-       }
-}
-
 /*
 =============
 GL_SetupFrame
@@ -549,7 +527,13 @@ void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, GLuint *in
        unsigned int i, j, in;
        qbyte *c;
        float *v;
-       GL_LockArray(firstvert, endvert - firstvert);
+       int arraylocked = false;
+       if (gl_supportslockarrays && gl_lockarrays.integer && gl_mesh_drawmode.integer > 0)
+       {
+               qglLockArraysEXT(firstvert, endvert - firstvert);
+               CHECKGLERROR
+               arraylocked = true;
+       }
        if (gl_mesh_drawmode.integer >= 3/* && (endvert - firstvert) <= gl_maxdrawrangeelementsvertices && (indexcount) <= gl_maxdrawrangeelementsindices*/)
        {
                // GL 1.2 or GL 1.1 with extension
@@ -616,7 +600,12 @@ void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, GLuint *in
                qglEnd();
                CHECKGLERROR
        }
-       GL_UnlockArray();
+       if (arraylocked)
+       {
+               qglUnlockArraysEXT();
+               CHECKGLERROR
+               arraylocked = false;
+       }
 }
 
 // enlarges geometry buffers if they are too small
index 1752635f6303a408d653855bc48a18efeed1d171..7190e0c2f41114839af4ec62db5b0d7a66b5fa60 100644 (file)
@@ -4,6 +4,8 @@
 
 #define MAX_TEXTUREUNITS 8
 
+extern cvar_t gl_lockarrays;
+
 extern int c_meshtris, c_meshs;
 
 typedef struct
index d92928858ad31f794b427950c8cf2702978267ab..66fc741d8c3487234a6fe85f410f3c002196e698 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -371,6 +371,7 @@ void R_DrawQueue(void)
        int batch, batchcount, additive;
        unsigned int color;
        drawqueuemesh_t *mesh;
+       int arraylocked = false;
 
        if (!r_render.integer)
                return;
@@ -571,34 +572,34 @@ void R_DrawQueue(void)
                                qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
                        }
 
+                       if (gl_supportslockarrays && gl_lockarrays.integer && gl_mesh_drawmode.integer > 0)
+                       {
+                               qglLockArraysEXT(0, mesh->numvertices);
+                               CHECKGLERROR
+                               arraylocked = true;
+                       }
                        if (gl_mesh_drawmode.integer >= 3/* && (mesh->numvertices) <= gl_maxdrawrangeelementsvertices && (mesh->numindices) <= gl_maxdrawrangeelementsindices*/)
                        {
                                // GL 1.2 or GL 1.1 with extension
-                               GL_LockArray(0, mesh->numvertices);
                                qglDrawRangeElements(GL_TRIANGLES, 0, mesh->numvertices, mesh->numindices, GL_UNSIGNED_INT, mesh->indices);
                                CHECKGLERROR
-                               GL_UnlockArray();
                        }
                        else if (gl_mesh_drawmode.integer >= 2)
                        {
                                // GL 1.1
-                               GL_LockArray(0, mesh->numvertices);
                                qglDrawElements(GL_TRIANGLES, mesh->numindices, GL_UNSIGNED_INT, mesh->indices);
                                CHECKGLERROR
-                               GL_UnlockArray();
                        }
                        else if (gl_mesh_drawmode.integer >= 1)
                        {
                                int i;
                                // GL 1.1
                                // feed it manually using glArrayElement
-                               GL_LockArray(0, mesh->numvertices);
                                qglBegin(GL_TRIANGLES);
                                for (i = 0;i < mesh->numindices;i++)
                                        qglArrayElement(mesh->indices[i]);
                                qglEnd();
                                CHECKGLERROR
-                               GL_UnlockArray();
                        }
                        else
                        {
@@ -616,6 +617,12 @@ void R_DrawQueue(void)
                                qglEnd();
                                CHECKGLERROR
                        }
+                       if (arraylocked)
+                       {
+                               qglUnlockArraysEXT();
+                               CHECKGLERROR
+                               arraylocked = false;
+                       }
                        if (gl_mesh_drawmode.integer > 0)
                        {
                                qglDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
index 8aa0457f31984dc5ad961b4e1026d3f58bbb4415..a9842972b69bf7abbc9ebd1677ac3755ce643dc3 100644 (file)
@@ -45,7 +45,7 @@ typedef struct
 textypeinfo_t;
 
 static textypeinfo_t textype_qpalette       = {TEXTYPE_QPALETTE, 1, 4, GL_RGBA, 3, 1};
-static textypeinfo_t textype_rgb            = {TEXTYPE_RGB     , 3, 3, GL_RGB , 3, 3};
+static textypeinfo_t textype_rgb            = {TEXTYPE_RGB     , 3, 3, GL_RGB , 3, 1};
 static textypeinfo_t textype_rgba           = {TEXTYPE_RGBA    , 4, 4, GL_RGBA, 3, 1};
 static textypeinfo_t textype_qpalette_alpha = {TEXTYPE_QPALETTE, 1, 4, GL_RGBA, 4, 1};
 static textypeinfo_t textype_rgba_alpha     = {TEXTYPE_RGBA    , 4, 4, GL_RGBA, 4, 1};
@@ -446,6 +446,9 @@ static void r_textures_start(void)
        // deal with size limits of various drivers (3dfx in particular)
        qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &realmaxsize);
        CHECKGLERROR
+       // LordHavoc: allow any alignment
+       qglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+       CHECKGLERROR
 
        // use the largest scrap texture size we can (not sure if this is really a good idea)
        for (block_size = 1;block_size < realmaxsize && block_size < r_max_scrapsize.integer;block_size <<= 1);
index bf362edc81a5e087db17869336ac4c77fcfe6fe4..d9ce90ee0dfea6cf1f4fa138de4cabe582401d67 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -115,6 +115,7 @@ typedef double GLclampd;
 #define GL_TEXTURE_WRAP_T                      0x2803
 #define GL_TEXTURE_MAG_FILTER                  0x2800
 #define GL_TEXTURE_MIN_FILTER                  0x2801
+#define GL_UNPACK_ALIGNMENT                    0x0CF5
 
 #define GL_NEAREST                             0x2600
 #define GL_LINEAR                              0x2601
@@ -362,6 +363,8 @@ extern void (GLAPIENTRY *qglBindTexture)(GLenum target, GLuint texture);
 extern void (GLAPIENTRY *qglTexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels );
 extern void (GLAPIENTRY *qglTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
 extern void (GLAPIENTRY *qglDeleteTextures)(GLsizei n, const GLuint *textures);
+extern void (GLAPIENTRY *qglPixelStoref)(GLenum pname, GLfloat param);
+extern void (GLAPIENTRY *qglPixelStorei)(GLenum pname, GLint param);
 
 #if WIN32
 extern int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
index 05dcd5f77652f0b7951de1d24c04448654575989..426893c84eedda9732a99837eda107abd2bf999f 100644 (file)
--- a/render.h
+++ b/render.h
@@ -162,10 +162,6 @@ extern cvar_t r_render;
 extern cvar_t r_textureunits;
 extern cvar_t gl_dither;
 
-// FIXME: this should live in the backend only
-void GL_LockArray(int first, int count);
-void GL_UnlockArray(void);
-
 #include "gl_backend.h"
 
 #include "r_light.h"
index a35bb1ed26694f23066bf8f413543c336a1272d6..ad8e0d3481c7e031135e8dae056946b5bf3620b9 100644 (file)
@@ -143,6 +143,8 @@ void (GLAPIENTRY *qglBindTexture)(GLenum target, GLuint texture);
 void (GLAPIENTRY *qglTexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
 void (GLAPIENTRY *qglTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
 void (GLAPIENTRY *qglDeleteTextures)(GLsizei n, const GLuint *textures);
+void (GLAPIENTRY *qglPixelStoref)(GLenum pname, GLfloat param);
+void (GLAPIENTRY *qglPixelStorei)(GLenum pname, GLint param);
 
 void (GLAPIENTRY *qglDrawRangeElementsEXT)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
 
@@ -257,6 +259,8 @@ static gl_extensionfunctionlist_t opengl110funcs[] =
        {"glTexImage2D", (void **) &qglTexImage2D},
        {"glTexSubImage2D", (void **) &qglTexSubImage2D},
        {"glDeleteTextures", (void **) &qglDeleteTextures},
+       {"glPixelStoref", (void **) &qglPixelStoref},
+       {"glPixelStorei", (void **) &qglPixelStorei},
        {NULL, NULL}
 };