From de3f4d03baa67f3383b4348c9f8d875c391a5d53 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 10 Apr 2013 22:07:57 -0700 Subject: [PATCH] Update WindowsHeadlessHost to fix graphic tests. Although I'm not sure if they actually work... --- headless/Headless.cpp | 4 ++-- headless/StubHost.h | 4 +--- headless/WindowsHeadlessHost.cpp | 10 +++++----- headless/WindowsHeadlessHost.h | 4 +--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 6de97bb4e5..07e8cd63da 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -150,7 +150,7 @@ int main(int argc, const char* argv[]) host = headlessHost; std::string error_string; - host->InitGL(&error_string); + bool glWorking = host->InitGL(&error_string); LogManager::Init(); LogManager *logman = LogManager::GetInstance(); @@ -170,7 +170,7 @@ int main(int argc, const char* argv[]) coreParameter.mountIso = mountIso ? mountIso : ""; coreParameter.startPaused = false; coreParameter.cpuCore = useJit ? CPU_JIT : CPU_INTERPRETER; - coreParameter.gpuCore = headlessHost->isGLWorking() ? GPU_GLES : GPU_NULL; + coreParameter.gpuCore = glWorking ? GPU_GLES : GPU_NULL; coreParameter.enableSound = false; coreParameter.headLess = true; coreParameter.printfEmuLog = true; diff --git a/headless/StubHost.h b/headless/StubHost.h index 5a17b07c56..70cc2dcc47 100644 --- a/headless/StubHost.h +++ b/headless/StubHost.h @@ -33,7 +33,7 @@ public: virtual void SetDebugMode(bool mode) { } - virtual bool InitGL(std::string *error_message) {return true;} + virtual bool InitGL(std::string *error_message) {return false;} virtual void ShutdownGL() {} virtual void InitSound(PMixer *mixer) {} @@ -49,8 +49,6 @@ public: virtual void SendDebugOutput(const std::string &output) { printf("%s", output.c_str()); } virtual void SetComparisonScreenshot(const std::string &filename) {} - virtual bool isGLWorking() { return false; } - // Unique for HeadlessHost virtual void SwapBuffers() {} diff --git a/headless/WindowsHeadlessHost.cpp b/headless/WindowsHeadlessHost.cpp index b3b13a37a9..f2337692fc 100644 --- a/headless/WindowsHeadlessHost.cpp +++ b/headless/WindowsHeadlessHost.cpp @@ -78,6 +78,8 @@ void WindowsHeadlessHost::LoadNativeAssets() VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader("")); VFSRegister("", new DirectoryAssetReader("../")); + VFSRegister("", new DirectoryAssetReader("../Windows/assets/")); + VFSRegister("", new DirectoryAssetReader("../Windows/")); gl_lost_manager_init(); @@ -138,9 +140,8 @@ void WindowsHeadlessHost::SetComparisonScreenshot(const std::string &filename) comparisonScreenshot = filename; } -void WindowsHeadlessHost::InitGL() +bool WindowsHeadlessHost::InitGL(std::string *error_message) { - glOkay = false; hWnd = CreateHiddenWindow(); if (WINDOW_VISIBLE) @@ -160,7 +161,7 @@ void WindowsHeadlessHost::InitGL() pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; -#define ENFORCE(x, msg) { if (!(x)) { fprintf(stderr, msg); return; } } +#define ENFORCE(x, msg) { if (!(x)) { fprintf(stderr, msg); *error_message = msg; return false; } } ENFORCE(hDC = GetDC(hWnd), "Unable to create DC."); ENFORCE(pixelFormat = ChoosePixelFormat(hDC, &pfd), "Unable to match pixel format."); @@ -175,8 +176,7 @@ void WindowsHeadlessHost::InitGL() LoadNativeAssets(); - if (ResizeGL()) - glOkay = true; + return ResizeGL(); } void WindowsHeadlessHost::ShutdownGL() diff --git a/headless/WindowsHeadlessHost.h b/headless/WindowsHeadlessHost.h index faf5c7b54a..022a2c6065 100644 --- a/headless/WindowsHeadlessHost.h +++ b/headless/WindowsHeadlessHost.h @@ -28,9 +28,8 @@ class WindowsHeadlessHost : public HeadlessHost { public: - virtual void InitGL(); + virtual bool InitGL(std::string *error_message); virtual void ShutdownGL(); - virtual bool isGLWorking() { return glOkay; } virtual void SwapBuffers(); @@ -42,7 +41,6 @@ private: bool ResizeGL(); void LoadNativeAssets(); - bool glOkay; HWND hWnd; HDC hDC; HGLRC hRC;