Browse Source

graphics: fix recursion when creating a default texture.

Sasha Szpakowski 1 year ago
parent
commit
131b6c51e0
2 changed files with 8 additions and 3 deletions
  1. 6 3
      src/modules/graphics/Graphics.cpp
  2. 2 0
      src/modules/graphics/Graphics.h

+ 6 - 3
src/modules/graphics/Graphics.cpp

@@ -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;
@@ -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));
@@ -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()

+ 2 - 0
src/modules/graphics/Graphics.h

@@ -989,6 +989,8 @@ protected:
 		StreamBuffer::MapInfo vbMap[2];
 		StreamBuffer::MapInfo indexBufferMap = StreamBuffer::MapInfo();
 
+		bool flushing = false;
+
 		BatchedDrawState()
 		{
 			vb[0] = vb[1] = nullptr;