Jump to content
  • Advertisement
Sign in to follow this  
Robinhood

Texture Loading Error

This topic is 4753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use following code to load textures,but it will fail in Windowed Mode on some PC. I want to know why.(Total Image:about 100MB) if( FAILED( hr = D3DXCreateTextureFromFileEx(pd3dDevice,szFileName,0,0,1,0, D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_FILTER_NONE,D3DX_DEFAULT,D3DCOLOR_RGBA (255,0,255,255), &imageInfo,NULL,&m_pTexture) ) ) return hr;

Share this post


Link to post
Share on other sites
Advertisement
It depends on a lot of things:
- whether the device can copy to textures
- whether the device can stretch during such a copy
- which formats are allowed (may be device-dependent) as source and targets
- etc

Have a look at the long list of remarks for this function (and its SDK sibling; something like this without D3DX in front of it). First of all, turn on debug mode and search for warnings and errors. Also, figure out what the return value is.

Greetz,

Illco

Share this post


Link to post
Share on other sites
But the strange thing is that it never failed in fullscreen Mode.
I think it must have something to do with current screen Resolution

Share this post


Link to post
Share on other sites
Have a look at the documentation. The texture rendering capabilities sometimes depend on the format of the backbuffer. In windowed mode this is the format the desktop is set to, but in fullscreen mode this is what you set it to be. Hence it may differ.

Share this post


Link to post
Share on other sites
You can't solve a problem like this without a full and complete error analysis. As Illco mentioned - you need to know what that error is. Unless you know all the available information, you're as good as blind!!

If you're new to the game, follow my journal entry to get maximum information - if the information you get from D3D doesn't help, copy-n-paste it back here and I'm sure we can have a look at it for you [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Here is my Setting code and I just use default settings for windowed mode:

HRESULT CMyD3DApplication::OneTimeSceneInit()
{
ShowCursor(FALSE);
m_d3dSettings.Fullscreen_PresentInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
m_d3dSettings.Fullscreen_DisplayMode.Width = SCREEN_RESOLUTION_WIDTH;
m_d3dSettings.Fullscreen_DisplayMode.Height = SCREEN_RESOLUTION_HEIGHT;
m_d3dSettings.Fullscreen_DisplayMode.RefreshRate = 0;
m_d3dSettings.PDeviceCombo()->BackBufferFormat = D3DFMT_R5G6B5;
return S_OK;
}

CMyD3DApplication is just derive from CD3DApplication(SDK sample).

if( FAILED( hr = D3DXCreateTextureFromFileEx(pd3dDevice,szFileName,0,0,1,0,
D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_FILTER_NONE,D3DX_DEFAULT,D3DCOLOR_RGBA (255,0,255,255),
&imageInfo,NULL,&m_pTexture) ) )
return hr;

In fullscreen mode,backbuffer format is same with the screen resolution.But in windowed mode,it depends on current screen resolution.Is this the problem?

Share this post


Link to post
Share on other sites
Quote:

But in windowed mode,it depends on current screen resolution.Is this the problem?


That's what I suggested, yes, but it is for you to find out. Look at the error code. Check if the device can do this and with what formats.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!