Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXCheckTextureRequirements

Started by dxsux Feb 26, 2005 at 11:51 PM 4 replies 1.7k views
Original Post
dxsux
dxsux
Can someone tell me if and how I should use this. Whats happening is I am building a 2D Tile based game and I mad a texture tilemap 4 tiles x 4 tiles each tile is 64x64 pixels. so the first 4 tiles in my map are rendered alright but then if I go to the next row it blits only a partial tile and the tile above it overlaps. so my question is....can I and how do I use D3DXCheckTextureRequirements to see if my parameters for D3DXCreateTextureFromFileEx are correct ?
dxsux
dxsux
Now I have a follow up question. Does anyone know if its better to use DDS files instead of BMP files which I am using. And what is the advantage or disadvantage ?
matthughson
matthughson
I'm not positive but I don't the textures are your problem. It sounds more like your rendering has some flaws; which isn't uncommon when writing algorithmic rendering functions like tile engines. Maybe post a picture of what is happening if you can.

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
circlesoft
circlesoft
Quote:
Original post by dxsux
Now I have a follow up question. Does anyone know if its better to use DDS files instead of BMP files which I am using. And what is the advantage or disadvantage ?

DDS stands for DirectDraw Surface. They are files that are exact representations of D3D surfaces, including mipmap levels. This means that very little, if any, processing has to be applied to the data, which decreases load times.

DDS files will generally have a smaller file size then BMP, but they are lossy.

There are plugins that come with the DXSDK that let you load and save DDS files in Photoshop.
dxsux
dxsux
Im using some code from Jim Adams book Programming Role Playing Games w/DirectX 2nd Edition...

so I load my tileset Walkable.dds...
4x3 tileset each image is exactly 64pixels x 64pixels


m_Tiles.Load(0, "Walkable.dds", 64, 64,D3DCOLOR_RGBA(0,0,0, 255),  D3DFMT_X8R8G8B8  );


then the load function
BOOL cTexture::Load(cGraphics *Graphics, char *Filename, DWORD Transparent, D3DFORMAT Format){  Free();  if((m_Graphics = Graphics) == NULL)    return FALSE;  if(Graphics->GetDeviceCOM() == NULL)    return FALSE;  if(Filename == NULL)    return FALSE;   D3DXIMAGE_INFO image_info;    if(FAILED(D3DXCreateTextureFromFileEx(Graphics->GetDeviceCOM(),    Filename, 256/*D3DX_DEFAULT, D3DX_DEFAULT*/,192, 1,     0, Format,D3DPOOL_MANAGED ,     D3DX_DEFAULT , D3DX_FILTER_BOX,    Transparent, NULL, NULL, &m_Texture)))      return FALSE;  m_Width = GetWidth();  m_Height = GetHeight();  return TRUE;}




I noticed that if I "hardcode" the 256x192 tileset it works ..but if I use D3DX__DEFAULT I get a blank screen !
dxsux
dxsux
well I got it to work dynamically using the following code ...

D3DXIMAGE_INFO image_info;image_info.Format=D3DFMT_X8R8G8B8;image_info.ResourceType=D3DRTYPE_TEXTURE;  if(FAILED(D3DXCreateTextureFromFileEx(Graphics->GetDeviceCOM(),    Filename, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 1,     0, Format,D3DPOOL_MANAGED ,     D3DX_DEFAULT , D3DX_FILTER_BOX,    Transparent, ℑ_info, NULL, &m_Texture)))      return FALSE;


I used D3DX_DEFAULT_NONPOW2 instead of D3DX_DEFAULT and for some reason it works now so I dunno.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.