If video backend initialization fails, have the emulator die gracefully instead of crashing the application. Also a little clean up of the passage of the video window handle to the backend and back.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7248 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2011-02-25 21:14:13 +00:00
parent eef715b1cf
commit 992f8be5b0
17 changed files with 53 additions and 96 deletions

View File

@ -16,7 +16,6 @@
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#include "Core.h"
#include "../../Plugin_VideoOGL/Src/GLUtil.h"
#include "SWRenderer.h"
@ -31,11 +30,6 @@ RasterFont* s_pfont = NULL;
void SWRenderer::Init()
{
if (!OpenGL_Create(640, 480)) // 640x480 will be the default if all else fails
{
Core::Callback_VideoLog("SWRenderer::Create failed\n");
return;
}
}
void SWRenderer::Shutdown()

View File

@ -39,6 +39,7 @@
#include "FileUtil.h"
#include "VideoBackend.h"
#include "../../../Core/VideoCommon/Src/Fifo.h"
#include "Core.h"
namespace SW
{
@ -62,10 +63,16 @@ void VideoBackend::ShowConfig(void *_hParent)
#endif
}
void VideoBackend::Initialize()
bool VideoBackend::Initialize(void *&window_handle)
{
g_SWVideoConfig.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_software.ini").c_str());
if (!OpenGL_Create(window_handle))
{
Core::Callback_VideoLog("SWRenderer::Create failed\n");
return false;
}
InitBPMemory();
InitXFMemory();
SWCommandProcessor::Init();
@ -76,6 +83,8 @@ void VideoBackend::Initialize()
HwRasterizer::Init();
SWRenderer::Init();
DebugUtil::Init();
return true;
}
void VideoBackend::DoState(PointerWrap&)

View File

@ -9,7 +9,7 @@ namespace SW
class VideoBackend : public VideoBackendLLE
{
void Initialize();
bool Initialize(void *&);
void Shutdown();
std::string GetName();

View File

@ -43,11 +43,6 @@ WNDCLASSEX wndClass;
const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
int g_winstyle;
static void*& VideoWindowHandle()
{
return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow;
}
// ------------------------------------------
/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make
an empty transparent cursor */
@ -206,44 +201,14 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
CreateCursors(/*m_hInstance*/GetModuleHandle(0));
// Create child window
if (parent)
{
m_hParent = parent;
m_hParent = parent;
m_hWnd = CreateWindow(m_szClassName, title,
m_hWnd = CreateWindow(m_szClassName, title,
WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
parent, NULL, hInstance, NULL);
ShowWindow(m_hWnd, SW_SHOWMAXIMIZED);
}
// Create new separate window
else
{
DWORD style = g_SWVideoConfig.bFullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW;
RECT rc = {0, 0, width, height};
AdjustWindowRect(&rc, style, false);
int w = rc.right - rc.left;
int h = rc.bottom - rc.top;
rc.left = (1280 - w)/2;
rc.right = rc.left + w;
rc.top = (1024 - h)/2;
rc.bottom = rc.top + h;
m_hParent = (HWND)VideoWindowHandle();
m_hWnd = CreateWindow(m_szClassName, title,
style,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
parent, NULL, hInstance, NULL );
g_winstyle = GetWindowLong( m_hWnd, GWL_STYLE );
g_winstyle &= ~WS_MAXIMIZE & ~WS_MINIMIZE; // remove minimize/maximize style
}
ShowWindow(m_hWnd, SW_SHOWMAXIMIZED);
return m_hWnd;
}