Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 anders211   Members   -  Reputation: 184

Like
0Likes
Like

Posted 16 February 2012 - 03:05 PM

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);
vb->Unlock();

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



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];
pTex->UnlockRect(0);



Thanks in advance for a little help.

Sponsor:

#2 phantom   Moderators   -  Reputation: 7109

Like
1Likes
Like

Posted 16 February 2012 - 03:41 PM

My first question would be; why do you want to?

If you have filled the buffer already you should have the data laying around after all...

#3 anders211   Members   -  Reputation: 184

Like
0Likes
Like

Posted 16 February 2012 - 04:14 PM

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?

#4 mhagain   Crossbones+   -  Reputation: 7823

Like
0Likes
Like

Posted 16 February 2012 - 04:22 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS