From df2f6089bea14e5de3bdd520542c1f7ec31f1246 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 2 Jan 2016 14:12:32 -0500 Subject: [PATCH 1/4] GLInterface: Add missing override specifiers --- Source/Core/Common/GL/GLInterface/AGL.h | 18 +++++++++--------- Source/Core/Common/GL/GLInterface/EGL.h | 16 ++++++++-------- Source/Core/Common/GL/GLInterface/WGL.h | 18 +++++++++--------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Source/Core/Common/GL/GLInterface/AGL.h b/Source/Core/Common/GL/GLInterface/AGL.h index b08b7ec802..f9aeb77a95 100644 --- a/Source/Core/Common/GL/GLInterface/AGL.h +++ b/Source/Core/Common/GL/GLInterface/AGL.h @@ -13,15 +13,15 @@ class cInterfaceAGL : public cInterfaceBase { private: - NSView *cocoaWin; - NSOpenGLContext *cocoaCtx; + NSView* cocoaWin; + NSOpenGLContext* cocoaCtx; public: - void Swap(); - bool Create(void *window_handle, bool core); - bool MakeCurrent(); - bool ClearCurrent(); - void Shutdown(); - void Update(); - void SwapInterval(int interval); + void Swap() override; + bool Create(void* window_handle, bool core) override; + bool MakeCurrent() override; + bool ClearCurrent() override; + void Shutdown() override; + void Update() override; + void SwapInterval(int interval) override; }; diff --git a/Source/Core/Common/GL/GLInterface/EGL.h b/Source/Core/Common/GL/GLInterface/EGL.h index f25b129d90..f3a769dfd8 100644 --- a/Source/Core/Common/GL/GLInterface/EGL.h +++ b/Source/Core/Common/GL/GLInterface/EGL.h @@ -21,12 +21,12 @@ protected: virtual EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) = 0; virtual void ShutdownPlatform() = 0; public: - void SwapInterval(int Interval); - void Swap(); - void SetMode(u32 mode) { s_opengl_mode = mode; } - void* GetFuncAddress(const std::string& name); - bool Create(void *window_handle, bool core); - bool MakeCurrent(); - bool ClearCurrent(); - void Shutdown(); + void Swap() override; + void SwapInterval(int interval) override; + void SetMode(u32 mode) override { s_opengl_mode = mode; } + void* GetFuncAddress(const std::string& name) override; + bool Create(void* window_handle, bool core) override; + bool MakeCurrent() override; + bool ClearCurrent() override; + void Shutdown() override; }; diff --git a/Source/Core/Common/GL/GLInterface/WGL.h b/Source/Core/Common/GL/GLInterface/WGL.h index 6a1b8c133e..8d77486247 100644 --- a/Source/Core/Common/GL/GLInterface/WGL.h +++ b/Source/Core/Common/GL/GLInterface/WGL.h @@ -10,16 +10,16 @@ class cInterfaceWGL : public cInterfaceBase { public: - void SwapInterval(int Interval); - void Swap(); - void* GetFuncAddress(const std::string& name); - bool Create(void *window_handle, bool core); - bool MakeCurrent(); - bool ClearCurrent(); - void Shutdown(); + void SwapInterval(int interval) override; + void Swap() override; + void* GetFuncAddress(const std::string& name) override; + bool Create(void* window_handle, bool core) override; + bool MakeCurrent() override; + bool ClearCurrent() override; + void Shutdown() override; - void Update(); - bool PeekMessages(); + void Update() override; + bool PeekMessages() override; HWND m_window_handle; }; From 11a7defdba576739688b73f815db736f5e52b277 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 2 Jan 2016 14:12:58 -0500 Subject: [PATCH 2/4] WGL: Make class member private --- Source/Core/Common/GL/GLInterface/WGL.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/GL/GLInterface/WGL.h b/Source/Core/Common/GL/GLInterface/WGL.h index 8d77486247..b82a521b16 100644 --- a/Source/Core/Common/GL/GLInterface/WGL.h +++ b/Source/Core/Common/GL/GLInterface/WGL.h @@ -21,5 +21,6 @@ public: void Update() override; bool PeekMessages() override; - HWND m_window_handle; +private: + HWND m_window_handle = nullptr; }; From df9c9ad706636f9e9a2bf14caebe09fba2ac79db Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 2 Jan 2016 14:14:59 -0500 Subject: [PATCH 3/4] GLInterfaceBase: In-class initialize protected members Gives the class a well-defined initial state --- Source/Core/Common/GL/GLInterfaceBase.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/GL/GLInterfaceBase.h b/Source/Core/Common/GL/GLInterfaceBase.h index 8fed61f0d4..5598f360b7 100644 --- a/Source/Core/Common/GL/GLInterfaceBase.h +++ b/Source/Core/Common/GL/GLInterfaceBase.h @@ -20,10 +20,10 @@ class cInterfaceBase { protected: // Window dimensions. - u32 s_backbuffer_width; - u32 s_backbuffer_height; + u32 s_backbuffer_width = 0; + u32 s_backbuffer_height = 0; - u32 s_opengl_mode; + u32 s_opengl_mode = GLInterfaceMode::MODE_DETECT; public: virtual ~cInterfaceBase() {} virtual void Swap() {} From f3c05d39b9558339838f22f8fd50f0a2d946252f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 2 Jan 2016 14:19:28 -0500 Subject: [PATCH 4/4] GLInterface: Make GLInterfaceMode an enum class --- Source/Core/Common/GL/GLInterface/EGL.cpp | 10 +++++----- Source/Core/Common/GL/GLInterface/EGL.h | 2 +- Source/Core/Common/GL/GLInterfaceBase.h | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Source/Core/Common/GL/GLInterface/EGL.cpp b/Source/Core/Common/GL/GLInterface/EGL.cpp index 8f42c98253..202568b2e9 100644 --- a/Source/Core/Common/GL/GLInterface/EGL.cpp +++ b/Source/Core/Common/GL/GLInterface/EGL.cpp @@ -25,7 +25,7 @@ void* cInterfaceEGL::GetFuncAddress(const std::string& name) void cInterfaceEGL::DetectMode() { - if (s_opengl_mode != MODE_DETECT) + if (s_opengl_mode != GLInterfaceMode::MODE_DETECT) return; EGLint num_configs; @@ -136,15 +136,15 @@ bool cInterfaceEGL::Create(void *window_handle, bool core) }; switch (s_opengl_mode) { - case MODE_OPENGL: + case GLInterfaceMode::MODE_OPENGL: attribs[1] = EGL_OPENGL_BIT; ctx_attribs[0] = EGL_NONE; break; - case MODE_OPENGLES2: + case GLInterfaceMode::MODE_OPENGLES2: attribs[1] = EGL_OPENGL_ES2_BIT; ctx_attribs[1] = 2; break; - case MODE_OPENGLES3: + case GLInterfaceMode::MODE_OPENGLES3: attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */ ctx_attribs[1] = 3; break; @@ -160,7 +160,7 @@ bool cInterfaceEGL::Create(void *window_handle, bool core) exit(1); } - if (s_opengl_mode == MODE_OPENGL) + if (s_opengl_mode == GLInterfaceMode::MODE_OPENGL) eglBindAPI(EGL_OPENGL_API); else eglBindAPI(EGL_OPENGL_ES_API); diff --git a/Source/Core/Common/GL/GLInterface/EGL.h b/Source/Core/Common/GL/GLInterface/EGL.h index f3a769dfd8..21f563f861 100644 --- a/Source/Core/Common/GL/GLInterface/EGL.h +++ b/Source/Core/Common/GL/GLInterface/EGL.h @@ -23,7 +23,7 @@ protected: public: void Swap() override; void SwapInterval(int interval) override; - void SetMode(u32 mode) override { s_opengl_mode = mode; } + void SetMode(GLInterfaceMode mode) override { s_opengl_mode = mode; } void* GetFuncAddress(const std::string& name) override; bool Create(void* window_handle, bool core) override; bool MakeCurrent() override; diff --git a/Source/Core/Common/GL/GLInterfaceBase.h b/Source/Core/Common/GL/GLInterfaceBase.h index 5598f360b7..d7885635bb 100644 --- a/Source/Core/Common/GL/GLInterfaceBase.h +++ b/Source/Core/Common/GL/GLInterfaceBase.h @@ -9,8 +9,9 @@ #include "Common/CommonTypes.h" -enum GLInterfaceMode { - MODE_DETECT = 0, +enum class GLInterfaceMode +{ + MODE_DETECT, MODE_OPENGL, MODE_OPENGLES2, MODE_OPENGLES3, @@ -23,12 +24,12 @@ protected: u32 s_backbuffer_width = 0; u32 s_backbuffer_height = 0; - u32 s_opengl_mode = GLInterfaceMode::MODE_DETECT; + GLInterfaceMode s_opengl_mode = GLInterfaceMode::MODE_DETECT; public: virtual ~cInterfaceBase() {} virtual void Swap() {} - virtual void SetMode(u32 mode) { s_opengl_mode = GLInterfaceMode::MODE_OPENGL; } - virtual u32 GetMode() { return s_opengl_mode; } + virtual void SetMode(GLInterfaceMode mode) { s_opengl_mode = GLInterfaceMode::MODE_OPENGL; } + virtual GLInterfaceMode GetMode() { return s_opengl_mode; } virtual void* GetFuncAddress(const std::string& name) { return nullptr; } virtual bool Create(void *window_handle, bool core = true) { return true; } virtual bool MakeCurrent() { return true; }