   Problem with CheckDeviceFormat
  I have a few questions.  I'm trying to create a texture using the D3DXCreateTextureFromFileEx function.  I can create a texture if I change the usage from DYNAMIC to SOFTWAREPROCESSING.  That's not a big deal but I'm trying to create a method that will check if the parameters I use will be compatable with the video card so I'm using the CheckDeviceFormat method to achieve this.if(!SUCCEEDED(D3DXCreateTextureFromFileEx(m_Device, Dir, Width, Height, D3DX_FROM_FILE, D3DUSAGE_DYNAMIC, D3DFMT_FROM_FILE, D3DPOOL_DEFAULT,D3DX_DEFAULT, D3DX_DEFAULT, 0, &Info, NULL, &m_Texture))){if(UD3DUtility::CCaps::IsTextureFormat(m_Device, D3DFMT_FROM_FILE))  <-- return false;}UD3DUtility::CCaps::IsTextureFormat:  Uses this code.hr = D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, DisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, TextureFormat);I used every option for parameters 4 and 6, but it always returns D3DERR_NOTAVAILABLE even though I can create the texture using those same parameters in the D3DXCreateTextureFromFileEx function.Here's the entire method that is failing no matter what parameters I put in:static bool IsTextureFormat(LPDIRECT3DDEVICE9 Device, D3DFORMAT TextureFormat) {D3DDISPLAYMODE DisplayMode;ZeroMemory(&DisplayMode, sizeof(D3DDISPLAYMODE));Device->GetDisplayMode(0, &DisplayMode);LPDIRECT3D9D3D = NULL;Device->GetDirect3D(&D3D);HRESULT hr;if(!(D3D == NULL)){hr = D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, DisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, TextureFormat);}elsereturn false;if(FAILED(hr))return false;elsereturn true;}Thanks for you help.   
  D3DFMT_FROM_FILE is just a "marker" flag - its not a real format (there are a couple of others if you look them up in the appropriate header file). Off the top of my head, I think it'll be a DWORD cast of -3 which is a rather large number [wink]Try using D3DXGetImageInfoFromFile() first and verifying the results against your device. You can also save yourself some code by using D3DXCheckTextureRequirements() (and the Cube/Volume variants)...hthJack   ;Quote:Original post by jollyjeffersI think it'll be a DWORD cast of -3 which is a rather large number [wink]Yay me - I was right [grin]Starting on line 21 of d3dx9.h:#define D3DX_DEFAULT  ((UINT) -1)#define D3DX_DEFAULT_NONPOW2    ((UINT) -2)#define D3DX_DEFAULT_FLOAT FLT_MAX#define D3DX_FROM_FILE((UINT) -3)#define D3DFMT_FROM_FILE   ((D3DFORMAT) -3)Cheers,Jack   ;  Did you want the texture to be a render target? If not, then do not use the render target usage flag. Also, you say you are doing this to see if the format is compatible with the video card, but you are telling it to check the reference device's abilities, not the HAL device's. If you just want a plain old texture with no special properties, use a usage of 0, and stick the texture in the managed pool.   ;  For testing proposes I hard coded D3DUSAGE_RENDERTARGET, and every other option in the 4th parameter, and every option in the 6th parameter as well.  The issue is not creating the texture, its, finding out what options I have with different hardware.   ;  Yes, JollyJeffers already pointed out the main bug. I was merely pointing out that those other parametes didn't make sense, or rather were suspicious.   ;  D3DFMT_FROM_FILE  works fine in that line of code, I just have to use software processing in place of dynamic.  Creating the texture works, I'm just trying to figure out why CheckDeviceFormat doesn't work when I put in the same parameters.   ;  No, you are using D3DFMT_FROM_FILE in the line that is checking the format. D3DFMT_FROM_FILE is not a format.   ;  Yes, I've used that, but I used every other option that is available for both parameter 4 and 6.  What you see in the code above is just an example of what I put in there, I know that that's not correct.;  Try this line as a test:HRESULT result=D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8);If you are in a 32 bit color mode, and that line fails, then you have other issues.   