Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Tell if vertex or index buffer is changing

This topic is 5262 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

Is there a way to tell if the contents of my Vertex or Index buffers are getting changed after they are created? I have them set up this way
hr = GetCurrentDisplayDevice()->CreateVertexBuffer
hr = m_pUIVB->Lock( 0, 0, (void**)&pVertices, 0);
memcpy(pVertices, m_VB, G_NUM_VERTS_IN_UI * sizeof     

hr = GetCurrentDisplayDevice()->CreateIndexBuffer
short* pIndices;
hr = m_pUIIB->Lock(0, 0, (void**)&pIndices, 0);
memcpy(pIndices, m_IB, G_NUM_INDICES_IN_UI * sizeof(short));
The definitions for the buffers are. LPDIRECT3DVERTEXBUFFER9 m_pUIVB; LPDIRECT3DINDEXBUFFER9 m_pUIIB; I am storing my vertexes and indices before copying them to the buffers in arrays like this CUSTOMUIVERTEX m_VB[NUM_VERTS_IN_UI]; short m_IB[NUM_INDICES_IN_UI]; I currently have NUM_VERTS_IN_UI = 400 NUM_INDICES_IN_UI = 600 I have stepped through every line of code I have. My first quad is started at vertices 0-3 and indices 0-5. The next one and so on step up the vertices by 4 and the indices by 6. Each quad I create is done through an Init function and the Init function updates a count of vertices and indices I have. I also store the first Index for each quad as this is the reference I use when rendering a quad like so DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_iStartIndex, 4, m_iStartIndex, 2); I am making calls to SetStreamSource where appropriate. Now here is the still existing trouble. If I just init and render the root window and the mouse cursor, both render fine. If I init and render my inventory window which contains many other quads, things get screwy. The background will go blue and some quads will render, others won''t and the mouse quad won''t render. Now in both cases, the mouse quad starts at index 0 and when I step through, these are exactly correct, yet it does not show up in the program. Because of this I am wondering if it is possible for the actual vertex data to be contaminated after it is created. I am only locking and writing to it once (in the code above). I just can''t figure this out. I have other posts for this same problem within the past week or so and they each deal with other specific questions. This is getting really frustrating... Thanks for any help, Webby

Share this post

Link to post
Share on other sites
I would think so as well and I am certain I am not. One thing is for certain. What used to work on a Geforce 4 MX no longer works on ATI 9800 pro. Since I discovered this I have changed many things in the code while trying to sort out the issue and nothing seems to work. The strangest part is that the icons that do render are in the correct screen places. The window borders, background, etc are not rendering. I can even narrow it down to single quads that are not rendering. I look at their initialization and they are identical. It''s basically things like

Call render on all 3 and Bar2 will not show up, and I am certain it''s not the coordinates I am placing it at. IT MAKES NO SENSE!

Furthermore, other calls after these will sometimes render so it''s not like I stepping out of an array or something because I would get errors or NOTHING else rendered.

Almost seems like the card is picking out the icons that it thinks are ugly...


Share this post

Link to post
Share on other sites
After more testing I have found this to be the case. It is not my render code for sure, as the problem occurrs whether or not I render all of the quads.

I also know that it is not my quad initialzation that is doing it. All quads use the same init function. Last night I found that if I init the same quads multiple times, like so:
Build2Quads(ptrVertexBuffer, ptrIndexBuffer, "Test");
Build2Quads(ptrVertexBuffer, ptrIndexBuffer, "Test");
//Build2Quads(ptrVertexBuffer, ptrIndexBuffer, "Test");
//Build2Quads(ptrVertexBuffer, ptrIndexBuffer, "Test");
everything renders fine until I uncomment the 3rd quad at which point my mouse cursor disappears. Uncommenting the 4th call makes the background disappear (even if I do not call the render function for these quads).

Now I am almost 100% certain the trouble is in the way I am setting up the vertex or index buffers, or I am hitting some upper limit on one of them. Three problems there though, 1) the code used to work. 2) At the time of the failure, the total number of vertices initialized is 124 and 186. So commenting out 1 call to Build2Quads will reduce these numbers to 116, 174. In neither case if the number crossing a power of 2 boundary. You would expect his to happen when going from 127 to 128 or 255 to 256, but not where I am. 3) These buffers should hold wayyyy more than 124 verts and 186 indices...

This one will definitely be worth adding to the FAQ once it''s solved, even if it does turn out to be something simple... If it turns out to be the video card I''m gonna scream, but seeing how it plays all my other games I"m certain this is not the case.

Thanks for any help,

Share this post

Link to post
Share on other sites
Can you put the old card back in your pc and see if it works with that? Are your textures powers of 2? I assume they must be but its worth asking. Maybe try it on a friends pc.

Share this post

Link to post
Share on other sites
Card was sold to a friend so I can''t switch it out. However, I do get the same results across 2 other machines. One is a PII 450 with a Diamond Viper V770 Ultra. The other is an AMD 1100 with an ATI 7000? and then there is mine, P4 2.8 Gig of ram and ATI 9800 pro.

Application looks identical on all 3...

Share this post

Link to post
Share on other sites
I have once again fiddled with the code even more.
Now I am down to having code that renders one root quad the size of the screen, one quad for the mouse cursor and another quad for a random image.

If I init just the root and the cursor they both render fine,
when I init the random quad, the cursor will still render but the rot window will not (it's just blue, the color I clear the screen to).

Now when I init I go in this order, Mouse, Root, Other.
I have stepped through each line.
Mouse = vertices 0-3, indices 0-5
Root = vertices 4-7, indices 6-11
Other = vertices 8-11, 12-17

Each one is an object and I store the start index for each one. These check out to be 0, 6, and 12 respectively.

Then I do my vertex and index buffer initialization like so

m_pUIVB, NULL );

(void**)&pVertices, 0);
memcpy(pVertices, m_VB, G_NUM_VERTS_IN_UI * sizeof


WORD* pIndices;
m_pUIIB->Lock(0, G_NUM_INDICES_IN_UI * sizeof(WORD), (void**)
&pIndices, 0);
memcpy(pIndices, m_IB, G_NUM_INDICES_IN_UI * sizeof(WORD));

At the time of the above code,
as they should be.
It doesn't matter if I render the Other quad or not, just the initialization causes to problem. All three quads use the same initialization code shown below

ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 0].x = 0;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 0].y = 0;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 0].z = 1.0f;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 0].color = D3DCOLOR_ARGB(255, 255, 255, 255);
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 0].u = UV[0][0];
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 0].v = UV[0][1];

ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 1].x = Width;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 1].y = 0;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 1].z = 1.0f;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 1].color = D3DCOLOR_ARGB(255, 255, 255, 255);
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 1].u = UV[2][0];
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 1].v = UV[2][1];

ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 2].x = 0;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 2].y = Height;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 2].z = 1.0f;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 2].color = D3DCOLOR_ARGB(255, 255, 255, 255);
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 2].u = UV[1][0];
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 2].v = UV[1][1];

ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 3].x = Width;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 3].y = Height;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 3].z = 1.0f;
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 3].color = D3DCOLOR_ARGB(255, 255, 255, 255);
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 3].u = UV[3][0];
ptrVertexBuffer[g_cGUIManager.G_NUM_VERTS_IN_UI + 3].v = UV[3][1];

ptrIndexBuffer[g_cGUIManager.G_NUM_INDICES_IN_UI + 0] = g_cGUIManager.G_NUM_VERTS_IN_UI + 0;
ptrIndexBuffer[g_cGUIManager.G_NUM_INDICES_IN_UI + 1] = g_cGUIManager.G_NUM_VERTS_IN_UI + 1;
ptrIndexBuffer[g_cGUIManager.G_NUM_INDICES_IN_UI + 2] = g_cGUIManager.G_NUM_VERTS_IN_UI + 2;
ptrIndexBuffer[g_cGUIManager.G_NUM_INDICES_IN_UI + 3] = g_cGUIManager.G_NUM_VERTS_IN_UI + 2;
ptrIndexBuffer[g_cGUIManager.G_NUM_INDICES_IN_UI + 4] = g_cGUIManager.G_NUM_VERTS_IN_UI + 1;
ptrIndexBuffer[g_cGUIManager.G_NUM_INDICES_IN_UI + 5] = g_cGUIManager.G_NUM_VERTS_IN_UI + 3;

g_cGUIManager.G_NUM_VERTS_IN_UI += 4;
g_cGUIManager.G_NUM_INDICES_IN_UI += 6;

The vertex and index buffers are defined like this


CUSTOMUIVERTEX m_VB[400]; //I've tried larger and smaller numbers here.

WORD m_IB[600];//And here

I have gone through this many times and don't see a problem with it. Sorry I keep pestering the board over this one but as you can probably tell, it's been over 2 weeks and I am still getting no where and is frustrating as all hell...

Anyway, thanks for taking a look,

[edited by - websitewill on April 22, 2004 11:01:13 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!