mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl: factorize common context init code
This commit is contained in:
parent
66a87ce4d0
commit
2204885fbb
|
@ -183,3 +183,11 @@ void GSWndGL::PopulateGlFunction()
|
|||
// renderer/device
|
||||
GLLoader::check_gl_requirements();
|
||||
}
|
||||
|
||||
void GSWndGL::FullContextInit()
|
||||
{
|
||||
CreateContext(3, 3);
|
||||
AttachContext();
|
||||
PopulateGlFunction();
|
||||
PopulateWndGlFunction();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ class GSWndEGL : public GSWndGL
|
|||
|
||||
int m_platform;
|
||||
|
||||
void PopulateWndGlFunction();
|
||||
void CreateContext(int major, int minor);
|
||||
void BindAPI();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -31,6 +31,7 @@ class GSWndWGL : public GSWndGL
|
|||
|
||||
PFNWGLSWAPINTERVALEXTPROC m_swapinterval;
|
||||
|
||||
void PopulateWndGlFunction();
|
||||
void CreateContext(int major, int minor);
|
||||
|
||||
void CloseWGLDisplay();
|
||||
|
|
Loading…
Reference in New Issue