Skip to content

Commit

Permalink
graphics: fix recursion when creating a default texture.
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Jan 6, 2024
1 parent aaab979 commit 131b6c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/modules/graphics/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ void Graphics::flushBatchedDraws()
{
auto &sbstate = batchedDrawState;

if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0 || sbstate.flushing)
return;

VertexAttributes attributes;
Expand All @@ -1952,6 +1952,8 @@ void Graphics::flushBatchedDraws()
if (attributes.enableBits == 0)
return;

sbstate.flushing = true;

Colorf nc = getColor();
if (attributes.isEnabled(ATTRIB_COLOR))
setColor(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
Expand Down Expand Up @@ -1996,8 +1998,9 @@ void Graphics::flushBatchedDraws()
if (attributes.isEnabled(ATTRIB_COLOR))
setColor(nc);

batchedDrawState.vertexCount = 0;
batchedDrawState.indexCount = 0;
sbstate.vertexCount = 0;
sbstate.indexCount = 0;
sbstate.flushing = false;
}

void Graphics::flushBatchedDrawsGlobal()
Expand Down
2 changes: 2 additions & 0 deletions src/modules/graphics/Graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,8 @@ class Graphics : public Module
StreamBuffer::MapInfo vbMap[2];
StreamBuffer::MapInfo indexBufferMap = StreamBuffer::MapInfo();

bool flushing = false;

BatchedDrawState()
{
vb[0] = vb[1] = nullptr;
Expand Down

0 comments on commit 131b6c5

Please sign in to comment.