mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07: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:
parent
eef715b1cf
commit
992f8be5b0
@ -86,7 +86,7 @@ public:
|
||||
|
||||
virtual unsigned int PeekMessages() = 0;
|
||||
|
||||
virtual void Initialize() = 0;
|
||||
virtual bool Initialize(void *&) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void DoState(PointerWrap &p) = 0;
|
||||
|
@ -120,7 +120,6 @@ bool BootCore(const std::string& _rFilename)
|
||||
}
|
||||
|
||||
// Run the game
|
||||
StartUp.hMainWindow = Host_GetRenderHandle();
|
||||
// Init the core
|
||||
if (!Core::Init())
|
||||
{
|
||||
|
@ -215,13 +215,16 @@ bool Init()
|
||||
GetData<u8>("IPL.AR"));
|
||||
}
|
||||
|
||||
// _CoreParameter.hMainWindow is first the m_Panel handle,
|
||||
// then it is updated to have the new window handle,
|
||||
// g_pWindowHandle is first the m_Panel handle,
|
||||
// then it is updated to the render window handle,
|
||||
// within g_video_backend->Initialize()
|
||||
// TODO: that's ugly, change Initialize() to take m_Panel
|
||||
// and return the new window handle
|
||||
g_video_backend->Initialize();
|
||||
g_pWindowHandle = _CoreParameter.hMainWindow;
|
||||
g_pWindowHandle = Host_GetRenderHandle();
|
||||
if (!g_video_backend->Initialize(g_pWindowHandle))
|
||||
{
|
||||
emuThreadGoing.Shutdown();
|
||||
Host_SetWaitCursor(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
HW::Init();
|
||||
DSP::GetDSPEmulator()->Initialize(g_pWindowHandle,
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "Core.h" // for bWii
|
||||
|
||||
SCoreStartupParameter::SCoreStartupParameter()
|
||||
: hInstance(0), hMainWindow(0),
|
||||
: hInstance(0),
|
||||
bJITNoBlockCache(false), bJITBlockLinking(true),
|
||||
bJITOff(false),
|
||||
bJITLoadStoreOff(false), bJITLoadStorelXzOff(false),
|
||||
|
@ -69,9 +69,6 @@ struct SCoreStartupParameter
|
||||
{
|
||||
void* hInstance; // HINSTANCE but we don't want to include <windows.h>
|
||||
|
||||
// Windows/GUI related
|
||||
void* hMainWindow;
|
||||
|
||||
// Settings
|
||||
bool bEnableDebugging;
|
||||
bool bAutomaticStart;
|
||||
|
@ -9,7 +9,7 @@ namespace DX11
|
||||
|
||||
class VideoBackend : public VideoBackendHLE
|
||||
{
|
||||
void Initialize();
|
||||
bool Initialize(void *&);
|
||||
void Shutdown();
|
||||
|
||||
std::string GetName();
|
||||
|
@ -52,11 +52,6 @@
|
||||
namespace DX11
|
||||
{
|
||||
|
||||
void*& VideoWindowHandle()
|
||||
{
|
||||
return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow;
|
||||
}
|
||||
|
||||
unsigned int VideoBackend::PeekMessages()
|
||||
{
|
||||
MSG msg;
|
||||
@ -158,7 +153,7 @@ void VideoBackend::ShowConfig(void *_hParent)
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoBackend::Initialize()
|
||||
bool VideoBackend::Initialize(void *&window_handle)
|
||||
{
|
||||
InitBackendInfo();
|
||||
|
||||
@ -169,15 +164,17 @@ void VideoBackend::Initialize()
|
||||
UpdateProjectionHack(g_Config.iPhackvalue, g_Config.sPhackvalue);
|
||||
UpdateActiveConfig();
|
||||
|
||||
VideoWindowHandle() = (void*)EmuWindow::Create((HWND)VideoWindowHandle(), GetModuleHandle(0), _T("Loading - Please wait."));
|
||||
if (VideoWindowHandle() == NULL)
|
||||
window_handle = (void*)EmuWindow::Create((HWND)window_handle, GetModuleHandle(0), _T("Loading - Please wait."));
|
||||
if (window_handle == NULL)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "An error has occurred while trying to create the window.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
OSD::AddMessage("Dolphin Direct3D11 Video Backend.", 5000);
|
||||
s_BackendInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VideoBackend::Video_Prepare()
|
||||
|
@ -9,7 +9,7 @@ namespace DX9
|
||||
|
||||
class VideoBackend : public VideoBackendHLE
|
||||
{
|
||||
void Initialize();
|
||||
bool Initialize(void *&);
|
||||
void Shutdown();
|
||||
|
||||
std::string GetName();
|
||||
|
@ -60,11 +60,6 @@
|
||||
namespace DX9
|
||||
{
|
||||
|
||||
void*& VideoWindowHandle()
|
||||
{
|
||||
return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow;
|
||||
}
|
||||
|
||||
unsigned int VideoBackend::PeekMessages()
|
||||
{
|
||||
MSG msg;
|
||||
@ -138,7 +133,7 @@ void VideoBackend::ShowConfig(void* parent)
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoBackend::Initialize()
|
||||
bool VideoBackend::Initialize(void *&window_handle)
|
||||
{
|
||||
InitBackendInfo();
|
||||
|
||||
@ -149,20 +144,22 @@ void VideoBackend::Initialize()
|
||||
UpdateProjectionHack(g_Config.iPhackvalue, g_Config.sPhackvalue); // DX9 projection hack could be disabled by commenting out this line
|
||||
UpdateActiveConfig();
|
||||
|
||||
VideoWindowHandle() = (void*)EmuWindow::Create((HWND)VideoWindowHandle(), GetModuleHandle(0), _T("Loading - Please wait."));
|
||||
if (VideoWindowHandle() == NULL)
|
||||
window_handle = (void*)EmuWindow::Create((HWND)window_handle, GetModuleHandle(0), _T("Loading - Please wait."));
|
||||
if (window_handle == NULL)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "An error has occurred while trying to create the window.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
else if (FAILED(DX9::D3D::Init()))
|
||||
{
|
||||
MessageBox(GetActiveWindow(), _T("Unable to initialize Direct3D. Please make sure that you have the latest version of DirectX 9.0c correctly installed."), _T("Fatal Error"), MB_ICONERROR|MB_OK);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
OSD::AddMessage("Dolphin Direct3D9 Video Backend.", 5000);
|
||||
s_BackendInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VideoBackend::Video_Prepare()
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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&)
|
||||
|
@ -9,7 +9,7 @@ namespace SW
|
||||
|
||||
class VideoBackend : public VideoBackendLLE
|
||||
{
|
||||
void Initialize();
|
||||
bool Initialize(void *&);
|
||||
void Shutdown();
|
||||
|
||||
std::string GetName();
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user