Minor X11 library struct changes.

This commit is contained in:
Camilla Berglund 2010-09-09 20:25:33 +02:00
parent 8074209af4
commit 8a04910a45
4 changed files with 13 additions and 15 deletions

View File

@ -264,12 +264,10 @@ typedef struct _GLFWlibraryX11
struct { struct {
double resolution; double resolution;
long long t0; long long t0;
} Timer; } timer;
#if defined(_GLFW_DLOPEN_LIBGL) #if defined(_GLFW_DLOPEN_LIBGL)
struct { void* libGL; // dlopen handle for libGL.so
void* libGL; // dlopen handle for libGL.so
} Libs;
#endif #endif
} _GLFWlibraryX11; } _GLFWlibraryX11;

View File

@ -45,7 +45,7 @@ void (*glXGetProcAddressEXT(const GLubyte* procName))();
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT) #elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT)
#define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x) #define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x)
#elif defined(_GLFW_HAS_DLOPEN) #elif defined(_GLFW_HAS_DLOPEN)
#define _glfw_glXGetProcAddress(x) dlsym(_glfwLibs.libGL,x) #define _glfw_glXGetProcAddress(x) dlsym(_glfwLibrary.X11.libGL, x)
#define _GLFW_DLOPEN_LIBGL #define _GLFW_DLOPEN_LIBGL
#else #else
#define _glfw_glXGetProcAddress(x) NULL #define _glfw_glXGetProcAddress(x) NULL

View File

@ -54,11 +54,11 @@ static void initLibraries(void)
NULL NULL
}; };
_glfwLibrary.Libs.libGL = NULL; _glfwLibrary.X11.libGL = NULL;
for (i = 0; libGL_names[i] != NULL; i++) for (i = 0; libGL_names[i] != NULL; i++)
{ {
_glfwLibrary.Libs.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL); _glfwLibrary.X11.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (_glfwLibrary.Libs.libGL) if (_glfwLibrary.X11.libGL)
break; break;
} }
#endif #endif
@ -191,10 +191,10 @@ int _glfwPlatformTerminate(void)
// Unload libGL.so if necessary // Unload libGL.so if necessary
#ifdef _GLFW_DLOPEN_LIBGL #ifdef _GLFW_DLOPEN_LIBGL
if (_glfwLibrary.Libs.libGL != NULL) if (_glfwLibrary.X11.libGL != NULL)
{ {
dlclose(_glfwLibrary.Libs.libGL); dlclose(_glfwLibrary.X11.libGL);
_glfwLibrary.Libs.libGL = NULL; _glfwLibrary.X11.libGL = NULL;
} }
#endif #endif

View File

@ -40,11 +40,11 @@ void _glfwInitTimer(void)
struct timeval tv; struct timeval tv;
// "Resolution" is 1 us // "Resolution" is 1 us
_glfwLibrary.X11.Timer.resolution = 1e-6; _glfwLibrary.X11.timer.resolution = 1e-6;
// Set start-time for timer // Set start-time for timer
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
_glfwLibrary.X11.Timer.t0 = (long long) tv.tv_sec * (long long) 1000000 + _glfwLibrary.X11.timer.t0 = (long long) tv.tv_sec * (long long) 1000000 +
(long long) tv.tv_usec; (long long) tv.tv_usec;
} }
@ -66,7 +66,7 @@ double _glfwPlatformGetTime(void)
t = (long long) tv.tv_sec * (long long) 1000000 + t = (long long) tv.tv_sec * (long long) 1000000 +
(long long) tv.tv_usec; (long long) tv.tv_usec;
return (double)(t - _glfwLibrary.X11.Timer.t0) * _glfwLibrary.X11.Timer.resolution; return (double)(t - _glfwLibrary.X11.timer.t0) * _glfwLibrary.X11.timer.resolution;
} }
@ -84,6 +84,6 @@ void _glfwPlatformSetTime(double t)
(long long) tv.tv_usec; (long long) tv.tv_usec;
// Calulate new starting time // Calulate new starting time
_glfwLibrary.X11.Timer.t0 = t0 - (long long)(t / _glfwLibrary.X11.Timer.resolution); _glfwLibrary.X11.timer.t0 = t0 - (long long)(t / _glfwLibrary.X11.timer.resolution);
} }