Moved OpenGL init and terminate to opengl module.

This commit is contained in:
Camilla Berglund
2012-04-23 13:00:49 +02:00
parent 49dfbe86b2
commit 9614b9b22f
3 changed files with 74 additions and 54 deletions
+4 -54
View File
@@ -36,33 +36,6 @@
#include <limits.h>
//========================================================================
// Dynamically load libraries
//========================================================================
static void initLibraries(void)
{
#ifdef _GLFW_DLOPEN_LIBGL
int i;
char* libGL_names[ ] =
{
"libGL.so",
"libGL.so.1",
"/usr/lib/libGL.so",
"/usr/lib/libGL.so.1",
NULL
};
for (i = 0; libGL_names[i] != NULL; i++)
{
_glfwLibrary.GLX.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (_glfwLibrary.GLX.libGL)
break;
}
#endif
}
//========================================================================
// Translate an X11 key code to a GLFW key code.
//========================================================================
@@ -561,22 +534,6 @@ static GLboolean initDisplay(void)
_glfwLibrary.X11.RandR.available = GL_FALSE;
#endif /*_GLFW_HAS_XRANDR*/
// Check if GLX is supported on this display
if (!glXQueryExtension(_glfwLibrary.X11.display, NULL, NULL))
{
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: GLX supported not found");
return GL_FALSE;
}
if (!glXQueryVersion(_glfwLibrary.X11.display,
&_glfwLibrary.GLX.majorVersion,
&_glfwLibrary.GLX.minorVersion))
{
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"X11/GLX: Failed to query GLX version");
return GL_FALSE;
}
// Check if Xkb is supported on this display
#if defined(_GLFW_HAS_XKB)
_glfwLibrary.X11.Xkb.majorVersion = 1;
@@ -739,15 +696,15 @@ int _glfwPlatformInit(void)
if (!initDisplay())
return GL_FALSE;
if (!_glfwInitOpenGL())
return GL_FALSE;
initGammaRamp();
initEWMH();
_glfwLibrary.X11.cursor = createNULLCursor();
// Try to load libGL.so if necessary
initLibraries();
_glfwInitJoysticks();
// Start the timer
@@ -773,14 +730,7 @@ int _glfwPlatformTerminate(void)
_glfwTerminateJoysticks();
// Unload libGL.so if necessary
#ifdef _GLFW_DLOPEN_LIBGL
if (_glfwLibrary.GLX.libGL != NULL)
{
dlclose(_glfwLibrary.GLX.libGL);
_glfwLibrary.GLX.libGL = NULL;
}
#endif
_glfwTerminateOpenGL();
// Free clipboard memory
if (_glfwLibrary.X11.selection.string)