Alt Tab + Restoring Textures

Started by
23 comments, last by utilae 19 years, 2 months ago
Quote:Original post by jollyjeffers
everything [smile].

Resources in D3DPOOL_SYSMEM and D3DPOOL_MANAGED will be looked after for you; All resources of any type in D3DPOOL_DEFAULT should be released when you minimize and re-created again when you get focus (recreate the device) again.

hth
Jack


Hi -

I've found it a lot easier to do *nothing* until your app gets focus again - that is, once you get focus again (Present returns DEVICELOST, TestCooperativeLevel returns DEVICENOTRESET), only then do you release resources, Reset the device, then recreate resources. While you're minimized, all DX calls will silently fail. If you release everything as soon as you're minimized, you'll have to check every bloody thing for lost or whatever, very tedious.

joe
image space
Advertisement
You never check the return value of D3DXCreateTextureFromFileEx(). The call is failing, and giving you an invalid pointer. So newTexture->m_texture isn't set to a valid value.
Always always always check your return values.
Ok, I'll look into that "Evil Steve".

If this:

D3DXCreateTextureFromFileEx(g_pD3DDevice9,sFilename.c_str(),D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,
D3DX_DEFAULT,D3DX_DEFAULT,0,0,0,&newTexture->m_texture);

s failing, then how can I stop it from failing. The only thing I am not sure about is this part of it(the last parameter):
&newTexture->m_texture

Cause newTexture is a struct LOADEDTEXTURE, eg
struct LOADEDTEXTURE
{
IDirect3DTexture9 *m_texture; //The texture
string m_sFilename; //The filename of the texture
int m_nWidth; //Width of the texture
int m_nHeight; //Height of the texture
};




HTML5, iOS and Android Game Development using Corona SDK and moai SDK

This page lists the following return codes:

Quote:D3DERR_INVALIDCALL
The method call is invalid. For example, a method's parameter may have an invalid value.
D3DERR_NOTAVAILABLE
This device does not support the queried technique.
D3DERR_OUTOFVIDEOMEMORY
Direct3D does not have enough display memory to perform the operation.
D3DXERR_INVALIDDATA
The data is invalid.
E_OUTOFMEMORY
Direct3D could not allocate sufficient memory to complete the call.


Test for these as return values from your call - presuming it is D3DXCreateTextureFromFileEx that is tripping up, then it will be one of the values on that list. Matching them up against the descriptions should reveal the next step in the puzzla: why.

Only when you know the why can you give serious thought to a work-around and/or bug fix.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

D3DXCreateTextureFromFileEx returns S_OK.

I only get this error when I run debug->start. I'm wondering if the debug is too sensitive or something, whether it's detecting errors that are not there.

When I run from the debug directory it works fine. I alt tab to minimize app and them give app focus again, and it all runs smoothly. Only issue now is that the textures that were being rendered to screen, no longer appear.


Here's what my log says(the bit about alt tab):

TestCooperativeLevel() S_OK
TestCooperativeLevel() S_OK //alt tab pressed somewhere around here
TestCooperativeLevel() D3DERR_DEVICELOST
TestCooperativeLevel() D3DERR_DEVICELOST
TestCooperativeLevel() D3DERR_DEVICELOST
TestCooperativeLevel() D3DERR_DEVICELOST
TestCooperativeLevel() D3DERR_DEVICELOST
TestCooperativeLevel() D3DERR_DEVICELOST
TestCooperativeLevel() D3DERR_DEVICENOTRESET
DeviceReset() S_OK
TestCooperativeLevel() S_OK //focus regained here, but textures not showing
TestCooperativeLevel() S_OK

HTML5, iOS and Android Game Development using Corona SDK and moai SDK

This topic is closed to new replies.

Advertisement