Changed the vertex transformation method so now we don't have to pass the projection matrices to OpenGL.

(I left the proj matrix cache commented so if this change causes problems, we can revert it easily)
This commit is contained in:
luigi__ 2009-01-13 17:32:56 +00:00
parent 30eb7eb773
commit 9a49138493
3 changed files with 28 additions and 26 deletions

View File

@ -1260,6 +1260,9 @@ static void OGLRender()
glClearDepth(gfx3d.clearDepth);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//render display list
//TODO - properly doublebuffer the display lists
@ -1284,11 +1287,11 @@ static void OGLRender()
}
//since we havent got the whole pipeline working yet, lets use opengl for the projection
if(lastProjIndex != poly->projIndex) {
/* if(lastProjIndex != poly->projIndex) {
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(gfx3d.projlist->projMatrix[poly->projIndex]);
lastProjIndex = poly->projIndex;
}
}*/
glBegin(type==3?GL_TRIANGLES:GL_QUADS);
for(int j=0;j<type;j++) {
@ -1301,7 +1304,7 @@ static void OGLRender()
};
//float tempCoord[4];
//Vector4Copy(tempCoord,vert->coord);
//Vector4Copy(tempCoord, vert->coord);
//we havent got the whole pipeline working yet, so we cant do this
////convert from ds device coords to opengl
//tempCoord[0] *= 2;
@ -1312,8 +1315,8 @@ static void OGLRender()
//todo - edge flag?
glTexCoord2fv(vert->texcoord);
glColor4ubv((GLubyte*)color);
//glVertex3fv(tempCoord);
glVertex3fv(vert->coord);
//glVertex4fv(tempCoord);
glVertex4fv(vert->coord);
}
glEnd();
}

View File

@ -147,8 +147,8 @@ POLYLIST polylists[2];
POLYLIST* polylist = &polylists[0];
VERTLIST vertlists[2];
VERTLIST* vertlist = &vertlists[0];
PROJLIST projlists[2];
PROJLIST* projlist = &projlists[0];
//PROJLIST projlists[2];
//PROJLIST* projlist = &projlists[0];
int listTwiddle = 1;
int triStripToggle;
@ -167,10 +167,10 @@ static void twiddleLists() {
listTwiddle &= 1;
polylist = &polylists[listTwiddle];
vertlist = &vertlists[listTwiddle];
projlist = &projlists[listTwiddle];
// projlist = &projlists[listTwiddle];
polylist->count = 0;
vertlist->count = 0;
projlist->count = 0;
// projlist->count = 0;
}
static BOOL flushPending = FALSE;
@ -531,9 +531,8 @@ static void SetVertex()
//apply modelview matrix
MatrixMultVec4x4 (mtxCurrent[1], coordTransformed);
//todo - we havent got the whole pipeline working yet, so lets save the projection matrix and let opengl do it
////apply projection matrix
//MatrixMultVec4x4 (mtxCurrent[0], coordTransformed);
//apply projection matrix
MatrixMultVec4x4 (mtxCurrent[0], coordTransformed);
////perspective division
//coordTransformed[0] = (coordTransformed[0] + coordTransformed[3]) / 2 / coordTransformed[3];
@ -631,7 +630,7 @@ static void SetVertex()
//todo - dont overrun proj list
//see if the last entry in the proj list matches the current matrix, if there is one.
if(projlist->count != 0 &&
/* if(projlist->count != 0 &&
//here is an example of something that does not work.
//(for a speed hack, we consider the matrices different if the first element differs)
//mtxCurrent[0][0] == projlist->projMatrix[projlist->count-1][0]
@ -648,7 +647,7 @@ static void SetVertex()
MatrixCopy(projlist->projMatrix[projlist->count],mtxCurrent[0]);
poly.projIndex = projlist->count;
projlist->count++;
}
}*/
poly.polyAttr = polyAttr;
poly.texParam = textureFormat;
@ -1180,7 +1179,7 @@ void gfx3d_glFlush(unsigned long v)
//the renderer wil lget the lists we just built
gfx3d.polylist = polylist;
gfx3d.vertlist = vertlist;
gfx3d.projlist = projlist;
// gfx3d.projlist = projlist;
//we need to sort the poly list with alpha polys last
//first, look for alpha polys
@ -2050,16 +2049,16 @@ bool gfx3d_loadstate(std::istream* is)
//jiggle the lists. and also wipe them. this is clearly not the best thing to be doing.
polylist = &polylists[listTwiddle];
vertlist = &vertlists[listTwiddle];
projlist = &projlists[listTwiddle];
// projlist = &projlists[listTwiddle];
polylist->count = 0;
vertlist->count = 0;
projlist->count = 0;
// projlist->count = 0;
gfx3d.polylist = &polylists[listTwiddle^1];
gfx3d.vertlist = &vertlists[listTwiddle^1];
gfx3d.projlist = &projlists[listTwiddle^1];
// gfx3d.projlist = &projlists[listTwiddle^1];
gfx3d.polylist->count=0;
gfx3d.vertlist->count=0;
gfx3d.projlist->count = 0;
// gfx3d.projlist->count = 0;
return true;
}

View File

@ -40,7 +40,7 @@ struct POLY {
int type; //tri or quad
u16 vertIndexes[4]; //up to four verts can be referenced by this poly
u32 polyAttr, texParam, texPalette; //the hardware rendering params
int projIndex; //the index into the projlist that this poly uses
// int projIndex; //the index into the projlist that this poly uses
u32 pad;
bool isTranslucent()
@ -65,11 +65,11 @@ struct POLYLIST {
int count;
};
#define PROJLIST_SIZE 1000
/*#define PROJLIST_SIZE 1000
struct PROJLIST {
float projMatrix[PROJLIST_SIZE][16];
int count;
};
};*/
struct VERT {
float coord[4];
@ -112,7 +112,7 @@ struct GFX3D
POLYLIST* polylist;
VERTLIST* vertlist;
PROJLIST* projlist;
//PROJLIST* projlist;
int indexlist[POLYLIST_SIZE];
BOOL wbuffer, sortmode;