c++ - Loading Textures in Directx -


im trying load textures in directx draw textured quad.

but d3dxcreatetexturefromfile never returns d3d_ok ....

here code load texture....

feraltexture(string name,feralvector2 position,idirect3ddevice9 *device)     {         filename = name;         m_pdevice = device;         x= position.x;         y= position.y;         if(d3dxcreatetexturefromfile(m_pdevice,filename.c_str(),&m_ptexturefile) != d3d_ok)         {             texturecreated = false;             m_ptexturefile = null;             d3dxcreatetexturefromfile(m_pdevice,filename.c_str(),&m_ptexturefile);         }         else         {             if(d3dxgetimageinfofromfile(filename.c_str(),&imageinfo) == d3d_ok)             {                 texturecreated = true;                 width = imageinfo.width;                 height = imageinfo.height;                 minvector = feralvector2(x,y);                 maxvector = feralvector2(x+width,y+height);                 //boundingrect = feralrect2(minvector,maxvector);             }             else             {                 width = 0;                 height = 0;             }         }     } 

i placed copies of image in both debug folder of project , in main folder of project... neither works....

any input appreciated ....

  1. make sure texture file name correct
  2. try using absolute path of texture file in program if step 1 not work.

if that's still not work try using directx debug runtime, open directx control panel(dxcpl.exe) c:\program files\microsoft directx sdk (june 2010)\utilities\bin\x86(the path depends on install directx sdk) , make settings below enter image description here

then running app in debug mode, detail error message output window of visual studio, tell what's problem.

d3dxcreatetexturefromfile support following texture format

.bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, , .tga

make sure texture format in list above.

d3dxcreatetexturefromfile has following return codes, can check return value , fix app.

  • d3d_ok
  • d3derr_notavailable
  • d3derr_outofvideomemory
  • d3derr_invalidcall
  • d3dxerr_invaliddata
  • e_outofmemory

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -