Updated glfw to version 3.1.1.

This commit is contained in:
Faerbit 2015-06-03 23:15:52 +02:00
parent 8452d18575
commit 3437ce6173
42 changed files with 551 additions and 665 deletions

38
extern/glfw/CMake/AppleInfo.plist vendored Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${APPLE_GUI_EXECUTABLE}</string>
<key>CFBundleGetInfoString</key>
<string>${APPLE_GUI_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${APPLE_GUI_ICON}</string>
<key>CFBundleIdentifier</key>
<string>${APPLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${APPLE_GUI_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${APPLE_GUI_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${APPLE_GUI_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${APPLE_GUI_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${APPLE_GUI_COPYRIGHT}</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>

View File

@ -1,19 +0,0 @@
#----------------------------------------------------------------
# Generated CMake target import file for configuration "Release".
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "glfw" for configuration "Release"
set_property(TARGET glfw APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(glfw PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libglfw3.a"
)
list(APPEND _IMPORT_CHECK_TARGETS glfw )
list(APPEND _IMPORT_CHECK_FILES_FOR_glfw "${_IMPORT_PREFIX}/lib/libglfw3.a" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)

View File

@ -1,84 +0,0 @@
# Generated by CMake 3.1.3
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget glfw)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
endif()
if(TARGET ${_expectedTarget})
list(APPEND _targetsDefined ${_expectedTarget})
endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
# Create imported target glfw
add_library(glfw STATIC IMPORTED)
# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/glfwTargets-*.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
endforeach()
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
if(NOT EXISTS "${file}" )
message(FATAL_ERROR "The imported target \"${target}\" references the file
\"${file}\"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
\"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
endif()
endforeach()
unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)
# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)

View File

@ -10,7 +10,7 @@ endif()
set(GLFW_VERSION_MAJOR "3") set(GLFW_VERSION_MAJOR "3")
set(GLFW_VERSION_MINOR "1") set(GLFW_VERSION_MINOR "1")
set(GLFW_VERSION_PATCH "0") set(GLFW_VERSION_PATCH "1")
set(GLFW_VERSION_EXTRA "") set(GLFW_VERSION_EXTRA "")
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}") set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}") set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}")
@ -273,11 +273,9 @@ if (_GLFW_X11)
list(APPEND glfw_PKG_DEPS "xinerama") list(APPEND glfw_PKG_DEPS "xinerama")
# Check for XInput (high-resolution cursor motion) # Check for XInput (high-resolution cursor motion)
if (NOT X11_Xinput_FOUND) if (X11_Xinput_FOUND)
message(FATAL_ERROR "The XInput library and headers were not found")
endif()
list(APPEND glfw_INCLUDE_DIRS "${X11_Xinput_INCLUDE_PATH}") list(APPEND glfw_INCLUDE_DIRS "${X11_Xinput_INCLUDE_PATH}")
list(APPEND glfw_PKG_DEPS "xi")
if (X11_Xinput_LIB) if (X11_Xinput_LIB)
list(APPEND glfw_LIBRARIES "${X11_Xinput_LIB}") list(APPEND glfw_LIBRARIES "${X11_Xinput_LIB}")
@ -285,13 +283,12 @@ if (_GLFW_X11)
# Backwards compatibility (bug in CMake 2.8.7) # Backwards compatibility (bug in CMake 2.8.7)
list(APPEND glfw_LIBRARIES Xi) list(APPEND glfw_LIBRARIES Xi)
endif() endif()
list(APPEND glfw_PKG_DEPS "xi")
# Check for Xf86VidMode (fallback gamma control) set(_GLFW_HAS_XINPUT TRUE)
if (NOT X11_xf86vmode_FOUND)
message(FATAL_ERROR "The Xf86VidMode library and headers were not found")
endif() endif()
# Check for Xf86VidMode (fallback gamma control)
if (X11_xf86vmode_FOUND)
list(APPEND glfw_INCLUDE_DIRS "${X11_xf86vmode_INCLUDE_PATH}") list(APPEND glfw_INCLUDE_DIRS "${X11_xf86vmode_INCLUDE_PATH}")
list(APPEND glfw_PKG_DEPS "xxf86vm") list(APPEND glfw_PKG_DEPS "xxf86vm")
@ -302,6 +299,9 @@ if (_GLFW_X11)
list(APPEND glfw_LIBRARIES Xxf86vm) list(APPEND glfw_LIBRARIES Xxf86vm)
endif() endif()
set(_GLFW_HAS_XF86VM TRUE)
endif()
# Check for Xkb (X keyboard extension) # Check for Xkb (X keyboard extension)
if (NOT X11_Xkb_FOUND) if (NOT X11_Xkb_FOUND)
message(FATAL_ERROR "The X keyboard extension headers were not found") message(FATAL_ERROR "The X keyboard extension headers were not found")

135
extern/glfw/README.md vendored
View File

@ -6,10 +6,8 @@ GLFW is a free, Open Source, multi-platform library for OpenGL and OpenGL ES
application development. It provides a simple, platform-independent API for application development. It provides a simple, platform-independent API for
creating windows and contexts, reading input, handling events, etc. creating windows and contexts, reading input, handling events, etc.
Version 3.1 adds improved documentation, support for custom system cursors, file Version 3.1.1 adds fixes for a number of bugs that together affect all supported
drop events, main thread wake-up, window frame size retrieval, floating windows, platforms, most notably workarounds for bugs in some popular window managers.
character input with modifier keys, single buffered windows, build improvements
and fixes for a large number of bugs.
If you are new to GLFW, you may find the If you are new to GLFW, you may find the
[introductory tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW [introductory tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW
@ -65,110 +63,26 @@ GLFW bundles a number of dependencies in the `deps/` directory.
## Changelog ## Changelog
- Added `GLFWcursor` custom system cursor handle - Made library compilation fail if any header option macros are defined
- Added `glfwCreateCursor`, `glfwCreateStandardCursor`, `glfwDestroyCursor` and - Removed support for LCC and Borland C++
`glfwSetCursor` for managing system cursor images - Bugfix: `glfwSetTime` silently accepted invalid values
- Added `GLFWimage` struct for passing 32-bit RGBA images - [Cocoa] Bugfix: `NSHighResolutionCapable` was not enabled for test and
- Added monitor and adapter identifier access to native API example programs
- Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files - [Cocoa] Bugfix: Sleeping monitors were not included in the monitor list
- Added `glfwPostEmptyEvent` for allowing secondary threads to cause - [Cocoa] Bugfix: `glfwSetWindowSize` did not change the video mode for full
`glfwWaitEvents` to return screen windows
- Added `empty` test program for verifying posting of empty events - [X11] Added support for Cygwin-X
- Added `glfwSetCharModsCallback` for receiving character events with modifiers - [X11] Made XInput2 optional at compile-time
- Added `glfwGetWindowFrameSize` for retrieving the size of the frame around - [X11] Made Xxf86vm optional at compile-time
the client area of a window - [X11] Bugfix: Moved `_NET_REQUEST_FRAME_EXTENTS` request to
- Added `GLFW_AUTO_ICONIFY` for controlling whether full screen windows `glfwGetWindowFrameSize` and added protocol-breaking timeout
automatically iconify (and restore the previous video mode) on focus loss as a workaround for broken support in Unity, Fluxbox and Xfwm
- Added `GLFW_DONT_CARE` for indicating that any value is acceptable - [X11] Bugfix: Mouse button `GLFW_MOUSE_BUTTON_4` was never used
- Added `GLFW_DOUBLEBUFFER` for controlling whether to use double buffering - [X11] Bugfix: `glfwTerminate` could close an unrelated file descriptor
- Added `GLFW_CONTEXT_RELEASE_BEHAVIOR` and values - [X11] Bugfix: Some WMs (KWM, Fluxbox) did not respect cursor redefinition
`GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` and - [WGL] Bugfix: The context flags debug bit was not set for OpenGL ES
`GLFW_RELEASE_BEHAVIOR_NONE` for `GL_KHR_context_flush_control` support - [GLX] Bugfix: The context flags debug bit was not set for OpenGL ES
- Added `GLFW_INCLUDE_ES31` for including the OpenGL ES 3.1 header - [EGL] Bugfix: The context flags debug bit was not set for OpenGL ES
- Added `GLFW_FLOATING` for creating always-on-top windowed mode windows
- Added `GLFW_FOCUSED` window hint for controlling initial input focus
- Added *partial and experimental* support for Wayland
- Added *partial and experimental* support for Mir
- Changed the window state attributes (focused, iconified and visible) to query
the system directly
- Changed the default of `GLFW_REFRESH_RATE` to `GLFW_DONT_CARE` to maintain
the default behavior
- Changed static library to build as position independent code for easier use
from the Rust language
- Changed `glfwGetCursorPos` to query the system directly for all cursor modes
except captured mode
- Bugfix: The debug context attribute was set from `GL_ARB_debug_output` even
when a debug context had not been requested
- Bugfix: The particles example was not linked against the threading library
- Bugfix: The cursor was not positioned over newly created full screen windows
- Bugfix: The queried cursor position was not always up-to-date
- Bugfix: `glfwExtensionSupported` always failed for OpenGL ES 3.0 and later if
the library was compiled for OpenGL ES
- [Cocoa] Added `_GLFW_USE_RETINA` to control whether windows will use the full
resolution on Retina displays
- [Cocoa] Made content view subclass of `NSOpenGLView`
- [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen
recorders to fail
- [Cocoa] Bugfix: Some Core Foundation objects were leaked during joystick
enumeration and termination
- [Cocoa] Bugfix: One copy of each display name string was leaked
- [Cocoa] Bugfix: Monitor enumeration caused a segfault if no `NSScreen` was
found for a given `CGDisplay`
- [Cocoa] Bugfix: Modifier key events were lost if the corresponding modifier
bit field was unchanged
- [Cocoa] Bugfix: Joystick enumeration took hundreds of ms on some systems
- [Cocoa] Bugfix: The cursor was hidden when the user resized a GLFW window
- [Cocoa] Bugfix: The 10.10 Yosemite OpenGL 4.1 profile token was not used
- [Cocoa] Bugfix: The generic software OpenGL renderer could be selected under
certain conditions
- [Cocoa] Bugfix: The virtual cursor jumped unpredictably when entering
disabled cursor mode
- [Win32] Enabled generation of pkg-config file for MinGW
- [Win32] Removed option to require explicitly linking against `winmm.dll`
- [Win32] Bugfix: Failure to load winmm or its functions was not reported to
the error callback
- [Win32] Bugfix: Some keys were reported based on the current layout instead
of their physical location
- [Win32] Bugfix: Maximized hidden windows were restored by `glfwShowWindow`
- [Win32] Bugfix: Context re-creation was not triggered by sRGB hint
- [Win32] Bugfix: Full screen windows were incorrectly sized and placed on some
systems
- [Win32] Bugfix: Gamma ramp functions acted on entire desktop instead of the
specified monitor
- [Win32] Bugfix: The wrong incorrect physical size was returned for
non-primary monitors
- [Win32] Bugfix: X-axis scroll offsets were inverted
- [Win32] Bugfix: The Optimus HPG forcing variable was not correctly exported
- [Win32] Bugfix: The iconified window state attribute was not always updated
- [Win32] Bugfix: Previously focused windows with disabled cursor mode and that
had been iconified by Win+D were not visible when restored
- [Win32] Bugfix: The virtual cursor jumped unpredictably when entering
disabled cursor mode
- [X11] Added run-time support for systems lacking the XKB extension
- [X11] Made GLX 1.3 the minimum supported version
- [X11] Replaced `XRRGetScreenResources` with `XRRGetScreenResourcesCurrent`
for monitor property retrieval
- [X11] Bugfix: The case of finding no usable CRTCs was not detected
- [X11] Bugfix: Detection of broken Nvidia RandR gamma support did not verify
that at least one CRTC was present
- [X11] Bugfix: A stale `_NET_SUPPORTING_WM_CHECK` root window property would
cause an uncaught `BadWindow` error
- [X11] Bugfix: No check was made for the presence of GLX 1.3 when
`GLX_SGIX_fbconfig` was unavailable
- [X11] Bugfix: The message type of ICCCM protocol events was not checked
- [X11] Bugfix: `glfwDestroyWindow` did not flush the output buffer
- [X11] Bugfix: Window frame interactions were reported as focus events
- [X11] Bugfix: Workaround for legacy Compiz caused flickering during resize
- [X11] Bugfix: The name pointer of joysticks were not cleared on disconnection
- [X11] Bugfix: Video mode resolutions and monitor physical sizes were not
corrected for rotated CRTCs
- [X11] Bugfix: Unicode character input ignored dead keys
- [X11] Bugfix: X-axis scroll offsets were inverted
- [X11] Bugfix: Full screen override redirect windows were not always
positioned over the specified monitor
- [X11] Bugfix: Character input did not work for the default `"C"` locale
- [X11] Bugfix: Joysticks connected after `glfwInit` were not detected
(temporary inotify solution until proper libudev solution)
## Contact ## Contact
@ -216,6 +130,7 @@ skills.
- Michael Dickens - Michael Dickens
- Jonathan Dummer - Jonathan Dummer
- Ralph Eastwood - Ralph Eastwood
- Siavash Eliasi
- Michael Fogleman - Michael Fogleman
- Gerald Franz - Gerald Franz
- GeO4d - GeO4d
@ -241,8 +156,10 @@ skills.
- Hans Mackowiak - Hans Mackowiak
- Kyle McDonald - Kyle McDonald
- David Medlock - David Medlock
- Bryce Mehring
- Jonathan Mercier - Jonathan Mercier
- Marcel Metz - Marcel Metz
- Jonathan Miller
- Kenneth Miller - Kenneth Miller
- Bruce Mitchener - Bruce Mitchener
- Jack Moffitt - Jack Moffitt
@ -260,6 +177,7 @@ skills.
- Pieroman - Pieroman
- Jorge Rodriguez - Jorge Rodriguez
- Ed Ropple - Ed Ropple
- Aleksey Rybalkin
- Riku Salminen - Riku Salminen
- Brandon Schaefer - Brandon Schaefer
- Sebastian Schuberth - Sebastian Schuberth
@ -276,6 +194,7 @@ skills.
- Nathan Sweet - Nathan Sweet
- TTK-Bandit - TTK-Bandit
- Sergey Tikhomirov - Sergey Tikhomirov
- A. Tombs
- Samuli Tuomola - Samuli Tuomola
- urraka - urraka
- Jari Vetoniemi - Jari Vetoniemi

View File

@ -1,3 +1,4 @@
#include <stdio.h>
#include <string.h> #include <string.h>
#include <glad/glad.h> #include <glad/glad.h>
@ -687,9 +688,33 @@ static void find_extensionsGL(void) {
} }
static void find_coreGL(void) { static void find_coreGL(void) {
const char *v = (const char *)glGetString(GL_VERSION);
int major = v[0] - '0'; /* Thank you @elmindreda
int minor = v[2] - '0'; * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176
* https://github.com/glfw/glfw/blob/master/src/context.c#L36
*/
int i, major, minor;
const char* version;
const char* prefixes[] = {
"OpenGL ES-CM ",
"OpenGL ES-CL ",
"OpenGL ES ",
NULL
};
version = (const char*) glGetString(GL_VERSION);
if (!version) return;
for (i = 0; prefixes[i]; i++) {
const size_t length = strlen(prefixes[i]);
if (strncmp(version, prefixes[i], length) == 0) {
version += length;
break;
}
}
sscanf(version, "%d.%d", &major, &minor);
GLVersion.major = major; GLVersion.minor = minor; GLVersion.major = major; GLVersion.minor = minor;
GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
@ -704,10 +729,11 @@ static void find_coreGL(void) {
GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
} }
void gladLoadGLLoader(GLADloadproc load) { int gladLoadGLLoader(GLADloadproc load) {
GLVersion.major = 0; GLVersion.minor = 0; GLVersion.major = 0; GLVersion.minor = 0;
glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
if(glGetString == NULL) return; if(glGetString == NULL) return 0;
if(glGetString(GL_VERSION) == NULL) return 0;
find_coreGL(); find_coreGL();
load_GL_VERSION_1_0(load); load_GL_VERSION_1_0(load);
load_GL_VERSION_1_1(load); load_GL_VERSION_1_1(load);
@ -722,7 +748,6 @@ void gladLoadGLLoader(GLADloadproc load) {
load_GL_VERSION_3_2(load); load_GL_VERSION_3_2(load);
find_extensionsGL(); find_extensionsGL();
return GLVersion.major != 0 || GLVersion.minor != 0;
return;
} }

View File

@ -22,15 +22,17 @@
#define APIENTRYP APIENTRY * #define APIENTRYP APIENTRY *
#endif #endif
extern struct gladGLversionStruct {
int major;
int minor;
} GLVersion;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct gladGLversionStruct {
int major;
int minor;
};
extern struct gladGLversionStruct GLVersion;
typedef void* (* GLADloadproc)(const char *name); typedef void* (* GLADloadproc)(const char *name);
#ifndef GLAPI #ifndef GLAPI
@ -58,7 +60,7 @@ typedef void* (* GLADloadproc)(const char *name);
# define GLAPI extern # define GLAPI extern
# endif # endif
#endif #endif
GLAPI void gladLoadGLLoader(GLADloadproc); GLAPI int gladLoadGLLoader(GLADloadproc);
#include <stddef.h> #include <stddef.h>
#include <KHR/khrplatform.h> #include <KHR/khrplatform.h>
@ -836,11 +838,13 @@ typedef GLintptr GLvdpauSurfaceNV;
#define GL_UNIFORM_BUFFER_START 0x8A29 #define GL_UNIFORM_BUFFER_START 0x8A29
#define GL_UNIFORM_BUFFER_SIZE 0x8A2A #define GL_UNIFORM_BUFFER_SIZE 0x8A2A
#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
@ -859,6 +863,7 @@ typedef GLintptr GLvdpauSurfaceNV;
#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
#define GL_INVALID_INDEX 0xFFFFFFFF #define GL_INVALID_INDEX 0xFFFFFFFF
#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001

View File

@ -41,7 +41,9 @@ if (APPLE)
set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
set_target_properties(Boing Gears Heightmap Particles Simple SplitView Wave PROPERTIES set_target_properties(Boing Gears Heightmap Particles Simple SplitView Wave PROPERTIES
FOLDER "GLFW3/Examples") FOLDER "GLFW3/Examples"
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/AppleInfo.plist")
else() else()
# Set boring names for executables # Set boring names for executables
add_executable(boing WIN32 boing.c) add_executable(boing WIN32 boing.c)

View File

@ -371,7 +371,9 @@ static void framebufferSizeFun(GLFWwindow* window, int w, int h)
static void windowRefreshFun(GLFWwindow* window) static void windowRefreshFun(GLFWwindow* window)
{ {
do_redraw = 1; drawAllViews();
glfwSwapBuffers(window);
do_redraw = 0;
} }
@ -485,15 +487,7 @@ int main(void)
{ {
// Only redraw if we need to // Only redraw if we need to
if (do_redraw) if (do_redraw)
{ windowRefreshFun(window);
// Draw all views
drawAllViews();
// Swap buffers
glfwSwapBuffers(window);
do_redraw = 0;
}
// Wait for new events // Wait for new events
glfwWaitEvents(); glfwWaitEvents();

View File

@ -68,28 +68,17 @@ extern "C" {
/************************************************************************* /*************************************************************************
* Global definitions * Compiler- and platform-specific preprocessor work
*************************************************************************/ *************************************************************************/
/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */ /* If we are we on Windows, we want a single define for it.
/* Please report any problems that you find with your compiler, which may
* be solved in this section! There are several compilers that I have not
* been able to test this file with yet.
*
* First: If we are we on Windows, we want a single define for it (_WIN32)
* (Note: For Cygwin the compiler flag -mwin32 should be used, but to
* make sure that things run smoothly for Cygwin users, we add __CYGWIN__
* to the list of "valid Win32 identifiers", which removes the need for
* -mwin32)
*/ */
#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)) #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
#define _WIN32 #define _WIN32
#endif /* _WIN32 */ #endif /* _WIN32 */
/* In order for extension support to be portable, we need to define an /* It is customary to use APIENTRY for OpenGL function pointer declarations on
* OpenGL function call method. We use the keyword APIENTRY, which is * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
* defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
*/ */
#ifndef APIENTRY #ifndef APIENTRY
#ifdef _WIN32 #ifdef _WIN32
@ -99,44 +88,23 @@ extern "C" {
#endif #endif
#endif /* APIENTRY */ #endif /* APIENTRY */
/* The following three defines are here solely to make some Windows-based /* Some Windows OpenGL headers need this.
* <GL/gl.h> files happy. Theoretically we could include <windows.h>, but
* it has the major drawback of severely polluting our namespace.
*/ */
/* Under Windows, we need WINGDIAPI defined */
#if !defined(WINGDIAPI) && defined(_WIN32) #if !defined(WINGDIAPI) && defined(_WIN32)
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
/* Microsoft Visual C++, Borland C++ Builder and Pelles C */
#define WINGDIAPI __declspec(dllimport) #define WINGDIAPI __declspec(dllimport)
#elif defined(__LCC__)
/* LCC-Win32 */
#define WINGDIAPI __stdcall
#else
/* Others (e.g. MinGW, Cygwin) */
#define WINGDIAPI extern
#endif
#define GLFW_WINGDIAPI_DEFINED #define GLFW_WINGDIAPI_DEFINED
#endif /* WINGDIAPI */ #endif /* WINGDIAPI */
/* Some <GL/glu.h> files also need CALLBACK defined */ /* Some Windows GLU headers need this.
*/
#if !defined(CALLBACK) && defined(_WIN32) #if !defined(CALLBACK) && defined(_WIN32)
#if defined(_MSC_VER)
/* Microsoft Visual C++ */
#if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
#define CALLBACK __stdcall #define CALLBACK __stdcall
#else
#define CALLBACK
#endif
#else
/* Other Windows compilers */
#define CALLBACK __stdcall
#endif
#define GLFW_CALLBACK_DEFINED #define GLFW_CALLBACK_DEFINED
#endif /* CALLBACK */ #endif /* CALLBACK */
/* Most GL/glu.h variants on Windows need wchar_t /* Most Windows GLU headers need wchar_t.
* OpenGL/gl.h blocks the definition of ptrdiff_t by glext.h on OS X */ * The OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.
*/
#if !defined(GLFW_INCLUDE_NONE) #if !defined(GLFW_INCLUDE_NONE)
#include <stddef.h> #include <stddef.h>
#endif #endif
@ -197,7 +165,7 @@ extern "C" {
* version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
* configuration header when compiling the DLL version of the library. * configuration header when compiling the DLL version of the library.
*/ */
#error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined" #error "You may not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
#endif #endif
/* GLFWAPI is used to declare public API functions for export /* GLFWAPI is used to declare public API functions for export
@ -208,11 +176,7 @@ extern "C" {
#define GLFWAPI __declspec(dllexport) #define GLFWAPI __declspec(dllexport)
#elif defined(_WIN32) && defined(GLFW_DLL) #elif defined(_WIN32) && defined(GLFW_DLL)
/* We are calling GLFW as a Win32 DLL */ /* We are calling GLFW as a Win32 DLL */
#if defined(__LCC__)
#define GLFWAPI extern
#else
#define GLFWAPI __declspec(dllimport) #define GLFWAPI __declspec(dllimport)
#endif
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL) #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
/* We are building GLFW as a shared / dynamic library */ /* We are building GLFW as a shared / dynamic library */
#define GLFWAPI __attribute__((visibility("default"))) #define GLFWAPI __attribute__((visibility("default")))
@ -221,8 +185,6 @@ extern "C" {
#define GLFWAPI #define GLFWAPI
#endif #endif
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
/************************************************************************* /*************************************************************************
* GLFW API tokens * GLFW API tokens
@ -249,7 +211,7 @@ extern "C" {
* API changes. * API changes.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_REVISION 0 #define GLFW_VERSION_REVISION 1
/*! @} */ /*! @} */
/*! @name Key and button actions /*! @name Key and button actions
@ -558,7 +520,9 @@ extern "C" {
/*! @brief GLFW could not find support for the requested client API on the /*! @brief GLFW could not find support for the requested client API on the
* system. * system.
* *
* GLFW could not find support for the requested client API on the system. * GLFW could not find support for the requested client API on the system. If
* emitted by functions other than @ref glfwCreateWindow, no supported client
* API was found.
* *
* @par Analysis * @par Analysis
* The installed graphics driver does not support the requested client API, or * The installed graphics driver does not support the requested client API, or
@ -575,8 +539,8 @@ extern "C" {
#define GLFW_API_UNAVAILABLE 0x00010006 #define GLFW_API_UNAVAILABLE 0x00010006
/*! @brief The requested OpenGL or OpenGL ES version is not available. /*! @brief The requested OpenGL or OpenGL ES version is not available.
* *
* The requested OpenGL or OpenGL ES version (including any requested profile * The requested OpenGL or OpenGL ES version (including any requested context
* or context option) is not available on this machine. * or framebuffer hints) is not available on this machine.
* *
* @par Analysis * @par Analysis
* The machine does not support your requirements. If your application is * The machine does not support your requirements. If your application is
@ -598,7 +562,8 @@ extern "C" {
* specific categories. * specific categories.
* *
* @par Analysis * @par Analysis
* A bug in GLFW or the underlying operating system. Report the bug to our * A bug or configuration error in GLFW, the underlying operating system or
* its drivers, or a lack of required resources. Report the issue to our
* [issue tracker](https://github.com/glfw/glfw/issues). * [issue tracker](https://github.com/glfw/glfw/issues).
*/ */
#define GLFW_PLATFORM_ERROR 0x00010008 #define GLFW_PLATFORM_ERROR 0x00010008
@ -988,7 +953,7 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
* *
* @param[in] window The window that received the event. * @param[in] window The window that received the event.
* @param[in] count The number of dropped files. * @param[in] count The number of dropped files.
* @param[in] names The UTF-8 encoded path names of the dropped files. * @param[in] paths The UTF-8 encoded file and/or directory path names.
* *
* @sa glfwSetDropCallback * @sa glfwSetDropCallback
* *
@ -1462,7 +1427,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
/*! @brief Generates a gamma ramp and sets it for the specified monitor. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
* *
* This function generates a 256-element gamma ramp from the specified exponent * This function generates a 256-element gamma ramp from the specified exponent
* and then calls @ref glfwSetGammaRamp with it. * and then calls @ref glfwSetGammaRamp with it. The value must be a finite
* number greater than zero.
* *
* @param[in] monitor The monitor whose gamma ramp to set. * @param[in] monitor The monitor whose gamma ramp to set.
* @param[in] gamma The desired exponent. * @param[in] gamma The desired exponent.
@ -1512,7 +1478,10 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
* @param[in] monitor The monitor whose gamma ramp to set. * @param[in] monitor The monitor whose gamma ramp to set.
* @param[in] ramp The gamma ramp to use. * @param[in] ramp The gamma ramp to use.
* *
* @note Gamma ramp sizes other than 256 are not supported by all hardware. * @remarks Gamma ramp sizes other than 256 are not supported by all platforms
* or graphics hardware.
*
* @remarks __Windows:__ The gamma ramp size must be 256.
* *
* @par Pointer Lifetime * @par Pointer Lifetime
* The specified gamma ramp is copied before this function returns. * The specified gamma ramp is copied before this function returns.
@ -1648,6 +1617,13 @@ GLFWAPI void glfwWindowHint(int target, int hint);
* The menu bar can be disabled with a * The menu bar can be disabled with a
* [compile-time option](@ref compile_options_osx). * [compile-time option](@ref compile_options_osx).
* *
* @remarks __OS X:__ On OS X 10.10 and later the window frame will not be
* rendered at full resolution on Retina displays unless the
* `NSHighResolutionCapable` key is enabled in the application bundle's
* `Info.plist`. For more information, see
* [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
* in the Mac Developer Library.
*
* @remarks __X11:__ There is no mechanism for setting the window icon yet. * @remarks __X11:__ There is no mechanism for setting the window icon yet.
* *
* @remarks __X11:__ Some window managers will not respect the placement of * @remarks __X11:__ Some window managers will not respect the placement of
@ -3136,10 +3112,15 @@ GLFWAPI double glfwGetTime(void);
/*! @brief Sets the GLFW timer. /*! @brief Sets the GLFW timer.
* *
* This function sets the value of the GLFW timer. It then continues to count * This function sets the value of the GLFW timer. It then continues to count
* up from that value. * up from that value. The value must be a positive finite number less than
* or equal to 18446744073.0, which is approximately 584.5 years.
* *
* @param[in] time The new value, in seconds. * @param[in] time The new value, in seconds.
* *
* @remarks The upper limit of the timer is calculated as
* floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
* storing nanoseconds in 64 bits. The limit may be increased in the future.
*
* @par Thread Safety * @par Thread Safety
* This function may only be called from the main thread. * This function may only be called from the main thread.
* *
@ -3243,14 +3224,14 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
* @param[in] interval The minimum number of screen updates to wait for * @param[in] interval The minimum number of screen updates to wait for
* until the buffers are swapped by @ref glfwSwapBuffers. * until the buffers are swapped by @ref glfwSwapBuffers.
* *
* @note This function is not called during window creation, leaving the swap * @remarks This function is not called during context creation, leaving the
* interval set to whatever is the default on that platform. This is done * swap interval set to whatever is the default on that platform. This is done
* because some swap interval extensions used by GLFW do not allow the swap * because some swap interval extensions used by GLFW do not allow the swap
* interval to be reset to zero once it has been set to a non-zero value. * interval to be reset to zero once it has been set to a non-zero value.
* *
* @note Some GPU drivers do not honor the requested swap interval, either * @remarks Some GPU drivers do not honor the requested swap interval, either
* because of user settings that override the request or due to bugs in the * because of a user setting that overrides the application's request or due to
* driver. * bugs in the driver.
* *
* @par Thread Safety * @par Thread Safety
* This function may be called from any thread. * This function may be called from any thread.
@ -3267,9 +3248,9 @@ GLFWAPI void glfwSwapInterval(int interval);
/*! @brief Returns whether the specified extension is available. /*! @brief Returns whether the specified extension is available.
* *
* This function returns whether the specified * This function returns whether the specified
* [API extension](@ref context_glext) is supported by the current OpenGL or * [client API extension](@ref context_glext) is supported by the current
* OpenGL ES context. It searches both for OpenGL and OpenGL ES extension and * OpenGL or OpenGL ES context. It searches both for OpenGL and OpenGL ES
* platform-specific context creation API extensions. * extension and platform-specific context creation API extensions.
* *
* A context must be current on the calling thread. Calling this function * A context must be current on the calling thread. Calling this function
* without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
@ -3298,7 +3279,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension);
* context. * context.
* *
* This function returns the address of the specified * This function returns the address of the specified
* [client API or extension function](@ref context_glext), if it is supported * [core or extension function](@ref context_glext), if it is supported
* by the current context. * by the current context.
* *
* A context must be current on the calling thread. Calling this function * A context must be current on the calling thread. Calling this function
@ -3308,9 +3289,13 @@ GLFWAPI int glfwExtensionSupported(const char* extension);
* @return The address of the function, or `NULL` if the function is * @return The address of the function, or `NULL` if the function is
* unavailable or an [error](@ref error_handling) occurred. * unavailable or an [error](@ref error_handling) occurred.
* *
* @note The addresses of a given function is not guaranteed to be the same * @remarks The addresses of a given function is not guaranteed to be the same
* between contexts. * between contexts.
* *
* @remarks This function may return a non-`NULL` address despite the
* associated version or extension not being available. Always check the
* context version or extension string presence first.
*
* @par Pointer Lifetime * @par Pointer Lifetime
* The returned function pointer is valid until the context is destroyed or the * The returned function pointer is valid until the context is destroyed or the
* library is terminated. * library is terminated.

View File

@ -57,7 +57,8 @@ static char* getDisplayName(CGDirectDisplayID displayID)
(const void**) &value)) (const void**) &value))
{ {
// This may happen if a desktop Mac is running headless // This may happen if a desktop Mac is running headless
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to retrieve display name"); _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve display name");
CFRelease(info); CFRelease(info);
return strdup("Unknown"); return strdup("Unknown");
@ -263,9 +264,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
{ {
int j; int j;
if (CGDisplayIsAsleep(displays[i]))
continue;
CGDirectDisplayID screenDisplayID = CGDisplayMirrorsDisplay(displays[i]); CGDirectDisplayID screenDisplayID = CGDisplayMirrorsDisplay(displays[i]);
if (screenDisplayID == kCGNullDirectDisplay) if (screenDisplayID == kCGNullDirectDisplay)
screenDisplayID = displays[i]; screenDisplayID = displays[i];

View File

@ -592,17 +592,17 @@ static int translateKey(unsigned int key)
if (count) if (count)
{ {
NSEnumerator* e = [files objectEnumerator]; NSEnumerator* e = [files objectEnumerator];
char** names = calloc(count, sizeof(char*)); char** paths = calloc(count, sizeof(char*));
int i; int i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
names[i] = strdup([[e nextObject] UTF8String]); paths[i] = strdup([[e nextObject] UTF8String]);
_glfwInputDrop(window, count, (const char**) names); _glfwInputDrop(window, count, (const char**) paths);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
free(names[i]); free(paths[i]);
free(names); free(paths);
} }
return YES; return YES;
@ -990,6 +990,9 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{ {
if (window->monitor)
enterFullscreenMode(window);
else
[window->ns.object setContentSize:NSMakeSize(width, height)]; [window->ns.object setContentSize:NSMakeSize(width, height)];
} }
@ -1208,7 +1211,8 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
cursor->ns.object = getStandardCursor(shape); cursor->ns.object = getStandardCursor(shape);
if (!cursor->ns.object) if (!cursor->ns.object)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Cocoa: Invalid standard cursor"); _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve standard cursor");
return GL_FALSE; return GL_FALSE;
} }
@ -1252,7 +1256,8 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
if (![[pasteboard types] containsObject:NSStringPboardType]) if (![[pasteboard types] containsObject:NSStringPboardType])
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, NULL); _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"Cocoa: Failed to retrieve string from pasteboard");
return NULL; return NULL;
} }

View File

@ -89,7 +89,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
if (ctxconfig->api != GLFW_OPENGL_API && if (ctxconfig->api != GLFW_OPENGL_API &&
ctxconfig->api != GLFW_OPENGL_ES_API) ctxconfig->api != GLFW_OPENGL_ES_API)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Invalid client API requested"); _glfwInputError(GLFW_INVALID_ENUM, "Invalid client API");
return GL_FALSE; return GL_FALSE;
} }
@ -104,16 +104,13 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
// OpenGL 1.x series ended with version 1.5 // OpenGL 1.x series ended with version 1.5
// OpenGL 2.x series ended with version 2.1 // OpenGL 2.x series ended with version 2.1
// OpenGL 3.x series ended with version 3.3 // OpenGL 3.x series ended with version 3.3
// For now, let everything else through
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL version %i.%i requested", "Invalid OpenGL version %i.%i",
ctxconfig->major, ctxconfig->minor); ctxconfig->major, ctxconfig->minor);
return GL_FALSE; return GL_FALSE;
} }
else
{
// For now, let everything else through
}
if (ctxconfig->profile) if (ctxconfig->profile)
{ {
@ -121,7 +118,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE) ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
{ {
_glfwInputError(GLFW_INVALID_ENUM, _glfwInputError(GLFW_INVALID_ENUM,
"Invalid OpenGL profile requested"); "Invalid OpenGL profile");
return GL_FALSE; return GL_FALSE;
} }
@ -132,8 +129,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
// and above // and above
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,
"Context profiles only exist for " "Context profiles are only defined for OpenGL version 3.2 and above");
"OpenGL version 3.2 and above");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -142,8 +138,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
{ {
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,
"Forward compatibility only exist for OpenGL " "Forward-compatibility is only defined for OpenGL version 3.0 and above");
"version 3.0 and above");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -156,30 +151,11 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
// OpenGL ES 1.0 is the smallest valid version // OpenGL ES 1.0 is the smallest valid version
// OpenGL ES 1.x series ended with version 1.1 // OpenGL ES 1.x series ended with version 1.1
// OpenGL ES 2.x series ended with version 2.0 // OpenGL ES 2.x series ended with version 2.0
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL ES version %i.%i requested",
ctxconfig->major, ctxconfig->minor);
return GL_FALSE;
}
else
{
// For now, let everything else through // For now, let everything else through
}
if (ctxconfig->profile)
{
// OpenGL ES does not support profiles
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,
"Context profiles are not supported by OpenGL ES"); "Invalid OpenGL ES version %i.%i",
return GL_FALSE; ctxconfig->major, ctxconfig->minor);
}
if (ctxconfig->forward)
{
// OpenGL ES does not support forward-compatibility
_glfwInputError(GLFW_INVALID_VALUE,
"Forward compatibility is not supported by OpenGL ES");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -189,8 +165,8 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION && if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET) ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
{ {
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_ENUM,
"Invalid context robustness mode requested"); "Invalid context robustness mode");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -200,8 +176,8 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE && if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH) ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
{ {
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_ENUM,
"Invalid context release behavior requested"); "Invalid context release behavior");
return GL_FALSE; return GL_FALSE;
} }
} }

View File

@ -47,33 +47,25 @@ static const char* getErrorString(EGLint error)
case EGL_BAD_ALLOC: case EGL_BAD_ALLOC:
return "EGL failed to allocate resources for the requested operation"; return "EGL failed to allocate resources for the requested operation";
case EGL_BAD_ATTRIBUTE: case EGL_BAD_ATTRIBUTE:
return "An unrecognized attribute or attribute value was passed " return "An unrecognized attribute or attribute value was passed in the attribute list";
"in the attribute list";
case EGL_BAD_CONTEXT: case EGL_BAD_CONTEXT:
return "An EGLContext argument does not name a valid EGL " return "An EGLContext argument does not name a valid EGL rendering context";
"rendering context";
case EGL_BAD_CONFIG: case EGL_BAD_CONFIG:
return "An EGLConfig argument does not name a valid EGL frame " return "An EGLConfig argument does not name a valid EGL frame buffer configuration";
"buffer configuration";
case EGL_BAD_CURRENT_SURFACE: case EGL_BAD_CURRENT_SURFACE:
return "The current surface of the calling thread is a window, pixel " return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid";
"buffer or pixmap that is no longer valid";
case EGL_BAD_DISPLAY: case EGL_BAD_DISPLAY:
return "An EGLDisplay argument does not name a valid EGL display " return "An EGLDisplay argument does not name a valid EGL display connection";
"connection";
case EGL_BAD_SURFACE: case EGL_BAD_SURFACE:
return "An EGLSurface argument does not name a valid surface " return "An EGLSurface argument does not name a valid surface configured for GL rendering";
"configured for GL rendering";
case EGL_BAD_MATCH: case EGL_BAD_MATCH:
return "Arguments are inconsistent"; return "Arguments are inconsistent";
case EGL_BAD_PARAMETER: case EGL_BAD_PARAMETER:
return "One or more argument values are invalid"; return "One or more argument values are invalid";
case EGL_BAD_NATIVE_PIXMAP: case EGL_BAD_NATIVE_PIXMAP:
return "A NativePixmapType argument does not refer to a valid " return "A NativePixmapType argument does not refer to a valid native pixmap";
"native pixmap";
case EGL_BAD_NATIVE_WINDOW: case EGL_BAD_NATIVE_WINDOW:
return "A NativeWindowType argument does not refer to a valid " return "A NativeWindowType argument does not refer to a valid native window";
"native window";
case EGL_CONTEXT_LOST: case EGL_CONTEXT_LOST:
return "The application must destroy all contexts and reinitialise"; return "The application must destroy all contexts and reinitialise";
} }
@ -309,7 +301,7 @@ int _glfwCreateContext(_GLFWwindow* window,
{ {
if (!eglBindAPI(EGL_OPENGL_ES_API)) if (!eglBindAPI(EGL_OPENGL_ES_API))
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL ES: %s", "EGL: Failed to bind OpenGL ES: %s",
getErrorString(eglGetError())); getErrorString(eglGetError()));
return GL_FALSE; return GL_FALSE;
@ -319,7 +311,7 @@ int _glfwCreateContext(_GLFWwindow* window,
{ {
if (!eglBindAPI(EGL_OPENGL_API)) if (!eglBindAPI(EGL_OPENGL_API))
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL: %s", "EGL: Failed to bind OpenGL: %s",
getErrorString(eglGetError())); getErrorString(eglGetError()));
return GL_FALSE; return GL_FALSE;
@ -339,10 +331,10 @@ int _glfwCreateContext(_GLFWwindow* window,
if (ctxconfig->forward) if (ctxconfig->forward)
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR; flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
}
if (ctxconfig->debug) if (ctxconfig->debug)
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR; flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
}
if (ctxconfig->robustness) if (ctxconfig->robustness)
{ {
@ -389,7 +381,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (window->egl.context == EGL_NO_CONTEXT) if (window->egl.context == EGL_NO_CONTEXT)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"EGL: Failed to create context: %s", "EGL: Failed to create context: %s",
getErrorString(eglGetError())); getErrorString(eglGetError()));
return GL_FALSE; return GL_FALSE;

View File

@ -5,7 +5,7 @@ libdir=${exec_prefix}/lib
Name: GLFW Name: GLFW
Description: A multi-platform library for OpenGL, window and input Description: A multi-platform library for OpenGL, window and input
Version: 3.1.0 Version: 3.1.1
URL: http://www.glfw.org/ URL: http://www.glfw.org/
Requires.private: x11 xrandr xinerama xi xxf86vm xcursor gl Requires.private: x11 xrandr xinerama xi xxf86vm xcursor gl
Libs: -L${libdir} -lglfw3 Libs: -L${libdir} -lglfw3

View File

@ -4,7 +4,7 @@
# GLFW3_LIBRARY_DIR, folder in which the GLFW library is located # GLFW3_LIBRARY_DIR, folder in which the GLFW library is located
# GLFW3_LIBRARY, library to link against to use GLFW # GLFW3_LIBRARY, library to link against to use GLFW
set(GLFW3_VERSION "3.1.0") set(GLFW3_VERSION "3.1.1")
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ####### ####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######

View File

@ -9,16 +9,16 @@
# The variable CVF_VERSION must be set before calling configure_file(). # The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "3.1.0") set(PACKAGE_VERSION "3.1.1")
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
else() else()
if("3.1.0" MATCHES "^([0-9]+)\\.") if("3.1.1" MATCHES "^([0-9]+)\\.")
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
else() else()
set(CVF_VERSION_MAJOR "3.1.0") set(CVF_VERSION_MAJOR "3.1.1")
endif() endif()
if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}") if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}")

View File

@ -62,6 +62,10 @@
// Define this to 1 to force use of high-performance GPU on Optimus systems // Define this to 1 to force use of high-performance GPU on Optimus systems
/* #undef _GLFW_USE_OPTIMUS_HPG */ /* #undef _GLFW_USE_OPTIMUS_HPG */
// Define this to 1 if the XInput X11 extension is available
#define _GLFW_HAS_XINPUT
// Define this to 1 if the Xxf86vm X11 extension is available
#define _GLFW_HAS_XF86VM
// Define this to 1 if glXGetProcAddress is available // Define this to 1 if glXGetProcAddress is available
#define _GLFW_HAS_GLXGETPROCADDRESS #define _GLFW_HAS_GLXGETPROCADDRESS
// Define this to 1 if glXGetProcAddressARB is available // Define this to 1 if glXGetProcAddressARB is available

View File

@ -62,6 +62,10 @@
// Define this to 1 to force use of high-performance GPU on Optimus systems // Define this to 1 to force use of high-performance GPU on Optimus systems
#cmakedefine _GLFW_USE_OPTIMUS_HPG #cmakedefine _GLFW_USE_OPTIMUS_HPG
// Define this to 1 if the XInput X11 extension is available
#cmakedefine _GLFW_HAS_XINPUT
// Define this to 1 if the Xxf86vm X11 extension is available
#cmakedefine _GLFW_HAS_XF86VM
// Define this to 1 if glXGetProcAddress is available // Define this to 1 if glXGetProcAddress is available
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS #cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
// Define this to 1 if glXGetProcAddressARB is available // Define this to 1 if glXGetProcAddressARB is available

View File

@ -175,7 +175,7 @@ int _glfwInitContextAPI(void)
_glfw.glx.libGL = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); _glfw.glx.libGL = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
if (!_glfw.glx.libGL) if (!_glfw.glx.libGL)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to find libGL"); _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to find libGL");
return GL_FALSE; return GL_FALSE;
} }
#endif #endif
@ -320,8 +320,7 @@ int _glfwCreateContext(_GLFWwindow* window,
!_glfw.glx.EXT_create_context_es2_profile) !_glfw.glx.EXT_create_context_es2_profile)
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: OpenGL ES requested but " "GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
"GLX_EXT_create_context_es2_profile is unavailable");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -331,8 +330,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!_glfw.glx.ARB_create_context) if (!_glfw.glx.ARB_create_context)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: Forward compatibility requested but " "GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
"GLX_ARB_create_context_profile is unavailable");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -343,8 +341,7 @@ int _glfwCreateContext(_GLFWwindow* window,
!_glfw.glx.ARB_create_context_profile) !_glfw.glx.ARB_create_context_profile)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: An OpenGL profile requested but " "GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
"GLX_ARB_create_context_profile is unavailable");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -360,9 +357,6 @@ int _glfwCreateContext(_GLFWwindow* window,
if (ctxconfig->forward) if (ctxconfig->forward)
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
if (ctxconfig->debug)
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->profile) if (ctxconfig->profile)
{ {
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
@ -374,6 +368,9 @@ int _glfwCreateContext(_GLFWwindow* window,
else else
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT; mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
if (ctxconfig->debug)
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->robustness) if (ctxconfig->robustness)
{ {
if (_glfw.glx.ARB_create_context_robustness) if (_glfw.glx.ARB_create_context_robustness)
@ -454,7 +451,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!window->glx.context) if (!window->glx.context)
{ {
_glfwInputXError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context"); _glfwInputXError(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
return GL_FALSE; return GL_FALSE;
} }

View File

@ -46,7 +46,7 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
newMode != GLFW_CURSOR_HIDDEN && newMode != GLFW_CURSOR_HIDDEN &&
newMode != GLFW_CURSOR_DISABLED) newMode != GLFW_CURSOR_DISABLED)
{ {
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid cursor mode");
return; return;
} }
@ -216,10 +216,10 @@ void _glfwInputCursorEnter(_GLFWwindow* window, int entered)
window->callbacks.cursorEnter((GLFWwindow*) window, entered); window->callbacks.cursorEnter((GLFWwindow*) window, entered);
} }
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names) void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
{ {
if (window->callbacks.drop) if (window->callbacks.drop)
window->callbacks.drop((GLFWwindow*) window, count, names); window->callbacks.drop((GLFWwindow*) window, count, paths);
} }
@ -242,7 +242,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
case GLFW_STICKY_MOUSE_BUTTONS: case GLFW_STICKY_MOUSE_BUTTONS:
return window->stickyMouseButtons; return window->stickyMouseButtons;
default: default:
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode");
return 0; return 0;
} }
} }
@ -265,7 +265,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE); setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE);
break; break;
default: default:
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode");
break; break;
} }
} }
@ -278,7 +278,7 @@ GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
if (key < 0 || key > GLFW_KEY_LAST) if (key < 0 || key > GLFW_KEY_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "The specified key is invalid"); _glfwInputError(GLFW_INVALID_ENUM, "Invalid key");
return GLFW_RELEASE; return GLFW_RELEASE;
} }
@ -301,7 +301,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, _glfwInputError(GLFW_INVALID_ENUM,
"The specified mouse button is invalid"); "Invalid mouse button");
return GLFW_RELEASE; return GLFW_RELEASE;
} }
@ -384,6 +384,17 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (shape != GLFW_ARROW_CURSOR &&
shape != GLFW_IBEAM_CURSOR &&
shape != GLFW_CROSSHAIR_CURSOR &&
shape != GLFW_HAND_CURSOR &&
shape != GLFW_HRESIZE_CURSOR &&
shape != GLFW_VRESIZE_CURSOR)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor");
return NULL;
}
cursor = calloc(1, sizeof(_GLFWcursor)); cursor = calloc(1, sizeof(_GLFWcursor));
cursor->next = _glfw.cursorListHead; cursor->next = _glfw.cursorListHead;
_glfw.cursorListHead = cursor; _glfw.cursorListHead = cursor;
@ -518,7 +529,7 @@ GLFWAPI int glfwJoystickPresent(int joy)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST) if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
return 0; return 0;
} }
@ -533,7 +544,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST) if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
return NULL; return NULL;
} }
@ -548,7 +559,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST) if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
return NULL; return NULL;
} }
@ -561,7 +572,7 @@ GLFWAPI const char* glfwGetJoystickName(int joy)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST) if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
return NULL; return NULL;
} }
@ -591,6 +602,13 @@ GLFWAPI double glfwGetTime(void)
GLFWAPI void glfwSetTime(double time) GLFWAPI void glfwSetTime(double time)
{ {
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
if (time != time || time < 0.0 || time > 18446744073.0)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time");
return;
}
_glfwPlatformSetTime(time); _glfwPlatformSetTime(time);
} }

View File

@ -33,7 +33,18 @@
#include "glfw_config.h" #include "glfw_config.h"
#endif #endif
#define _GLFW_VERSION_NUMBER "3.1.0" #define _GLFW_VERSION_NUMBER "3.1.1"
#if defined(GLFW_INCLUDE_GLCOREARB) || \
defined(GLFW_INCLUDE_ES1) || \
defined(GLFW_INCLUDE_ES2) || \
defined(GLFW_INCLUDE_ES3) || \
defined(GLFW_INCLUDE_NONE) || \
defined(GLFW_INCLUDE_GLEXT) || \
defined(GLFW_INCLUDE_GLU) || \
defined(GLFW_DLL)
#error "You may not define any header option macros when compiling GLFW"
#endif
#if defined(_GLFW_USE_OPENGL) #if defined(_GLFW_USE_OPENGL)
// This is the default for glfw3.h // This is the default for glfw3.h

View File

@ -277,11 +277,13 @@ void _glfwTerminateJoysticks(void)
regfree(&_glfw.linux_js.regex); regfree(&_glfw.linux_js.regex);
if (_glfw.linux_js.watch > 0)
close(_glfw.linux_js.watch);
if (_glfw.linux_js.inotify > 0) if (_glfw.linux_js.inotify > 0)
{
if (_glfw.linux_js.watch > 0)
inotify_rm_watch(_glfw.linux_js.inotify, _glfw.linux_js.watch);
close(_glfw.linux_js.inotify); close(_glfw.linux_js.inotify);
}
#endif // __linux__ #endif // __linux__
} }

View File

@ -65,7 +65,7 @@ int _glfwPlatformInit(void)
if (error) if (error)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Failed to create event mutex: %s\n", "Mir: Failed to create event mutex: %s",
strerror(error)); strerror(error));
return GL_FALSE; return GL_FALSE;
} }

View File

@ -127,12 +127,12 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }

View File

@ -470,7 +470,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (wndconfig->width > mode.width || wndconfig->height > mode.height) if (wndconfig->width > mode.width || wndconfig->height > mode.height)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Requested surface size is to large (%i %i)", "Mir: Requested surface size too large: %ix%i",
wndconfig->width, wndconfig->height); wndconfig->width, wndconfig->height);
return GL_FALSE; return GL_FALSE;
@ -502,13 +502,13 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
@ -516,19 +516,19 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
int* right, int* bottom) int* right, int* bottom)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
@ -552,39 +552,39 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwPlatformHideWindow(_GLFWwindow* window) void _glfwPlatformHideWindow(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformShowWindow(_GLFWwindow* window) void _glfwPlatformShowWindow(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformUnhideWindow(_GLFWwindow* window) void _glfwPlatformUnhideWindow(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
int _glfwPlatformWindowFocused(_GLFWwindow* window) int _glfwPlatformWindowFocused(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
return GL_FALSE; return GL_FALSE;
} }
int _glfwPlatformWindowIconified(_GLFWwindow* window) int _glfwPlatformWindowIconified(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
return GL_FALSE; return GL_FALSE;
} }
int _glfwPlatformWindowVisible(_GLFWwindow* window) int _glfwPlatformWindowVisible(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
return GL_FALSE; return GL_FALSE;
} }
@ -628,7 +628,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
int xhot, int yhot) int xhot, int yhot)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
return GL_FALSE; return GL_FALSE;
} }
@ -636,7 +636,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
return GL_FALSE; return GL_FALSE;
} }
@ -644,43 +644,43 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos) void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformApplyCursorMode(_GLFWwindow* window) void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string) void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
} }
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__); "Mir: Unsupported function %s", __PRETTY_FUNCTION__);
return NULL; return NULL;
} }

View File

@ -28,6 +28,7 @@
#include "internal.h" #include "internal.h"
#include <math.h> #include <math.h>
#include <float.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
@ -385,10 +386,9 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
if (gamma <= 0.f) if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
{ {
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value");
"Gamma value must be greater than zero");
return; return;
} }

View File

@ -42,7 +42,7 @@ int _glfwInitContextAPI(void)
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl")); CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfw.nsgl.framework == NULL) if (_glfw.nsgl.framework == NULL)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: Failed to locate OpenGL framework"); "NSGL: Failed to locate OpenGL framework");
return GL_FALSE; return GL_FALSE;
} }
@ -76,8 +76,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (ctxconfig->major == 3 && ctxconfig->minor < 2) if (ctxconfig->major == 3 && ctxconfig->minor < 2)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X does not " "NSGL: The targeted version of OS X does not support OpenGL 3.0 or 3.1");
"support OpenGL 3.0 or 3.1");
return GL_FALSE; return GL_FALSE;
} }
@ -86,18 +85,14 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!ctxconfig->forward) if (!ctxconfig->forward)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X only " "NSGL: The targeted version of OS X only supports forward-compatible contexts for OpenGL 3.2 and above");
"supports OpenGL 3.2 and later versions if they "
"are forward-compatible");
return GL_FALSE; return GL_FALSE;
} }
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE) if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X only " "NSGL: The targeted version of OS X only supports core profile contexts for OpenGL 3.2 and above");
"supports OpenGL 3.2 and later versions if they "
"use the core profile");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -106,8 +101,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (ctxconfig->major > 2) if (ctxconfig->major > 2)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X does not " "NSGL: The targeted version of OS X does not support OpenGL version 3.0 or above");
"support OpenGL version 3.0 or above");
return GL_FALSE; return GL_FALSE;
} }
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ #endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
@ -232,7 +226,7 @@ int _glfwCreateContext(_GLFWwindow* window,
shareContext:share]; shareContext:share];
if (window->nsgl.context == nil) if (window->nsgl.context == nil)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: Failed to create OpenGL context"); "NSGL: Failed to create OpenGL context");
return GL_FALSE; return GL_FALSE;
} }

View File

@ -167,12 +167,6 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
NULL); NULL);
} }
if (!nativeCount)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "WGL: No pixel formats found");
return GL_FALSE;
}
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0; usableCount = 0;
@ -325,7 +319,7 @@ int _glfwInitContextAPI(void)
_glfw.wgl.opengl32.instance = LoadLibraryW(L"opengl32.dll"); _glfw.wgl.opengl32.instance = LoadLibraryW(L"opengl32.dll");
if (!_glfw.wgl.opengl32.instance) if (!_glfw.wgl.opengl32.instance)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to load opengl32.dll"); _glfwInputError(GLFW_PLATFORM_ERROR, "WGL: Failed to load opengl32.dll");
return GL_FALSE; return GL_FALSE;
} }
@ -367,7 +361,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!window->wgl.dc) if (!window->wgl.dc)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve DC for window"); "WGL: Failed to retrieve DC for window");
return GL_FALSE; return GL_FALSE;
} }
@ -377,15 +371,14 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!DescribePixelFormat(window->wgl.dc, pixelFormat, sizeof(pfd), &pfd)) if (!DescribePixelFormat(window->wgl.dc, pixelFormat, sizeof(pfd), &pfd))
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve PFD for selected pixel " "WGL: Failed to retrieve PFD for selected pixel format");
"format");
return GL_FALSE; return GL_FALSE;
} }
if (!SetPixelFormat(window->wgl.dc, pixelFormat, &pfd)) if (!SetPixelFormat(window->wgl.dc, pixelFormat, &pfd))
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to set selected pixel format"); "WGL: Failed to set selected pixel format");
return GL_FALSE; return GL_FALSE;
} }
@ -398,9 +391,6 @@ int _glfwCreateContext(_GLFWwindow* window,
if (ctxconfig->forward) if (ctxconfig->forward)
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
if (ctxconfig->debug)
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->profile) if (ctxconfig->profile)
{ {
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
@ -412,6 +402,9 @@ int _glfwCreateContext(_GLFWwindow* window,
else else
mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT; mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
if (ctxconfig->debug)
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->robustness) if (ctxconfig->robustness)
{ {
if (window->wgl.ARB_create_context_robustness) if (window->wgl.ARB_create_context_robustness)
@ -478,7 +471,7 @@ int _glfwCreateContext(_GLFWwindow* window,
window->wgl.context = wglCreateContext(window->wgl.dc); window->wgl.context = wglCreateContext(window->wgl.dc);
if (!window->wgl.context) if (!window->wgl.context)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL context"); "WGL: Failed to create OpenGL context");
return GL_FALSE; return GL_FALSE;
} }
@ -488,8 +481,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!wglShareLists(share, window->wgl.context)) if (!wglShareLists(share, window->wgl.context))
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to enable sharing with specified " "WGL: Failed to enable sharing with specified OpenGL context");
"OpenGL context");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -535,9 +527,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
if (!window->wgl.ARB_create_context) if (!window->wgl.ARB_create_context)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: A forward compatible OpenGL context " "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
"requested but WGL_ARB_create_context is "
"unavailable");
return _GLFW_RECREATION_IMPOSSIBLE; return _GLFW_RECREATION_IMPOSSIBLE;
} }
@ -549,8 +539,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
if (!window->wgl.ARB_create_context_profile) if (!window->wgl.ARB_create_context_profile)
{ {
_glfwInputError(GLFW_VERSION_UNAVAILABLE, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: OpenGL profile requested but " "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
"WGL_ARB_create_context_profile is unavailable");
return _GLFW_RECREATION_IMPOSSIBLE; return _GLFW_RECREATION_IMPOSSIBLE;
} }
@ -570,8 +559,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
!window->wgl.EXT_create_context_es2_profile) !window->wgl.EXT_create_context_es2_profile)
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_API_UNAVAILABLE,
"WGL: OpenGL ES requested but " "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
"WGL_ARB_create_context_es2_profile is unavailable");
return _GLFW_RECREATION_IMPOSSIBLE; return _GLFW_RECREATION_IMPOSSIBLE;
} }

View File

@ -30,11 +30,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#ifdef __BORLANDC__
// With the Borland C++ compiler, we want to disable FPU exceptions
#include <float.h>
#endif // __BORLANDC__
#if defined(_GLFW_USE_OPTIMUS_HPG) #if defined(_GLFW_USE_OPTIMUS_HPG)
@ -335,12 +330,6 @@ int _glfwPlatformInit(void)
if (_glfw_SetProcessDPIAware) if (_glfw_SetProcessDPIAware)
_glfw_SetProcessDPIAware(); _glfw_SetProcessDPIAware();
#ifdef __BORLANDC__
// With the Borland C++ compiler, we want to disable FPU exceptions
// (this is recommended for OpenGL applications under Windows)
_control87(MCW_EM, MCW_EM);
#endif
if (!_glfwRegisterWindowClass()) if (!_glfwRegisterWindowClass())
return GL_FALSE; return GL_FALSE;
@ -381,8 +370,6 @@ const char* _glfwPlatformGetVersionString(void)
" MinGW" " MinGW"
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
" VisualC" " VisualC"
#elif defined(__BORLANDC__)
" BorlandC"
#endif #endif
#if defined(_GLFW_BUILD_DLL) #if defined(_GLFW_BUILD_DLL)
" DLL" " DLL"

View File

@ -144,7 +144,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
if (!name) if (!name)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Failed to convert string to UTF-8"); "Win32: Failed to convert string to UTF-8");
continue; continue;
} }

View File

@ -584,7 +584,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
int i; int i;
const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0); const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0);
char** names = calloc(count, sizeof(char*)); char** paths = calloc(count, sizeof(char*));
// Move the mouse to the position of the drop // Move the mouse to the position of the drop
DragQueryPoint(hDrop, &pt); DragQueryPoint(hDrop, &pt);
@ -596,16 +596,16 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
WCHAR* buffer = calloc(length + 1, sizeof(WCHAR)); WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));
DragQueryFileW(hDrop, i, buffer, length + 1); DragQueryFileW(hDrop, i, buffer, length + 1);
names[i] = _glfwCreateUTF8FromWideString(buffer); paths[i] = _glfwCreateUTF8FromWideString(buffer);
free(buffer); free(buffer);
} }
_glfwInputDrop(window, count, (const char**) names); _glfwInputDrop(window, count, (const char**) paths);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
free(names[i]); free(paths[i]);
free(names); free(paths);
DragFinish(hDrop); DragFinish(hDrop);
return 0; return 0;
@ -679,7 +679,7 @@ static int createWindow(_GLFWwindow* window,
if (!wideTitle) if (!wideTitle)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert title to wide string"); "Win32: Failed to convert window title to UTF-16");
return GL_FALSE; return GL_FALSE;
} }
@ -862,7 +862,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
if (!wideTitle) if (!wideTitle)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert title to wide string"); "Win32: Failed to convert window title to UTF-16");
return; return;
} }
@ -1168,18 +1168,12 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
LPCWSTR native = translateCursorShape(shape); cursor->win32.handle =
if (!native) CopyCursor(LoadCursorW(NULL, translateCursorShape(shape)));
{
_glfwInputError(GLFW_INVALID_ENUM, "Win32: Invalid standard cursor");
return GL_FALSE;
}
cursor->win32.handle = CopyCursor(LoadCursorW(NULL, native));
if (!cursor->win32.handle) if (!cursor->win32.handle)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve shared cursor"); "Win32: Failed to create standard cursor");
return GL_FALSE; return GL_FALSE;
} }
@ -1219,8 +1213,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
if (!wideString) if (!wideString)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert clipboard string to " "Win32: Failed to convert string to UTF-16");
"wide string");
return; return;
} }
@ -1259,12 +1252,6 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
{ {
HANDLE stringHandle; HANDLE stringHandle;
if (!IsClipboardFormatAvailable(CF_UNICODETEXT))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, NULL);
return NULL;
}
if (!OpenClipboard(window->win32.handle)) if (!OpenClipboard(window->win32.handle))
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard"); _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard");
@ -1276,8 +1263,8 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
{ {
CloseClipboard(); CloseClipboard();
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"Win32: Failed to retrieve clipboard data"); "Win32: Failed to convert clipboard to string");
return NULL; return NULL;
} }

View File

@ -394,7 +394,7 @@ GLFWAPI void glfwWindowHint(int target, int hint)
_glfw.hints.release = hint; _glfw.hints.release = hint;
break; break;
default: default:
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint");
break; break;
} }
} }
@ -479,7 +479,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
if (window->monitor) if (window->monitor)
{ {
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,
"Full screen windows cannot be positioned"); "Full screen windows cannot be moved");
return; return;
} }
@ -624,7 +624,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->context.release; return window->context.release;
} }
_glfwInputError(GLFW_INVALID_ENUM, NULL); _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute");
return 0; return 0;
} }

View File

@ -479,11 +479,13 @@ static GLboolean initExtensions(void)
"_MOTIF_WM_HINTS", "_MOTIF_WM_HINTS",
False); False);
#if defined(_GLFW_HAS_XF86VM)
// Check for XF86VidMode extension // Check for XF86VidMode extension
_glfw.x11.vidmode.available = _glfw.x11.vidmode.available =
XF86VidModeQueryExtension(_glfw.x11.display, XF86VidModeQueryExtension(_glfw.x11.display,
&_glfw.x11.vidmode.eventBase, &_glfw.x11.vidmode.eventBase,
&_glfw.x11.vidmode.errorBase); &_glfw.x11.vidmode.errorBase);
#endif /*_GLFW_HAS_XF86VM*/
// Check for RandR extension // Check for RandR extension
_glfw.x11.randr.available = _glfw.x11.randr.available =
@ -535,6 +537,7 @@ static GLboolean initExtensions(void)
_glfw.x11.xinerama.available = GL_TRUE; _glfw.x11.xinerama.available = GL_TRUE;
} }
#if defined(_GLFW_HAS_XINPUT)
if (XQueryExtension(_glfw.x11.display, if (XQueryExtension(_glfw.x11.display,
"XInputExtension", "XInputExtension",
&_glfw.x11.xi.majorOpcode, &_glfw.x11.xi.majorOpcode,
@ -551,6 +554,7 @@ static GLboolean initExtensions(void)
_glfw.x11.xi.available = GL_TRUE; _glfw.x11.xi.available = GL_TRUE;
} }
} }
#endif /*_GLFW_HAS_XINPUT*/
// Check if Xkb is supported on this display // Check if Xkb is supported on this display
_glfw.x11.xkb.versionMajor = 1; _glfw.x11.xkb.versionMajor = 1;
@ -583,7 +587,7 @@ static GLboolean initExtensions(void)
detectEWMH(); detectEWMH();
// Find or create string format atoms // Find or create string format atoms
_glfw.x11._NULL = XInternAtom(_glfw.x11.display, "NULL", False); _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
_glfw.x11.UTF8_STRING = _glfw.x11.UTF8_STRING =
XInternAtom(_glfw.x11.display, "UTF8_STRING", False); XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
_glfw.x11.COMPOUND_STRING = _glfw.x11.COMPOUND_STRING =
@ -710,6 +714,8 @@ Cursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
int _glfwPlatformInit(void) int _glfwPlatformInit(void)
{ {
// HACK: If the current locale is C, apply the environment's locale
// This is done because the C locale breaks character input
if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0) if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
@ -718,7 +724,7 @@ int _glfwPlatformInit(void)
_glfw.x11.display = XOpenDisplay(NULL); _glfw.x11.display = XOpenDisplay(NULL);
if (!_glfw.x11.display) if (!_glfw.x11.display)
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, "X11: Failed to open X display"); _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to open X display");
return GL_FALSE; return GL_FALSE;
} }

View File

@ -432,6 +432,7 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
XRRFreeGamma(gamma); XRRFreeGamma(gamma);
} }
#if defined(_GLFW_HAS_XF86VM)
else if (_glfw.x11.vidmode.available) else if (_glfw.x11.vidmode.available)
{ {
int size; int size;
@ -443,6 +444,7 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
_glfw.x11.screen, _glfw.x11.screen,
ramp->size, ramp->red, ramp->green, ramp->blue); ramp->size, ramp->red, ramp->green, ramp->blue);
} }
#endif /*_GLFW_HAS_XF86VM*/
} }
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
@ -458,6 +460,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma); XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma);
XRRFreeGamma(gamma); XRRFreeGamma(gamma);
} }
#if defined(_GLFW_HAS_XF86VM)
else if (_glfw.x11.vidmode.available) else if (_glfw.x11.vidmode.available)
{ {
XF86VidModeSetGammaRamp(_glfw.x11.display, XF86VidModeSetGammaRamp(_glfw.x11.display,
@ -467,6 +470,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
(unsigned short*) ramp->green, (unsigned short*) ramp->green,
(unsigned short*) ramp->blue); (unsigned short*) ramp->blue);
} }
#endif /*_GLFW_HAS_XF86VM*/
} }

View File

@ -37,21 +37,25 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xcursor/Xcursor.h> #include <X11/Xcursor/Xcursor.h>
// The Xf86VidMode extension provides fallback gamma control
#include <X11/extensions/xf86vmode.h>
// The XRandR extension provides mode setting and gamma control // The XRandR extension provides mode setting and gamma control
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
// The XInput2 extension provides improved input events
#include <X11/extensions/XInput2.h>
// The Xkb extension provides improved keyboard support // The Xkb extension provides improved keyboard support
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
// The Xinerama extension provides legacy monitor indices // The Xinerama extension provides legacy monitor indices
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#if defined(_GLFW_HAS_XINPUT)
// The XInput2 extension provides improved input events
#include <X11/extensions/XInput2.h>
#endif
#if defined(_GLFW_HAS_XF86VM)
// The Xf86VidMode extension provides fallback gamma control
#include <X11/extensions/xf86vmode.h>
#endif
#include "posix_tls.h" #include "posix_tls.h"
#if defined(_GLFW_GLX) #if defined(_GLFW_GLX)
@ -156,18 +160,12 @@ typedef struct _GLFWlibraryX11
Atom CLIPBOARD; Atom CLIPBOARD;
Atom CLIPBOARD_MANAGER; Atom CLIPBOARD_MANAGER;
Atom SAVE_TARGETS; Atom SAVE_TARGETS;
Atom _NULL; Atom NULL_;
Atom UTF8_STRING; Atom UTF8_STRING;
Atom COMPOUND_STRING; Atom COMPOUND_STRING;
Atom ATOM_PAIR; Atom ATOM_PAIR;
Atom GLFW_SELECTION; Atom GLFW_SELECTION;
struct {
GLboolean available;
int eventBase;
int errorBase;
} vidmode;
struct { struct {
GLboolean available; GLboolean available;
int eventBase; int eventBase;
@ -188,15 +186,6 @@ typedef struct _GLFWlibraryX11
int versionMinor; int versionMinor;
} xkb; } xkb;
struct {
GLboolean available;
int majorOpcode;
int eventBase;
int errorBase;
int versionMajor;
int versionMinor;
} xi;
struct { struct {
int count; int count;
int timeout; int timeout;
@ -215,6 +204,25 @@ typedef struct _GLFWlibraryX11
int versionMinor; int versionMinor;
} xinerama; } xinerama;
#if defined(_GLFW_HAS_XINPUT)
struct {
GLboolean available;
int majorOpcode;
int eventBase;
int errorBase;
int versionMajor;
int versionMinor;
} xi;
#endif /*_GLFW_HAS_XINPUT*/
#if defined(_GLFW_HAS_XF86VM)
struct {
GLboolean available;
int eventBase;
int errorBase;
} vidmode;
#endif /*_GLFW_HAS_XF86VM*/
} _GLFWlibraryX11; } _GLFWlibraryX11;

View File

@ -28,6 +28,7 @@
#include "internal.h" #include "internal.h"
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
#include <X11/Xmd.h>
#include <sys/select.h> #include <sys/select.h>
@ -57,6 +58,22 @@ typedef struct
#define MWM_HINTS_DECORATIONS (1L << 1) #define MWM_HINTS_DECORATIONS (1L << 1)
// Wait for data to arrive
//
void selectDisplayConnection(struct timeval* timeout)
{
fd_set fds;
const int fd = ConnectionNumber(_glfw.x11.display);
FD_ZERO(&fds);
FD_SET(fd, &fds);
// select(1) is used instead of an X function like XNextEvent, as the
// wait inside those are guarded by the mutex protecting the display
// struct, locking out other threads from using X (including GLX)
select(fd + 1, &fds, NULL, NULL, timeout);
}
// Returns whether the window is iconified // Returns whether the window is iconified
// //
static int getWindowState(_GLFWwindow* window) static int getWindowState(_GLFWwindow* window)
@ -183,11 +200,12 @@ static void changeWindowState(_GLFWwindow* window, Atom state, int action)
} }
// Splits and translates a text/uri-list into separate file paths // Splits and translates a text/uri-list into separate file paths
// NOTE: This function destroys the provided string
// //
static char** parseUriList(char* text, int* count) static char** parseUriList(char* text, int* count)
{ {
const char* prefix = "file://"; const char* prefix = "file://";
char** names = NULL; char** paths = NULL;
char* line; char* line;
*count = 0; *count = 0;
@ -196,7 +214,7 @@ static char** parseUriList(char* text, int* count)
{ {
text = NULL; text = NULL;
if (*line == '#') if (line[0] == '#')
continue; continue;
if (strncmp(line, prefix, strlen(prefix)) == 0) if (strncmp(line, prefix, strlen(prefix)) == 0)
@ -204,27 +222,27 @@ static char** parseUriList(char* text, int* count)
(*count)++; (*count)++;
char* name = calloc(strlen(line) + 1, 1); char* path = calloc(strlen(line) + 1, 1);
names = realloc(names, *count * sizeof(char*)); paths = realloc(paths, *count * sizeof(char*));
names[*count - 1] = name; paths[*count - 1] = path;
while (*line) while (*line)
{ {
if (line[0] == '%' && line[1] && line[2]) if (line[0] == '%' && line[1] && line[2])
{ {
const char digits[3] = { line[1], line[2], '\0' }; const char digits[3] = { line[1], line[2], '\0' };
*name = strtol(digits, NULL, 16); *path = strtol(digits, NULL, 16);
line += 2; line += 2;
} }
else else
*name = *line; *path = *line;
name++; path++;
line++; line++;
} }
} }
return names; return paths;
} }
// Create the X11 window (and its colormap) // Create the X11 window (and its colormap)
@ -411,6 +429,7 @@ static GLboolean createWindow(_GLFWwindow* window,
XFree(hint); XFree(hint);
} }
#if defined(_GLFW_HAS_XINPUT)
if (_glfw.x11.xi.available) if (_glfw.x11.xi.available)
{ {
// Select for XInput2 events // Select for XInput2 events
@ -425,6 +444,7 @@ static GLboolean createWindow(_GLFWwindow* window,
XISelectEvents(_glfw.x11.display, window->x11.handle, &eventmask, 1); XISelectEvents(_glfw.x11.display, window->x11.handle, &eventmask, 1);
} }
#endif /*_GLFW_HAS_XINPUT*/
if (_glfw.x11.XdndAware) if (_glfw.x11.XdndAware)
{ {
@ -435,27 +455,6 @@ static GLboolean createWindow(_GLFWwindow* window,
PropModeReplace, (unsigned char*) &version, 1); PropModeReplace, (unsigned char*) &version, 1);
} }
if (_glfw.x11.NET_REQUEST_FRAME_EXTENTS)
{
// Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
// function before the window is mapped
XEvent event;
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfw.x11.NET_REQUEST_FRAME_EXTENTS;
XSendEvent(_glfw.x11.display,
_glfw.x11.root,
False,
SubstructureNotifyMask | SubstructureRedirectMask,
&event);
XIfEvent(_glfw.x11.display, &event, isFrameExtentsEvent, (XPointer) window);
}
if (wndconfig->floating && !wndconfig->monitor) if (wndconfig->floating && !wndconfig->monitor)
{ {
if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_ABOVE) if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_ABOVE)
@ -629,7 +628,7 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
XChangeProperty(_glfw.x11.display, XChangeProperty(_glfw.x11.display,
request->requestor, request->requestor,
request->property, request->property,
_glfw.x11._NULL, _glfw.x11.NULL_,
32, 32,
PropModeReplace, PropModeReplace,
NULL, NULL,
@ -701,9 +700,8 @@ static void pushSelectionToManager(_GLFWwindow* window)
{ {
XEvent event; XEvent event;
if (!XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL)) while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
continue; {
switch (event.type) switch (event.type)
{ {
case SelectionRequest: case SelectionRequest:
@ -729,6 +727,9 @@ static void pushSelectionToManager(_GLFWwindow* window)
} }
} }
} }
selectDisplayConnection(NULL);
}
} }
// Enter full screen mode // Enter full screen mode
@ -1007,7 +1008,7 @@ static void processEvent(XEvent *event)
// Additional buttons after 7 are treated as regular buttons // Additional buttons after 7 are treated as regular buttons
// We subtract 4 to fill the gap left by scroll input above // We subtract 4 to fill the gap left by scroll input above
_glfwInputMouseClick(window, _glfwInputMouseClick(window,
event->xbutton.button - 4, event->xbutton.button - Button1 - 4,
GLFW_PRESS, GLFW_PRESS,
mods); mods);
} }
@ -1045,7 +1046,7 @@ static void processEvent(XEvent *event)
// Additional buttons after 7 are treated as regular buttons // Additional buttons after 7 are treated as regular buttons
// We subtract 4 to fill the gap left by scroll input above // We subtract 4 to fill the gap left by scroll input above
_glfwInputMouseClick(window, _glfwInputMouseClick(window,
event->xbutton.button - 4, event->xbutton.button - Button1 - 4,
GLFW_RELEASE, GLFW_RELEASE,
mods); mods);
} }
@ -1054,6 +1055,11 @@ static void processEvent(XEvent *event)
case EnterNotify: case EnterNotify:
{ {
// HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
// ignore the defined cursor for hidden cursor mode
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
hideCursor(window);
_glfwInputCursorEnter(window, GL_TRUE); _glfwInputCursorEnter(window, GL_TRUE);
break; break;
} }
@ -1216,13 +1222,13 @@ static void processEvent(XEvent *event)
if (result) if (result)
{ {
int i, count; int i, count;
char** names = parseUriList(data, &count); char** paths = parseUriList(data, &count);
_glfwInputDrop(window, count, (const char**) names); _glfwInputDrop(window, count, (const char**) paths);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
free(names[i]); free(paths[i]);
free(names); free(paths);
} }
XFree(data); XFree(data);
@ -1309,6 +1315,7 @@ static void processEvent(XEvent *event)
case DestroyNotify: case DestroyNotify:
return; return;
#if defined(_GLFW_HAS_XINPUT)
case GenericEvent: case GenericEvent:
{ {
if (event->xcookie.extension == _glfw.x11.xi.majorOpcode && if (event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
@ -1354,6 +1361,7 @@ static void processEvent(XEvent *event)
XFreeEventData(_glfw.x11.display, &event->xcookie); XFreeEventData(_glfw.x11.display, &event->xcookie);
break; break;
} }
#endif /*_GLFW_HAS_XINPUT*/
default: default:
{ {
@ -1447,8 +1455,8 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
if (window->x11.handle) if (window->x11.handle)
{ {
if (window->x11.handle == if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD)) window->x11.handle)
{ {
pushSelectionToManager(window); pushSelectionToManager(window);
} }
@ -1596,6 +1604,56 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
if (_glfw.x11.NET_FRAME_EXTENTS == None) if (_glfw.x11.NET_FRAME_EXTENTS == None)
return; return;
if (!_glfwPlatformWindowVisible(window) &&
_glfw.x11.NET_REQUEST_FRAME_EXTENTS)
{
// Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
// function before the window is mapped
double base;
XEvent event;
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfw.x11.NET_REQUEST_FRAME_EXTENTS;
XSendEvent(_glfw.x11.display,
_glfw.x11.root,
False,
SubstructureNotifyMask | SubstructureRedirectMask,
&event);
// HACK: Poll with timeout for the required response instead of blocking
// This is done because some window managers (at least Unity,
// Fluxbox and Xfwm) failed to send the required response
// They have been fixed but broken versions are still in the wild
// If you are affected by this and your window manager is NOT
// listed above, PLEASE report it to their and our issue trackers
base = _glfwPlatformGetTime();
while (!XCheckIfEvent(_glfw.x11.display,
&event,
isFrameExtentsEvent,
(XPointer) window))
{
double remaining;
struct timeval timeout;
remaining = 0.5 + base - _glfwPlatformGetTime();
if (remaining <= 0.0)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue");
return;
}
timeout.tv_sec = 0;
timeout.tv_usec = (long) (remaining * 1e6);
selectDisplayConnection(&timeout);
}
}
if (_glfwGetWindowProperty(window->x11.handle, if (_glfwGetWindowProperty(window->x11.handle,
_glfw.x11.NET_FRAME_EXTENTS, _glfw.x11.NET_FRAME_EXTENTS,
XA_CARDINAL, XA_CARDINAL,
@ -1621,9 +1679,8 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{ {
// Override-redirect windows cannot be iconified or restored, as those // Override-redirect windows cannot be iconified or restored, as those
// tasks are performed by the window manager // tasks are performed by the window manager
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Iconification of full screen windows requires " "X11: Iconification of full screen windows requires a WM that supports EWMH");
"a WM that supports EWMH");
return; return;
} }
@ -1637,9 +1694,8 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{ {
// Override-redirect windows cannot be iconified or restored, as those // Override-redirect windows cannot be iconified or restored, as those
// tasks are performed by the window manager // tasks are performed by the window manager
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Iconification of full screen windows requires " "X11: Iconification of full screen windows requires a WM that supports EWMH");
"a WM that supports EWMH");
return; return;
} }
@ -1708,19 +1764,7 @@ void _glfwPlatformPollEvents(void)
void _glfwPlatformWaitEvents(void) void _glfwPlatformWaitEvents(void)
{ {
if (!XPending(_glfw.x11.display)) if (!XPending(_glfw.x11.display))
{ selectDisplayConnection(NULL);
fd_set fds;
const int fd = ConnectionNumber(_glfw.x11.display);
FD_ZERO(&fds);
FD_SET(fd, &fds);
// select(1) is used instead of an X function like XNextEvent, as the
// wait inside those are guarded by the mutex protecting the display
// struct, locking out other threads from using X (including GLX)
if (select(fd + 1, &fds, NULL, NULL, NULL) < 0)
return;
}
_glfwPlatformPollEvents(); _glfwPlatformPollEvents();
} }
@ -1734,7 +1778,7 @@ void _glfwPlatformPostEmptyEvent(void)
event.type = ClientMessage; event.type = ClientMessage;
event.xclient.window = window->x11.handle; event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfw.x11._NULL; event.xclient.message_type = _glfw.x11.NULL_;
XSendEvent(_glfw.x11.display, window->x11.handle, False, 0, &event); XSendEvent(_glfw.x11.display, window->x11.handle, False, 0, &event);
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);
@ -1796,14 +1840,8 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
const unsigned int native = translateCursorShape(shape); cursor->x11.handle = XCreateFontCursor(_glfw.x11.display,
if (!native) translateCursorShape(shape));
{
_glfwInputError(GLFW_INVALID_ENUM, "X11: Invalid standard cursor");
return GL_FALSE;
}
cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
if (!cursor->x11.handle) if (!cursor->x11.handle)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
@ -1846,7 +1884,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
window->x11.handle) window->x11.handle)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Failed to become owner of the clipboard selection"); "X11: Failed to become owner of clipboard selection");
} }
} }
@ -1883,7 +1921,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
// XCheckTypedEvent is used instead of XIfEvent in order not to lock // XCheckTypedEvent is used instead of XIfEvent in order not to lock
// other threads out from the display during the entire wait period // other threads out from the display during the entire wait period
while (!XCheckTypedEvent(_glfw.x11.display, SelectionNotify, &event)) while (!XCheckTypedEvent(_glfw.x11.display, SelectionNotify, &event))
; selectDisplayConnection(NULL);
if (event.xselection.property == None) if (event.xselection.property == None)
continue; continue;
@ -1909,7 +1947,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
if (_glfw.x11.clipboardString == NULL) if (_glfw.x11.clipboardString == NULL)
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"X11: Failed to convert selection to string"); "X11: Failed to convert clipboard to string");
} }
return _glfw.x11.clipboardString; return _glfw.x11.clipboardString;

View File

@ -1,5 +1,5 @@
link_libraries(glfw "${OPENGL_glu_LIBRARY}") link_libraries(glfw)
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL) add_definitions(-DGLFW_DLL)
@ -28,7 +28,7 @@ add_executable(gamma gamma.c ${GETOPT})
add_executable(glfwinfo glfwinfo.c ${GETOPT}) add_executable(glfwinfo glfwinfo.c ${GETOPT})
add_executable(iconify iconify.c ${GETOPT}) add_executable(iconify iconify.c ${GETOPT})
add_executable(joysticks joysticks.c) add_executable(joysticks joysticks.c)
add_executable(modes modes.c ${GETOPT}) add_executable(monitors monitors.c ${GETOPT})
add_executable(peter peter.c) add_executable(peter peter.c)
add_executable(reopen reopen.c) add_executable(reopen reopen.c)
add_executable(cursor cursor.c) add_executable(cursor cursor.c)
@ -62,7 +62,7 @@ target_link_libraries(threads "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}")
set(WINDOWS_BINARIES accuracy empty sharing tearing threads title windows cursoranim) set(WINDOWS_BINARIES accuracy empty sharing tearing threads title windows cursoranim)
set(CONSOLE_BINARIES clipboard defaults events fsaa gamma glfwinfo set(CONSOLE_BINARIES clipboard defaults events fsaa gamma glfwinfo
iconify joysticks modes peter reopen cursor) iconify joysticks monitors peter reopen cursor)
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
FOLDER "GLFW3/Tests") FOLDER "GLFW3/Tests")
@ -76,6 +76,7 @@ endif()
if (APPLE) if (APPLE)
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}) MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/AppleInfo.plist")
endif() endif()

View File

@ -27,7 +27,6 @@
// //
//======================================================================== //========================================================================
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h> #include <stdio.h>

View File

@ -398,7 +398,7 @@ static void char_mods_callback(GLFWwindow* window, unsigned int codepoint, int m
get_mods_name(mods)); get_mods_name(mods));
} }
static void drop_callback(GLFWwindow* window, int count, const char** names) static void drop_callback(GLFWwindow* window, int count, const char** paths)
{ {
int i; int i;
Slot* slot = glfwGetWindowUserPointer(window); Slot* slot = glfwGetWindowUserPointer(window);
@ -407,7 +407,7 @@ static void drop_callback(GLFWwindow* window, int count, const char** names)
counter++, slot->number, glfwGetTime()); counter++, slot->number, glfwGetTime());
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
printf(" %i: \"%s\"\n", i, names[i]); printf(" %i: \"%s\"\n", i, paths[i]);
} }
static void monitor_callback(GLFWmonitor* monitor, int event) static void monitor_callback(GLFWmonitor* monitor, int event)

View File

@ -110,7 +110,7 @@ static void draw_joystick(Joystick* j, int x, int y, int width, int height)
static void draw_joysticks(GLFWwindow* window) static void draw_joysticks(GLFWwindow* window)
{ {
int i, width, height; int i, width, height, offset = 0;
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
@ -126,8 +126,9 @@ static void draw_joysticks(GLFWwindow* window)
if (j->present) if (j->present)
{ {
draw_joystick(j, draw_joystick(j,
0, i * height / joystick_count, 0, offset * height / joystick_count,
width, height / joystick_count); width, height / joystick_count);
offset++;
} }
} }
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// Video mode test // Monitor information tool
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> // Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
// //
// This software is provided 'as-is', without any express or implied // This software is provided 'as-is', without any express or implied
@ -23,7 +23,8 @@
// //
//======================================================================== //========================================================================
// //
// This test enumerates or verifies video modes // This test prints monitor and video mode information or verifies video
// modes
// //
//======================================================================== //========================================================================
@ -43,8 +44,8 @@ enum Mode
static void usage(void) static void usage(void)
{ {
printf("Usage: modes [-t]\n"); printf("Usage: monitors [-t]\n");
printf(" modes -h\n"); printf(" monitors -h\n");
} }
static const char* format_mode(const GLFWvidmode* mode) static const char* format_mode(const GLFWvidmode* mode)