Hi,
A while ago I was recommended to use buffer streaming to pass data across to the GPU.
Now the problem im currently having is I have set up an index buffer to reduce the size of the data being passed to the VBO however when the next buffer is orphaned the next draw glitch out and seem to connect to the other sprites.
Hopefully this image should show the issue. The lower sprite also flickers.
I use the following method to render.
if (m_BufferOffset + (SpriteCount * m_spriteSize) >= m_BufferSize)
{
VBO->setBufferData(m_BufferSize, NULL, GL_STREAM_DRAW);
m_BufferOffset = 0;
}
VertexPosTexCol* mappedData = (VertexPosTexCol*)VBO->mapRange(m_BufferOffset, m_BufferOffset + (SpriteCount * m_spriteSize));
//Set all the sprite data
glBindTexture(GL_TEXTURE_2D, m_LastTexture);
VBO->unmap();
IBO->bind();
glDrawElements(GL_TRIANGLES, SpriteCount * 6, GL_UNSIGNED_INT, NULL);
m_BufferOffset += (SpriteCount * m_spriteSize);
IBO->unbind();
VBO->unbind();
//unbind the texture
glBindTexture(GL_TEXTURE_2D, 0);
The index buffer is fixed to 4096 sprite index's so I can only render 4096 sprites before I have have to call draw elements again (unless the texture changes).
At the moment the buffer size is fixed to accomidate for 4096 sprites as well so In the image there are 4096 sprites rendered on the higher sprite and then the lower sprite is the 4097 so it will use a new buffer to send the data across.
Im not sure if there is anything I am missing or if I have explained anything incorrectly but Im sure im doing something wrong otherwise I wouldnt not be getting this issue.
Thanks