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_A5I3: //a5i3
|
||||||
case TEXMODE_16BPP: //16bpp
|
case TEXMODE_16BPP: //16bpp
|
||||||
case TEXMODE_4X4: //4x4
|
case TEXMODE_4X4: //4x4
|
||||||
default:
|
default:
|
||||||
paletteAddress = texturePalette<<4;
|
paletteAddress = texturePalette<<4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -938,9 +938,9 @@ REJECT:
|
||||||
{
|
{
|
||||||
//RGB16TO32 is used here because the other conversion macros result in broken interpolation logic
|
//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");
|
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:
|
//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");
|
//if(msIndex.numItems != 1) PROGINFO("Your 4x4 texture index has overrun its slot.\n");
|
||||||
|
|
||||||
|
@ -1260,6 +1260,9 @@ static void OGLRender()
|
||||||
glClearDepth(gfx3d.clearDepth);
|
glClearDepth(gfx3d.clearDepth);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
|
||||||
//render display list
|
//render display list
|
||||||
//TODO - properly doublebuffer the display lists
|
//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
|
//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);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadMatrixf(gfx3d.projlist->projMatrix[poly->projIndex]);
|
glLoadMatrixf(gfx3d.projlist->projMatrix[poly->projIndex]);
|
||||||
lastProjIndex = poly->projIndex;
|
lastProjIndex = poly->projIndex;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
glBegin(type==3?GL_TRIANGLES:GL_QUADS);
|
glBegin(type==3?GL_TRIANGLES:GL_QUADS);
|
||||||
for(int j=0;j<type;j++) {
|
for(int j=0;j<type;j++) {
|
||||||
|
@ -1301,7 +1304,7 @@ static void OGLRender()
|
||||||
};
|
};
|
||||||
|
|
||||||
//float tempCoord[4];
|
//float tempCoord[4];
|
||||||
//Vector4Copy(tempCoord,vert->coord);
|
//Vector4Copy(tempCoord, vert->coord);
|
||||||
//we havent got the whole pipeline working yet, so we cant do this
|
//we havent got the whole pipeline working yet, so we cant do this
|
||||||
////convert from ds device coords to opengl
|
////convert from ds device coords to opengl
|
||||||
//tempCoord[0] *= 2;
|
//tempCoord[0] *= 2;
|
||||||
|
@ -1312,8 +1315,8 @@ static void OGLRender()
|
||||||
//todo - edge flag?
|
//todo - edge flag?
|
||||||
glTexCoord2fv(vert->texcoord);
|
glTexCoord2fv(vert->texcoord);
|
||||||
glColor4ubv((GLubyte*)color);
|
glColor4ubv((GLubyte*)color);
|
||||||
//glVertex3fv(tempCoord);
|
//glVertex4fv(tempCoord);
|
||||||
glVertex3fv(vert->coord);
|
glVertex4fv(vert->coord);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,8 +147,8 @@ POLYLIST polylists[2];
|
||||||
POLYLIST* polylist = &polylists[0];
|
POLYLIST* polylist = &polylists[0];
|
||||||
VERTLIST vertlists[2];
|
VERTLIST vertlists[2];
|
||||||
VERTLIST* vertlist = &vertlists[0];
|
VERTLIST* vertlist = &vertlists[0];
|
||||||
PROJLIST projlists[2];
|
//PROJLIST projlists[2];
|
||||||
PROJLIST* projlist = &projlists[0];
|
//PROJLIST* projlist = &projlists[0];
|
||||||
|
|
||||||
int listTwiddle = 1;
|
int listTwiddle = 1;
|
||||||
int triStripToggle;
|
int triStripToggle;
|
||||||
|
@ -167,10 +167,10 @@ static void twiddleLists() {
|
||||||
listTwiddle &= 1;
|
listTwiddle &= 1;
|
||||||
polylist = &polylists[listTwiddle];
|
polylist = &polylists[listTwiddle];
|
||||||
vertlist = &vertlists[listTwiddle];
|
vertlist = &vertlists[listTwiddle];
|
||||||
projlist = &projlists[listTwiddle];
|
// projlist = &projlists[listTwiddle];
|
||||||
polylist->count = 0;
|
polylist->count = 0;
|
||||||
vertlist->count = 0;
|
vertlist->count = 0;
|
||||||
projlist->count = 0;
|
// projlist->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL flushPending = FALSE;
|
static BOOL flushPending = FALSE;
|
||||||
|
@ -531,9 +531,8 @@ static void SetVertex()
|
||||||
//apply modelview matrix
|
//apply modelview matrix
|
||||||
MatrixMultVec4x4 (mtxCurrent[1], coordTransformed);
|
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
|
||||||
////apply projection matrix
|
MatrixMultVec4x4 (mtxCurrent[0], coordTransformed);
|
||||||
//MatrixMultVec4x4 (mtxCurrent[0], coordTransformed);
|
|
||||||
|
|
||||||
////perspective division
|
////perspective division
|
||||||
//coordTransformed[0] = (coordTransformed[0] + coordTransformed[3]) / 2 / coordTransformed[3];
|
//coordTransformed[0] = (coordTransformed[0] + coordTransformed[3]) / 2 / coordTransformed[3];
|
||||||
|
@ -631,7 +630,7 @@ static void SetVertex()
|
||||||
//todo - dont overrun proj list
|
//todo - dont overrun proj list
|
||||||
|
|
||||||
//see if the last entry in the proj list matches the current matrix, if there is one.
|
//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.
|
//here is an example of something that does not work.
|
||||||
//(for a speed hack, we consider the matrices different if the first element differs)
|
//(for a speed hack, we consider the matrices different if the first element differs)
|
||||||
//mtxCurrent[0][0] == projlist->projMatrix[projlist->count-1][0]
|
//mtxCurrent[0][0] == projlist->projMatrix[projlist->count-1][0]
|
||||||
|
@ -648,7 +647,7 @@ static void SetVertex()
|
||||||
MatrixCopy(projlist->projMatrix[projlist->count],mtxCurrent[0]);
|
MatrixCopy(projlist->projMatrix[projlist->count],mtxCurrent[0]);
|
||||||
poly.projIndex = projlist->count;
|
poly.projIndex = projlist->count;
|
||||||
projlist->count++;
|
projlist->count++;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
poly.polyAttr = polyAttr;
|
poly.polyAttr = polyAttr;
|
||||||
poly.texParam = textureFormat;
|
poly.texParam = textureFormat;
|
||||||
|
@ -1180,7 +1179,7 @@ void gfx3d_glFlush(unsigned long v)
|
||||||
//the renderer wil lget the lists we just built
|
//the renderer wil lget the lists we just built
|
||||||
gfx3d.polylist = polylist;
|
gfx3d.polylist = polylist;
|
||||||
gfx3d.vertlist = vertlist;
|
gfx3d.vertlist = vertlist;
|
||||||
gfx3d.projlist = projlist;
|
// gfx3d.projlist = projlist;
|
||||||
|
|
||||||
//we need to sort the poly list with alpha polys last
|
//we need to sort the poly list with alpha polys last
|
||||||
//first, look for alpha polys
|
//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.
|
//jiggle the lists. and also wipe them. this is clearly not the best thing to be doing.
|
||||||
polylist = &polylists[listTwiddle];
|
polylist = &polylists[listTwiddle];
|
||||||
vertlist = &vertlists[listTwiddle];
|
vertlist = &vertlists[listTwiddle];
|
||||||
projlist = &projlists[listTwiddle];
|
// projlist = &projlists[listTwiddle];
|
||||||
polylist->count = 0;
|
polylist->count = 0;
|
||||||
vertlist->count = 0;
|
vertlist->count = 0;
|
||||||
projlist->count = 0;
|
// projlist->count = 0;
|
||||||
gfx3d.polylist = &polylists[listTwiddle^1];
|
gfx3d.polylist = &polylists[listTwiddle^1];
|
||||||
gfx3d.vertlist = &vertlists[listTwiddle^1];
|
gfx3d.vertlist = &vertlists[listTwiddle^1];
|
||||||
gfx3d.projlist = &projlists[listTwiddle^1];
|
// gfx3d.projlist = &projlists[listTwiddle^1];
|
||||||
gfx3d.polylist->count=0;
|
gfx3d.polylist->count=0;
|
||||||
gfx3d.vertlist->count=0;
|
gfx3d.vertlist->count=0;
|
||||||
gfx3d.projlist->count = 0;
|
// gfx3d.projlist->count = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct POLY {
|
||||||
int type; //tri or quad
|
int type; //tri or quad
|
||||||
u16 vertIndexes[4]; //up to four verts can be referenced by this poly
|
u16 vertIndexes[4]; //up to four verts can be referenced by this poly
|
||||||
u32 polyAttr, texParam, texPalette; //the hardware rendering params
|
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;
|
u32 pad;
|
||||||
|
|
||||||
bool isTranslucent()
|
bool isTranslucent()
|
||||||
|
@ -65,11 +65,11 @@ struct POLYLIST {
|
||||||
int count;
|
int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PROJLIST_SIZE 1000
|
/*#define PROJLIST_SIZE 1000
|
||||||
struct PROJLIST {
|
struct PROJLIST {
|
||||||
float projMatrix[PROJLIST_SIZE][16];
|
float projMatrix[PROJLIST_SIZE][16];
|
||||||
int count;
|
int count;
|
||||||
};
|
};*/
|
||||||
|
|
||||||
struct VERT {
|
struct VERT {
|
||||||
float coord[4];
|
float coord[4];
|
||||||
|
@ -112,7 +112,7 @@ struct GFX3D
|
||||||
|
|
||||||
POLYLIST* polylist;
|
POLYLIST* polylist;
|
||||||
VERTLIST* vertlist;
|
VERTLIST* vertlist;
|
||||||
PROJLIST* projlist;
|
//PROJLIST* projlist;
|
||||||
int indexlist[POLYLIST_SIZE];
|
int indexlist[POLYLIST_SIZE];
|
||||||
|
|
||||||
BOOL wbuffer, sortmode;
|
BOOL wbuffer, sortmode;
|
||||||
|
|
Loading…
Reference in New Issue