Translating texture coordinates..? I'm not getting this to work and I'm not sure if I'm even going down the right path.. I've run out of ideas to try.. so I'll just post what I'm doing and see if any of you bright minds can assist me..
All I get is my static background image drawn to the screen.. No movement or attempted movement (i.e. corrupt image)
Below should be any code of relevance.. thnx for any help..
Oh yeah I originally had rhw in my Custom vertex but I deleted it because I thought I read somewhere that texture transformations can't be done on transformed vertices. This true?
Code:
struct SCustomVertex
{
float x;
float y;
float z;
DWORD color;
float tu;
float tv;
};
#define CustomVertexFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1)
Code:
SCustomVertex vertices[4] =
{
{0.0f, 0.0f, 0.5f, 0xFFFFFFFF, 0.0f, 0.0f},
{640.0f, 0.0f, 0.5f, 0xFFFFFFFF, 1.0f, 0.0f},
{0.0f, 480.0f, 0.5f, 0xFFFFFFFF, 0.0f, 1.0f},
{640.0f, 480.0f, 0.5f, 0xFFFFFFFF, 1.0f, 1.0f}
};
HRESULT result;
result = g_Direct3dDevice->CreateVertexBuffer(sizeof(SCustomVertex) * 4, D3DUSAGE_WRITEONLY, CustomVertexFVF, D3DPOOL_DEFAULT, &g_VertexBuffer, NULL);
if(result != D3D_OK)
return false;
void *tempPtr;
result = g_VertexBuffer->Lock(0, sizeof(vertices), (void**)&tempPtr, 0);
if(result != D3D_OK)
return false;
memcpy(tempPtr, vertices, sizeof(vertices));
tempPtr = NULL;
result = g_VertexBuffer->Unlock();
if(result != D3D_OK)
return false;
Code:
g_Direct3dDevice->SetStreamSource(0, g_VertexBuffer, 0, sizeof(SCustomVertex));
g_Direct3dDevice->SetFVF(CustomVertexFVF);
g_Direct3dDevice->SetTexture(0, g_BackgroundTexture.GetTexture());
g_Direct3dDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
D3DXMATRIX backgroundScroll;
static float deltaU = 0.0f;
deltaU++;
D3DXMatrixTranslation(&backgroundScroll, deltaU, 0.0f, 0.0f);
g_Direct3dDevice->SetTransform(D3DTS_TEXTURE0, &backgroundScroll);
g_Direct3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
g_Direct3dDevice->EndScene();