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
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
qglEnd();
CHECKGLERROR
}
- GL_UnlockArray();
+ if (arraylocked)
+ {
+ qglUnlockArraysEXT();
+ CHECKGLERROR
+ arraylocked = false;
+ }
}
// enlarges geometry buffers if they are too small
#define MAX_TEXTUREUNITS 8
+extern cvar_t gl_lockarrays;
+
extern int c_meshtris, c_meshs;
typedef struct
int batch, batchcount, additive;
unsigned int color;
drawqueuemesh_t *mesh;
+ int arraylocked = false;
if (!r_render.integer)
return;
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
{
qglEnd();
CHECKGLERROR
}
+ if (arraylocked)
+ {
+ qglUnlockArraysEXT();
+ CHECKGLERROR
+ arraylocked = false;
+ }
if (gl_mesh_drawmode.integer > 0)
{
qglDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
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};
// 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);
#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
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 *);
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"
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);
{"glTexImage2D", (void **) &qglTexImage2D},
{"glTexSubImage2D", (void **) &qglTexSubImage2D},
{"glDeleteTextures", (void **) &qglDeleteTextures},
+ {"glPixelStoref", (void **) &qglPixelStoref},
+ {"glPixelStorei", (void **) &qglPixelStorei},
{NULL, NULL}
};