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

@ -7,6 +7,7 @@
#ifdef _IRR_COMPILE_WITH_GLX_MANAGER_
#include "os.h"
#include <dlfcn.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1
@ -28,7 +29,7 @@ namespace video
{
CGLXManager::CGLXManager(const SIrrlichtCreationParameters& params, const SExposedVideoData& videodata, int screennr)
: Params(params), PrimaryContext(videodata), VisualInfo(0), glxFBConfig(0), GlxWin(0)
: Params(params), PrimaryContext(videodata), VisualInfo(0), glxFBConfig(0), GlxWin(0), libHandle(NULL)
{
#ifdef _DEBUG
setDebugName("CGLXManager");
@ -279,6 +280,8 @@ bool CGLXManager::initialize(const SIrrlichtCreationParameters& params, const SE
void CGLXManager::terminate()
{
if (libHandle)
dlclose(libHandle);
memset(&CurrentContext, 0, sizeof(CurrentContext));
}
@ -428,6 +431,19 @@ void CGLXManager::destroyContext()
}
}
void* CGLXManager::getProcAddress(const std::string &procName)
{
void* proc = NULL;
proc = (void*)glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(procName.c_str()));
if (!proc) {
if (!libHandle)
libHandle = dlopen("libGL.so", RTLD_LAZY);
if (libHandle)
proc = dlsym(libHandle, procName.c_str());
}
return proc;
}
bool CGLXManager::swapBuffers()
{
glXSwapBuffers((Display*)CurrentContext.OpenGLLinux.X11Display, CurrentContext.OpenGLLinux.GLXWindow);