Archived

This topic is now archived and is closed to further replies.

Verminaard

texture mapping d3d/d3dx

Recommended Posts

Well, I''m sort of getting there (texture mapping), but it would be a great help if someone could link to some source of theirs that does something to do with texture mapping in d3d. you dont have to comment or anything, i can figure the stuff out, i JUST NEED SOME SOURCE! sorry, just venting some frustration.

Share this post


Link to post
Share on other sites
Try the Examples from the SDK, the nearly all use Texturemapping.

Of course there are some good tutorials with Sourcecode here on gamedev.

And an other good source is Nvidia, under www.nvidia.com/developer they have many examples, even with advanced texturemapping

Lars

Share this post


Link to post
Share on other sites
Here''s some source ripped right out of my engine. Feel free to use it if you want to .

    
//represents a texture

class Texture
{
protected:
LPDIRECTDRAWSURFACE7 lpDDSTexture;
public:

Texture() { lpDDSTexture = NULL; }
~Texture() { Destroy(); }

bool LoadTexture(Screen3D* D3DCard, char *filename, BOOL mipmap);
void Destroy() { if(lpDDSTexture) lpDDSTexture->Release(); lpDDSTexture = NULL; }

LPDIRECTDRAWSURFACE7 GetTextureSurface() { return lpDDSTexture; }

};


bool Texture::LoadTexture(Screen3D* D3DCard, char *filename, BOOL mipmap)
{
//create a texture

D3DX_SURFACEFORMAT TextureFormat = D3DX_SF_UNKNOWN;
DWORD NumberOfMips;

HRESULT hr = D3DXCreateTextureFromFile(D3DCard->lpD3DDevice,
NULL,
0,
0,
&TextureFormat,
NULL,
&lpDDSTexture,
&NumberOfMips,
filename,
D3DX_FT_LINEAR );

if(FAILED(hr))
return false;

return true;
}

///To use the texture you''d just do this:

lpD3DDevice->SetTexture(stage, texture->GetTextureSurface());



Note that since this uses D3DX at the start of your application you''ll need to use D3DXInitialize(), and when it shuts down you should use D3DXUninitialize().

Good luck.

--TheGoop

Share this post


Link to post
Share on other sites