Jump to content
  • Advertisement
Sign in to follow this  

How to access the vertex and indices buffer data in graphic memory card?

This topic is 2796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have in CreateVertexBuffer flag D3DUSAGE_DYNAMIC and D3DPOOL_DEFAULT.
I have in Lock method of vertex and index buffer flag D3DLOCK_DISCARD.
The effect is that at the scene I have the rendered figure which I want.

But I don't know how can I access back again the vertex buffer and index buffer data?
I thought that I can do it with the aid of once again Lock method but with flag D3DLOCK_READONLY.

vector<NormalVertex2> verts(numVertices);
vb->Lock(0, numVertices*sizeof(NormalVertex2), (void**)&verts, D3DLOCK_READONLY);

vector<WORD> indices(numTriangles*3);
ib->Lock(0, numTriangles*3*sizeof(WORD), (void**)&indices, D3DLOCK_READONLY);

But the effect is that verts has all the same some amazing big values and indices vector consists of all zeros.
So how can I access the vertices and indexed buffer once again?

For example for texture I can access data properly with D3DLOCKED_RECT and LockRect method and it works great. Is there something equivalent for vertex and index buffer???
vector<DWORD> textureData(numCellsPerCol*numCellsPerRow);
D3DLOCKED_RECT lockedRect;
pTex->LockRect(0, &lockedRect, 0, D3DLOCK_READONLY);
DWORD* imageData = (DWORD*)lockedRect.pBits;
for(i32 i=0; i<numCellsPerCol; i++)
for(i32 j=0; j<numCellsPerRow; j++)
textureData[i*numCellsPerRow +j] = imageData[i * lockedRect.Pitch/4+j];

Thanks in advance for a little help.

Share this post

Link to post
Share on other sites
Frankly speaking I have been learning DirectX since about quite not so long and there are matters which I am not sure. I want it because the question is:
Is a good way to keep saved data also in memory (RAM I suppose) or there is no need to keep data on the memory because You have a possibility to get them from vertex (index) buffer which You used to save data in graphic memory card... I believe that if You don't change very often position of vertices in this part of message loop which is responsible for present the scene, the best way is not to save data twice (on RAM memory and graphic memory card). Nevertheless I would like to get to know is there any way to get back data from vertex (index) buffer like in IDirect3DTexture9 object example from the previous e-mail?

Share this post

Link to post
Share on other sites
It's advisable to keep them in memory anyway - or to at least have some way of recreating them (such as loading them from a model) - as you're going to need them if you get a lost device.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!