void CIntroductionState::PreReset()
{
m_Text.Free();
m_pCFireQuad->DestroyVertexBuffer();
}
void CIntroductionState::PostReset()
{
m_Text.Create(m_pCGraphics, "Arial");
OutputDebugString("debug\n");
if (m_pCFireQuad->CreateVertexBuffer() == FALSE)
{
OutputDebugString("Error: Failed to m_pCFireQuad->CreateVertexBuffer()");
}
}
_______________________________________
Understanding is a three edged sword...
Have your independent game reviewed by your peers on the www.FreelanceGames.com review ladder.
[edited by - Sean Doherty on January 24, 2004 11:17:11 AM]
I am trying to get everything to work with alt-tab in full screen mode. However, for some reason, nothing is being displayed exepect the background color and the ID3DXFont that I am using to display debug messages.
The device is being reset and it looks like everything is fine, but nothing else is being rendered to the screen. At first glance, I thought that my tectures were being destroyed; but I am using managed texture which means that they are only flushed from video memory. I must be missing somehting?
Please Help!
PS: Here is some code...
quote:Are you restoring the device states? Such as D3DRS_LIGHTING = TRUE. etc?
I am trying to reset all the states; here is where most are reset:
BOOL CFreelanceDefender::Init(){ // Initialize the graphics device and set display mode m_CGraphics.Init(); #ifdef FULLSCREENMODE m_CGraphics.SetMode(m_pIWindow->GethWnd(), FALSE, TRUE, 1024, 768); #else m_CGraphics.SetMode(m_pIWindow->GethWnd(), TRUE, TRUE, 1024,768); #endif // Match perspective from modeler m_CGraphics.SetPerspective(D3DX_PI / 4.0f, 1.333333f, 1.0f, 50.0f); ShowMouse(TRUE); // Initialize input and input devices m_CInput.Init(m_pIWindow->GethWnd(), m_pIWindow->GethInst()); m_CKeyboard.Create(&m_CInput, KEYBOARD); m_CGraphics.GetDeviceCOM()->SetRenderState(D3DRS_NORMALIZENORMALS,TRUE); // Enable lighting and ambient light level m_CGraphics.EnableLighting(TRUE); // Create a directional light to illuminate the scene cLight Light; Light.SetType(D3DLIGHT_DIRECTIONAL); Light.SetAmbientColor(0,0,0); Light.Move(0, -50, 0); Light.Point(0,0,0, 0, 1, 0); m_CGraphics.SetLight(0, &Light); m_CGraphics.EnableLight(0, TRUE); m_pCSound = new cSound(); if (m_pCSound->Init(m_pIWindow->GethWnd(), 22050) == TRUE) { OutputDebugString("Sound Created!\n"); } m_CGameManager.Initialize(&m_CGraphics, &m_CKeyboard, m_pCSound, m_pIWindow); return TRUE;}
_______________________________________
Understanding is a three edged sword...
Have your independent game reviewed by your peers on the www.FreelanceGames.com review ladder.
Remember to redo your projection matrix and your view matrix if it is not caluclated each frame. If you're using ID3DXFont you have to release and reset that too (It has methods OnLostDevice() and OnResetDevice() I believe). Assuming your meshes are D3DXMESH_MANAGED and textures are D3DPOOL_MANAGED they should reappear one you do these (as well as thing like lighting too).
Here is my ValidateDevice() method:
[edited by - __Daedalus__ on January 24, 2004 4:41:08 PM]
Here is my ValidateDevice() method:
HRESULT CApp::ValidateDevice(){ // Declare local variables HRESULT Result = 0; // Test the current state of the device Result = m_D3DDevice->TestCooperativeLevel(); if( FAILED(Result) ) { // If the device is lost then return failure if( Result == D3DERR_DEVICELOST ){ return E_FAIL; } // If device is ready to be reset then try it if( Result == D3DERR_DEVICENOTRESET ) { // Release all ID3DXFonts m_AppFont.GetFontCOM()->OnLostDevice(); // Reset the device Result = m_D3DDevice->Reset( &m_d3dpp ); if( FAILED(Result) ) { // Quit the fucking thing PostQuitMessage(0); return E_FAIL; } else { // Set default rendering states m_D3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); // Lighting m_D3DDevice->SetRenderState( D3DRS_ZENABLE, (m_d3dpp.EnableAutoDepthStencil == TRUE) ? D3DZB_TRUE : D3DZB_FALSE ); // Z Buffer m_D3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE ); // Alpha Blending m_D3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE ); // Alpha Test m_D3DDevice->SetRenderState( D3DRS_EDGEANTIALIAS, TRUE); // Anti Alias m_D3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); m_D3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD ); // Enable texture rendering stages and filer types m_D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); m_D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); m_D3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); m_D3DDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); m_D3DDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); // Set the default ambient light colour to white m_D3DDevice->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE(0.25, 0.25, 0.25, 1.0) ); // Calculate the aspect ratio based on the window size float Aspect = (float)m_AppSettings.m_Height / (float)m_AppSettings.m_Width; // Set the perspective (Projection Matrix) D3DXMATRIX matProjection; D3DXMatrixPerspectiveFovLH( &matProjection, D3DXToRadian(45), Aspect, 5.0f, 10000.0f ); if( FAILED( m_D3DDevice->SetTransform( D3DTS_PROJECTION, &matProjection ) ) ) { // Error return FALSE; } // Reinstate fonts m_AppFont.GetFontCOM()->OnResetDevice(); // Clear the device m_D3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 0.0f, 0 ); } } } return S_OK;}
[edited by - __Daedalus__ on January 24, 2004 4:41:08 PM]
I have it kind of working; what render state am I missing for the ship at the bottom to look like this? It is like the zBuffer is off or not being recreated correctly?
_______________________________________
Understanding is a three edged sword...
Have your independent game reviewed by your peers on the www.FreelanceGames.com review ladder.
[edited by - Sean Doherty on January 24, 2004 7:43:59 PM]
_______________________________________
Understanding is a three edged sword...
Have your independent game reviewed by your peers on the www.FreelanceGames.com review ladder.
[edited by - Sean Doherty on January 24, 2004 7:43:59 PM]
Looks like re-creating the device after an alt-tab was causing the z-buffer to be turned off and the device to be created with out a z-buffer. I really have to spend some time to get away from the remaining code from Jim''s Adams Programming Role Playing Games with DirectX. Don''t get me wrong, it is a good book; but IMHO it is hard for any book wrapper to meet your needs over the long run.
_______________________________________
Understanding is a three edged sword...
Have your independent game reviewed by your peers on the www.FreelanceGames.com review ladder.
_______________________________________
Understanding is a three edged sword...
Have your independent game reviewed by your peers on the www.FreelanceGames.com review ladder.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement