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();
Why won't my vb draw?
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
Any ideas?
thx
[Edited by - johnnyBravo on April 30, 2006 4:50:09 AM]
Hi there,
I haven't used vertex decl. before. But I am checking the SDK docs right now.
I dont think you specified the correct offset for your texture coordinates.
Just a guess, but try doing this instead:
- Pure
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement