Original Post
Could someone please help me, I can't figure out what I'm doing wrong. I'm new to DirectX and I've been trying to texture map a simple 256 x 256 image: http://www.mycgiserver.com/~ll0377/stuff/reddot.bmp to a single triangle. I end up with this: http://www.mycgiserver.com/~ll0377/stuff/scene.JPG It seems like the texture is being sampled at the same coordinate repeated across the horizontal, and is being repeated in the vertical. The following is the portion of my code concerning texture mapping. // This is done in the constructor of the object D3DXCreateTextureFromFile(g_pdevice, "res/tex/reddot.bmp", &ptex); g_pdevice->CreateVertexBuffer(sizeof(d3d::STex1Vertex) * 3, 0, d3d::STex1Vertex::FVF, D3DPOOL_DEFAULT, &vb, 0); d3d::STex1Vertex *pverts; vb->Lock(0, 0, (void**)&pverts, 0); pverts[0] = d3d::STex1Vertex(-10.0f, -10.0f, 10.0f, 0.0f, 1.0f); pverts[1] = d3d::STex1Vertex(-10.0f, 10.0f, 10.0f, 0.0f, 0.0f); pverts[2] = d3d::STex1Vertex(10.0f, 10.0f, 10.0f, 1.0f, 0.0f); vb->Unlock(); // This is done some time before rendering g_pdevice->SetRenderState(D3DRS_LIGHTING, FALSE); g_pdevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); g_pdevice->SetRenderState(D3DRS_ZENABLE, TRUE); g_pdevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); // This is done in the render() of the object g_pdevice->SetTexture(0, ptex); g_pdevice->SetFVF(d3d::STex1Vertex::FVF); g_pdevice->SetStreamSource(0, vb, 0, sizeof(d3d::STex1Vertex)); g_pdevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); // This is the FVF I defined struct STex1Vertex { STex1Vertex(float x, float y, float z, float u, float v) { this->x = x; this->y = y; this->z = z; this->u = y; this->v = v; } float x, y, z; float u, v; static const DWORD FVF = D3DFVF_XYZ | D3DFVF_TEX1; }; I've tried different images, different texture stage states and different sampler states, all leads back to the same problem. I'd appreciate any suggestions.