OGLRender: prefer GL_LINE_LOOP rather than GL_QUADS for line segment.
Algorithm of isPolyLine() isn't perfect, but I think it'll work good enough for most cases. This change should improve Castlevania Portrait of Ruin (trajectory of ricochet, and glow of warp stone) SoftRasterizer must have a similar issue, it doesn't display both of them.
This commit is contained in:
parent
b721929595
commit
4ba4419e8f
|
@ -817,6 +817,64 @@ static void GL_ReadFramebuffer()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "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()
|
static void OGLRender()
|
||||||
{
|
{
|
||||||
|
@ -894,8 +952,11 @@ static void OGLRender()
|
||||||
|
|
||||||
float alpha = poly->getAlpha()/31.0f;
|
float alpha = poly->getAlpha()/31.0f;
|
||||||
if(wireframe) alpha = 1.0;
|
if(wireframe) alpha = 1.0;
|
||||||
|
bool linePoly = isLinePoly(i);
|
||||||
|
|
||||||
if (type == 4)
|
if (linePoly)
|
||||||
|
glBegin(GL_LINE_LOOP);
|
||||||
|
else if (type == 4)
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
else
|
else
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
Loading…
Reference in New Issue