Probelm using Dynamic Vertex Buffer.

Started by
0 comments, last by Paulop 11 years, 11 months ago
Hello,

I've got a problem using a circular dynamic vertex buffer for drawing basic primitives with a no-overwrite/discard pattern.
I'm trying to draw 500+ rectangles using D3DPT_LINESTRIP. Everything seems good but i've got flickering on the screen.
Before the 500th rectangle the last rectangle is draw in top left, after the 500th rectangle few or all of the next rectangles flick and appears some times in place or in top left of the screen.
I've tried to sleep the application for 16 ms, and everything looks fine, using DrawPrimitiveUP or forcing Discard work well too.

I've tried multiple Vertex Buffer Size but it's happening for every size. But with a smallest VB, i have just one rectangle going in top left

Do you have an idea of what happen and how to fix it ?

Sorry for my not so perfect english, it's not my native language. happy.png

Thanks

Here is a sample code :


int dataSize = Vertices.size() * sizeof( Vertex );
BufferFlag::Enum bufferFlag = BufferFlag::NoOverwrite;
if ( ForceDiscardVB || ( PositionInBuffer + Vertices.size() > VertexBufferSize ) )
{
bufferFlag = BufferFlag::Discard;
PositionInBuffer = 0;
ForceDiscardVB = false;
}
SetVertexBufferData ( *pVertexBuffer , &Vertices[0] , dataSize , bufferFlag , PositionInBuffer * sizeof ( Vertex ) );

// Draw
DrawPrimitives ( PrimitiveType , PositionInBuffer , (unsigned int) ( Vertices.size() * PrimitiveNumberCoeff ) );

// Increment the buffer offset
PositionInBuffer += Vertices.size();
Advertisement
I found the problem, i was not reinitialising my variables in Begin() and I was not using Discard for the first Lock of each frame.

This topic is closed to new replies.

Advertisement