Currently I am making a game in C++ using DirectX9 (and starting to wish I'd started in DX11) and I am currently working on changing the game resolution. My problem is that when I reset the graphics device, my meshes no longer draw and I can't see how to resolve the issue.
Answer Found:
http://www.gamedev.net/topic/571846-directx-9-mesh-gone-after-device-reset/
Thanks.
Show differencesHistory of post edits
#5Nexian
Posted 14 August 2012 - 11:40 AM
Currently I am making a game in C++ using DirectX9 (and starting to wish I'd started in DX11) and I am currently working on changing the game resolution. My problem is that when I reset the graphics device, my meshes no longer draw and I can't see how to resolve the issue.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
The same process is used to load Meshes and Fonts:
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
The assets methods are as follows, resetting the fonts:
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
Finally, here's my initial Device creation:
So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
P.S. The reloading of the meshes in test() is done before it actually assigns the meshes to objects. I also have a button-press trigger for resetting the device after the game objects are loaded and displaying and they simply disappear as soon as the button is pressed.
Also, just for the record:
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
typedef std::map<string, IDirect3DTexture9*> TexMap; typedef std::map<string, ID3DXMesh*> MeshMap; typedef std::map<string, ID3DXFont*> FontMap; TexMap textureList; MeshMap meshList; FontMap fontList;
HRESULT LoadMesh( IDirect3DDevice9* pd3dDevice, LPCWSTR file, string key)
{
//load and store a mesh from file
ID3DXMesh* mesh;
D3DXLoadMeshFromX(file, D3DXMESH_MANAGED, pd3dDevice, NULL, NULL, NULL, NULL, &mesh);
if (meshList.find(key) != meshList.end())
{
meshList.erase(meshList.find(key));
}
meshList.insert(MeshMap::value_type(key, mesh));
return S_OK;
}
The same process is used to load Meshes and Fonts:
... D3DXCreateTextureFromFileEx(pd3dDevice, file, 512, 512, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &tex); ...
... D3DXCreateFont( pd3dDevice, Height, Width, Weight, MipLevels, Italic, CharSet, OutputPrecision, Quality, PitchAndFamily, pFacename, &font ); ...
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
if (input->MouseDown(0) && gui->PointIntersection(&buttonStart, input->GetMouseScreen(&d3dPresentParameters)))
{
d3dPresentParameters.BackBufferWidth = 800;
d3dPresentParameters.BackBufferHeight = 600;
assets->OnLostDevice();
graphicsDevice->Reset(&d3dPresentParameters);
assets->OnResetDevice();
assets->test(graphicsDevice);
}
The assets methods are as follows, resetting the fonts:
void OnLostDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnLostDevice();
}
}
void OnResetDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnResetDevice();
}
}
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
void test(IDirect3DDevice9* graphicsDevice)
{
LoadMesh(graphicsDevice, L"../Assets/Tile.x", "Game_Mesh_Tile");
LoadMesh(graphicsDevice, L"../Assets/Wall.x", "Game_Mesh_Wall");
LoadMesh(graphicsDevice, L"../Assets/Icon.x", "Game_Mesh_Icon");
LoadMesh(graphicsDevice, L"../Assets/Border.x", "Game_Mesh_Border");
}Finally, here's my initial Device creation:
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWindow;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
if( SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, FALSE,
D3DMULTISAMPLE_8_SAMPLES, NULL ) ) )
{
d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;
}
// create a device class using this information and the info from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWindow,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
P.S. The reloading of the meshes in test() is done before it actually assigns the meshes to objects. I also have a button-press trigger for resetting the device after the game objects are loaded and displaying and they simply disappear as soon as the button is pressed.
Also, just for the record:
HRESULT answer = graphicsDevice->TestCooperativeLevel();answer = S_OK after the reset
#4Nexian
Posted 14 August 2012 - 11:36 AM
Currently I am making a game in C++ using DirectX9 (and starting to wish I'd started in DX11) and I am currently working on changing the game resolution. My problem is that when I reset the graphics device, my meshes no longer draw and I can't see how to resolve the issue.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
The same process is used to load Meshes and Fonts:
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
The assets methods are as follows, resetting the fonts:
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
Finally, here's my initial Device creation:
So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
P.S. The reloading of the meshes in test() is done before it actually assigns the meshes to objects. I also have a button-press trigger for resetting the device after the game objects are loaded and displaying and they simply disappear as soon as the button is pressed.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
typedef std::map<string, IDirect3DTexture9*> TexMap; typedef std::map<string, ID3DXMesh*> MeshMap; typedef std::map<string, ID3DXFont*> FontMap; TexMap textureList; MeshMap meshList; FontMap fontList;
HRESULT LoadMesh( IDirect3DDevice9* pd3dDevice, LPCWSTR file, string key)
{
//load and store a mesh from file
ID3DXMesh* mesh;
D3DXLoadMeshFromX(file, D3DXMESH_MANAGED, pd3dDevice, NULL, NULL, NULL, NULL, &mesh);
if (meshList.find(key) != meshList.end())
{
meshList.erase(meshList.find(key));
}
meshList.insert(MeshMap::value_type(key, mesh));
return S_OK;
}
The same process is used to load Meshes and Fonts:
... D3DXCreateTextureFromFileEx(pd3dDevice, file, 512, 512, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &tex); ...
... D3DXCreateFont( pd3dDevice, Height, Width, Weight, MipLevels, Italic, CharSet, OutputPrecision, Quality, PitchAndFamily, pFacename, &font ); ...
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
if (input->MouseDown(0) && gui->PointIntersection(&buttonStart, input->GetMouseScreen(&d3dPresentParameters)))
{
d3dPresentParameters.BackBufferWidth = 800;
d3dPresentParameters.BackBufferHeight = 600;
assets->OnLostDevice();
graphicsDevice->Reset(&d3dPresentParameters);
assets->OnResetDevice();
assets->test(graphicsDevice);
}
The assets methods are as follows, resetting the fonts:
void OnLostDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnLostDevice();
}
}
void OnResetDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnResetDevice();
}
}
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
void test(IDirect3DDevice9* graphicsDevice)
{
LoadMesh(graphicsDevice, L"../Assets/Tile.x", "Game_Mesh_Tile");
LoadMesh(graphicsDevice, L"../Assets/Wall.x", "Game_Mesh_Wall");
LoadMesh(graphicsDevice, L"../Assets/Icon.x", "Game_Mesh_Icon");
LoadMesh(graphicsDevice, L"../Assets/Border.x", "Game_Mesh_Border");
}Finally, here's my initial Device creation:
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWindow;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
if( SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, FALSE,
D3DMULTISAMPLE_8_SAMPLES, NULL ) ) )
{
d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;
}
// create a device class using this information and the info from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWindow,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
P.S. The reloading of the meshes in test() is done before it actually assigns the meshes to objects. I also have a button-press trigger for resetting the device after the game objects are loaded and displaying and they simply disappear as soon as the button is pressed.
#3Nexian
Posted 14 August 2012 - 11:13 AM
Currently I am making a game in C++ using DirectX9 (and starting to wish I'd started in DX11) and I am currently working on changing the game resolution. My problem is that when I reset the graphics device, my meshes no longer draw and I can't see how to resolve the issue.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
The same process is used to load Meshes and Fonts:
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
The assets methods are as follows, resetting the fonts:
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
Finally, here's my initial Device creation:
So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
typedef std::map<string, IDirect3DTexture9*> TexMap; typedef std::map<string, ID3DXMesh*> MeshMap; typedef std::map<string, ID3DXFont*> FontMap; TexMap textureList; MeshMap meshList; FontMap fontList;
HRESULT LoadMesh( IDirect3DDevice9* pd3dDevice, LPCWSTR file, string key)
{
//load and store a mesh from file
ID3DXMesh* mesh;
D3DXLoadMeshFromX(file, D3DXMESH_MANAGED, pd3dDevice, NULL, NULL, NULL, NULL, &mesh);
if (meshList.find(key) != meshList.end())
{
meshList.erase(meshList.find(key));
}
meshList.insert(MeshMap::value_type(key, mesh));
return S_OK;
}
The same process is used to load Meshes and Fonts:
... D3DXCreateTextureFromFileEx(pd3dDevice, file, 512, 512, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &tex); ...
... D3DXCreateFont( pd3dDevice, Height, Width, Weight, MipLevels, Italic, CharSet, OutputPrecision, Quality, PitchAndFamily, pFacename, &font ); ...
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
if (input->MouseDown(0) && gui->PointIntersection(&buttonStart, input->GetMouseScreen(&d3dPresentParameters)))
{
d3dPresentParameters.BackBufferWidth = 800;
d3dPresentParameters.BackBufferHeight = 600;
assets->OnLostDevice();
graphicsDevice->Reset(&d3dPresentParameters);
assets->OnResetDevice();
assets->test(graphicsDevice);
}
The assets methods are as follows, resetting the fonts:
void OnLostDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnLostDevice();
}
}
void OnResetDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnResetDevice();
}
}
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
void test(IDirect3DDevice9* graphicsDevice)
{
LoadMesh(graphicsDevice, L"../Assets/Tile.x", "Game_Mesh_Tile");
LoadMesh(graphicsDevice, L"../Assets/Wall.x", "Game_Mesh_Wall");
LoadMesh(graphicsDevice, L"../Assets/Icon.x", "Game_Mesh_Icon");
LoadMesh(graphicsDevice, L"../Assets/Border.x", "Game_Mesh_Border");
}Finally, here's my initial Device creation:
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWindow;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
if( SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, FALSE,
D3DMULTISAMPLE_8_SAMPLES, NULL ) ) )
{
d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;
}
// create a device class using this information and the info from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWindow,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
#2Nexian
Posted 14 August 2012 - 11:12 AM
Currently I am making a game in C++ using DirectX9 (and starting to wish I'd started in DX11) and I am currently working on changing the game resolution. My problem is that when I reset the graphics device, my meshes no longer draw and I can't see how to resolve the issue.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
The same process is used to load Meshes and Fonts:
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
The assets methods are as follows, resetting the fonts:
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
Finally, here's my initial Device creation:
So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
P.S. I am aware of my lack of error checking right now and the irony is not wasted
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
typedef std::map<string, IDirect3DTexture9*> TexMap; typedef std::map<string, ID3DXMesh*> MeshMap; typedef std::map<string, ID3DXFont*> FontMap; TexMap textureList; MeshMap meshList; FontMap fontList;
HRESULT LoadMesh( IDirect3DDevice9* pd3dDevice, LPCWSTR file, string key)
{
//load and store a mesh from file
ID3DXMesh* mesh;
D3DXLoadMeshFromX(file, D3DXMESH_MANAGED, pd3dDevice, NULL, NULL, NULL, NULL, &mesh);
if (meshList.find(key) != meshList.end())
{
meshList.erase(meshList.find(key));
}
meshList.insert(MeshMap::value_type(key, mesh));
return S_OK;
}
The same process is used to load Meshes and Fonts:
... D3DXCreateTextureFromFileEx(pd3dDevice, file, 512, 512, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &tex); ...
... D3DXCreateFont( pd3dDevice, Height, Width, Weight, MipLevels, Italic, CharSet, OutputPrecision, Quality, PitchAndFamily, pFacename, &font ); ...
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
if (input->MouseDown(0) && gui->PointIntersection(&buttonStart, input->GetMouseScreen(&d3dPresentParameters)))
{
d3dPresentParameters.BackBufferWidth = 800;
d3dPresentParameters.BackBufferHeight = 600;
assets->OnLostDevice();
graphicsDevice->Reset(&d3dPresentParameters);
assets->OnResetDevice();
assets->test(graphicsDevice);
}
The assets methods are as follows, resetting the fonts:
void OnLostDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnLostDevice();
}
}
void OnResetDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnResetDevice();
}
}
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
void test(IDirect3DDevice9* graphicsDevice)
{
LoadMesh(graphicsDevice, L"../Assets/Tile.x", "Game_Mesh_Tile");
LoadMesh(graphicsDevice, L"../Assets/Wall.x", "Game_Mesh_Wall");
LoadMesh(graphicsDevice, L"../Assets/Icon.x", "Game_Mesh_Icon");
LoadMesh(graphicsDevice, L"../Assets/Border.x", "Game_Mesh_Border");
}Finally, here's my initial Device creation:
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWindow;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
if( SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, FALSE,
D3DMULTISAMPLE_8_SAMPLES, NULL ) ) )
{
d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;
}
// create a device class using this information and the info from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWindow,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
P.S. I am aware of my lack of error checking right now and the irony is not wasted
#1Nexian
Posted 14 August 2012 - 11:04 AM
Currently I am making a game in C++ using DirectX9 (and starting to wish I'd started in DX11) and I am currently working on changing the game resolution. My problem is that when I reset the graphics device, my meshes no longer draw and I can't see how to resolve the issue.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
The same process is used to load Meshes and Fonts:
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
The assets methods are as follows, resetting the fonts:
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
Finally, here's my initial Device creation:
So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.
At the moment, fonts, textures and meshes are all loaded and pointers to them are stored in maps to be retrieved when needed:
typedef std::map<string, IDirect3DTexture9*> TexMap; typedef std::map<string, ID3DXMesh*> MeshMap; typedef std::map<string, ID3DXFont*> FontMap; TexMap textureList; MeshMap meshList; FontMap fontList;
HRESULT LoadMesh( IDirect3DDevice9* pd3dDevice, LPCWSTR file, string key)
{
//load and store a mesh from file
ID3DXMesh* mesh;
D3DXLoadMeshFromX(file, D3DXMESH_MANAGED, pd3dDevice, NULL, NULL, NULL, NULL, &mesh);
//store the loaded mesh to a vector array
//meshList.push_back(mesh);
if (meshList.find(key) != meshList.end())
{
meshList.erase(meshList.find(key));
}
meshList.insert(MeshMap::value_type(key, mesh));
return S_OK;
}
The same process is used to load Meshes and Fonts:
... D3DXCreateTextureFromFileEx(pd3dDevice, file, 512, 512, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &tex); ...
... D3DXCreateFont( pd3dDevice, Height, Width, Weight, MipLevels, Italic, CharSet, OutputPrecision, Quality, PitchAndFamily, pFacename, &font ); ...
I assume from the settings that both Meshes and Textures are managed and do not need to be released and re-acquired when the device is reset.
Right now, for the sake of testing I have it change the resolution on a button click:
if (input->MouseDown(0) && gui->PointIntersection(&buttonStart, input->GetMouseScreen(&d3dPresentParameters)))
{
d3dPresentParameters.BackBufferWidth = 800;
d3dPresentParameters.BackBufferHeight = 600;
assets->OnLostDevice();
graphicsDevice->Reset(&d3dPresentParameters);
assets->OnResetDevice();
assets->test(graphicsDevice);
}
The assets methods are as follows, resetting the fonts:
void OnLostDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnLostDevice();
}
}
void OnResetDevice()
{
FontMap::iterator it;
for(it = fontList.begin();
it != fontList.end();
it++)
{
it->second->OnResetDevice();
}
}
The test method simply re-loads the meshes. I just added this in to be sure, but it makes no difference:
void test(IDirect3DDevice9* graphicsDevice)
{
LoadMesh(graphicsDevice, L"../Assets/Tile.x", "Game_Mesh_Tile");
LoadMesh(graphicsDevice, L"../Assets/Wall.x", "Game_Mesh_Wall");
LoadMesh(graphicsDevice, L"../Assets/Icon.x", "Game_Mesh_Icon");
LoadMesh(graphicsDevice, L"../Assets/Border.x", "Game_Mesh_Border");
}Finally, here's my initial Device creation:
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWindow;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;// D3DFMT_D24S8;
if( SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, FALSE,
D3DMULTISAMPLE_8_SAMPLES, NULL ) ) )
{
d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;
}
// create a device class using this information and the info from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWindow,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);So basically I am unsure what is causing my meshes to not draw. The program does not crash, I just basically say some UI textures drawn, but no 3D objects. If I remove the device reset, I am, of course, able to see them.
Any advice or suspicions are welcome.