diff --git a/readme.html b/readme.html
index 65fbf372..a028b45b 100644
--- a/readme.html
+++ b/readme.html
@@ -287,6 +287,7 @@ version of GLFW.
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 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
Replaced mouse wheel interface with two-dimensional scrolling interface
@@ -302,7 +303,7 @@ version of GLFW.
Removed GLFW_OPENED
window parameter
Removed nonsensical key actions for Unicode character input
Removed GLFWCALL
and GLFWAPIENTRY
macros for stdcall calling convention
- Bugfix: The default OpenGL version in the version
test was set to 1.1
+ Bugfix: The default OpenGL version in the glfwinfo
test was set to 1.1
Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation
Bugfix: The FSAA test did not check for the availability of GL_ARB_multisample
[Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index dd85f3f8..c7c0d6c5 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -228,6 +228,7 @@ int _glfwPlatformInit(void)
// Save the original gamma ramp
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
+ _glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
return GL_TRUE;
}
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 93e37089..4f662faf 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);
}
}
@@ -707,8 +688,8 @@ 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;
diff --git a/src/enable.c b/src/enable.c
index 82ba940c..897f0753 100644
--- a/src/enable.c
+++ b/src/enable.c
@@ -152,6 +152,7 @@ GLFWAPI void glfwEnable(GLFWwindow window, int token)
enableKeyRepeat(window);
break;
default:
+ _glfwSetError(GLFW_INVALID_ENUM, NULL);
break;
}
}
@@ -184,6 +185,7 @@ GLFWAPI void glfwDisable(GLFWwindow window, int token)
disableKeyRepeat(window);
break;
default:
+ _glfwSetError(GLFW_INVALID_ENUM, NULL);
break;
}
}
diff --git a/src/fullscreen.c b/src/fullscreen.c
index 7cc96bb7..631f6193 100644
--- a/src/fullscreen.c
+++ b/src/fullscreen.c
@@ -110,9 +110,18 @@ GLFWAPI int glfwGetVideoModes(GLFWvidmode* list, int maxcount)
return 0;
}
- if (maxcount <= 0 || list == NULL)
+ if (maxcount <= 0)
{
- // TODO: Figure out if this is an error
+ _glfwSetError(GLFW_INVALID_VALUE,
+ "glfwGetVideoModes: Parameter 'maxcount' must be "
+ "greater than zero");
+ return 0;
+ }
+
+ if (list == NULL)
+ {
+ _glfwSetError(GLFW_INVALID_VALUE,
+ "glfwGetVideoModes: Parameter 'list' cannot be NULL");
return 0;
}
diff --git a/src/input.c b/src/input.c
index 04c835a4..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 //////
//////////////////////////////////////////////////////////////////////////
@@ -53,7 +166,7 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
if (key < 0 || key > GLFW_KEY_LAST)
{
// TODO: Decide whether key is a value or enum
- _glfwSetError(GLFW_INVALID_VALUE,
+ _glfwSetError(GLFW_INVALID_ENUM,
"glfwGetKey: The specified key is invalid");
return GLFW_RELEASE;
}
@@ -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,6 +304,7 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode)
{
+ int centerPosX, centerPosY;
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
@@ -210,29 +324,17 @@ GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode)
if (window->cursorMode == mode)
return;
- int centerPosX = window->width / 2;
- int centerPosY = window->height / 2;
+ centerPosX = window->width / 2;
+ 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);
@@ -311,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 3b82d47e..477032ac 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -59,6 +59,10 @@
#include "config.h"
#include "../include/GL/glfw3.h"
+
+// This path may need to be changed if you build GLFW using your own setup
+// We ship and use our own copy of glext.h since GLFW uses fairly new
+// extensions and not all operating systems come with an up-to-date version
#include "../support/GL/glext.h"
#if defined(_GLFW_COCOA_NSGL)
@@ -180,7 +184,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];
@@ -339,12 +343,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/opengl.c b/src/opengl.c
index d75eee8f..f4c6984c 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -345,6 +345,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
return GL_TRUE;
}
+
//========================================================================
// Checks whether the specified context fulfils the requirements
// It blames glfwOpenWindow because that's the only caller
diff --git a/src/win32_init.c b/src/win32_init.c
index 51b3f093..a69cccd7 100644
--- a/src/win32_init.c
+++ b/src/win32_init.c
@@ -163,6 +163,7 @@ int _glfwPlatformInit(void)
// Save the original gamma ramp
_glfwLibrary.originalRampSize = 256;
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
+ _glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
_glfwInitTimer();
diff --git a/src/win32_platform.h b/src/win32_platform.h
index db5b82ae..8aa3561b 100644
--- a/src/win32_platform.h
+++ b/src/win32_platform.h
@@ -43,6 +43,9 @@
#include
#include
+// This path may need to be changed if you build GLFW using your own setup
+// We ship and use our own copy of wglext.h since GLFW uses fairly new
+// extensions and not all operating systems come with an up-to-date version
#include "../support/GL/wglext.h"
@@ -251,7 +254,7 @@ typedef struct _GLFWwindowWin32
// Various platform specific internal variables
int desiredRefreshRate; // Desired vertical monitor refresh rate
- GLboolean mouseMoved;
+ GLboolean cursorCentered;
int oldMouseX, oldMouseY;
} _GLFWwindowWin32;
diff --git a/src/win32_window.c b/src/win32_window.c
index 1bfef9f5..d81da139 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -472,6 +472,50 @@ static GLboolean createContext(_GLFWwindow* window,
}
+//========================================================================
+// Hide mouse cursor
+//========================================================================
+
+static void hideMouseCursor(_GLFWwindow* window)
+{
+}
+
+
+//========================================================================
+// Capture mouse cursor
+//========================================================================
+
+static void captureMouseCursor(_GLFWwindow* window)
+{
+ RECT ClipWindowRect;
+
+ ShowCursor(FALSE);
+
+ // Clip cursor to the window
+ if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
+ ClipCursor(&ClipWindowRect);
+
+ // Capture cursor to user window
+ SetCapture(window->Win32.handle);
+}
+
+
+//========================================================================
+// Show mouse cursor
+//========================================================================
+
+static void showMouseCursor(_GLFWwindow* window)
+{
+ // Un-capture cursor
+ ReleaseCapture();
+
+ // Release the cursor from the window
+ ClipCursor(NULL);
+
+ ShowCursor(TRUE);
+}
+
+
//========================================================================
// Translates a Windows key to the corresponding GLFW key
//========================================================================
@@ -808,15 +852,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;
}
@@ -962,32 +998,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;
@@ -1009,9 +1040,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)
{
@@ -1020,21 +1048,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)
{
@@ -1042,15 +1061,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;
}
@@ -1352,8 +1371,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;
}
@@ -1761,14 +1780,14 @@ void _glfwPlatformPollEvents(void)
window = _glfwLibrary.activeWindow;
if (window)
{
- window->Win32.mouseMoved = GL_FALSE;
+ window->Win32.cursorCentered = GL_FALSE;
window->Win32.oldMouseX = window->width / 2;
window->Win32.oldMouseY = window->height / 2;
}
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))
@@ -1846,41 +1865,6 @@ void _glfwPlatformWaitEvents(void)
}
-//========================================================================
-// Hide mouse cursor (lock it)
-//========================================================================
-
-void _glfwPlatformHideMouseCursor(_GLFWwindow* window)
-{
- RECT ClipWindowRect;
-
- ShowCursor(FALSE);
-
- // Clip cursor to the window
- if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
- ClipCursor(&ClipWindowRect);
-
- // Capture cursor to user window
- SetCapture(window->Win32.handle);
-}
-
-
-//========================================================================
-// Show mouse cursor (unlock it)
-//========================================================================
-
-void _glfwPlatformShowMouseCursor(_GLFWwindow* window)
-{
- // Un-capture cursor
- ReleaseCapture();
-
- // Release the cursor from the window
- ClipCursor(NULL);
-
- ShowCursor(TRUE);
-}
-
-
//========================================================================
// Set physical mouse cursor position
//========================================================================
@@ -1897,3 +1881,24 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
SetCursorPos(pos.x, pos.y);
}
+
+//========================================================================
+// Set physical mouse cursor mode
+//========================================================================
+
+void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
+{
+ switch (mode)
+ {
+ case GLFW_CURSOR_NORMAL:
+ showMouseCursor(window);
+ break;
+ case GLFW_CURSOR_HIDDEN:
+ hideMouseCursor(window);
+ break;
+ case GLFW_CURSOR_CAPTURED:
+ captureMouseCursor(window);
+ break;
+ }
+}
+
diff --git a/src/window.c b/src/window.c
index a39125ef..68893f09 100644
--- a/src/window.c
+++ b/src/window.c
@@ -103,85 +103,6 @@ void _glfwSetDefaultWindowHints(void)
}
-//========================================================================
-// 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 window focus events
//========================================================================
@@ -227,6 +148,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 //////
//////////////////////////////////////////////////////////////////////////
@@ -468,6 +444,7 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
_glfwLibrary.hints.glRobustness = hint;
break;
default:
+ _glfwSetError(GLFW_INVALID_ENUM, NULL);
break;
}
}
@@ -748,12 +725,10 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
return window->glProfile;
case GLFW_OPENGL_ROBUSTNESS:
return window->glRobustness;
- default:
- _glfwSetError(GLFW_INVALID_ENUM,
- "glfwGetWindowParam: Invalid enum value for 'param' "
- "parameter");
- return 0;
}
+
+ _glfwSetError(GLFW_INVALID_ENUM, NULL);
+ return 0;
}
@@ -818,6 +793,7 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun)
}
}
+
//========================================================================
// Set callback function for window close events
//========================================================================
diff --git a/src/x11_enable.c b/src/x11_enable.c
index 9b439385..49961395 100644
--- a/src/x11_enable.c
+++ b/src/x11_enable.c
@@ -48,6 +48,7 @@ void _glfwPlatformEnableSystemKeys(_GLFWwindow* window)
}
}
+
//========================================================================
// Disable system keys
//========================================================================
diff --git a/src/x11_fullscreen.c b/src/x11_fullscreen.c
index c154fe3d..bb0a3d53 100644
--- a/src/x11_fullscreen.c
+++ b/src/x11_fullscreen.c
@@ -45,21 +45,16 @@
int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
{
int i, match, bestmatch;
-#if defined(_GLFW_HAS_XRANDR)
- int sizecount, bestsize;
- int ratecount, bestrate;
- short* ratelist;
- XRRScreenConfiguration* sc;
- XRRScreenSize* sizelist;
-#endif /*_GLFW_HAS_XRANDR*/
-#if defined(_GLFW_HAS_XF86VIDMODE)
- XF86VidModeModeInfo** modelist;
- int bestmode, modecount;
-#endif /*_GLFW_HAS_XF86VIDMODE*/
if (_glfwLibrary.X11.RandR.available)
{
#if defined(_GLFW_HAS_XRANDR)
+ int sizecount, bestsize;
+ int ratecount, bestrate;
+ short* ratelist;
+ XRRScreenConfiguration* sc;
+ XRRScreenSize* sizelist;
+
sc = XRRGetScreenInfo(_glfwLibrary.X11.display,
RootWindow(_glfwLibrary.X11.display, screen));
@@ -108,7 +103,6 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
}
}
- // Free modelist
XRRFreeScreenConfigInfo(sc);
if (bestsize != -1)
@@ -118,6 +112,9 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
else if (_glfwLibrary.X11.VidMode.available)
{
#if defined(_GLFW_HAS_XF86VIDMODE)
+ XF86VidModeModeInfo** modelist;
+ int bestmode, modecount;
+
// Get a list of all available display modes
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
&modecount, &modelist);
@@ -145,7 +142,6 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
*height = modelist[bestmode]->vdisplay;
}
- // Free modelist
XFree(modelist);
if (bestmode != -1)
@@ -167,18 +163,12 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
void _glfwSetVideoModeMODE(int screen, int mode, int rate)
{
-#if defined(_GLFW_HAS_XRANDR)
- XRRScreenConfiguration* sc;
- Window root;
-#endif /*_GLFW_HAS_XRANDR*/
-#if defined(_GLFW_HAS_XF86VIDMODE)
- XF86VidModeModeInfo **modelist;
- int modecount;
-#endif /*_GLFW_HAS_XF86VIDMODE*/
-
if (_glfwLibrary.X11.RandR.available)
{
#if defined(_GLFW_HAS_XRANDR)
+ XRRScreenConfiguration* sc;
+ Window root;
+
root = RootWindow(_glfwLibrary.X11.display, screen);
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, root);
@@ -220,6 +210,9 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
else if (_glfwLibrary.X11.VidMode.available)
{
#if defined(_GLFW_HAS_XF86VIDMODE)
+ XF86VidModeModeInfo **modelist;
+ int modecount;
+
// Get a list of all available display modes
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
&modecount, &modelist);
@@ -229,8 +222,7 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
XF86VidModeLockModeSwitch(_glfwLibrary.X11.display, screen, 0);
// Change the video mode to the desired mode
- XF86VidModeSwitchToMode(_glfwLibrary.X11.display, screen,
- modelist[mode]);
+ XF86VidModeSwitchToMode(_glfwLibrary.X11.display, screen, modelist[mode]);
// Set viewport to upper left corner (where our window will be)
XF86VidModeSetViewPort(_glfwLibrary.X11.display, screen, 0, 0);
@@ -245,7 +237,6 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
_glfwLibrary.X11.FS.modeChanged = GL_TRUE;
}
- // Free mode list
XFree(modelist);
#endif /*_GLFW_HAS_XF86VIDMODE*/
}
@@ -338,21 +329,13 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
int viscount, rgbcount, rescount;
int* rgbarray;
struct _glfwResolution* resarray;
-#if defined(_GLFW_HAS_XRANDR)
- XRRScreenConfiguration* sc;
- XRRScreenSize* sizelist;
- int sizecount;
-#endif /*_GLFW_HAS_XRANDR*/
-#if defined(_GLFW_HAS_XF86VIDMODE)
- XF86VidModeModeInfo** modelist;
- int modecount, width, height;
-#endif /*_GLFW_HAS_XF86VIDMODE*/
// Get list of visuals
vislist = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &viscount);
if (vislist == NULL)
{
- // TODO: Figure out which error this is
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "X11/GLX: Failed to retrieve the available visuals");
return 0;
}
@@ -397,6 +380,10 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
if (_glfwLibrary.X11.RandR.available)
{
#if defined(_GLFW_HAS_XRANDR)
+ XRRScreenConfiguration* sc;
+ XRRScreenSize* sizelist;
+ int sizecount;
+
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
sizelist = XRRConfigSizes(sc, &sizecount);
@@ -415,6 +402,9 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
else if (_glfwLibrary.X11.VidMode.available)
{
#if defined(_GLFW_HAS_XF86VIDMODE)
+ XF86VidModeModeInfo** modelist;
+ int modecount, width, height;
+
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * modecount);
@@ -467,7 +457,6 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
}
}
- // Free visuals list
XFree(vislist);
_glfwFree(resarray);
@@ -484,15 +473,9 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
{
int bpp;
-#if defined(_GLFW_HAS_XF86VIDMODE)
- XF86VidModeModeInfo** modelist;
- int modecount;
-#endif /*_GLFW_HAS_XF86VIDMODE*/
- // Get display depth
+ // Get and split display depth
bpp = DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
-
- // Convert BPP to RGB bits
_glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
if (_glfwLibrary.X11.FS.modeChanged)
diff --git a/src/x11_init.c b/src/x11_init.c
index 1fa549bd..21b42240 100644
--- a/src/x11_init.c
+++ b/src/x11_init.c
@@ -32,6 +32,7 @@
#include
#include
+#include
//========================================================================
@@ -516,6 +517,7 @@ static void initGammaRamp(void)
// Save the original gamma ramp
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
+ _glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
}
diff --git a/src/x11_platform.h b/src/x11_platform.h
index 6f1bf6a5..ca4d1fd5 100644
--- a/src/x11_platform.h
+++ b/src/x11_platform.h
@@ -41,6 +41,9 @@
#define GLX_GLXEXT_LEGACY
#include
+// This path may need to be changed if you build GLFW using your own setup
+// We ship and use our own copy of glxext.h since GLFW uses fairly new
+// extensions and not all operating systems come with an up-to-date version
#include "../support/GL/glxext.h"
@@ -204,7 +207,7 @@ typedef struct _GLFWlibraryX11
} Xkb;
// Key code LUT (mapping X11 key codes to GLFW key codes)
- int keyCodeLUT[256];
+ int keyCodeLUT[256];
// Screensaver data
struct {
@@ -233,7 +236,7 @@ typedef struct _GLFWlibraryX11
struct {
GLboolean monotonic;
double resolution;
- uint64_t t0;
+ uint64_t base;
} timer;
// Selection data
diff --git a/src/x11_time.c b/src/x11_time.c
index 431389c4..e2203941 100644
--- a/src/x11_time.c
+++ b/src/x11_time.c
@@ -78,7 +78,7 @@ void _glfwInitTimer(void)
_glfwLibrary.X11.timer.resolution = 1e-6;
}
- _glfwLibrary.X11.timer.t0 = getRawTime();
+ _glfwLibrary.X11.timer.base = getRawTime();
}
@@ -92,7 +92,7 @@ void _glfwInitTimer(void)
double _glfwPlatformGetTime(void)
{
- return (double) (getRawTime() - _glfwLibrary.X11.timer.t0) *
+ return (double) (getRawTime() - _glfwLibrary.X11.timer.base) *
_glfwLibrary.X11.timer.resolution;
}
@@ -101,9 +101,9 @@ double _glfwPlatformGetTime(void)
// Set timer value in seconds
//========================================================================
-void _glfwPlatformSetTime(double t)
+void _glfwPlatformSetTime(double time)
{
- _glfwLibrary.X11.timer.t0 = getRawTime() -
- (uint64_t) (t / _glfwLibrary.X11.timer.resolution);
+ _glfwLibrary.X11.timer.base = getRawTime() -
+ (uint64_t) (time / _glfwLibrary.X11.timer.resolution);
}
diff --git a/src/x11_window.c b/src/x11_window.c
index 0fe4db83..8d19aff8 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -206,6 +206,7 @@ static GLboolean hasEWMH(_GLFWwindow* window)
return GL_TRUE;
}
+
//========================================================================
// Translates an X Window key to internal coding
//========================================================================
@@ -974,6 +975,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
window->width / 2, window->height / 2);
}
+
//========================================================================
// Leave fullscreen mode
//========================================================================
@@ -1192,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;
@@ -1234,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;
}
@@ -1303,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;
}
@@ -1321,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;
}
@@ -1375,9 +1349,7 @@ static void processSingleEvent(void)
return;
}
- if (_glfwLibrary.windowRefreshCallback)
- _glfwLibrary.windowRefreshCallback(window);
-
+ _glfwInputWindowDamage(window);
break;
}
@@ -1520,8 +1492,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;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 23a1ebd0..95d5cd06 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -11,12 +11,12 @@ 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)
-add_executable(version version.c getopt.c)
if(APPLE)
# Set fancy names for bundles
@@ -33,8 +33,8 @@ else()
endif(APPLE)
set(WINDOWS_BINARIES accuracy sharing tearing windows)
-set(CONSOLE_BINARIES clipboard defaults events fsaa fsfocus gamma iconify
- joysticks listmodes peter reopen version)
+set(CONSOLE_BINARIES clipboard defaults events fsaa fsfocus gamma glfwinfo iconify
+ joysticks listmodes peter reopen)
if(MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
diff --git a/tests/accuracy.c b/tests/accuracy.c
index c3bebaca..f235cf75 100644
--- a/tests/accuracy.c
+++ b/tests/accuracy.c
@@ -78,17 +78,10 @@ int main(void)
glfwSetWindowSizeCallback(window_size_callback);
glfwSwapInterval(1);
- glClearColor(0, 0, 0, 0);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
while (glfwIsWindow(window))
{
glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1.f, 1.f, 1.f);
-
glBegin(GL_LINES);
glVertex2f(0.f, (GLfloat) window_height - cursor_y);
glVertex2f((GLfloat) window_width, (GLfloat) window_height - cursor_y);
diff --git a/tests/fsaa.c b/tests/fsaa.c
index 404e77f4..6cdb77e0 100644
--- a/tests/fsaa.c
+++ b/tests/fsaa.c
@@ -132,8 +132,6 @@ int main(int argc, char** argv)
glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1.f, 1.f, 1.f);
-
glLoadIdentity();
glTranslatef(0.25f, 0.25f, 0.f);
glRotatef(time, 0.f, 0.f, 1.f);
diff --git a/tests/version.c b/tests/glfwinfo.c
similarity index 89%
rename from tests/version.c
rename to tests/glfwinfo.c
index 9bcdd0f8..4de6634d 100644
--- a/tests/version.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);
diff --git a/tests/reopen.c b/tests/reopen.c
index 9d76580f..2922cb84 100644
--- a/tests/reopen.c
+++ b/tests/reopen.c
@@ -62,7 +62,7 @@ static void window_size_callback(GLFWwindow window, int width, int height)
static int window_close_callback(GLFWwindow window)
{
printf("Close callback triggered\n");
- window_handle = NULL;
+ closed = GL_TRUE;
return 0;
}
@@ -136,9 +136,6 @@ int main(int argc, char** argv)
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
glMatrixMode(GL_MODELVIEW);
- glClearColor(0.f, 0.f, 0.f, 0.f);
- glColor3f(1.f, 1.f, 1.f);
-
glfwSetTime(0.0);
while (glfwGetTime() < 5.0)
diff --git a/tests/tearing.c b/tests/tearing.c
index 6e43e88f..10170b0f 100644
--- a/tests/tearing.c
+++ b/tests/tearing.c
@@ -62,9 +62,6 @@ int main(void)
glfwSetWindowSizeCallback(window_size_callback);
glfwSwapInterval(1);
- glClearColor(0.f, 0.f, 0.f, 0.f);
- glColor3f(1.f, 1.f, 1.f);
-
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
glMatrixMode(GL_MODELVIEW);
diff --git a/tests/windows.c b/tests/windows.c
index ddb8a224..c7ff32b2 100644
--- a/tests/windows.c
+++ b/tests/windows.c
@@ -66,7 +66,10 @@ int main(void)
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
- glClearColor((GLclampf) (i & 1), (GLclampf) (i >> 1), 0.0, 0.0);
+ glClearColor((GLclampf) (i & 1),
+ (GLclampf) (i >> 1),
+ i ? 0.0 : 1.0,
+ 0.0);
}
while (running)