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:
parent
30eb7eb773
commit
9a49138493
|
@ -716,7 +716,7 @@ static void setTexture(unsigned int format, unsigned int texpal)
|
|||
case TEXMODE_A5I3: //a5i3
|
||||
case TEXMODE_16BPP: //16bpp
|
||||
case TEXMODE_4X4: //4x4
|
||||
default:
|
||||
default:
|
||||
paletteAddress = texturePalette<<4;
|
||||
break;
|
||||
}
|
||||
|
@ -938,9 +938,9 @@ REJECT:
|
|||
{
|
||||
//RGB16TO32 is used here because the other conversion macros result in broken interpolation logic
|
||||
|
||||
if(ms.numItems != 1) {
|
||||
if(ms.numItems != 1) {
|
||||
PROGINFO("Your 4x4 texture has overrun its texture slot.\n");
|
||||
}
|
||||
}
|
||||
//this check isnt necessary since the addressing is tied to the texture data which will also run out:
|
||||
//if(msIndex.numItems != 1) PROGINFO("Your 4x4 texture index has overrun its slot.\n");
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue