Add a unified cross platform OpenGL core profile binding (#52)

This commit is contained in:
hecks
2021-08-07 21:56:00 +02:00
committed by GitHub
parent 7709e1e5f8
commit 5bf68b5731
16 changed files with 4466 additions and 22 deletions

View File

@ -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;