aboutsummaryrefslogtreecommitdiff
path: root/source/Irrlicht/CWGLManager.cpp
diff options
context:
space:
mode:
authorhecks <42101236+hecktest@users.noreply.github.com>2021-08-07 21:56:00 +0200
committerGitHub <noreply@github.com>2021-08-07 21:56:00 +0200
commit5bf68b5731b1817c31959b8e3adf19a4c2307630 (patch)
treebcd0af6f07df105882f0353cd610abf00e26fe2e /source/Irrlicht/CWGLManager.cpp
parent7709e1e5f8d8429308ae20d366171fdf6e64bee8 (diff)
downloadirrlicht-5bf68b5731b1817c31959b8e3adf19a4c2307630.tar.xz
Add a unified cross platform OpenGL core profile binding (#52)
Diffstat (limited to 'source/Irrlicht/CWGLManager.cpp')
-rw-r--r--source/Irrlicht/CWGLManager.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/source/Irrlicht/CWGLManager.cpp b/source/Irrlicht/CWGLManager.cpp
index b807acb..3d6e4f8 100644
--- a/source/Irrlicht/CWGLManager.cpp
+++ b/source/Irrlicht/CWGLManager.cpp
@@ -21,7 +21,7 @@ namespace video
{
CWGLManager::CWGLManager()
- : PrimaryContext(SExposedVideoData(0)), PixelFormat(0)
+ : PrimaryContext(SExposedVideoData(0)), PixelFormat(0), libHandle(NULL)
{
#ifdef _DEBUG
setDebugName("CWGLManager");
@@ -322,6 +322,8 @@ void CWGLManager::terminate()
if (PrimaryContext.OpenGLWin32.HDc && PrimaryContext.OpenGLWin32.HDc == CurrentContext.OpenGLWin32.HDc)
memset(&PrimaryContext, 0, sizeof(PrimaryContext));
memset(&CurrentContext, 0, sizeof(CurrentContext));
+ if (libHandle)
+ FreeLibrary(libHandle);
}
bool CWGLManager::generateSurface()
@@ -367,7 +369,7 @@ bool CWGLManager::generateSurface()
if (PixelFormat)
break;
}
-
+
// set pixel format
if (!SetPixelFormat(HDc, PixelFormat, &pfd))
{
@@ -490,6 +492,19 @@ void CWGLManager::destroyContext()
}
}
+void* CWGLManager::getProcAddress(const std::string &procName)
+{
+ void* proc = NULL;
+ proc = (void*)wglGetProcAddress(procName.c_str());
+ if (!proc) { // Fallback
+ if (!libHandle)
+ libHandle = LoadLibraryA("opengl32.dll");
+ if (libHandle)
+ proc = (void*)GetProcAddress(libHandle, procName.c_str());
+ }
+ return proc;
+}
+
bool CWGLManager::swapBuffers()
{
return SwapBuffers((HDC)CurrentContext.OpenGLWin32.HDc) == TRUE;