0.9.6: backport OpenGL line poly workaround.

This commit is contained in:
gocha 2010-12-20 13:10:12 +00:00
parent cddc705b17
commit 0ce084d8ba
1 changed files with 63 additions and 1 deletions

View File

@ -813,6 +813,65 @@ static void GL_ReadFramebuffer()
}
// "Workaround" for line poly
static bool isLinePoly(int listIndex)
{
POLY *poly = &gfx3d.polylist->list[gfx3d.indexlist.list[listIndex]];
int type = poly->type;
VERT *vert1, *vert2;
if (type <= 2)
return true;
else if (type > 4)
return false;
// Method 1:
// Castlevania Portrait of Ruin - trajectory of ricochet
bool duplicatedVert[4] = { false, false, false, false };
for(int i = 0; i < type - 1; i++)
{
vert1 = &gfx3d.vertlist->list[poly->vertIndexes[i]];
for(int j = i + 1; j < type; j++)
{
vert2 = &gfx3d.vertlist->list[poly->vertIndexes[j]];
if (vert1->x == vert2->x && vert1->y == vert2->y)
{
duplicatedVert[j] = true;
}
}
}
int vertCount = type;
for(int i = 0; i < type; i++)
{
if (duplicatedVert[i])
vertCount--;
}
if (vertCount <= 2)
return true;
// Method 2:
// Castlevania Portrait of Ruin - warp stone
bool horizontalLine = true;
bool verticalLine = true;
vert1 = &gfx3d.vertlist->list[poly->vertIndexes[0]];
for(int i = 1; i < type && (horizontalLine || verticalLine); i++)
{
vert2 = &gfx3d.vertlist->list[poly->vertIndexes[i]];
if (vert1->coord[0] != vert2->coord[0])
{
verticalLine = false;
}
if (vert1->coord[1] != vert2->coord[1])
{
horizontalLine = false;
}
}
if (horizontalLine || verticalLine)
return true;
return false;
}
static void OGLRender()
{
if(!BEGINGL()) return;
@ -913,7 +972,10 @@ static void OGLRender()
lastViewport = poly->viewport;
}
glBegin(GL_TRIANGLES);
if (isLinePoly(i))
glBegin(GL_LINE_LOOP);
else
glBegin(GL_TRIANGLES);
VERT *vert0 = &gfx3d.vertlist->list[poly->vertIndexes[0]];
float alpha = poly->getAlpha()/31.0f;