Skip to content

Commit

Permalink
Revert "Replace immediate-mode rendering with VA-based rendering" for…
Browse files Browse the repository at this point in the history
… now, since it makes rendering trucks very slow.

This reverts commit f363a02.

Please revert this revert when this is fixed.
  • Loading branch information
Cyp committed Oct 26, 2010
1 parent fb18403 commit 25671b1
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 339 deletions.
39 changes: 13 additions & 26 deletions lib/betawidget/src/widget.c
Expand Up @@ -1485,32 +1485,19 @@ void widgetCompositeImpl(widget *self)
// Composite ourself
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self->textureId);

glPushMatrix();
glScalef(self->size.x, self->size.y, 1.f);
glMatrixMode(GL_TEXTURE);
glPushMatrix(); // texture matrix
glScalef(self->size.x, self->size.y, 1.f);
{
const short vertices[][2] = {
{ 0, 1 },
{ 0, 0 },
{ 1, 1 },
{ 1, 0 },
};

glVertexPointer(2, GL_SHORT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);

glTexCoordPointer(2, GL_SHORT, 0, vertices);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
glPopMatrix(); // texture matrix
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0f, self->size.y);
glVertex2f(0.0f, self->size.y);

glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);

glTexCoord2f(self->size.x, self->size.y);
glVertex2f(self->size.x, self->size.y);

glTexCoord2f(self->size.x, 0.0f);
glVertex2f(self->size.x, 0.0f);
glEnd();

// Now our children
for (i = 0; i < vectorSize(self->children); i++)
Expand Down
86 changes: 24 additions & 62 deletions lib/ivis_opengl/pieblitfunc.c
Expand Up @@ -64,40 +64,30 @@ static GLfloat radarTexX, radarTexY;

void iV_Line(int x0, int y0, int x1, int y1, PIELIGHT colour)
{
const Vector2i vertices[] = {
{ x0, y0 },
{ x1, y1 },
};

pie_SetTexturePage(TEXPAGE_NONE);
pie_SetAlphaTest(false);

glColor4ubv(colour.vector);
glVertexPointer(2, GL_INT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_LINE_STRIP, 0, ARRAY_SIZE(vertices));
glDisableClientState(GL_VERTEX_ARRAY);
glBegin(GL_LINE_STRIP);
glVertex2i(x0, y0);
glVertex2i(x1, y1);
glEnd();
}

/**
* Assumes render mode set up externally, draws filled rectangle.
*/
static void pie_DrawRect(float x0, float y0, float x1, float y1, PIELIGHT colour)
{
const Vector2f vertices[] = {
{ x0, y0 },
{ x1, y0 },
{ x0, y1 },
{ x1, y1 },
};

pie_SetAlphaTest(false);

glColor4ubv(colour.vector);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAY_SIZE(vertices));
glDisableClientState(GL_VERTEX_ARRAY);
glBegin(GL_TRIANGLE_STRIP);
glVertex2f(x0, y0);
glVertex2f(x1, y0);
glVertex2f(x0, y1);
glVertex2f(x1, y1);
glEnd();
}


Expand All @@ -123,21 +113,14 @@ void iV_Box(int x0,int y0, int x1, int y1, PIELIGHT colour)
if (y1>rendSurface.clip.bottom)
y1 = rendSurface.clip.bottom;

{
const Vector2f vertices[] = {
{ x0, y0 },
{ x1, y0 },
{ x1, y1 },
{ x0, y1 },
{ x0, y0 },
};

glColor4ubv(colour.vector);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_LINE_STRIP, 0, ARRAY_SIZE(vertices));
glDisableClientState(GL_VERTEX_ARRAY);
}
glColor4ubv(colour.vector);
glBegin(GL_LINE_STRIP);
glVertex2f(x0, y0);
glVertex2f(x1, y0);
glVertex2f(x1, y1);
glVertex2f(x0, y1);
glVertex2f(x0, y0);
glEnd();
}

/***************************************************************************/
Expand Down Expand Up @@ -338,33 +321,12 @@ void pie_RenderRadar(int x, int y, int width, int height)
pie_SetRendMode(REND_ALPHA);

glColor4ubv(WZCOL_WHITE.vector);
glPushMatrix();
glTranslatef(x, y, 0);
glScalef(width, height, 1);
glMatrixMode(GL_TEXTURE);
glPushMatrix(); // texture matrix
glScalef(radarTexX, radarTexY, 1);
{
const Vector2i vertices[] = {
{ 0, 0 },
{ 1, 0 },
{ 0, 1 },
{ 1, 1 },
};

glVertexPointer(2, GL_INT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);

glTexCoordPointer(2, GL_INT, 0, vertices);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAY_SIZE(vertices));
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
glPopMatrix(); // texture matrix
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0, 0); glVertex2f(x, y);
glTexCoord2f(radarTexX, 0); glVertex2f(x + width, y);
glTexCoord2f(0, radarTexY); glVertex2f(x, y + height);
glTexCoord2f(radarTexX, radarTexY); glVertex2f(x + width, y + height);
glEnd();
}

void pie_LoadBackDrop(SCREENTYPE screenType)
Expand Down
147 changes: 49 additions & 98 deletions lib/ivis_opengl/piedraw.c
Expand Up @@ -306,39 +306,25 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
}
}

{
Vector3f normals[pie_MAX_VERTICES_PER_POLYGON];

if (light)
{
for (n = 0; n < pPolys->npnts; ++n)
normals[n] = pPolys->normal;
glNormalPointer(GL_FLOAT, 0, normals);
glEnableClientState(GL_NORMAL_ARRAY);
}
glBegin(GL_TRIANGLE_FAN);

glVertexPointer(3, GL_FLOAT, 0, vertexCoords);
glEnableClientState(GL_VERTEX_ARRAY);

glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE1);
if (light)
{
glNormal3fv((GLfloat*)&pPolys->normal);
}

if (shape->flags & iV_IMD_TCMASK
&& rendStates.rendMode == REND_OPAQUE
&& !pie_GetShadersStatus())
for (n = 0; n < pPolys->npnts; n++)
{
glTexCoord2fv((GLfloat*)&texCoords[n]);
if (shape->flags & iV_IMD_TCMASK && rendStates.rendMode == REND_OPAQUE &&
!pie_GetShadersStatus())
{
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glMultiTexCoord2fv(GL_TEXTURE1, (GLfloat*)&texCoords[n]);
}

glDrawArrays(GL_TRIANGLE_FAN, 0, pPolys->npnts);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glVertex3fv((GLfloat*)&vertexCoords[n]);
}

glEnd();
}

// Deactivate TCMask if it was previously enabled
Expand Down Expand Up @@ -530,50 +516,40 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
}

// draw the shadow volume
glEnableClientState(GL_VERTEX_ARRAY);
for (i = 0; i < edge_count; i++)
glBegin(GL_QUADS);
for(i=0;i<edge_count;i++)
{
int a = drawlist[i].from, b = drawlist[i].to;
if (a < 0)
continue;

if(a < 0)
{
const Vector3f vertices[] = {
{ pVertices[b].x, scale_y(pVertices[b].y, flag, flag_data), pVertices[b].z },
{ light->x + pVertices[b].x, light->y + scale_y(pVertices[b].y, flag, flag_data), light->z + pVertices[b].z },
{ light->x + pVertices[a].x, light->y + scale_y(pVertices[a].y, flag, flag_data), light->z + pVertices[a].z },
{ pVertices[a].x, scale_y(pVertices[a].y, flag, flag_data), pVertices[a].z },
};

glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawArrays(GL_QUADS, 0, ARRAY_SIZE(vertices));
continue;
}

glVertex3f(pVertices[b].x, scale_y(pVertices[b].y, flag, flag_data), pVertices[b].z);
glVertex3f(pVertices[b].x+light->x, scale_y(pVertices[b].y, flag, flag_data)+light->y, pVertices[b].z+light->z);
glVertex3f(pVertices[a].x+light->x, scale_y(pVertices[a].y, flag, flag_data)+light->y, pVertices[a].z+light->z);
glVertex3f(pVertices[a].x, scale_y(pVertices[a].y, flag, flag_data), pVertices[a].z);
}
glDisableClientState(GL_VERTEX_ARRAY);
glEnd();

#ifdef SHOW_SHADOW_EDGES
glDisable(GL_DEPTH_TEST);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

glColor4ub(0xFF, 0, 0, 0xFF);
glEnableClientState(GL_VERTEX_ARRAY);
glBegin(GL_LINES);
for(i = 0; i < edge_count; i++)
{
int a = drawlist[i].from, b = drawlist[i].to;
if (a < 0)
continue;

if(a < 0)
{
const Vector3f vertices[] = {
{ pVertices[b].x, scale_y(pVertices[b].y, flag, flag_data), pVertices[b].z },
{ pVertices[a].x, scale_y(pVertices[a].y, flag, flag_data), pVertices[a].z },
};

glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawArrays(GL_LINES, 0, ARRAY_SIZE(vertices));
continue;
}

glVertex3f(pVertices[b].x, scale_y(pVertices[b].y, flag, flag_data), pVertices[b].z);
glVertex3f(pVertices[a].x, scale_y(pVertices[a].y, flag, flag_data), pVertices[a].z);
}
glDisableClientState(GL_VERTEX_ARRAY);
glEnd();
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glEnable(GL_DEPTH_TEST);
#endif
Expand Down Expand Up @@ -802,24 +778,14 @@ static void pie_DrawShadows(void)
glColor4f(0, 0, 0, 0.5);

pie_PerspectiveEnd();
glDisable(GL_DEPTH_TEST);
glLoadIdentity();
glScalef(width, height, 1.f);
{
const Vector2i vertices[] = {
{ 0, 0 },
{ 1, 0 },
{ 0, 1 },
{ 1, 1 },
};

glVertexPointer(2, GL_INT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);

glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAY_SIZE(vertices));
glDisableClientState(GL_VERTEX_ARRAY);
}
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glBegin(GL_TRIANGLE_STRIP);
glVertex2f(0, 0);
glVertex2f(width, 0);
glVertex2f(0, height);
glVertex2f(width, height);
glEnd();
pie_PerspectiveBegin();

pie_SetRendMode(REND_OPAQUE);
Expand Down Expand Up @@ -877,36 +843,20 @@ void pie_DrawImage(const PIEIMAGE *image, const PIERECT *dest)

glColor4ubv(colour.vector);

glPushMatrix();
glTranslatef(dest->x, dest->y, 0);
glScalef(dest->w, dest->h, 1);
glMatrixMode(GL_TEXTURE);
glPushMatrix(); // texture matrix
glScalef(1.f / OLD_TEXTURE_SIZE_FIX, 1.f / OLD_TEXTURE_SIZE_FIX, 1.f);
glTranslatef(image->tu, image->tv, 0);
glScalef(image->tw, image->th, 1);
{
glBegin(GL_TRIANGLE_STRIP);
//set up 4 pie verts
const Vector2i vertices[] = {
{ 0, 0 },
{ 1, 0 },
{ 0, 1 },
{ 1, 1 },
};
glTexCoord2f(image->tu / OLD_TEXTURE_SIZE_FIX, image->tv / OLD_TEXTURE_SIZE_FIX);
glVertex2f(dest->x, dest->y);

glVertexPointer(2, GL_INT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoord2f((image->tu + image->tw) / OLD_TEXTURE_SIZE_FIX, image->tv / OLD_TEXTURE_SIZE_FIX);
glVertex2f(dest->x + dest->w, dest->y);

glTexCoordPointer(2, GL_INT, 0, vertices);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoord2f(image->tu / OLD_TEXTURE_SIZE_FIX, (image->tv + image->th) / OLD_TEXTURE_SIZE_FIX);
glVertex2f(dest->x, dest->y + dest->h);

glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAY_SIZE(vertices));
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
glPopMatrix(); // texture matrix
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glTexCoord2f((image->tu + image->tw) / OLD_TEXTURE_SIZE_FIX, (image->tv + image->th) / OLD_TEXTURE_SIZE_FIX);
glVertex2f(dest->x + dest->w, dest->y + dest->h);
glEnd();
}

void pie_GetResetCounts(unsigned int* pPieCount, unsigned int* pTileCount, unsigned int* pPolyCount, unsigned int* pStateCount)
Expand All @@ -920,4 +870,5 @@ void pie_GetResetCounts(unsigned int* pPieCount, unsigned int* pTileCount, unsig
tileCount = 0;
polyCount = 0;
pieStateCount = 0;
return;
}

0 comments on commit 25671b1

Please sign in to comment.