|
@@ -316,84 +316,6 @@ void Graphics::setActive(bool enable)
|
|
active = enable;
|
|
active = enable;
|
|
}
|
|
}
|
|
|
|
|
|
-void Graphics::flushStreamDraws()
|
|
|
|
-{
|
|
|
|
- using namespace vertex;
|
|
|
|
-
|
|
|
|
- auto &sbstate = streamBufferState;
|
|
|
|
-
|
|
|
|
- if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- OpenGL::TempDebugGroup debuggroup("Stream vertices flush and draw");
|
|
|
|
-
|
|
|
|
- Attributes attributes;
|
|
|
|
- Buffers buffers;
|
|
|
|
-
|
|
|
|
- size_t usedsizes[3] = {0, 0, 0};
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < 2; i++)
|
|
|
|
- {
|
|
|
|
- if (sbstate.formats[i] == CommonFormat::NONE)
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- attributes.setCommonFormat(sbstate.formats[i], (uint8) i);
|
|
|
|
-
|
|
|
|
- usedsizes[i] = getFormatStride(sbstate.formats[i]) * sbstate.vertexCount;
|
|
|
|
-
|
|
|
|
- size_t offset = sbstate.vb[i]->unmap(usedsizes[i]);
|
|
|
|
- buffers.set(i, sbstate.vb[i], offset);
|
|
|
|
- sbstate.vbMap[i] = StreamBuffer::MapInfo();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (attributes.enablebits == 0)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- Colorf nc = gl.getConstantColor();
|
|
|
|
- if (attributes.isEnabled(ATTRIB_COLOR))
|
|
|
|
- gl.setConstantColor(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
-
|
|
|
|
- pushIdentityTransform();
|
|
|
|
-
|
|
|
|
- gl.prepareDraw();
|
|
|
|
- gl.bindTextureToUnit(sbstate.texture, 0, false);
|
|
|
|
-
|
|
|
|
- gl.setVertexAttributes(attributes, buffers);
|
|
|
|
-
|
|
|
|
- GLenum glprimitivetype = OpenGL::getGLPrimitiveType(sbstate.primitiveMode);
|
|
|
|
-
|
|
|
|
- if (sbstate.indexCount > 0)
|
|
|
|
- {
|
|
|
|
- usedsizes[2] = sizeof(uint16) * sbstate.indexCount;
|
|
|
|
-
|
|
|
|
- gl.bindBuffer(BUFFER_INDEX, (GLuint) sbstate.indexBuffer->getHandle());
|
|
|
|
- size_t offset = sbstate.indexBuffer->unmap(usedsizes[2]);
|
|
|
|
-
|
|
|
|
- sbstate.indexBufferMap = StreamBuffer::MapInfo();
|
|
|
|
-
|
|
|
|
- gl.drawElements(glprimitivetype, sbstate.indexCount, GL_UNSIGNED_SHORT, BUFFER_OFFSET(offset));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- gl.drawArrays(glprimitivetype, 0, sbstate.vertexCount);
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < 2; i++)
|
|
|
|
- {
|
|
|
|
- if (usedsizes[i] > 0)
|
|
|
|
- sbstate.vb[i]->markUsed(usedsizes[i]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (usedsizes[2] > 0)
|
|
|
|
- sbstate.indexBuffer->markUsed(usedsizes[2]);
|
|
|
|
-
|
|
|
|
- popTransform();
|
|
|
|
-
|
|
|
|
- if (attributes.isEnabled(ATTRIB_COLOR))
|
|
|
|
- gl.setConstantColor(nc);
|
|
|
|
-
|
|
|
|
- streamBufferState.vertexCount = 0;
|
|
|
|
- streamBufferState.indexCount = 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void Graphics::draw(PrimitiveType primtype, int vertexstart, int vertexcount, int instancecount, const vertex::Attributes &attribs, const vertex::Buffers &buffers, love::graphics::Texture *texture)
|
|
void Graphics::draw(PrimitiveType primtype, int vertexstart, int vertexcount, int instancecount, const vertex::Attributes &attribs, const vertex::Buffers &buffers, love::graphics::Texture *texture)
|
|
{
|
|
{
|
|
gl.prepareDraw();
|
|
gl.prepareDraw();
|