Merge pull request #3433 from lioncash/gl

GLInterface: Minor changes
This commit is contained in:
Markus Wick 2016-01-04 13:49:40 +01:00
commit d29b406292
5 changed files with 41 additions and 39 deletions

View File

@ -13,15 +13,15 @@
class cInterfaceAGL : public cInterfaceBase class cInterfaceAGL : public cInterfaceBase
{ {
private: private:
NSView *cocoaWin; NSView* cocoaWin;
NSOpenGLContext *cocoaCtx; NSOpenGLContext* cocoaCtx;
public: public:
void Swap(); void Swap() override;
bool Create(void *window_handle, bool core); bool Create(void* window_handle, bool core) override;
bool MakeCurrent(); bool MakeCurrent() override;
bool ClearCurrent(); bool ClearCurrent() override;
void Shutdown(); void Shutdown() override;
void Update(); void Update() override;
void SwapInterval(int interval); void SwapInterval(int interval) override;
}; };

View File

@ -25,7 +25,7 @@ void* cInterfaceEGL::GetFuncAddress(const std::string& name)
void cInterfaceEGL::DetectMode() void cInterfaceEGL::DetectMode()
{ {
if (s_opengl_mode != MODE_DETECT) if (s_opengl_mode != GLInterfaceMode::MODE_DETECT)
return; return;
EGLint num_configs; EGLint num_configs;
@ -136,15 +136,15 @@ bool cInterfaceEGL::Create(void *window_handle, bool core)
}; };
switch (s_opengl_mode) switch (s_opengl_mode)
{ {
case MODE_OPENGL: case GLInterfaceMode::MODE_OPENGL:
attribs[1] = EGL_OPENGL_BIT; attribs[1] = EGL_OPENGL_BIT;
ctx_attribs[0] = EGL_NONE; ctx_attribs[0] = EGL_NONE;
break; break;
case MODE_OPENGLES2: case GLInterfaceMode::MODE_OPENGLES2:
attribs[1] = EGL_OPENGL_ES2_BIT; attribs[1] = EGL_OPENGL_ES2_BIT;
ctx_attribs[1] = 2; ctx_attribs[1] = 2;
break; break;
case MODE_OPENGLES3: case GLInterfaceMode::MODE_OPENGLES3:
attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */ attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */
ctx_attribs[1] = 3; ctx_attribs[1] = 3;
break; break;
@ -160,7 +160,7 @@ bool cInterfaceEGL::Create(void *window_handle, bool core)
exit(1); exit(1);
} }
if (s_opengl_mode == MODE_OPENGL) if (s_opengl_mode == GLInterfaceMode::MODE_OPENGL)
eglBindAPI(EGL_OPENGL_API); eglBindAPI(EGL_OPENGL_API);
else else
eglBindAPI(EGL_OPENGL_ES_API); eglBindAPI(EGL_OPENGL_ES_API);

View File

@ -21,12 +21,12 @@ protected:
virtual EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) = 0; virtual EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) = 0;
virtual void ShutdownPlatform() = 0; virtual void ShutdownPlatform() = 0;
public: public:
void SwapInterval(int Interval); void Swap() override;
void Swap(); void SwapInterval(int interval) override;
void SetMode(u32 mode) { s_opengl_mode = mode; } void SetMode(GLInterfaceMode mode) override { s_opengl_mode = mode; }
void* GetFuncAddress(const std::string& name); void* GetFuncAddress(const std::string& name) override;
bool Create(void *window_handle, bool core); bool Create(void* window_handle, bool core) override;
bool MakeCurrent(); bool MakeCurrent() override;
bool ClearCurrent(); bool ClearCurrent() override;
void Shutdown(); void Shutdown() override;
}; };

View File

@ -10,16 +10,17 @@
class cInterfaceWGL : public cInterfaceBase class cInterfaceWGL : public cInterfaceBase
{ {
public: public:
void SwapInterval(int Interval); void SwapInterval(int interval) override;
void Swap(); void Swap() override;
void* GetFuncAddress(const std::string& name); void* GetFuncAddress(const std::string& name) override;
bool Create(void *window_handle, bool core); bool Create(void* window_handle, bool core) override;
bool MakeCurrent(); bool MakeCurrent() override;
bool ClearCurrent(); bool ClearCurrent() override;
void Shutdown(); void Shutdown() override;
void Update(); void Update() override;
bool PeekMessages(); bool PeekMessages() override;
HWND m_window_handle; private:
HWND m_window_handle = nullptr;
}; };

View File

@ -9,8 +9,9 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
enum GLInterfaceMode { enum class GLInterfaceMode
MODE_DETECT = 0, {
MODE_DETECT,
MODE_OPENGL, MODE_OPENGL,
MODE_OPENGLES2, MODE_OPENGLES2,
MODE_OPENGLES3, MODE_OPENGLES3,
@ -20,15 +21,15 @@ class cInterfaceBase
{ {
protected: protected:
// Window dimensions. // Window dimensions.
u32 s_backbuffer_width; u32 s_backbuffer_width = 0;
u32 s_backbuffer_height; u32 s_backbuffer_height = 0;
u32 s_opengl_mode; GLInterfaceMode s_opengl_mode = GLInterfaceMode::MODE_DETECT;
public: public:
virtual ~cInterfaceBase() {} virtual ~cInterfaceBase() {}
virtual void Swap() {} virtual void Swap() {}
virtual void SetMode(u32 mode) { s_opengl_mode = GLInterfaceMode::MODE_OPENGL; } virtual void SetMode(GLInterfaceMode mode) { s_opengl_mode = GLInterfaceMode::MODE_OPENGL; }
virtual u32 GetMode() { return s_opengl_mode; } virtual GLInterfaceMode GetMode() { return s_opengl_mode; }
virtual void* GetFuncAddress(const std::string& name) { return nullptr; } virtual void* GetFuncAddress(const std::string& name) { return nullptr; }
virtual bool Create(void *window_handle, bool core = true) { return true; } virtual bool Create(void *window_handle, bool core = true) { return true; }
virtual bool MakeCurrent() { return true; } virtual bool MakeCurrent() { return true; }