Texture mapping probs under D3D

Started by
1 comment, last by cliffski 24 years ago
Ok this isn''t funny now... im trying to texture map a single polygon (square - rendered as a 4 vertex trianglestrip) under D3D7. All my code works fine if I just want a shaded polygon, i see my lovely coloured square on the screen. I know my bitmap loading stuff works, because i can do a DirectDraw Blt() from the texture surface to the back buffer and see it no problem, its just that when I call SetTexture(0,tex) and then render the primitive, the screen is just black (no it aint a black texture), and the DrawPrimitive() call returns an unknown HRESULT (im checking them all and it aint returning any of em). This is driving me MADDDDDDDDDDDD! heres a code snippet: (debug stuff stripped out) lpD3DDevice7->BeginScene(); lpD3DDevice7->SetTexture(0,tex); lpD3DDevice7->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX,&tl,4,D3DDP_WAIT); lpD3DDevice7->EndScene(); Flip(); Any ideas gang? a tube of smarties to anyone who solves it... http://www.positech.co.uk
Advertisement
Try using D3DXGetErrorString(HRESULT hr, DWORD length, LPSTR string) to get what error it is.

Have you specified that the surfaces is a texture when you created it? If you don''t you can still blit from it, but you cannot use it in DrawPrimitive().

DDSURFACEDESC2 ddsd;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;



wow
that D3DX gives me this:
D3DERR_TEXTURE_CREATE_FAILED
which i dont see anywhere as a return type. I didnt know you could do that,cheers! however i still have my problem...I am including the texture flag. here is the full code:

ZeroMemory( &ddsd, sizeof(DDSURFACEDESC2) );
ddsd.dwSize = sizeof(DDSURFACEDESC2);
ddsd.dwFlags = DDSD_CAPS / DDSD_HEIGHT / DDSD_WIDTH / DDSD_PIXELFORMAT / DDSD_TEXTURESTAGE ;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.dwWidth = 32;
ddsd.dwHeight = 32;
ddsd.dwTextureStage = 0;
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
ddsd.ddpfPixelFormat.dwRGBBitCount = 16;

// Create the primary surface.
lpDD7->CreateSurface(&ddsd,&tex,NULL);

the CreateSurface() call works fine, ive experimented by adding the pixel format and texturestage stuff, im not sure if i need them, but either way it dosent work. I can blit fine from this surface, what could be wrong? Any help HUGELY appreciated.

http://www.positech.co.uk

This topic is closed to new replies.

Advertisement