diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 386785bda9..53f93d25b3 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -183,3 +183,11 @@ void GSWndGL::PopulateGlFunction() // renderer/device GLLoader::check_gl_requirements(); } + +void GSWndGL::FullContextInit() +{ + CreateContext(3, 3); + AttachContext(); + PopulateGlFunction(); + PopulateWndGlFunction(); +} diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index e05584a00c..981e5f2824 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -62,6 +62,10 @@ protected: bool m_ctx_attached; bool IsContextAttached() const { return m_ctx_attached; } + void PopulateGlFunction(); + virtual void PopulateWndGlFunction() = 0; + void FullContextInit(); + virtual void CreateContext(int major, int minor) = 0; public: GSWndGL() : m_ctx_attached(false) {}; @@ -85,6 +89,4 @@ public: virtual void HideFrame() = 0; virtual void Flip() = 0; virtual void SetVSync(int vsync) = 0; - - void PopulateGlFunction(); }; diff --git a/plugins/GSdx/GSWndEGL.cpp b/plugins/GSdx/GSWndEGL.cpp index a11e6d991a..c83492d6ad 100644 --- a/plugins/GSdx/GSWndEGL.cpp +++ b/plugins/GSdx/GSWndEGL.cpp @@ -153,6 +153,10 @@ void GSWndEGL::DetachContext() } } +void GSWndEGL::PopulateWndGlFunction() +{ +} + void GSWndEGL::BindAPI() { eglBindAPI(EGL_OPENGL_API); @@ -171,11 +175,7 @@ bool GSWndEGL::Attach(void* handle, bool managed) OpenEGLDisplay(); - CreateContext(3, 3); - - AttachContext(); - - PopulateGlFunction(); + FullContextInit(); return true; } @@ -209,11 +209,7 @@ bool GSWndEGL::Create(const string& title, int w, int h) m_native_window = CreateNativeWindow(w, h); - CreateContext(3, 3); - - AttachContext(); - - PopulateGlFunction(); + FullContextInit(); return true; } diff --git a/plugins/GSdx/GSWndEGL.h b/plugins/GSdx/GSWndEGL.h index e3edd6b57e..387065c30b 100644 --- a/plugins/GSdx/GSWndEGL.h +++ b/plugins/GSdx/GSWndEGL.h @@ -38,6 +38,7 @@ class GSWndEGL : public GSWndGL int m_platform; + void PopulateWndGlFunction(); void CreateContext(int major, int minor); void BindAPI(); diff --git a/plugins/GSdx/GSWndOGL.cpp b/plugins/GSdx/GSWndOGL.cpp index 37d3d4bb54..b9a6f0ff56 100644 --- a/plugins/GSdx/GSWndOGL.cpp +++ b/plugins/GSdx/GSWndOGL.cpp @@ -122,6 +122,12 @@ void GSWndOGL::DetachContext() } } +void GSWndOGL::PopulateWndGlFunction() +{ + m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); + m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); +} + bool GSWndOGL::Attach(void* handle, bool managed) { m_NativeWindow = *(Window*)handle; @@ -129,14 +135,7 @@ bool GSWndOGL::Attach(void* handle, bool managed) m_NativeDisplay = XOpenDisplay(NULL); - CreateContext(3, 3); - - AttachContext(); - - m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); - m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); - - PopulateGlFunction(); + FullContextInit(); return true; } @@ -175,14 +174,7 @@ bool GSWndOGL::Create(const string& title, int w, int h) if (m_NativeWindow == 0) throw GSDXRecoverableError(); - CreateContext(3, 3); - - AttachContext(); - - m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); - m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); - - PopulateGlFunction(); + FullContextInit(); return true; } diff --git a/plugins/GSdx/GSWndOGL.h b/plugins/GSdx/GSWndOGL.h index 0d8da9a2d7..012cf4f317 100644 --- a/plugins/GSdx/GSWndOGL.h +++ b/plugins/GSdx/GSWndOGL.h @@ -34,6 +34,7 @@ class GSWndOGL final : public GSWndGL PFNGLXSWAPINTERVALEXTPROC m_swapinterval_ext; PFNGLXSWAPINTERVALMESAPROC m_swapinterval_mesa; + void PopulateWndGlFunction(); void CreateContext(int major, int minor); public: diff --git a/plugins/GSdx/GSWndWGL.cpp b/plugins/GSdx/GSWndWGL.cpp index b5cb1d22a7..16424ab8af 100644 --- a/plugins/GSdx/GSWndWGL.cpp +++ b/plugins/GSdx/GSWndWGL.cpp @@ -139,6 +139,11 @@ void GSWndWGL::DetachContext() } } +void GSWndWGL::PopulateWndGlFunction() +{ + m_swapinterval = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); +} + bool GSWndWGL::Attach(void* handle, bool managed) { m_NativeWindow = (HWND)handle; @@ -146,13 +151,7 @@ bool GSWndWGL::Attach(void* handle, bool managed) OpenWGLDisplay(); - CreateContext(3, 3); - - AttachContext(); - - m_swapinterval = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); - - PopulateGlFunction(); + FullContextInit(); UpdateWindow(m_NativeWindow); @@ -288,16 +287,9 @@ bool GSWndWGL::Create(const string& title, int w, int h) OpenWGLDisplay(); - CreateContext(3, 3); - - AttachContext(); - - m_swapinterval = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); - - PopulateGlFunction(); + FullContextInit(); return true; - } //Same as DX diff --git a/plugins/GSdx/GSWndWGL.h b/plugins/GSdx/GSWndWGL.h index c4ccec4a2d..643893042f 100644 --- a/plugins/GSdx/GSWndWGL.h +++ b/plugins/GSdx/GSWndWGL.h @@ -31,6 +31,7 @@ class GSWndWGL : public GSWndGL PFNWGLSWAPINTERVALEXTPROC m_swapinterval; + void PopulateWndGlFunction(); void CreateContext(int major, int minor); void CloseWGLDisplay();