Sign in to follow this  

Probelm using Dynamic Vertex Buffer.

Recommended Posts

Paulop    114

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. [img][/img]


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();
[/CODE] Edited by Paulop

Share this post

Link to post
Share on other sites
Paulop    114
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this