help... i dont know what it makes

Started by
2 comments, last by Aragon 20 years, 9 months ago
i try to convert some code from dx8 to dx9 and got problem that often a lot of triangel are missing or painted in strange way... ...but not like they look in dx8 (there was all perfect) i try to find out the error with the code here... example: this is a stupid code here,but it shows the problem...at dx8 it works perfect.. with dx9 only the last of the 40 quads is drawn..the rest is in.. i dont know,evtl valhalla thx for any help..... ... void init(void) { if( FAILED( g_pd3dDevice->CreateVertexBuffer( 4000*2*sizeof(CUSTOMVERTEX),0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) { return E_FAIL; } } ..... void test(void) { setmatrix(blablabla) int tg=0; for (int test=0;test<40000;test+=1000) { g_pVB->Lock( 0, sizeof(pVertices), (void**)&pVertices, 0 ); cin=0; pVertices[cin].position = D3DXVECTOR3( 100+test,100 ,100); pVertices[cin].color = D3DCOLOR_ARGB(250,250,250,250); pVertices[cin].tu = 0.00f; pVertices[cin].tv = 1.00f; cin=1; pVertices[cin].position = D3DXVECTOR3(-100+test,100 ,100); pVertices[cin].color = D3DCOLOR_ARGB(250,250,250,250); pVertices[cin].tu = 0.00f; pVertices[cin].tv = 1.00f; cin=2; pVertices[cin].position = D3DXVECTOR3( 100+test,100 ,-100); pVertices[cin].color = D3DCOLOR_ARGB(250,250,250,250 ; pVertices[cin].tu = 0.00f; pVertices[cin].tv = 1.00f; cin=3; pVertices[cin].position = D3DXVECTOR3(-100+test,100 ,-100); pVertices[cin].color = D3DCOLOR_ARGB(250,250,250,250) ; pVertices[cin].tu = 0.00f; pVertices[cin].tv = 1.00f; //super simple, 40 quads to paint (each draw seperate) g_pVB->Unlock(); g_pd3dDevice->SetTexture(0, g_ppTex[tg]); tg++; //Yes ...every time a draw call to find the error!!!! g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); } //end of stupid code ... } why is only the last one painted?!?!
Advertisement
Shouldn´t your DrawPrimitive(blabla,0,2) be DrawPrimitive(blabla,0,80)???



Bad Monkey Productions
normally yes


i do it at moment so to
understand my error, not to find a
way around the problem...

i want to draw triangles
everytime and everywhere i want
without create first an indexbuffer


I assume pVertices is a pointer. When you call Lock() with sizeof(pVertices), you are only locking 4 bytes (the size of a pointer). You are also locking only the FIRST 4 bytes, because you specified a lock offset of 0.

Since you are modifying 4 vertices at a time, then you should probably be locking 4*sizeof(CUSTOMVERTEX) and adjusting the lock offset by that same amount each time.

This topic is closed to new replies.

Advertisement