mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
- use triangles instead of triangle fans to render flats.
This commit is contained in:
parent
fd3681dae2
commit
2125f8b9d1
2 changed files with 15 additions and 7 deletions
|
@ -181,24 +181,23 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
|
||||||
for (int i=0; i<flat->sector->subsectorcount; i++)
|
for (int i=0; i<flat->sector->subsectorcount; i++)
|
||||||
{
|
{
|
||||||
subsector_t * sub = flat->sector->subsectors[i];
|
subsector_t * sub = flat->sector->subsectors[i];
|
||||||
|
if (sub->numlines <= 2) continue;
|
||||||
|
|
||||||
if (gl_drawinfo->ss_renderflags[sub->Index()]& flat->renderflags || istrans)
|
if (gl_drawinfo->ss_renderflags[sub->Index()]& flat->renderflags || istrans)
|
||||||
{
|
{
|
||||||
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli);
|
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli);
|
||||||
drawcalls.Clock();
|
drawcalls.Clock();
|
||||||
//glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines);
|
glDrawElements(GL_TRIANGLES, (sub->numlines - 2) * 3, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + index);
|
||||||
glDrawElements(GL_TRIANGLE_FAN, sub->numlines, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + index);
|
|
||||||
drawcalls.Unclock();
|
drawcalls.Unclock();
|
||||||
flatvertices += sub->numlines;
|
flatvertices += sub->numlines;
|
||||||
flatprimitives++;
|
flatprimitives++;
|
||||||
}
|
}
|
||||||
index += sub->numlines;
|
index += (sub->numlines - 2) * 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Draw the subsectors belonging to this sector
|
// Draw the subsectors belonging to this sector
|
||||||
// (can this case even happen?)
|
|
||||||
for (int i=0; i<flat->sector->subsectorcount; i++)
|
for (int i=0; i<flat->sector->subsectorcount; i++)
|
||||||
{
|
{
|
||||||
subsector_t * sub = flat->sector->subsectors[i];
|
subsector_t * sub = flat->sector->subsectors[i];
|
||||||
|
|
|
@ -234,11 +234,20 @@ void FFlatVertexGenerator::CreateFlatVertices()
|
||||||
|
|
||||||
int FFlatVertexGenerator::CreateIndexedSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor, int vi, FFlatVertexGenerator::FIndexGenerationInfo &gen)
|
int FFlatVertexGenerator::CreateIndexedSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor, int vi, FFlatVertexGenerator::FIndexGenerationInfo &gen)
|
||||||
{
|
{
|
||||||
int idx = ibo_data.Reserve(sub->numlines);
|
if (sub->numlines < 3) return -1;
|
||||||
for (unsigned int k = 0; k<sub->numlines; k++)
|
|
||||||
|
int idx = ibo_data.Reserve((sub->numlines - 2) * 3);
|
||||||
|
int idxc = idx;
|
||||||
|
int firstndx = gen.GetIndex(sub->firstline[0].v1);
|
||||||
|
int secondndx = gen.GetIndex(sub->firstline[1].v1);
|
||||||
|
for (unsigned int k = 2; k<sub->numlines; k++)
|
||||||
{
|
{
|
||||||
auto ndx = gen.GetIndex(sub->firstline[k].v1);
|
auto ndx = gen.GetIndex(sub->firstline[k].v1);
|
||||||
ibo_data[idx + k] = vi + ndx;
|
|
||||||
|
ibo_data[idx++] = vi + firstndx;
|
||||||
|
ibo_data[idx++] = vi + secondndx;
|
||||||
|
ibo_data[idx++] = vi + ndx;
|
||||||
|
secondndx = ndx;
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue