Original Post
I don't exactly know how to start it off so if someone could, give me a little code that takes a quad and texturizes it with a idirect3dtexture9 texture. or something
// Assumes pDevice is a valid IDirect3DDevice9*// Assumes pTexture is a valid IDirect3DTexture9*// Vertex structure (post-transformed, in scrood coordinates)struct TLVertex{ TLVertex() {} TLVertex(D3DXVECTOR3 _pos, DWORD _colour, float _u, float _v, float _rhw=1.0f) : vPos(_pos), rhw(_rhw), dwColour(_colour), u1(_u), v1(_v) {} D3DXVECTOR3 vPos; float rhw; DWORD dwColour; float u1; float v1;};#define FVF_TLVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)// Create a vertex buffer with space for 4 quads. Specify D3DUSAGE_WRITEONLY!LPDIRECT3DVERTEXBUFFER9 pVB;HRESULT hResult = pDevice->CreateVertexBuffer(4*sizeof(TLVertex), D3DUSAGE_WRITEONLY, FVF_TLVERTEX, D3DPOOL_MANAGED, &pVB, NULL);if(FAILED(hResult)) return; // Error// Lock the vertex buffer, fill it, then unlock it:TLVertex* pVerts;hResult = pVB->Lock(0,0,(void**)&pVerts,0);if(FAILED(hResult)) return; // ErrorpVerts[0] = TLVertex(D3DXVECTOR3(0,0,0),0xffffffff,0,0);pVerts[1] = TLVertex(D3DXVECTOR3(0,100,0),0xffffffff,0,1);pVerts[2] = TLVertex(D3DXVECTOR3(100,0,0),0xffffffff,1,0);pVerts[3] = TLVertex(D3DXVECTOR3(100,100,0),0xffffffff,1,1);pVB->Unlock();// In your main rendering loop:// Only specify D3DCLEAR_ZBUFFER if you have a Z-Buffer attachedpDevice->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0x00000000,1.0f,0);pDevice->BeginScene();// Tell D3D to render from the VB, and tell it what format it's to render in (Transformed verts)pDevice->SetFVF(FVF_TLVERTEX);pDevice->SetStreamSource(0,pVB,0,sizeof(TLVertex));// Set the texturepDevice->SetTexture(0,pTexture);// Draw the quad pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);// Show what's rendered on the screenpDevice->EndScene();pDevice->Present(NULL,NULL,NULL,NULL);Quote:My example above shows how to create and fill a vertex buffer, and how to render from it, using a texture.
Original post by EvilKnuckles666
i got all the device setup and what not, i just need to know how to do the vertex and setting the texture and whatnot
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more