Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

Why won't my vb draw?

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

Hi, I'm trying to draw a triangle, if I use only positions, eg with 3 D3DXVECTOR3, it draws fine, but as soon as I try to add say something like texture coordinates, it just doesn't draw. eg
struct V{D3DXVECTOR3 p;float tu,tv;};
V v[] = {
	{D3DXVECTOR3(1,-1,1),0,0}, 
	{D3DXVECTOR3(1,1,1),0,0},	
	{D3DXVECTOR3(1,-1,-1),0,0},
};

void* pV = 0;
vb->Lock(0, 0, (void**)&pV, D3DLOCK_DISCARD);
memcpy(pV, v, sizeof(v));
vb->Unlock();

D3DVERTEXELEMENT9 meshVe[] = {
	{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
	{0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
	D3DDECL_END()
};

LPDIRECT3DVERTEXDECLARATION9 meshVd;
device->CreateVertexDeclaration(meshVe, &meshVd);
device->SetVertexDeclaration(meshVd);

device->SetStreamSource(0, vb, 0, sizeof(V));
device->SetTexture(0,0);
				
device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);	
meshVd->Release();



Any ideas? thx [Edited by - johnnyBravo on April 30, 2006 4:50:09 AM]

Share this post


Link to post
Share on other sites
Advertisement
Hi there,

I haven't used vertex decl. before. But I am checking the SDK docs right now.


typedef struct D3DVERTEXELEMENT9 {
WORD Stream;
WORD Offset;
BYTE Type;
BYTE Method;
BYTE Usage;
BYTE UsageIndex;
} D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9;





I dont think you specified the correct offset for your texture coordinates.

Just a guess, but try doing this instead:


D3DVERTEXELEMENT9 meshVe[] = {
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, sizeof(D3DXVECTOR3), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
D3DDECL_END()
};





- Pure

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.

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!