diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83eb8bf8..fad2f423 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,7 +36,7 @@ endif (WIN32)
#--------------------------------------------------------------------
# Set up GLFW for Xlib and GLX on Unix-like systems with X Windows
#--------------------------------------------------------------------
-if (UNIX AND NOT APPLE AND NOT CYGWIN)
+if (UNIX AND NOT APPLE)
message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
# Define the platform identifier
@@ -52,7 +52,7 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CheckX11Extensions.cmake)
# Check for XRandR (modern resolution switching extension)
- CHECK_X11_XRANDR()
+ check_x11_xrandr()
if (X11_XRANDR_FOUND)
set(_GLFW_HAS_XRANDR 1)
list(APPEND GLFW_INCLUDE_DIR ${X11_XRANDR_INCLUDE_DIR})
@@ -60,7 +60,7 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
endif(X11_XRANDR_FOUND)
# Check for Xf86VidMode (fallback legacy resolution switching extension)
- CHECK_X11_XF86VIDMODE()
+ check_x11_xf86vidmode()
if (X11_XF86VIDMODE_FOUND)
set(_GLFW_HAS_XF86VIDMODE 1)
list(APPEND GLFW_INCLUDE_DIR ${X11_XF86VIDMODE_INCLUDE_DIR})
@@ -68,17 +68,17 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
endif(X11_XF86VIDMODE_FOUND)
# Check for Xkb (X keyboard extension)
- CHECK_FUNCTION_EXISTS(XkbQueryExtension _GLFW_HAS_XKB)
+ check_function_exists(XkbQueryExtension _GLFW_HAS_XKB)
# Check for glXGetProcAddress
- CHECK_FUNCTION_EXISTS(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
+ check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
- CHECK_FUNCTION_EXISTS(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB)
+ check_function_exists(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB)
endif (NOT _GLFW_HAS_GLXGETPROCADDRESS)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
- CHECK_FUNCTION_EXISTS(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT)
+ check_function_exists(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT)
endif (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND
@@ -89,10 +89,15 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND
NOT _GLFW_HAS_GLXGETPROCADDRESSEXT)
+ find_library(LIBRT rt)
+ if (LIBRT)
+ list(APPEND GLFW_LIBRARIES ${LIBRT})
+ endif(LIBRT)
+
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(_GLFW_USE_LINUX_JOYSTICKS 1)
endif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-endif(UNIX AND NOT APPLE AND NOT CYGWIN)
+endif(UNIX AND NOT APPLE)
#--------------------------------------------------------------------
# Set up GLFW for Cocoa and NSOpenGL on Mac OS X
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 292db1ce..852e482d 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -38,10 +38,3 @@ if(MSVC)
LINK_FLAGS "/ENTRY:mainCRTStartup")
endif(MSVC)
-if(CYGWIN)
- # Set cross-compile and subsystem compile and link flags
- set_target_properties(${WINDOWS_BINARIES} PROPERTIES
- COMPILE_FLAGS "-mno-cygwin"
- LINK_FLAGS "-mno-cygwin -mwindows")
-endif(CYGWIN)
-
diff --git a/examples/heightmap.c b/examples/heightmap.c
index 1d3dd72e..b4dcf082 100644
--- a/examples/heightmap.c
+++ b/examples/heightmap.c
@@ -583,7 +583,7 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
- glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
+ glfwOpenWindowHint(GLFW_WINDOW_RESIZABLE, GL_FALSE);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 0a07fe84..35a5d80a 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -418,7 +418,7 @@ extern "C" {
#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
#define GLFW_AUX_BUFFERS 0x0002100B
#define GLFW_STEREO 0x0002100C
-#define GLFW_WINDOW_NO_RESIZE 0x0002100D
+#define GLFW_WINDOW_RESIZABLE 0x0002100D
#define GLFW_FSAA_SAMPLES 0x0002100E
#define GLFW_OPENGL_VERSION_MAJOR 0x0002100F
#define GLFW_OPENGL_VERSION_MINOR 0x00021010
diff --git a/readme.html b/readme.html
index a028b45b..175e3b81 100644
--- a/readme.html
+++ b/readme.html
@@ -281,12 +281,14 @@ version of GLFW.
Added GLFW_INCLUDE_GL3
macro for telling the GLFW header to include gl3.h
header instead of gl.h
Added windows
simple multi-window test program
Added sharing
simple OpenGL object sharing test program
+ Added dynamic
simple dynamic linking test program
Added a parameter to glfwOpenWindow
for specifying a context the new window's context will share objects with
Added initial window title parameter to glfwOpenWindow
Added glfwSetGamma
, glfwSetGammaRamp
and glfwGetGammaRamp
functions and GLFWgammaramp
type for monitor gamma ramp control
Changed buffer bit depth parameters of glfwOpenWindow
to window hints
Renamed glfw.h
to glfw3.h
to avoid conflicts with 2.x series
Renamed GLFW_WINDOW
token to GLFW_WINDOWED
+ Renamed GLFW_WINDOW_NO_RESIZE
to GLFW_WINDOW_RESIZABLE
Renamed version
test to glfwinfo
Replaced ad hoc build system with CMake
Replaced layout-dependent key codes with single, platform-independent set based on US layout
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c0913b88..ee510984 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,18 +3,6 @@ if(WIN32)
add_definitions(-DWINVER=0x0501)
endif(WIN32)
-if(CYGWIN)
-
- # These lines are intended to remove the --export-all-symbols
- # flag added in the Modules/Platform/CYGWIN.cmake file of the
- # CMake distribution.
- # This is a HACK. If you have trouble _linking_ the GLFW
- # _shared_ library on Cygwin, try disabling this.
- set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
- set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
-
-endif(CYGWIN)
-
if(UNIX)
if(_GLFW_HAS_XRANDR)
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
@@ -71,13 +59,6 @@ if(WIN32)
IMPORT_SUFFIX "dll.lib")
endif(WIN32)
-if(CYGWIN)
- # Build for the regular Win32 environment (not Cygwin)
- set_target_properties(libglfwStatic libglfwShared PROPERTIES
- COMPILE_FLAGS "-mwin32 -mno-cygwin"
- LINK_FLAGS "-mwin32 -mno-cygwin")
-endif(CYGWIN)
-
if(APPLE)
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index c7c0d6c5..785cd267 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -109,7 +109,7 @@ static NSString* findAppName(void)
char** progname = _NSGetProgname();
if (progname && *progname)
{
- // TODO: UTF8?
+ // TODO: UTF-8?
return [NSString stringWithUTF8String:*progname];
}
@@ -202,7 +202,7 @@ int _glfwPlatformInit(void)
[GLFWApplication sharedApplication];
_glfwLibrary.NS.OpenGLFramework =
- CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) );
+ CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfwLibrary.NS.OpenGLFramework == NULL)
{
_glfwSetError(GLFW_PLATFORM_ERROR,
@@ -229,7 +229,7 @@ int _glfwPlatformInit(void)
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
-
+
return GL_TRUE;
}
@@ -240,10 +240,10 @@ int _glfwPlatformInit(void)
int _glfwPlatformTerminate(void)
{
// TODO: Probably other cleanup
-
+
// Restore the original gamma ramp
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
-
+
[NSApp setDelegate:nil];
[_glfwLibrary.NS.delegate release];
_glfwLibrary.NS.delegate = nil;
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 93e37089..ce95217d 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -67,11 +67,8 @@
NSRect contentRect =
[window->NS.window contentRectForFrameRect:[window->NS.window frame]];
- window->width = contentRect.size.width;
- window->height = contentRect.size.height;
- if (_glfwLibrary.windowSizeCallback)
- _glfwLibrary.windowSizeCallback(window, window->width, window->height);
+ _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
}
- (void)windowDidMove:(NSNotification *)notification
@@ -87,24 +84,17 @@
mainScreenHeight - contentRect.origin.y -
mainScreenOrigin.y - window->height);
- window->positionX = flippedPos.x;
- window->positionY = flippedPos.y;
+ _glfwInputWindowPos(window, flippedPos.x, flippedPos.y);
}
- (void)windowDidMiniaturize:(NSNotification *)notification
{
- window->iconified = GL_TRUE;
-
- if (_glfwLibrary.windowIconifyCallback)
- _glfwLibrary.windowIconifyCallback(window, window->iconified);
+ _glfwInputWindowIconify(window, GL_TRUE);
}
- (void)windowDidDeminiaturize:(NSNotification *)notification
{
- window->iconified = GL_FALSE;
-
- if (_glfwLibrary.windowIconifyCallback)
- _glfwLibrary.windowIconifyCallback(window, window->iconified);
+ _glfwInputWindowIconify(window, GL_FALSE);
}
- (void)windowDidBecomeKey:(NSNotification *)notification
@@ -349,24 +339,15 @@ static int convertMacKeyCode(unsigned int macKeyCode)
- (void)mouseMoved:(NSEvent *)event
{
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
- {
- window->mousePosX += [event deltaX];
- window->mousePosY += [event deltaY];
- }
+ _glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
else
{
NSPoint p = [event locationInWindow];
// Cocoa coordinate system has origin at lower left
- window->mousePosX = p.x;
- window->mousePosY = [[window->NS.window contentView] bounds].size.height - p.y;
- }
+ p.y = [[window->NS.window contentView] bounds].size.height - p.y;
- if (_glfwLibrary.mousePosCallback)
- {
- _glfwLibrary.mousePosCallback(window,
- window->mousePosX,
- window->mousePosY);
+ _glfwInputCursorMotion(window, p.x, p.y);
}
}
@@ -587,7 +568,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
styleMask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask;
- if (!wndconfig->windowNoResize)
+ if (wndconfig->resizable)
styleMask |= NSResizableWindowMask;
}
else
@@ -707,10 +688,10 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
glfwMakeContextCurrent(window);
NSPoint point = [[NSCursor currentCursor] hotSpot];
- window->mousePosX = point.x;
- window->mousePosY = point.y;
+ window->cursorPosX = point.x;
+ window->cursorPosY = point.y;
- window->windowNoResize = wndconfig->windowNoResize;
+ window->resizable = wndconfig->resizable;
return GL_TRUE;
}
diff --git a/src/input.c b/src/input.c
index 1728742d..56ab0e5d 100644
--- a/src/input.c
+++ b/src/input.c
@@ -31,6 +31,119 @@
#include "internal.h"
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+//========================================================================
+// Register keyboard activity
+//========================================================================
+
+void _glfwInputKey(_GLFWwindow* window, int key, int action)
+{
+ GLboolean keyrepeat = GL_FALSE;
+
+ if (key < 0 || key > GLFW_KEY_LAST)
+ return;
+
+ // Are we trying to release an already released key?
+ if (action == GLFW_RELEASE && window->key[key] != GLFW_PRESS)
+ return;
+
+ // Register key action
+ if(action == GLFW_RELEASE && window->stickyKeys)
+ window->key[key] = GLFW_STICK;
+ else
+ {
+ keyrepeat = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS);
+ window->key[key] = (char) action;
+ }
+
+ // Call user callback function
+ if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat))
+ _glfwLibrary.keyCallback(window, key, action);
+}
+
+
+//========================================================================
+// Register (keyboard) character activity
+//========================================================================
+
+void _glfwInputChar(_GLFWwindow* window, int character)
+{
+ // Valid Unicode (ISO 10646) character?
+ if (!((character >= 32 && character <= 126) || character >= 160))
+ return;
+
+ if (_glfwLibrary.charCallback)
+ _glfwLibrary.charCallback(window, character);
+}
+
+
+//========================================================================
+// Register scroll events
+//========================================================================
+
+void _glfwInputScroll(_GLFWwindow* window, int xoffset, int yoffset)
+{
+ window->scrollX += xoffset;
+ window->scrollY += yoffset;
+
+ if (_glfwLibrary.scrollCallback)
+ _glfwLibrary.scrollCallback(window, xoffset, yoffset);
+}
+
+
+//========================================================================
+// Register mouse button clicks
+//========================================================================
+
+void _glfwInputMouseClick(_GLFWwindow* window, int button, int action)
+{
+ if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
+ return;
+
+ // Register mouse button action
+ if (action == GLFW_RELEASE && window->stickyMouseButtons)
+ window->mouseButton[button] = GLFW_STICK;
+ else
+ window->mouseButton[button] = (char) action;
+
+ if (_glfwLibrary.mouseButtonCallback)
+ _glfwLibrary.mouseButtonCallback(window, button, action);
+}
+
+
+//========================================================================
+// Register cursor moves
+//========================================================================
+
+void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
+{
+ if (window->cursorMode == GLFW_CURSOR_CAPTURED)
+ {
+ if (!x && !y)
+ return;
+
+ window->cursorPosX += x;
+ window->cursorPosY += y;
+ }
+ else
+ {
+ if (window->cursorPosX == x && window->cursorPosY == y)
+ return;
+
+ window->cursorPosX = x;
+ window->cursorPosY = y;
+ }
+
+ if (_glfwLibrary.mousePosCallback)
+ _glfwLibrary.mousePosCallback(window,
+ window->cursorPosX,
+ window->cursorPosY);
+}
+
+
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
@@ -118,10 +231,10 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
// Return mouse position
if (xpos != NULL)
- *xpos = window->mousePosX;
+ *xpos = window->cursorPosX;
if (ypos != NULL)
- *ypos = window->mousePosY;
+ *ypos = window->cursorPosY;
}
@@ -147,12 +260,12 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
}
// Don't do anything if the mouse position did not change
- if (xpos == window->mousePosX && ypos == window->mousePosY)
+ if (xpos == window->cursorPosX && ypos == window->cursorPosY)
return;
// Set GLFW mouse position
- window->mousePosX = xpos;
- window->mousePosY = ypos;
+ window->cursorPosX = xpos;
+ window->cursorPosY = ypos;
// Do not move physical cursor in locked cursor mode
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
@@ -191,8 +304,7 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode)
{
- int centerPosX;
- int centerPosY;
+ int centerPosX, centerPosY;
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
@@ -216,25 +328,13 @@ GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode)
centerPosY = window->height / 2;
if (mode == GLFW_CURSOR_CAPTURED)
- {
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
- }
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
- if (centerPosX != window->mousePosX || centerPosY != window->mousePosY)
- {
- _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
-
- window->mousePosX = centerPosX;
- window->mousePosY = centerPosY;
-
- if (_glfwLibrary.mousePosCallback)
- {
- _glfwLibrary.mousePosCallback(window,
- window->mousePosX,
- window->mousePosY);
- }
- }
+ _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
+ _glfwInputCursorMotion(window,
+ centerPosX - window->cursorPosX,
+ centerPosY - window->cursorPosY);
}
_glfwPlatformSetCursorMode(window, mode);
@@ -313,7 +413,7 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
- cbfun(window, window->mousePosX, window->mousePosY);
+ cbfun(window, window->cursorPosX, window->cursorPosY);
}
}
diff --git a/src/internal.h b/src/internal.h
index 74388d6e..91d507c1 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -104,7 +104,7 @@ struct _GLFWhints
int accumAlphaBits;
int auxBuffers;
GLboolean stereo;
- GLboolean windowNoResize;
+ GLboolean resizable;
int samples;
int glMajor;
int glMinor;
@@ -126,7 +126,7 @@ struct _GLFWwndconfig
int mode;
const char* title;
int refreshRate;
- GLboolean windowNoResize;
+ GLboolean resizable;
int glMajor;
int glMinor;
GLboolean glForward;
@@ -176,7 +176,7 @@ struct _GLFWwindow
int width, height;
int positionX, positionY;
int mode; // GLFW_WINDOW or GLFW_FULLSCREEN
- GLboolean windowNoResize; // resize- and maximize gadgets disabled flag
+ GLboolean resizable; // GL_TRUE if user may resize this window
int refreshRate; // monitor refresh rate
void* userPointer;
@@ -185,7 +185,7 @@ struct _GLFWwindow
GLboolean stickyMouseButtons;
GLboolean keyRepeat;
GLboolean sysKeysDisabled; // system keys disabled flag
- int mousePosX, mousePosY;
+ int cursorPosX, cursorPosY;
int cursorMode;
int scrollX, scrollY;
char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1];
@@ -365,12 +365,19 @@ void _glfwSetError(int error, const char* description);
// Window management (window.c)
void _glfwSetDefaultWindowHints(void);
-// Input handling (window.c)
+// WIndow event notification
+void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated);
+void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
+void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
+void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
+void _glfwInputWindowDamage(_GLFWwindow* window);
+
+// Input event notification
void _glfwInputKey(_GLFWwindow* window, int key, int action);
void _glfwInputChar(_GLFWwindow* window, int character);
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
-void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated);
+void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
// OpenGL context helpers (opengl.c)
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
diff --git a/src/win32_window.c b/src/win32_window.c
index f362368a..41199e5f 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -851,15 +851,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
}
_glfwInputWindowFocus(window, active);
-
- if (iconified != window->iconified)
- {
- window->iconified = iconified;
-
- if (_glfwLibrary.windowIconifyCallback)
- _glfwLibrary.windowIconifyCallback(window, window->iconified);
- }
-
+ _glfwInputWindowIconify(window, iconified);
return 0;
}
@@ -1005,32 +997,27 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (newMouseX != window->Win32.oldMouseX ||
newMouseY != window->Win32.oldMouseY)
{
+ int x, y;
+
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (_glfwLibrary.activeWindow != window)
return 0;
- window->mousePosX += newMouseX -
- window->Win32.oldMouseX;
- window->mousePosY += newMouseY -
- window->Win32.oldMouseY;
+ x = newMouseX - window->Win32.oldMouseX;
+ y = newMouseY - window->Win32.oldMouseY;
}
else
{
- window->mousePosX = newMouseX;
- window->mousePosY = newMouseY;
+ x = newMouseX;
+ y = newMouseY;
}
window->Win32.oldMouseX = newMouseX;
window->Win32.oldMouseY = newMouseY;
window->Win32.cursorCentered = GL_FALSE;
- if (_glfwLibrary.mousePosCallback)
- {
- _glfwLibrary.mousePosCallback(window,
- window->mousePosX,
- window->mousePosY);
- }
+ _glfwInputCursorMotion(window, x, y);
}
return 0;
@@ -1052,9 +1039,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_SIZE:
{
- window->width = LOWORD(lParam);
- window->height = HIWORD(lParam);
-
// If window is in cursor capture mode, update clipping rect
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
@@ -1063,21 +1047,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
ClipCursor(&ClipWindowRect);
}
- if (_glfwLibrary.windowSizeCallback)
- {
- _glfwLibrary.windowSizeCallback(window,
- window->width,
- window->height);
- }
-
+ _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
return 0;
}
case WM_MOVE:
{
- window->positionX = LOWORD(lParam);
- window->positionY = HIWORD(lParam);
-
// If window is in cursor capture mode, update clipping rect
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
@@ -1085,15 +1060,15 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
ClipCursor(&ClipWindowRect);
}
+
+ _glfwInputWindowPos(window, LOWORD(lParam), HIWORD(lParam));
return 0;
}
// Was the window contents damaged?
case WM_PAINT:
{
- if (_glfwLibrary.windowRefreshCallback)
- _glfwLibrary.windowRefreshCallback(window);
-
+ _glfwInputWindowDamage(window);
break;
}
@@ -1343,7 +1318,7 @@ static int createWindow(_GLFWwindow* window,
{
dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
- if (!wndconfig->windowNoResize)
+ if (wndconfig->resizable)
{
dwStyle |= (WS_MAXIMIZEBOX | WS_SIZEBOX);
dwExStyle |= WS_EX_WINDOWEDGE;
@@ -1405,8 +1380,8 @@ static int createWindow(_GLFWwindow* window,
// Initialize mouse position data
GetCursorPos(&pos);
ScreenToClient(window->Win32.handle, &pos);
- window->Win32.oldMouseX = window->mousePosX = pos.x;
- window->Win32.oldMouseY = window->mousePosY = pos.y;
+ window->Win32.oldMouseX = window->cursorPosX = pos.x;
+ window->Win32.oldMouseY = window->cursorPosY = pos.y;
return GL_TRUE;
}
@@ -1820,8 +1795,8 @@ void _glfwPlatformPollEvents(void)
}
else
{
- //window->Win32.oldMouseX = window->mousePosX;
- //window->Win32.oldMouseY = window->mousePosY;
+ //window->Win32.oldMouseX = window->cursorPosX;
+ //window->Win32.oldMouseY = window->cursorPosY;
}
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
diff --git a/src/window.c b/src/window.c
index 06c32b8d..88b3dc18 100644
--- a/src/window.c
+++ b/src/window.c
@@ -100,85 +100,9 @@ void _glfwSetDefaultWindowHints(void)
// The default minimum OpenGL version is 1.0
_glfwLibrary.hints.glMajor = 1;
_glfwLibrary.hints.glMinor = 0;
-}
-
-//========================================================================
-// Register keyboard activity
-//========================================================================
-
-void _glfwInputKey(_GLFWwindow* window, int key, int action)
-{
- GLboolean keyrepeat = GL_FALSE;
-
- if (key < 0 || key > GLFW_KEY_LAST)
- return;
-
- // Are we trying to release an already released key?
- if (action == GLFW_RELEASE && window->key[key] != GLFW_PRESS)
- return;
-
- // Register key action
- if(action == GLFW_RELEASE && window->stickyKeys)
- window->key[key] = GLFW_STICK;
- else
- {
- keyrepeat = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS);
- window->key[key] = (char) action;
- }
-
- // Call user callback function
- if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat))
- _glfwLibrary.keyCallback(window, key, action);
-}
-
-
-//========================================================================
-// Register (keyboard) character activity
-//========================================================================
-
-void _glfwInputChar(_GLFWwindow* window, int character)
-{
- // Valid Unicode (ISO 10646) character?
- if (!((character >= 32 && character <= 126) || character >= 160))
- return;
-
- if (_glfwLibrary.charCallback)
- _glfwLibrary.charCallback(window, character);
-}
-
-
-//========================================================================
-// Register scroll events
-//========================================================================
-
-void _glfwInputScroll(_GLFWwindow* window, int xoffset, int yoffset)
-{
- window->scrollX += xoffset;
- window->scrollY += yoffset;
-
- if (_glfwLibrary.scrollCallback)
- _glfwLibrary.scrollCallback(window, xoffset, yoffset);
-}
-
-
-//========================================================================
-// Register mouse button clicks
-//========================================================================
-
-void _glfwInputMouseClick(_GLFWwindow* window, int button, int action)
-{
- if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
- return;
-
- // Register mouse button action
- if (action == GLFW_RELEASE && window->stickyMouseButtons)
- window->mouseButton[button] = GLFW_STICK;
- else
- window->mouseButton[button] = (char) action;
-
- if (_glfwLibrary.mouseButtonCallback)
- _glfwLibrary.mouseButtonCallback(window, button, action);
+ // The default is to allow window resizing
+ _glfwLibrary.hints.resizable = GL_TRUE;
}
@@ -227,6 +151,61 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated)
}
+//========================================================================
+// Register window position events
+//========================================================================
+
+void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
+{
+ window->positionX = x;
+ window->positionY = y;
+}
+
+
+//========================================================================
+// Register window size events
+//========================================================================
+
+void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
+{
+ if (window->width == width && window->height == height)
+ return;
+
+ window->width = width;
+ window->height = height;
+
+ if (_glfwLibrary.windowSizeCallback)
+ _glfwLibrary.windowSizeCallback(window, width, height);
+}
+
+
+//========================================================================
+// Register window size events
+//========================================================================
+
+void _glfwInputWindowIconify(_GLFWwindow* window, int iconified)
+{
+ if (window->iconified == iconified)
+ return;
+
+ window->iconified = iconified;
+
+ if (_glfwLibrary.windowIconifyCallback)
+ _glfwLibrary.windowIconifyCallback(window, iconified);
+}
+
+
+//========================================================================
+// Register window damage events
+//========================================================================
+
+void _glfwInputWindowDamage(_GLFWwindow* window)
+{
+ if (_glfwLibrary.windowRefreshCallback)
+ _glfwLibrary.windowRefreshCallback(window);
+}
+
+
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
@@ -271,7 +250,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
wndconfig.mode = mode;
wndconfig.title = title;
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
- wndconfig.windowNoResize = _glfwLibrary.hints.windowNoResize ? GL_TRUE : GL_FALSE;
+ wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
@@ -443,8 +422,8 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
case GLFW_STEREO:
_glfwLibrary.hints.stereo = hint;
break;
- case GLFW_WINDOW_NO_RESIZE:
- _glfwLibrary.hints.windowNoResize = hint;
+ case GLFW_WINDOW_RESIZABLE:
+ _glfwLibrary.hints.resizable = hint;
break;
case GLFW_FSAA_SAMPLES:
_glfwLibrary.hints.samples = hint;
@@ -731,8 +710,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
return window->stereo;
case GLFW_REFRESH_RATE:
return window->refreshRate;
- case GLFW_WINDOW_NO_RESIZE:
- return window->windowNoResize;
+ case GLFW_WINDOW_RESIZABLE:
+ return window->resizable;
case GLFW_FSAA_SAMPLES:
return window->samples;
case GLFW_OPENGL_VERSION_MAJOR:
diff --git a/src/x11_window.c b/src/x11_window.c
index 962da7fb..61e39583 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -794,7 +794,7 @@ static GLboolean createWindow(_GLFWwindow* window,
hints->flags = 0;
- if (wndconfig->windowNoResize)
+ if (!wndconfig->resizable)
{
hints->flags |= (PMinSize | PMaxSize);
hints->min_width = hints->max_width = window->width;
@@ -1194,33 +1194,27 @@ static void processSingleEvent(void)
event.xmotion.y != window->X11.cursorPosY)
{
// The mouse cursor was moved and we didn't do it
+ int x, y;
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (_glfwLibrary.activeWindow != window)
break;
- window->mousePosX += event.xmotion.x -
- window->X11.cursorPosX;
- window->mousePosY += event.xmotion.y -
- window->X11.cursorPosY;
+ x = event.xmotion.x - window->X11.cursorPosX;
+ y = event.xmotion.y - window->X11.cursorPosY;
}
else
{
- window->mousePosX = event.xmotion.x;
- window->mousePosY = event.xmotion.y;
+ x = event.xmotion.x;
+ y = event.xmotion.y;
}
window->X11.cursorPosX = event.xmotion.x;
window->X11.cursorPosY = event.xmotion.y;
window->X11.cursorCentered = GL_FALSE;
- if (_glfwLibrary.mousePosCallback)
- {
- _glfwLibrary.mousePosCallback(window,
- window->mousePosX,
- window->mousePosY);
- }
+ _glfwInputCursorMotion(window, x, y);
}
break;
@@ -1236,27 +1230,13 @@ static void processSingleEvent(void)
return;
}
- if (event.xconfigure.width != window->width ||
- event.xconfigure.height != window->height)
- {
- // The window was resized
+ _glfwInputWindowSize(window,
+ event.xconfigure.width,
+ event.xconfigure.height);
- window->width = event.xconfigure.width;
- window->height = event.xconfigure.height;
- if (_glfwLibrary.windowSizeCallback)
- {
- _glfwLibrary.windowSizeCallback(window,
- window->width,
- window->height);
- }
- }
-
- if (event.xconfigure.x != window->positionX ||
- event.xconfigure.y != window->positionY)
- {
- window->positionX = event.xconfigure.x;
- window->positionY = event.xconfigure.y;
- }
+ _glfwInputWindowPos(window,
+ event.xconfigure.x,
+ event.xconfigure.y);
break;
}
@@ -1305,11 +1285,7 @@ static void processSingleEvent(void)
return;
}
- window->iconified = GL_FALSE;
-
- if (_glfwLibrary.windowIconifyCallback)
- _glfwLibrary.windowIconifyCallback(window, window->iconified);
-
+ _glfwInputWindowIconify(window, GL_FALSE);
break;
}
@@ -1323,11 +1299,7 @@ static void processSingleEvent(void)
return;
}
- window->iconified = GL_TRUE;
-
- if (_glfwLibrary.windowIconifyCallback)
- _glfwLibrary.windowIconifyCallback(window, window->iconified);
-
+ _glfwInputWindowIconify(window, GL_TRUE);
break;
}
@@ -1377,9 +1349,7 @@ static void processSingleEvent(void)
return;
}
- if (_glfwLibrary.windowRefreshCallback)
- _glfwLibrary.windowRefreshCallback(window);
-
+ _glfwInputWindowDamage(window);
break;
}
@@ -1421,8 +1391,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
{
_GLFWfbconfig closest;
- window->refreshRate = wndconfig->refreshRate;
- window->windowNoResize = wndconfig->windowNoResize;
+ window->refreshRate = wndconfig->refreshRate;
+ window->resizable = wndconfig->resizable;
initGLXExtensions(window);
@@ -1487,8 +1457,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
// TODO: Probably check for some corner cases here.
- window->mousePosX = windowX;
- window->mousePosY = windowY;
+ window->cursorPosX = windowX;
+ window->cursorPosY = windowY;
}
return GL_TRUE;
@@ -1563,7 +1533,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
&width, &height, &rate);
}
- if (window->windowNoResize)
+ if (!window->resizable)
{
// Update window size restrictions to match new window size
@@ -1730,7 +1700,7 @@ void _glfwPlatformRefreshWindowParams(void)
&dotclock, &modeline);
pixels_per_second = 1000.0f * (float) dotclock;
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
- window->refreshRate = (int)(pixels_per_second/pixels_per_frame+0.5);
+ window->refreshRate = (int) (pixels_per_second / pixels_per_frame + 0.5);
#endif /*_GLFW_HAS_XF86VIDMODE*/
}
else
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index cd57659c..5199592c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,5 +1,6 @@
-link_libraries(libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
+set(STATIC_DEPS libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
+set(SHARED_DEPS libglfwShared ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
if (UNIX AND NOT APPLE AND NOT CYGWIN)
find_library(MATH_LIBRARY m)
@@ -12,30 +13,52 @@ include_directories(${GLFW_SOURCE_DIR}/include
${OPENGL_INCLUDE_DIR})
add_executable(defaults defaults.c)
-add_executable(events events.c)
-add_executable(fsaa fsaa.c getopt.c)
-add_executable(fsfocus fsfocus.c)
-add_executable(gamma gamma.c getopt.c)
-add_executable(glfwinfo glfwinfo.c getopt.c)
-add_executable(iconify iconify.c getopt.c)
-add_executable(joysticks joysticks.c)
-add_executable(listmodes listmodes.c)
-add_executable(peter peter.c)
-add_executable(reopen reopen.c)
+target_link_libraries(defaults ${STATIC_DEPS})
-if(APPLE)
- # Set fancy names for bundles
- add_executable(Accuracy MACOSX_BUNDLE accuracy.c)
- add_executable(Sharing MACOSX_BUNDLE sharing.c)
- add_executable(Tearing MACOSX_BUNDLE tearing.c)
- add_executable(Windows MACOSX_BUNDLE windows.c)
-else()
- # Set boring names for executables
- add_executable(accuracy WIN32 accuracy.c)
- add_executable(sharing WIN32 sharing.c)
- add_executable(tearing WIN32 tearing.c)
- add_executable(windows WIN32 windows.c)
-endif(APPLE)
+add_executable(dynamic dynamic.c)
+target_link_libraries(dynamic ${SHARED_DEPS})
+
+add_executable(events events.c)
+target_link_libraries(events ${STATIC_DEPS})
+
+add_executable(fsaa fsaa.c getopt.c)
+target_link_libraries(fsaa ${STATIC_DEPS})
+
+add_executable(fsfocus fsfocus.c)
+target_link_libraries(fsfocus ${STATIC_DEPS})
+
+add_executable(gamma gamma.c getopt.c)
+target_link_libraries(gamma ${STATIC_DEPS})
+
+add_executable(glfwinfo glfwinfo.c getopt.c)
+target_link_libraries(glfwinfo ${STATIC_DEPS})
+
+add_executable(iconify iconify.c getopt.c)
+target_link_libraries(iconify ${STATIC_DEPS})
+
+add_executable(joysticks joysticks.c)
+target_link_libraries(joysticks ${STATIC_DEPS})
+
+add_executable(listmodes listmodes.c)
+target_link_libraries(listmodes ${STATIC_DEPS})
+
+add_executable(peter peter.c)
+target_link_libraries(peter ${STATIC_DEPS})
+
+add_executable(reopen reopen.c)
+target_link_libraries(reopen ${STATIC_DEPS})
+
+add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c)
+target_link_libraries(accuracy ${STATIC_DEPS})
+
+add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
+target_link_libraries(sharing ${STATIC_DEPS})
+
+add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
+target_link_libraries(tearing ${STATIC_DEPS})
+
+add_executable(windows WIN32 MACOSX_BUNDLE windows.c)
+target_link_libraries(windows ${STATIC_DEPS})
set(WINDOWS_BINARIES accuracy sharing tearing windows)
set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
@@ -47,13 +70,3 @@ if(MSVC)
LINK_FLAGS "/ENTRY:mainCRTStartup")
endif(MSVC)
-if(CYGWIN)
- # Set cross-compile and subsystem compile and link flags
- set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
- COMPILE_FLAGS "-mno-cygwin")
- set_target_properties(${WINDOWS_BINARIES} PROPERTIES
- LINK_FLAGS "-mno-cygwin -mwindows")
- set_target_properties(${CONSOLE_BINARIES} PROPERTIES
- LINK_FLAGS "-mno-cygwin -mconsole")
-endif(CYGWIN)
-
diff --git a/tests/dynamic.c b/tests/dynamic.c
new file mode 100644
index 00000000..8bc5568b
--- /dev/null
+++ b/tests/dynamic.c
@@ -0,0 +1,91 @@
+//========================================================================
+// Dynamic linking test
+// Copyright (c) Camilla Berglund
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+//
+// This test came about as the result of bug #3060461
+//
+//========================================================================
+
+#define GLFW_DLL
+#include
+
+#include
+#include
+
+static void window_size_callback(GLFWwindow window, int width, int height)
+{
+ glViewport(0, 0, width, height);
+}
+
+int main(void)
+{
+ GLFWwindow window;
+ int major, minor, rev;
+ glfwGetVersion(&major, &minor, &rev);
+
+ printf("GLFW header version: %i.%i.%i\n",
+ GLFW_VERSION_MAJOR,
+ GLFW_VERSION_MINOR,
+ GLFW_VERSION_REVISION);
+ printf("GLFW library version: %i.%i.%i\n", major, minor, rev);
+ printf("GLFW library version string: %s\n", glfwGetVersionString());
+
+ if (major != GLFW_VERSION_MAJOR ||
+ minor != GLFW_VERSION_MINOR ||
+ rev != GLFW_VERSION_REVISION)
+ {
+ fprintf(stderr, "GLFW library version mismatch\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (!glfwInit())
+ {
+ fprintf(stderr, "Failed to initialize GLFW\n");
+ exit(EXIT_FAILURE);
+ }
+
+ window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Dynamic Linking Test", NULL);
+ if (!window)
+ {
+ glfwTerminate();
+
+ fprintf(stderr, "Failed to open GLFW window\n");
+ exit(EXIT_FAILURE);
+ }
+
+ glfwSetWindowSizeCallback(window_size_callback);
+ glfwSwapInterval(1);
+
+ while (glfwIsWindow(window))
+ {
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glfwSwapBuffers();
+ glfwPollEvents();
+ }
+
+ glfwTerminate();
+ exit(EXIT_SUCCESS);
+}
+
diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c
index 9bcdd0f8..4de6634d 100644
--- a/tests/glfwinfo.c
+++ b/tests/glfwinfo.c
@@ -32,21 +32,28 @@
#include
#include
-#ifdef _MSC_VER
-#define strcasecmp(x, y) _stricmp(x, y)
-#endif
-
#include
#include
#include
#include "getopt.h"
+#ifdef _MSC_VER
+#define strcasecmp(x, y) _stricmp(x, y)
+#endif
+
+#define PROFILE_NAME_CORE "core"
+#define PROFILE_NAME_COMPAT "compat"
+#define PROFILE_NAME_ES2 "es2"
+
+#define STRATEGY_NAME_NONE "none"
+#define STRATEGY_NAME_LOSE "lose"
+
static void usage(void)
{
printf("Usage: version [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
- printf("available profiles: core compat es2\n");
- printf("available strategies: none lose\n");
+ printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT " " PROFILE_NAME_ES2 "\n");
+ printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
}
static void error_callback(int error, const char* description)
@@ -57,11 +64,11 @@ static void error_callback(int error, const char* description)
static const char* get_glfw_profile_name(int profile)
{
if (profile == GLFW_OPENGL_COMPAT_PROFILE)
- return "compatibility";
+ return PROFILE_NAME_COMPAT;
else if (profile == GLFW_OPENGL_CORE_PROFILE)
- return "core";
+ return PROFILE_NAME_CORE;
else if (profile == GLFW_OPENGL_ES2_PROFILE)
- return "es2";
+ return PROFILE_NAME_ES2;
return "unknown";
}
@@ -69,9 +76,9 @@ static const char* get_glfw_profile_name(int profile)
static const char* get_profile_name(GLint mask)
{
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
- return "compatibility";
+ return PROFILE_NAME_COMPAT;
if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
- return "core";
+ return PROFILE_NAME_CORE;
return "unknown";
}
@@ -142,11 +149,11 @@ int main(int argc, char** argv)
minor = atoi(optarg);
break;
case 'p':
- if (strcasecmp(optarg, "core") == 0)
+ if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0)
profile = GLFW_OPENGL_CORE_PROFILE;
- else if (strcasecmp(optarg, "compat") == 0)
+ else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0)
profile = GLFW_OPENGL_COMPAT_PROFILE;
- else if (strcasecmp(optarg, "es2") == 0)
+ else if (strcasecmp(optarg, PROFILE_NAME_ES2) == 0)
profile = GLFW_OPENGL_ES2_PROFILE;
else
{
@@ -155,9 +162,9 @@ int main(int argc, char** argv)
}
break;
case 'r':
- if (strcasecmp(optarg, "none") == 0)
+ if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0)
strategy = GLFW_OPENGL_NO_RESET_NOTIFICATION;
- else if (strcasecmp(optarg, "lose") == 0)
+ else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0)
strategy = GLFW_OPENGL_LOSE_CONTEXT_ON_RESET;
else
{
@@ -221,7 +228,9 @@ int main(int argc, char** argv)
if (major != GLFW_VERSION_MAJOR ||
minor != GLFW_VERSION_MINOR ||
revision != GLFW_VERSION_REVISION)
+ {
printf("*** WARNING: GLFW version mismatch! ***\n");
+ }
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
@@ -266,7 +275,7 @@ int main(int argc, char** argv)
if (major > 1)
{
printf("OpenGL context shading language version: \"%s\"\n",
- glGetString(GL_SHADING_LANGUAGE_VERSION));
+ glGetString(GL_SHADING_LANGUAGE_VERSION));
}
// Report OpenGL extensions
diff --git a/tests/peter.c b/tests/peter.c
index 50209908..cefdb103 100644
--- a/tests/peter.c
+++ b/tests/peter.c
@@ -37,22 +37,32 @@
static GLboolean cursor_captured = GL_FALSE;
static GLFWwindow window_handle = NULL;
+static int cursor_x;
+static int cursor_y;
static GLboolean open_window(void);
static void toggle_mouse_cursor(GLFWwindow window)
{
if (cursor_captured)
+ {
+ printf("Released cursor\n");
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
+ }
else
+ {
+ printf("Captured cursor\n");
glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED);
+ }
cursor_captured = !cursor_captured;
}
static void mouse_position_callback(GLFWwindow window, int x, int y)
{
- printf("Mouse moved to: %i %i\n", x, y);
+ printf("Mouse moved to: %i %i (%i %i)\n", x, y, x - cursor_x, y - cursor_y);
+ cursor_x = x;
+ cursor_y = y;
}
static void key_callback(GLFWwindow window, int key, int action)
@@ -87,14 +97,12 @@ static void window_size_callback(GLFWwindow window, int width, int height)
static GLboolean open_window(void)
{
- int x, y;
-
window_handle = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Peter Detector", NULL);
if (!window_handle)
return GL_FALSE;
- glfwGetMousePos(window_handle, &x, &y);
- printf("Mouse position: %i %i\n", x, y);
+ glfwGetMousePos(window_handle, &cursor_x, &cursor_y);
+ printf("Mouse position: %i %i\n", cursor_x, cursor_y);
glfwSetWindowSizeCallback(window_size_callback);
glfwSetMousePosCallback(mouse_position_callback);