Merge branch 'master' of github.com:elmindreda/glfw

This commit is contained in:
Camilla Berglund 2012-04-30 01:59:45 +02:00
commit 904db4c605
14 changed files with 62 additions and 32 deletions

View File

@ -3,7 +3,7 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY})
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL) add_definitions(-DGLFW_DLL)
link_libraries(${OPENGL_gl_LIBRARY}) link_libraries(${OPENGL_gl_LIBRARY} ${MATH_LIBRARY})
else() else()
link_libraries(${glfw_LIBRARIES}) link_libraries(${glfw_LIBRARIES})
endif() endif()

View File

@ -838,6 +838,8 @@ their skills. Special thanks go out to:</p>
<li>Keith Bauer, for his invaluable help with porting and maintaining GLFW on <li>Keith Bauer, for his invaluable help with porting and maintaining GLFW on
Mac OS X, and for his many ideas</li> Mac OS X, and for his many ideas</li>
<li>Lambert Clara, for a bug fix for the modes test</li>
<li>Jarrod Davis, for the Delphi port of GLFW</li> <li>Jarrod Davis, for the Delphi port of GLFW</li>
<li>Olivier Delannoy, for the initial implementation of FSAA support on <li>Olivier Delannoy, for the initial implementation of FSAA support on

View File

@ -81,9 +81,9 @@ int _glfwPlatformInit(void)
{ {
_glfwLibrary.NS.autoreleasePool = [[NSAutoreleasePool alloc] init]; _glfwLibrary.NS.autoreleasePool = [[NSAutoreleasePool alloc] init];
_glfwLibrary.NS.OpenGLFramework = _glfwLibrary.NSGL.framework =
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl")); CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfwLibrary.NS.OpenGLFramework == NULL) if (_glfwLibrary.NSGL.framework == NULL)
{ {
_glfwSetError(GLFW_PLATFORM_ERROR, _glfwSetError(GLFW_PLATFORM_ERROR,
"glfwInit: Failed to locate OpenGL framework"); "glfwInit: Failed to locate OpenGL framework");

View File

@ -94,7 +94,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
procname, procname,
kCFStringEncodingASCII); kCFStringEncodingASCII);
void* symbol = CFBundleGetFunctionPointerForName(_glfwLibrary.NS.OpenGLFramework, void* symbol = CFBundleGetFunctionPointerForName(_glfwLibrary.NSGL.framework,
symbolName); symbolName);
CFRelease(symbolName); CFRelease(symbolName);

View File

@ -43,8 +43,9 @@ typedef void* id;
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS NS #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS NS
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryNS NS
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL NSGL #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL NSGL
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS NS
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryNSGL NSGL
//======================================================================== //========================================================================
@ -80,7 +81,7 @@ typedef struct _GLFWwindowNS
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Platform-specific library global data // Platform-specific library global data for Cocoa
//------------------------------------------------------------------------ //------------------------------------------------------------------------
typedef struct _GLFWlibraryNS typedef struct _GLFWlibraryNS
{ {
@ -89,8 +90,6 @@ typedef struct _GLFWlibraryNS
double resolution; double resolution;
} timer; } timer;
// dlopen handle for dynamically loading OpenGL extension entry points
void* OpenGLFramework;
CGDisplayModeRef desktopMode; CGDisplayModeRef desktopMode;
CGEventSourceRef eventSource; CGEventSourceRef eventSource;
id delegate; id delegate;
@ -100,6 +99,16 @@ typedef struct _GLFWlibraryNS
} _GLFWlibraryNS; } _GLFWlibraryNS;
//------------------------------------------------------------------------
// Platform-specific library global data for NSGL
//------------------------------------------------------------------------
typedef struct _GLFWlibraryNSGL
{
// dlopen handle for dynamically loading OpenGL extension entry points
void* framework;
} _GLFWlibraryNSGL;
//======================================================================== //========================================================================
// Prototypes for platform specific internal functions // Prototypes for platform specific internal functions
//======================================================================== //========================================================================

View File

@ -1168,7 +1168,7 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
// calculating the maximum y coordinate of all screens, since Cocoa's // calculating the maximum y coordinate of all screens, since Cocoa's
// "global coordinates" are upside down from CG's... // "global coordinates" are upside down from CG's...
NSPoint localPoint = NSMakePoint(x, y); NSPoint localPoint = NSMakePoint(x, window->height - y);
NSPoint globalPoint = [window->NS.object convertBaseToScreen:localPoint]; NSPoint globalPoint = [window->NS.object convertBaseToScreen:localPoint];
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin; CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height; double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;

View File

@ -247,7 +247,8 @@ struct _GLFWlibrary
int originalRampSize; int originalRampSize;
// This is defined in the current port's platform.h // This is defined in the current port's platform.h
_GLFW_PLATFORM_LIBRARY_STATE; _GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
_GLFW_PLATFORM_LIBRARY_OPENGL_STATE;
}; };

View File

@ -517,8 +517,7 @@ GLFWAPI void glfwSwapBuffers(void)
return; return;
} }
if (_glfwLibrary.currentWindow) _glfwPlatformSwapBuffers();
_glfwPlatformSwapBuffers();
} }

View File

@ -111,8 +111,9 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32 #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryWin32 Win32
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 Win32
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryWGL WGL
//======================================================================== //========================================================================
@ -169,7 +170,7 @@ typedef struct _GLFWwindowWin32
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Platform-specific library global data // Platform-specific library global data for Win32
//------------------------------------------------------------------------ //------------------------------------------------------------------------
typedef struct _GLFWlibraryWin32 typedef struct _GLFWlibraryWin32
{ {
@ -210,6 +211,16 @@ typedef struct _GLFWlibraryWin32
} _GLFWlibraryWin32; } _GLFWlibraryWin32;
//------------------------------------------------------------------------
// Platform-specific library global data for WGL
//------------------------------------------------------------------------
typedef struct _GLFWlibraryWGL
{
int dummy;
} _GLFWlibraryWGL;
//======================================================================== //========================================================================
// Prototypes for platform specific internal functions // Prototypes for platform specific internal functions
//======================================================================== //========================================================================

View File

@ -55,8 +55,8 @@ static void initLibraries(void)
for (i = 0; libGL_names[i] != NULL; i++) for (i = 0; libGL_names[i] != NULL; i++)
{ {
_glfwLibrary.X11.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL); _glfwLibrary.GLX.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (_glfwLibrary.X11.libGL) if (_glfwLibrary.GLX.libGL)
break; break;
} }
#endif #endif
@ -569,8 +569,8 @@ static GLboolean initDisplay(void)
} }
if (!glXQueryVersion(_glfwLibrary.X11.display, if (!glXQueryVersion(_glfwLibrary.X11.display,
&_glfwLibrary.X11.glxMajor, &_glfwLibrary.GLX.majorVersion,
&_glfwLibrary.X11.glxMinor)) &_glfwLibrary.GLX.minorVersion))
{ {
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"X11/GLX: Failed to query GLX version"); "X11/GLX: Failed to query GLX version");
@ -775,10 +775,10 @@ int _glfwPlatformTerminate(void)
// Unload libGL.so if necessary // Unload libGL.so if necessary
#ifdef _GLFW_DLOPEN_LIBGL #ifdef _GLFW_DLOPEN_LIBGL
if (_glfwLibrary.X11.libGL != NULL) if (_glfwLibrary.GLX.libGL != NULL)
{ {
dlclose(_glfwLibrary.X11.libGL); dlclose(_glfwLibrary.GLX.libGL);
_glfwLibrary.X11.libGL = NULL; _glfwLibrary.GLX.libGL = NULL;
} }
#endif #endif

View File

@ -75,15 +75,16 @@
#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(_glfwLibrary.X11.libGL, x) #define _glfw_glXGetProcAddress(x) dlsym(_glfwLibrary.GLX.libGL, x)
#define _GLFW_DLOPEN_LIBGL #define _GLFW_DLOPEN_LIBGL
#else #else
#error "No OpenGL entry point retrieval mechanism was enabled" #error "No OpenGL entry point retrieval mechanism was enabled"
#endif #endif
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 X11 #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 X11
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryX11 X11
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX GLX #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX GLX
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 X11
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryGLX GLX
// Clipboard format atom indices // Clipboard format atom indices
#define _GLFW_CLIPBOARD_FORMAT_UTF8 0 #define _GLFW_CLIPBOARD_FORMAT_UTF8 0
@ -157,7 +158,7 @@ typedef struct _GLFWwindowX11
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Platform-specific library global data // Platform-specific library global data for X11
//------------------------------------------------------------------------ //------------------------------------------------------------------------
typedef struct _GLFWlibraryX11 typedef struct _GLFWlibraryX11
{ {
@ -177,9 +178,6 @@ typedef struct _GLFWlibraryX11
// True if window manager supports EWMH // True if window manager supports EWMH
GLboolean hasEWMH; GLboolean hasEWMH;
// Server-side GLX version
int glxMajor, glxMinor;
struct { struct {
GLboolean available; GLboolean available;
int eventBase; int eventBase;
@ -248,10 +246,21 @@ typedef struct _GLFWlibraryX11
int status; int status;
} selection; } selection;
} _GLFWlibraryX11;
//------------------------------------------------------------------------
// Platform-specific library global data for GLX
//------------------------------------------------------------------------
typedef struct _GLFWlibraryGLX
{
// Server-side GLX version
int majorVersion, minorVersion;
#if defined(_GLFW_DLOPEN_LIBGL) #if defined(_GLFW_DLOPEN_LIBGL)
void* libGL; // dlopen handle for libGL.so void* libGL; // dlopen handle for libGL.so
#endif #endif
} _GLFWlibraryX11; } _GLFWlibraryGLX;
//------------------------------------------------------------------------ //------------------------------------------------------------------------

View File

@ -131,7 +131,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
*found = 0; *found = 0;
if (_glfwLibrary.X11.glxMajor == 1 && _glfwLibrary.X11.glxMinor < 3) if (_glfwLibrary.GLX.majorVersion == 1 && _glfwLibrary.GLX.minorVersion < 3)
{ {
if (!window->GLX.SGIX_fbconfig) if (!window->GLX.SGIX_fbconfig)
{ {
@ -1287,7 +1287,6 @@ static void processSingleEvent(void)
break; break;
} }
// Was the window destroyed?
case DestroyNotify: case DestroyNotify:
return; return;

View File

@ -3,7 +3,7 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY})
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL) add_definitions(-DGLFW_DLL)
link_libraries(${OPENGL_gl_LIBRARY}) link_libraries(${OPENGL_gl_LIBRARY} ${MATH_LIBRARY})
else() else()
link_libraries(${glfw_LIBRARIES}) link_libraries(${glfw_LIBRARIES})
endif() endif()

View File

@ -153,7 +153,7 @@ static void test_modes(GLFWvidmode* modes, int count)
glfwGetWindowSize(window, &width, &height); glfwGetWindowSize(window, &width, &height);
if (width != modes[i].width || height != height) if (width != modes[i].width || height != modes[i].height)
{ {
printf("*** Size mismatch: %ix%i instead of %ix%i\n", printf("*** Size mismatch: %ix%i instead of %ix%i\n",
width, height, width, height,