Vertex buffer and Dynamic memory

Started by
1 comment, last by pawelpiotrowski 15 years, 11 months ago
My program needs to access data from the vertex and index buffer, before actually doing operations on them. Can you read directly from the vertex buffer without locking it? Or, if it doesen't hurt, I could do all operations while it is locked, if I cannot read from it like stated above? [Edited by - VprMatrix89 on April 30, 2008 10:10:44 AM]
Advertisement
To read and/or write the data in a vertex/index buffer you must call Lock. There is no way around that. You cannot render from a buffer while it is Lock'ed because the device needs to be sure that the data is ready to be rendered, is not changing, and is in a location in memory the GPU can access easily.

If you need access to the data and don't want to call Lock on the buffers, you can make a seperate copy at load time from whatever your source data is. Or perhaps you can call Lock on the buffer, copy the data out to some other location, and Unlock it.

What is it you're trying to do? Perhaps with a bit more info, people would be able to point you in the right direction.

neneboricua
Hi guys,

I have the similar problem I think.

When I was working using OpenGL I was able to move each vertex of a triangle without any problem for example:

ypos += 0.5f;
glVertex3f(xpos,ypos,zpos);

... and the vertex was going up.

Now when I am using DirectX, I am no longer able to do it because of vertex buffers.

in Render function I was trying to use something like that but it didn't work:

static void *pVertices = NULL;

g_pIndexedTexturedCube->Lock( 0, sizeof(myIndexedCube), (void**)&pVertices, D3DLOCK_NOOVERWRITE );

myIndexedCube[0].y += 5;

g_pIndexedTexturedCube->Unlock();

DrawCube();

where myIndexedCube is a struct vith my vertices details and g_pIndexedTexturedCube is the VB buffer

Do you know how to move my verticle?

I would be grateful if you could help.

Best regards
Pawel

This topic is closed to new replies.

Advertisement