mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-09 01:01:07 +00:00
Simple use of vertex arrays in R_DrawTextureChains_Multitexture.
The glBegin(GL_POLYGON), for() loop with GL_MTexCoord2fFunc()/glVertex3fv() calls, and glEnd () per polygon is replaced by a memcpy() and a glDrawArrays() call per poly. My guess is this only saves function call overhead, but it gives a decent ~20% speedup (36 -> 42fps) on my machine on orl’s map. Note: glDrawArrays() is in OpenGL 1.1, but the glClientActiveTextureARB function is part of the GL_ARB_multitexture extension but not GL_SGIS_multitexture. Instead of splitting into two code paths, I just dropped support for GL_SGIS_multitexture. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@981 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
52ee1b6c51
commit
745fa7ecce
3 changed files with 42 additions and 28 deletions
|
@ -86,6 +86,7 @@ qboolean gl_texture_NPOT = false; //ericw
|
|||
|
||||
PFNGLMULTITEXCOORD2FARBPROC GL_MTexCoord2fFunc = NULL; //johnfitz
|
||||
PFNGLACTIVETEXTUREARBPROC GL_SelectTextureFunc = NULL; //johnfitz
|
||||
PFNGLCLIENTACTIVETEXTUREARBPROC GL_ClientActiveTextureFunc = NULL; //ericw
|
||||
|
||||
//====================================
|
||||
|
||||
|
@ -561,7 +562,8 @@ static void GL_CheckExtensions (void)
|
|||
{
|
||||
GL_MTexCoord2fFunc = (PFNGLMULTITEXCOORD2FARBPROC) SDL_GL_GetProcAddress("glMultiTexCoord2fARB");
|
||||
GL_SelectTextureFunc = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB");
|
||||
if (GL_MTexCoord2fFunc && GL_SelectTextureFunc)
|
||||
GL_ClientActiveTextureFunc = (PFNGLCLIENTACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glClientActiveTextureARB");
|
||||
if (GL_MTexCoord2fFunc && GL_SelectTextureFunc && GL_ClientActiveTextureFunc)
|
||||
{
|
||||
Con_Printf("FOUND: ARB_multitexture\n");
|
||||
TEXTURE0 = GL_TEXTURE0_ARB;
|
||||
|
@ -573,22 +575,6 @@ static void GL_CheckExtensions (void)
|
|||
Con_Warning ("Couldn't link to multitexture functions\n");
|
||||
}
|
||||
}
|
||||
else if (GL_ParseExtensionList(gl_extensions, "GL_SGIS_multitexture"))
|
||||
{
|
||||
GL_MTexCoord2fFunc = (PFNGLMULTITEXCOORD2FARBPROC) SDL_GL_GetProcAddress("glMTexCoord2fSGIS");
|
||||
GL_SelectTextureFunc = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glSelectTextureSGIS");
|
||||
if (GL_MTexCoord2fFunc && GL_SelectTextureFunc)
|
||||
{
|
||||
Con_Printf("FOUND: SGIS_multitexture\n");
|
||||
TEXTURE0 = TEXTURE0_SGIS;
|
||||
TEXTURE1 = TEXTURE1_SGIS;
|
||||
gl_mtexable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Warning ("Couldn't link to multitexture functions\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Warning ("multitexture not supported (extension not found)\n");
|
||||
|
|
|
@ -157,6 +157,7 @@ extern qboolean gl_mtexable;
|
|||
//johnfitz -- modified multitexture support
|
||||
extern PFNGLMULTITEXCOORD2FARBPROC GL_MTexCoord2fFunc;
|
||||
extern PFNGLACTIVETEXTUREARBPROC GL_SelectTextureFunc;
|
||||
extern PFNGLCLIENTACTIVETEXTUREARBPROC GL_ClientActiveTextureFunc;
|
||||
extern GLenum TEXTURE0, TEXTURE1;
|
||||
//johnfitz
|
||||
|
||||
|
|
|
@ -31,6 +31,39 @@ byte *SV_FatPVS (vec3_t org, qmodel_t *worldmodel);
|
|||
extern byte mod_novis[MAX_MAP_LEAFS/8];
|
||||
int vis_changed; //if true, force pvs to be refreshed
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
// VERTEX ARRAY SUPPORT
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
#define VERTEXBYTES (VERTEXSIZE * sizeof (float))
|
||||
|
||||
// qbsp guarantees no more than 64 verts per surf
|
||||
#define MAX_VERTS_PER_SURF 64
|
||||
|
||||
static float r_surfvertexarray[MAX_VERTS_PER_SURF * VERTEXSIZE];
|
||||
|
||||
void R_VertexArrayMultitexturedSetup (void)
|
||||
{
|
||||
glVertexPointer(3, GL_FLOAT, VERTEXBYTES, &r_surfvertexarray[0]);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
GL_ClientActiveTextureFunc(TEXTURE0);
|
||||
glTexCoordPointer(2, GL_FLOAT, VERTEXBYTES, &r_surfvertexarray[3]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
GL_ClientActiveTextureFunc(TEXTURE1);
|
||||
glTexCoordPointer(2, GL_FLOAT, VERTEXBYTES, &r_surfvertexarray[5]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
void R_VertexArrayMultitexturedDrawGLPoly (glpoly_t *p)
|
||||
{
|
||||
memcpy(r_surfvertexarray, p->verts, p->numverts * VERTEXBYTES);
|
||||
glDrawArrays(GL_POLYGON, 0, p->numverts);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
// SETUP CHAINS
|
||||
|
@ -410,12 +443,13 @@ R_DrawTextureChains_Multitexture -- johnfitz
|
|||
*/
|
||||
void R_DrawTextureChains_Multitexture (qmodel_t *model, entity_t *ent, texchain_t chain)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
msurface_t *s;
|
||||
texture_t *t;
|
||||
float *v;
|
||||
qboolean bound;
|
||||
|
||||
R_VertexArrayMultitexturedSetup ();
|
||||
|
||||
for (i=0 ; i<model->numtextures ; i++)
|
||||
{
|
||||
t = model->textures[i];
|
||||
|
@ -439,15 +473,8 @@ void R_DrawTextureChains_Multitexture (qmodel_t *model, entity_t *ent, texchain_
|
|||
}
|
||||
R_RenderDynamicLightmaps (s);
|
||||
GL_Bind (lightmap_textures[s->lightmaptexturenum]);
|
||||
glBegin(GL_POLYGON);
|
||||
v = s->polys->verts[0];
|
||||
for (j=0 ; j<s->polys->numverts ; j++, v+= VERTEXSIZE)
|
||||
{
|
||||
GL_MTexCoord2fFunc (TEXTURE0, v[3], v[4]);
|
||||
GL_MTexCoord2fFunc (TEXTURE1, v[5], v[6]);
|
||||
glVertex3fv (v);
|
||||
}
|
||||
glEnd ();
|
||||
R_VertexArrayMultitexturedDrawGLPoly (s->polys);
|
||||
|
||||
rs_brushpasses++;
|
||||
}
|
||||
GL_DisableMultitexture(); // selects TEXTURE0
|
||||
|
|
Loading…
Reference in a new issue