mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
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:
@ -82,11 +82,6 @@ void OpenGL_SetWindowText(const char *text)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void*& VideoWindowHandle()
|
||||
{
|
||||
return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow;
|
||||
}
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
|
||||
@ -320,7 +315,7 @@ void XEventThread()
|
||||
|
||||
// Create rendering window.
|
||||
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
|
||||
bool OpenGL_Create(int _iwidth, int _iheight)
|
||||
bool OpenGL_Create(void *&window_handle)
|
||||
{
|
||||
int _tx, _ty, _twidth, _theight;
|
||||
Core::Callback_VideoGetWindowSize(_tx, _ty, _twidth, _theight);
|
||||
@ -330,7 +325,7 @@ bool OpenGL_Create(int _iwidth, int _iheight)
|
||||
s_backbuffer_height = _theight;
|
||||
|
||||
#if defined(USE_WX) && USE_WX
|
||||
GLWin.panel = (wxPanel *)VideoWindowHandle();
|
||||
GLWin.panel = (wxPanel *)window_handle;
|
||||
GLWin.glCanvas = new wxGLCanvas(GLWin.panel, wxID_ANY, NULL,
|
||||
wxPoint(0, 0), wxSize(_twidth, _theight));
|
||||
GLWin.glCanvas->Show(true);
|
||||
@ -364,7 +359,6 @@ bool OpenGL_Create(int _iwidth, int _iheight)
|
||||
style |= NSResizableWindowMask | NSTitledWindowMask;
|
||||
}
|
||||
|
||||
(void)VideoWindowHandle;
|
||||
GLWin.cocoaWin = [[NSWindow alloc] initWithContentRect: size
|
||||
styleMask: style backing: NSBackingStoreBuffered defer: NO];
|
||||
if (GLWin.cocoaWin == nil) {
|
||||
@ -381,8 +375,8 @@ bool OpenGL_Create(int _iwidth, int _iheight)
|
||||
[GLWin.cocoaWin makeKeyAndOrderFront: nil];
|
||||
|
||||
#elif defined(_WIN32)
|
||||
VideoWindowHandle() = (void*)EmuWindow::Create((HWND)VideoWindowHandle(), GetModuleHandle(0), _T("Please wait..."));
|
||||
if (VideoWindowHandle() == NULL)
|
||||
window_handle = (void*)EmuWindow::Create((HWND)window_handle, GetModuleHandle(0), _T("Please wait..."));
|
||||
if (window_handle == NULL)
|
||||
{
|
||||
Host_SysMessage("failed to create window");
|
||||
return false;
|
||||
@ -466,7 +460,7 @@ bool OpenGL_Create(int _iwidth, int _iheight)
|
||||
|
||||
GLWin.dpy = XOpenDisplay(0);
|
||||
GLWin.evdpy = XOpenDisplay(0);
|
||||
GLWin.parent = (Window)VideoWindowHandle();
|
||||
GLWin.parent = (Window)window_handle;
|
||||
GLWin.screen = DefaultScreen(GLWin.dpy);
|
||||
if (GLWin.parent == 0)
|
||||
GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
|
||||
@ -510,7 +504,7 @@ bool OpenGL_Create(int _iwidth, int _iheight)
|
||||
GLWin.height = _theight;
|
||||
|
||||
CreateXWindow();
|
||||
VideoWindowHandle() = (void *)GLWin.win;
|
||||
window_handle = (void *)GLWin.win;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ extern GLWindow GLWin;
|
||||
// Public OpenGL util
|
||||
|
||||
// Initialization / upkeep
|
||||
bool OpenGL_Create(int _width, int _height);
|
||||
bool OpenGL_Create(void *&);
|
||||
void OpenGL_Shutdown();
|
||||
void OpenGL_Update();
|
||||
bool OpenGL_MakeCurrent();
|
||||
|
@ -9,7 +9,7 @@ namespace OGL
|
||||
|
||||
class VideoBackend : public VideoBackendHLE
|
||||
{
|
||||
void Initialize();
|
||||
bool Initialize(void *&);
|
||||
void Shutdown();
|
||||
|
||||
std::string GetName();
|
||||
|
@ -157,7 +157,7 @@ void VideoBackend::ShowConfig(void *_hParent)
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoBackend::Initialize()
|
||||
bool VideoBackend::Initialize(void *&window_handle)
|
||||
{
|
||||
InitBackendInfo();
|
||||
|
||||
@ -170,11 +170,13 @@ void VideoBackend::Initialize()
|
||||
|
||||
UpdateActiveConfig();
|
||||
|
||||
if (!OpenGL_Create(640, 480))
|
||||
return;
|
||||
if (!OpenGL_Create(window_handle))
|
||||
return false;
|
||||
|
||||
OSD::AddMessage("Dolphin OpenGL Video Backend.", 5000);
|
||||
s_BackendInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is called after Initialize() from the Core
|
||||
|
Reference in New Issue
Block a user