mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-06 01:41:11 +00:00
Removed unused PF_Md2 flag
More OpenGL performance increase by making assumptions about client state
This commit is contained in:
parent
cf6af71d33
commit
00792f8dab
3 changed files with 58 additions and 88 deletions
|
@ -166,7 +166,7 @@ enum EPolyFlags
|
||||||
// When set, pass the color constant into the FSurfaceInfo -> FlatColor
|
// When set, pass the color constant into the FSurfaceInfo -> FlatColor
|
||||||
PF_NoTexture = 0x00002000, // Use the small white texture
|
PF_NoTexture = 0x00002000, // Use the small white texture
|
||||||
PF_Corona = 0x00004000, // Tell the rendrer we are drawing a corona
|
PF_Corona = 0x00004000, // Tell the rendrer we are drawing a corona
|
||||||
PF_MD2 = 0x00008000, // Tell the rendrer we are drawing an MD2
|
PF_Unused = 0x00008000, // Unused
|
||||||
PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y
|
PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y
|
||||||
PF_ForceWrapX = 0x00020000, // Force repeat texture on X
|
PF_ForceWrapX = 0x00020000, // Force repeat texture on X
|
||||||
PF_ForceWrapY = 0x00040000, // Force repeat texture on Y
|
PF_ForceWrapY = 0x00040000, // Force repeat texture on Y
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct GLRGBAFloat
|
||||||
GLfloat alpha;
|
GLfloat alpha;
|
||||||
};
|
};
|
||||||
typedef struct GLRGBAFloat GLRGBAFloat;
|
typedef struct GLRGBAFloat GLRGBAFloat;
|
||||||
|
static const float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
|
@ -936,6 +937,8 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask,
|
||||||
SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude);
|
SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude);
|
||||||
|
|
||||||
pglClear(ClearMask);
|
pglClear(ClearMask);
|
||||||
|
pglEnableClientState(GL_VERTEX_ARRAY); // We always use this one
|
||||||
|
pglEnableClientState(GL_TEXTURE_COORD_ARRAY); // And mostly this one, too
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -976,12 +979,12 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1,
|
||||||
p[6] = v2->x + dx; p[7] = -(v2->y - dy); p[8] = 1;
|
p[6] = v2->x + dx; p[7] = -(v2->y - dy); p[8] = 1;
|
||||||
p[9] = v1->x + dx; p[10] = -(v1->y - dy); p[11] = 1;
|
p[9] = v1->x + dx; p[10] = -(v1->y - dy); p[11] = 1;
|
||||||
|
|
||||||
|
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
pglColor4fv(&c.red); // is in RGBA float format
|
pglColor4fv(&c.red); // is in RGBA float format
|
||||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
pglVertexPointer(3, GL_FLOAT, 0, p);
|
pglVertexPointer(3, GL_FLOAT, 0, p);
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
pglDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
|
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
pglEnable(GL_TEXTURE_2D);
|
pglEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,7 +1097,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
|
||||||
if (oglflags & GLF_NOTEXENV)
|
if (oglflags & GLF_NOTEXENV)
|
||||||
{
|
{
|
||||||
if (!(PolyFlags & PF_Modulated))
|
if (!(PolyFlags & PF_Modulated))
|
||||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
pglColor4fv(white);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1452,16 +1455,9 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf,
|
||||||
pglColor4fv(&c.red);
|
pglColor4fv(&c.red);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PolyFlags & PF_MD2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x);
|
pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x);
|
||||||
pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].sow);
|
pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].sow);
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, iNumPts);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, iNumPts);
|
||||||
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
if (PolyFlags & PF_RemoveYWrap)
|
if (PolyFlags & PF_RemoveYWrap)
|
||||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
@ -1760,8 +1756,6 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
|
||||||
if (useTinyFrames)
|
if (useTinyFrames)
|
||||||
pglScalef(1 / 64.0f, 1 / 64.0f, 1 / 64.0f);
|
pglScalef(1 / 64.0f, 1 / 64.0f, 1 / 64.0f);
|
||||||
|
|
||||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglEnableClientState(GL_NORMAL_ARRAY);
|
pglEnableClientState(GL_NORMAL_ARRAY);
|
||||||
|
|
||||||
for (i = 0; i < model->numMeshes; i++)
|
for (i = 0; i < model->numMeshes; i++)
|
||||||
|
@ -1852,8 +1846,6 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
|
||||||
}
|
}
|
||||||
|
|
||||||
pglDisableClientState(GL_NORMAL_ARRAY);
|
pglDisableClientState(GL_NORMAL_ARRAY);
|
||||||
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
pglPopMatrix(); // should be the same as glLoadIdentity
|
pglPopMatrix(); // should be the same as glLoadIdentity
|
||||||
if (color)
|
if (color)
|
||||||
|
@ -1974,16 +1966,13 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
|
||||||
|
|
||||||
// const float blackBack[16]
|
// const float blackBack[16]
|
||||||
|
|
||||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
// Draw a black square behind the screen texture,
|
// Draw a black square behind the screen texture,
|
||||||
// so nothing shows through the edges
|
// so nothing shows through the edges
|
||||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
pglColor4fv(white);
|
||||||
|
|
||||||
pglVertexPointer(3, GL_FLOAT, 0, blackBack);
|
pglVertexPointer(3, GL_FLOAT, 0, blackBack);
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
|
||||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
for(x=0;x<SCREENVERTS-1;x++)
|
for(x=0;x<SCREENVERTS-1;x++)
|
||||||
{
|
{
|
||||||
for(y=0;y<SCREENVERTS-1;y++)
|
for(y=0;y<SCREENVERTS-1;y++)
|
||||||
|
@ -2030,9 +2019,6 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
|
|
||||||
pglDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
pglEnable(GL_DEPTH_TEST);
|
pglEnable(GL_DEPTH_TEST);
|
||||||
pglEnable(GL_BLEND);
|
pglEnable(GL_BLEND);
|
||||||
|
@ -2154,15 +2140,11 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void)
|
||||||
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
pglColor4fv(white);
|
||||||
|
|
||||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
tex_downloaded = screentexture;
|
tex_downloaded = screentexture;
|
||||||
}
|
}
|
||||||
|
@ -2219,12 +2201,11 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
|
||||||
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
SetBlend(PF_Modulated|PF_NoDepthTest|PF_Clip|PF_NoZClip);
|
SetBlend(PF_Modulated|PF_NoDepthTest|PF_Clip|PF_NoZClip);
|
||||||
|
pglEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
// Draw the original screen
|
// Draw the original screen
|
||||||
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
|
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
|
||||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
pglColor4fv(white);
|
||||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
@ -2233,20 +2214,16 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
|
||||||
|
|
||||||
// Draw the end screen that fades in
|
// Draw the end screen that fades in
|
||||||
pglActiveTexture(GL_TEXTURE0);
|
pglActiveTexture(GL_TEXTURE0);
|
||||||
pglEnable(GL_TEXTURE_2D);
|
|
||||||
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
|
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
|
||||||
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
|
||||||
pglActiveTexture(GL_TEXTURE1);
|
pglActiveTexture(GL_TEXTURE1);
|
||||||
pglEnable(GL_TEXTURE_2D);
|
|
||||||
pglBindTexture(GL_TEXTURE_2D, fademaskdownloaded);
|
pglBindTexture(GL_TEXTURE_2D, fademaskdownloaded);
|
||||||
|
|
||||||
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
// const float defaultST[8]
|
// const float defaultST[8]
|
||||||
|
|
||||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
|
|
||||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||||
pglClientActiveTexture(GL_TEXTURE0);
|
pglClientActiveTexture(GL_TEXTURE0);
|
||||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||||
|
@ -2254,9 +2231,6 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
|
||||||
pglTexCoordPointer(2, GL_FLOAT, 0, defaultST);
|
pglTexCoordPointer(2, GL_FLOAT, 0, defaultST);
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
|
||||||
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
pglClientActiveTexture(GL_TEXTURE0);
|
pglClientActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
pglDisable(GL_TEXTURE_2D); // disable the texture in the 2nd texture unit
|
pglDisable(GL_TEXTURE_2D); // disable the texture in the 2nd texture unit
|
||||||
|
@ -2389,18 +2363,12 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||||
ClearBuffer(true, false, &clearColour);
|
ClearBuffer(true, false, &clearColour);
|
||||||
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
||||||
|
|
||||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
pglColor4fv(white);
|
||||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
|
|
||||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||||
pglVertexPointer(3, GL_FLOAT, 0, off);
|
pglVertexPointer(3, GL_FLOAT, 0, off);
|
||||||
|
|
||||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
|
||||||
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
pglDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
tex_downloaded = finalScreenTexture;
|
tex_downloaded = finalScreenTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,8 @@ typedef void (APIENTRY * PFNglGetIntegerv) (GLenum pname, GLint *params);
|
||||||
extern PFNglGetIntegerv pglGetIntegerv;
|
extern PFNglGetIntegerv pglGetIntegerv;
|
||||||
typedef const GLubyte* (APIENTRY * PFNglGetString) (GLenum name);
|
typedef const GLubyte* (APIENTRY * PFNglGetString) (GLenum name);
|
||||||
extern PFNglGetString pglGetString;
|
extern PFNglGetString pglGetString;
|
||||||
|
typedef void (APIENTRY * PFNglEnableClientState) (GLenum cap);
|
||||||
|
static PFNglEnableClientState pglEnableClientState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue