fix crashes when fullscreen d3d window loses focus

This commit is contained in:
Glenn Maynard
2004-09-19 01:38:12 +00:00
parent 3dff054839
commit f056fedae2
7 changed files with 20 additions and 11 deletions
+1 -1
View File
@@ -158,7 +158,7 @@ public:
/* Call this when the resolution has been changed externally: */
virtual void ResolutionChanged() { }
virtual void BeginFrame() = 0;
virtual bool BeginFrame() = 0;
virtual void EndFrame() = 0;
virtual VideoModeParams GetVideoModeParams() const = 0;
bool IsWindowed() const { return this->GetVideoModeParams().windowed; }
+10 -3
View File
@@ -620,16 +620,23 @@ int RageDisplay_D3D::GetMaxTextureSize() const
return g_DeviceCaps.MaxTextureWidth;
}
void RageDisplay_D3D::BeginFrame()
bool RageDisplay_D3D::BeginFrame()
{
#ifndef _XBOX
if( g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET )
#if !defined(XBOX)
switch( g_pd3dDevice->TestCooperativeLevel() )
{
case D3DERR_DEVICELOST:
return false;
case D3DERR_DEVICENOTRESET:
SetVideoMode( g_CurrentParams );
break;
}
#endif
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
g_pd3dDevice->BeginScene();
return true;
}
void RageDisplay_D3D::EndFrame()
+1 -1
View File
@@ -26,7 +26,7 @@ public:
void ResolutionChanged();
const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const;
void BeginFrame();
bool BeginFrame();
void EndFrame();
VideoModeParams GetVideoModeParams() const;
void SetBlendMode( BlendMode mode );
+1 -1
View File
@@ -12,7 +12,7 @@ public:
void ResolutionChanged() { }
const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const;
void BeginFrame() { }
bool BeginFrame() { return true; }
void EndFrame();
VideoModeParams GetVideoModeParams() const { return m_Params; }
void SetBlendMode( BlendMode mode ) { }
+4 -3
View File
@@ -743,8 +743,8 @@ void RageDisplay_OGL::ResolutionChanged()
SetViewport(0,0);
/* Clear any junk that's in the framebuffer. */
BeginFrame();
EndFrame();
if( BeginFrame() )
EndFrame();
}
// Return true if mode change was successful.
@@ -803,11 +803,12 @@ int RageDisplay_OGL::GetMaxTextureSize() const
return size;
}
void RageDisplay_OGL::BeginFrame()
bool RageDisplay_OGL::BeginFrame()
{
glClearColor( 0,0,0,1 );
SetZWrite( true );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
return true;
}
void RageDisplay_OGL::EndFrame()
+1 -1
View File
@@ -14,7 +14,7 @@ public:
void ResolutionChanged();
const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const;
void BeginFrame();
bool BeginFrame();
void EndFrame();
VideoModeParams GetVideoModeParams() const;
void SetBlendMode( BlendMode mode );
+2 -1
View File
@@ -469,7 +469,8 @@ void ScreenManager::Draw()
if( m_ScreenStack.back()->IsFirstUpdate() )
return;
DISPLAY->BeginFrame();
if( !DISPLAY->BeginFrame() )
return;
if( !m_ScreenStack.empty() && !m_ScreenStack.back()->IsTransparent() ) // top screen isn't transparent
m_ScreenStack.back()->Draw();