Compare commits

..

No commits in common. "master" and "shadow-renderqueue" have entirely different histories.

51 changed files with 699 additions and 656 deletions

View File

@ -56,8 +56,8 @@ ADD_DEFINITIONS(-DNO_SPACE_NAVIGATOR_SUPPORT)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -DSAXUM_DEBUG -g")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -DSAXUM_DEBUG -g")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -DNDEBUG")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -DNDEBUG")
set(dir ${CMAKE_CURRENT_SOURCE_DIR}/binaries)
set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)

View File

@ -11,11 +11,11 @@
If you feel your game runs smooth enough you can increase them to
increase the visual quality. -->
<shadowCubeSize>512</shadowCubeSize>
<shadowCubeSize>1024</shadowCubeSize>
<farPlane>150.0</farPlane>
<maxShadowRenderCount>3</maxShadowRenderCount>
<maxShadowRenderCount>5</maxShadowRenderCount>
<!-- The following stuff is used to configure the application.
Do not change unless you know what you are doing. -->

View File

@ -1,5 +1,7 @@
#version 150
out float gl_FragDepth;
void main() {
gl_FragDepth = gl_FragCoord.z;
}

View File

@ -4,6 +4,8 @@ in vec4 fragPosition;
uniform float farPlane;
out float gl_FragDepth;
void main() {
float nearPlane = 0.1;
float A = -(farPlane+nearPlane)/(farPlane-nearPlane);

View File

@ -32,17 +32,6 @@ uniform samplerCubeShadow shadowMap_cube11;
uniform samplerCubeShadow shadowMap_cube12;
uniform samplerCubeShadow shadowMap_cube13;
uniform samplerCubeShadow shadowMap_cube14;
uniform samplerCubeShadow shadowMap_cube15;
uniform samplerCubeShadow shadowMap_cube16;
uniform samplerCubeShadow shadowMap_cube17;
uniform samplerCubeShadow shadowMap_cube18;
uniform samplerCubeShadow shadowMap_cube19;
uniform samplerCubeShadow shadowMap_cube20;
uniform samplerCubeShadow shadowMap_cube21;
uniform samplerCubeShadow shadowMap_cube22;
uniform samplerCubeShadow shadowMap_cube23;
uniform samplerCubeShadow shadowMap_cube24;
uniform samplerCubeShadow shadowMap_cube25;
uniform vec3 ambientColor;
uniform float ambientFactor;
uniform float diffuseFactor;
@ -283,7 +272,7 @@ void main()
for(int i = 0; i<lightCount; i++) {
vec3 lightPos = vec3(0.0, 0.0, 0.0);
if (isFlame[i] == true) {
lightPos = vec3(lightSources[i].x - 0.75*movement.y , lightSources[i].y, lightSources[i].z + 0.75*movement.x);
lightPos = vec3(lightSources[i].x + 0.75*movement.y , lightSources[i].y, lightSources[i].z + 0.75*movement.x);
}
else {
lightPos = lightSources[i];
@ -345,39 +334,6 @@ void main()
if (i == 14 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube14, lightDirection, intensity);
}
if (i == 15 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube15, lightDirection, intensity);
}
if (i == 16 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube16, lightDirection, intensity);
}
if (i == 17 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube17, lightDirection, intensity);
}
if (i == 18 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube18, lightDirection, intensity);
}
if (i == 19 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube19, lightDirection, intensity);
}
if (i == 20 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube20, lightDirection, intensity);
}
if (i == 21 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube21, lightDirection, intensity);
}
if (i == 22 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube22, lightDirection, intensity);
}
if (i == 23 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube23, lightDirection, intensity);
}
if (i == 24 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube24, lightDirection, intensity);
}
if (i == 25 && i<maxShadowRenderCount) {
pointVisibility = samplePointShadow(shadowMap_cube25, lightDirection, intensity);
}
vec3 lightVector = normalize(lightPos-vec3(fragPosition));
diffuseColor += clamp(dot(normalize(vNormal), lightVector)
*diffuseFactor*intensity*lightColors[i]*pointVisibility, 0.0, 1.0);

View File

@ -1,38 +0,0 @@
<?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

@ -0,0 +1,19 @@
#----------------------------------------------------------------
# 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

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

135
extern/glfw/README.md vendored
View File

@ -6,8 +6,10 @@ GLFW is a free, Open Source, multi-platform library for OpenGL and OpenGL ES
application development. It provides a simple, platform-independent API for
creating windows and contexts, reading input, handling events, etc.
Version 3.1.1 adds fixes for a number of bugs that together affect all supported
platforms, most notably workarounds for bugs in some popular window managers.
Version 3.1 adds improved documentation, support for custom system cursors, file
drop events, main thread wake-up, window frame size retrieval, floating windows,
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
[introductory tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW
@ -63,26 +65,110 @@ GLFW bundles a number of dependencies in the `deps/` directory.
## Changelog
- Made library compilation fail if any header option macros are defined
- Removed support for LCC and Borland C++
- Bugfix: `glfwSetTime` silently accepted invalid values
- [Cocoa] Bugfix: `NSHighResolutionCapable` was not enabled for test and
example programs
- [Cocoa] Bugfix: Sleeping monitors were not included in the monitor list
- [Cocoa] Bugfix: `glfwSetWindowSize` did not change the video mode for full
screen windows
- [X11] Added support for Cygwin-X
- [X11] Made XInput2 optional at compile-time
- [X11] Made Xxf86vm optional at compile-time
- [X11] Bugfix: Moved `_NET_REQUEST_FRAME_EXTENTS` request to
`glfwGetWindowFrameSize` and added protocol-breaking timeout
as a workaround for broken support in Unity, Fluxbox and Xfwm
- [X11] Bugfix: Mouse button `GLFW_MOUSE_BUTTON_4` was never used
- [X11] Bugfix: `glfwTerminate` could close an unrelated file descriptor
- [X11] Bugfix: Some WMs (KWM, Fluxbox) did not respect cursor redefinition
- [WGL] Bugfix: The context flags debug bit was not set for OpenGL ES
- [GLX] Bugfix: The context flags debug bit was not set for OpenGL ES
- [EGL] Bugfix: The context flags debug bit was not set for OpenGL ES
- Added `GLFWcursor` custom system cursor handle
- Added `glfwCreateCursor`, `glfwCreateStandardCursor`, `glfwDestroyCursor` and
`glfwSetCursor` for managing system cursor images
- Added `GLFWimage` struct for passing 32-bit RGBA images
- Added monitor and adapter identifier access to native API
- Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files
- Added `glfwPostEmptyEvent` for allowing secondary threads to cause
`glfwWaitEvents` to return
- Added `empty` test program for verifying posting of empty events
- Added `glfwSetCharModsCallback` for receiving character events with modifiers
- Added `glfwGetWindowFrameSize` for retrieving the size of the frame around
the client area of a window
- Added `GLFW_AUTO_ICONIFY` for controlling whether full screen windows
automatically iconify (and restore the previous video mode) on focus loss
- Added `GLFW_DONT_CARE` for indicating that any value is acceptable
- Added `GLFW_DOUBLEBUFFER` for controlling whether to use double buffering
- Added `GLFW_CONTEXT_RELEASE_BEHAVIOR` and values
`GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` and
`GLFW_RELEASE_BEHAVIOR_NONE` for `GL_KHR_context_flush_control` support
- Added `GLFW_INCLUDE_ES31` for including the OpenGL ES 3.1 header
- 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
@ -130,7 +216,6 @@ skills.
- Michael Dickens
- Jonathan Dummer
- Ralph Eastwood
- Siavash Eliasi
- Michael Fogleman
- Gerald Franz
- GeO4d
@ -156,10 +241,8 @@ skills.
- Hans Mackowiak
- Kyle McDonald
- David Medlock
- Bryce Mehring
- Jonathan Mercier
- Marcel Metz
- Jonathan Miller
- Kenneth Miller
- Bruce Mitchener
- Jack Moffitt
@ -177,7 +260,6 @@ skills.
- Pieroman
- Jorge Rodriguez
- Ed Ropple
- Aleksey Rybalkin
- Riku Salminen
- Brandon Schaefer
- Sebastian Schuberth
@ -194,7 +276,6 @@ skills.
- Nathan Sweet
- TTK-Bandit
- Sergey Tikhomirov
- A. Tombs
- Samuli Tuomola
- urraka
- Jari Vetoniemi

View File

@ -1,4 +1,3 @@
#include <stdio.h>
#include <string.h>
#include <glad/glad.h>
@ -688,33 +687,9 @@ static void find_extensionsGL(void) {
}
static void find_coreGL(void) {
/* Thank you @elmindreda
* 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);
const char *v = (const char *)glGetString(GL_VERSION);
int major = v[0] - '0';
int minor = v[2] - '0';
GLVersion.major = major; GLVersion.minor = minor;
GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
@ -729,11 +704,10 @@ static void find_coreGL(void) {
GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
}
int gladLoadGLLoader(GLADloadproc load) {
void gladLoadGLLoader(GLADloadproc load) {
GLVersion.major = 0; GLVersion.minor = 0;
glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
if(glGetString == NULL) return 0;
if(glGetString(GL_VERSION) == NULL) return 0;
if(glGetString == NULL) return;
find_coreGL();
load_GL_VERSION_1_0(load);
load_GL_VERSION_1_1(load);
@ -748,6 +722,7 @@ int gladLoadGLLoader(GLADloadproc load) {
load_GL_VERSION_3_2(load);
find_extensionsGL();
return GLVersion.major != 0 || GLVersion.minor != 0;
return;
}

View File

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

View File

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

View File

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

View File

@ -68,17 +68,28 @@ extern "C" {
/*************************************************************************
* Compiler- and platform-specific preprocessor work
* Global definitions
*************************************************************************/
/* If we are we on Windows, we want a single define for it.
/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
/* 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(__MINGW32__))
#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
#define _WIN32
#endif /* _WIN32 */
/* It is customary to use APIENTRY for OpenGL function pointer declarations on
* all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
/* In order for extension support to be portable, we need to define an
* OpenGL function call method. We use the keyword APIENTRY, which is
* defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
*/
#ifndef APIENTRY
#ifdef _WIN32
@ -88,23 +99,44 @@ extern "C" {
#endif
#endif /* APIENTRY */
/* Some Windows OpenGL headers need this.
/* The following three defines are here solely to make some Windows-based
* <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(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
/* Microsoft Visual C++, Borland C++ Builder and Pelles C */
#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
#endif /* WINGDIAPI */
/* Some Windows GLU headers need this.
*/
/* Some <GL/glu.h> files also need CALLBACK defined */
#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
#else
#define CALLBACK
#endif
#else
/* Other Windows compilers */
#define CALLBACK __stdcall
#endif
#define GLFW_CALLBACK_DEFINED
#endif /* CALLBACK */
/* Most Windows GLU headers need wchar_t.
* The OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.
*/
/* Most GL/glu.h variants on Windows need wchar_t
* OpenGL/gl.h blocks the definition of ptrdiff_t by glext.h on OS X */
#if !defined(GLFW_INCLUDE_NONE)
#include <stddef.h>
#endif
@ -165,7 +197,7 @@ extern "C" {
* version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
* configuration header when compiling the DLL version of the library.
*/
#error "You may not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
#error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
#endif
/* GLFWAPI is used to declare public API functions for export
@ -176,7 +208,11 @@ extern "C" {
#define GLFWAPI __declspec(dllexport)
#elif defined(_WIN32) && defined(GLFW_DLL)
/* We are calling GLFW as a Win32 DLL */
#if defined(__LCC__)
#define GLFWAPI extern
#else
#define GLFWAPI __declspec(dllimport)
#endif
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
/* We are building GLFW as a shared / dynamic library */
#define GLFWAPI __attribute__((visibility("default")))
@ -185,6 +221,8 @@ extern "C" {
#define GLFWAPI
#endif
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
/*************************************************************************
* GLFW API tokens
@ -211,7 +249,7 @@ extern "C" {
* API changes.
* @ingroup init
*/
#define GLFW_VERSION_REVISION 1
#define GLFW_VERSION_REVISION 0
/*! @} */
/*! @name Key and button actions
@ -520,9 +558,7 @@ extern "C" {
/*! @brief 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.
* GLFW could not find support for the requested client API on the system.
*
* @par Analysis
* The installed graphics driver does not support the requested client API, or
@ -539,8 +575,8 @@ extern "C" {
#define GLFW_API_UNAVAILABLE 0x00010006
/*! @brief The requested OpenGL or OpenGL ES version is not available.
*
* The requested OpenGL or OpenGL ES version (including any requested context
* or framebuffer hints) is not available on this machine.
* The requested OpenGL or OpenGL ES version (including any requested profile
* or context option) is not available on this machine.
*
* @par Analysis
* The machine does not support your requirements. If your application is
@ -562,8 +598,7 @@ extern "C" {
* specific categories.
*
* @par Analysis
* 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
* A bug in GLFW or the underlying operating system. Report the bug to our
* [issue tracker](https://github.com/glfw/glfw/issues).
*/
#define GLFW_PLATFORM_ERROR 0x00010008
@ -953,7 +988,7 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
*
* @param[in] window The window that received the event.
* @param[in] count The number of dropped files.
* @param[in] paths The UTF-8 encoded file and/or directory path names.
* @param[in] names The UTF-8 encoded path names of the dropped files.
*
* @sa glfwSetDropCallback
*
@ -1427,8 +1462,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* 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
* and then calls @ref glfwSetGammaRamp with it. The value must be a finite
* number greater than zero.
* and then calls @ref glfwSetGammaRamp with it.
*
* @param[in] monitor The monitor whose gamma ramp to set.
* @param[in] gamma The desired exponent.
@ -1478,10 +1512,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
* @param[in] monitor The monitor whose gamma ramp to set.
* @param[in] ramp The gamma ramp to use.
*
* @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.
* @note Gamma ramp sizes other than 256 are not supported by all hardware.
*
* @par Pointer Lifetime
* The specified gamma ramp is copied before this function returns.
@ -1617,13 +1648,6 @@ GLFWAPI void glfwWindowHint(int target, int hint);
* The menu bar can be disabled with a
* [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:__ Some window managers will not respect the placement of
@ -3112,15 +3136,10 @@ GLFWAPI double glfwGetTime(void);
/*! @brief Sets the GLFW timer.
*
* This function sets the value of the GLFW timer. It then continues to count
* 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.
* up from that value.
*
* @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
* This function may only be called from the main thread.
*
@ -3224,14 +3243,14 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
* @param[in] interval The minimum number of screen updates to wait for
* until the buffers are swapped by @ref glfwSwapBuffers.
*
* @remarks This function is not called during context creation, leaving the
* swap interval set to whatever is the default on that platform. This is done
* @note This function is not called during window creation, leaving the 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
* interval to be reset to zero once it has been set to a non-zero value.
*
* @remarks Some GPU drivers do not honor the requested swap interval, either
* because of a user setting that overrides the application's request or due to
* bugs in the driver.
* @note 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
* driver.
*
* @par Thread Safety
* This function may be called from any thread.
@ -3248,9 +3267,9 @@ GLFWAPI void glfwSwapInterval(int interval);
/*! @brief Returns whether the specified extension is available.
*
* This function returns whether the specified
* [client API extension](@ref context_glext) is supported by the current
* OpenGL or OpenGL ES context. It searches both for OpenGL and OpenGL ES
* extension and platform-specific context creation API extensions.
* [API extension](@ref context_glext) is supported by the current OpenGL or
* OpenGL ES context. It searches both for OpenGL and OpenGL ES extension and
* platform-specific context creation API extensions.
*
* 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.
@ -3279,7 +3298,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension);
* context.
*
* This function returns the address of the specified
* [core or extension function](@ref context_glext), if it is supported
* [client API or extension function](@ref context_glext), if it is supported
* by the current context.
*
* A context must be current on the calling thread. Calling this function
@ -3289,13 +3308,9 @@ GLFWAPI int glfwExtensionSupported(const char* extension);
* @return The address of the function, or `NULL` if the function is
* unavailable or an [error](@ref error_handling) occurred.
*
* @remarks The addresses of a given function is not guaranteed to be the same
* @note The addresses of a given function is not guaranteed to be the same
* 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
* The returned function pointer is valid until the context is destroyed or the
* library is terminated.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
# GLFW3_LIBRARY_DIR, folder in which the GLFW library is located
# GLFW3_LIBRARY, library to link against to use GLFW
set(GLFW3_VERSION "3.1.1")
set(GLFW3_VERSION "3.1.0")
####### 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().
set(PACKAGE_VERSION "3.1.1")
set(PACKAGE_VERSION "3.1.0")
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
if("3.1.1" MATCHES "^([0-9]+)\\.")
if("3.1.0" MATCHES "^([0-9]+)\\.")
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
set(CVF_VERSION_MAJOR "3.1.1")
set(CVF_VERSION_MAJOR "3.1.0")
endif()
if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}")

View File

@ -62,10 +62,6 @@
// Define this to 1 to force use of high-performance GPU on Optimus systems
/* #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 _GLFW_HAS_GLXGETPROCADDRESS
// Define this to 1 if glXGetProcAddressARB is available

View File

@ -62,10 +62,6 @@
// Define this to 1 to force use of high-performance GPU on Optimus systems
#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
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
// 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);
if (!_glfw.glx.libGL)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to find libGL");
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to find libGL");
return GL_FALSE;
}
#endif
@ -320,7 +320,8 @@ int _glfwCreateContext(_GLFWwindow* window,
!_glfw.glx.EXT_create_context_es2_profile)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
"GLX: OpenGL ES requested but "
"GLX_EXT_create_context_es2_profile is unavailable");
return GL_FALSE;
}
}
@ -330,7 +331,8 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!_glfw.glx.ARB_create_context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
"GLX: Forward compatibility requested but "
"GLX_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
}
@ -341,7 +343,8 @@ int _glfwCreateContext(_GLFWwindow* window,
!_glfw.glx.ARB_create_context_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
"GLX: An OpenGL profile requested but "
"GLX_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
}
@ -357,6 +360,9 @@ int _glfwCreateContext(_GLFWwindow* window,
if (ctxconfig->forward)
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
if (ctxconfig->debug)
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->profile)
{
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
@ -368,9 +374,6 @@ int _glfwCreateContext(_GLFWwindow* window,
else
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
if (ctxconfig->debug)
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->robustness)
{
if (_glfw.glx.ARB_create_context_robustness)
@ -451,7 +454,7 @@ int _glfwCreateContext(_GLFWwindow* window,
if (!window->glx.context)
{
_glfwInputXError(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
_glfwInputXError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context");
return GL_FALSE;
}

View File

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

View File

@ -33,18 +33,7 @@
#include "glfw_config.h"
#endif
#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
#define _GLFW_VERSION_NUMBER "3.1.0"
#if defined(_GLFW_USE_OPENGL)
// This is the default for glfw3.h

View File

@ -277,13 +277,11 @@ void _glfwTerminateJoysticks(void)
regfree(&_glfw.linux_js.regex);
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.watch);
if (_glfw.linux_js.inotify > 0)
close(_glfw.linux_js.inotify);
}
#endif // __linux__
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,6 +30,11 @@
#include <stdlib.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)
@ -330,6 +335,12 @@ int _glfwPlatformInit(void)
if (_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())
return GL_FALSE;
@ -370,6 +381,8 @@ const char* _glfwPlatformGetVersionString(void)
" MinGW"
#elif defined(_MSC_VER)
" VisualC"
#elif defined(__BORLANDC__)
" BorlandC"
#endif
#if defined(_GLFW_BUILD_DLL)
" DLL"

View File

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

View File

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

View File

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

View File

@ -479,13 +479,11 @@ static GLboolean initExtensions(void)
"_MOTIF_WM_HINTS",
False);
#if defined(_GLFW_HAS_XF86VM)
// Check for XF86VidMode extension
_glfw.x11.vidmode.available =
XF86VidModeQueryExtension(_glfw.x11.display,
&_glfw.x11.vidmode.eventBase,
&_glfw.x11.vidmode.errorBase);
#endif /*_GLFW_HAS_XF86VM*/
// Check for RandR extension
_glfw.x11.randr.available =
@ -537,7 +535,6 @@ static GLboolean initExtensions(void)
_glfw.x11.xinerama.available = GL_TRUE;
}
#if defined(_GLFW_HAS_XINPUT)
if (XQueryExtension(_glfw.x11.display,
"XInputExtension",
&_glfw.x11.xi.majorOpcode,
@ -554,7 +551,6 @@ static GLboolean initExtensions(void)
_glfw.x11.xi.available = GL_TRUE;
}
}
#endif /*_GLFW_HAS_XINPUT*/
// Check if Xkb is supported on this display
_glfw.x11.xkb.versionMajor = 1;
@ -587,7 +583,7 @@ static GLboolean initExtensions(void)
detectEWMH();
// 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 =
XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
_glfw.x11.COMPOUND_STRING =
@ -714,8 +710,6 @@ Cursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
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)
setlocale(LC_CTYPE, "");
@ -724,7 +718,7 @@ int _glfwPlatformInit(void)
_glfw.x11.display = XOpenDisplay(NULL);
if (!_glfw.x11.display)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to open X display");
_glfwInputError(GLFW_API_UNAVAILABLE, "X11: Failed to open X display");
return GL_FALSE;
}

View File

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

View File

@ -37,25 +37,21 @@
#include <X11/Xatom.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
#include <X11/extensions/Xrandr.h>
// The XInput2 extension provides improved input events
#include <X11/extensions/XInput2.h>
// The Xkb extension provides improved keyboard support
#include <X11/XKBlib.h>
// The Xinerama extension provides legacy monitor indices
#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"
#if defined(_GLFW_GLX)
@ -160,12 +156,18 @@ typedef struct _GLFWlibraryX11
Atom CLIPBOARD;
Atom CLIPBOARD_MANAGER;
Atom SAVE_TARGETS;
Atom NULL_;
Atom _NULL;
Atom UTF8_STRING;
Atom COMPOUND_STRING;
Atom ATOM_PAIR;
Atom GLFW_SELECTION;
struct {
GLboolean available;
int eventBase;
int errorBase;
} vidmode;
struct {
GLboolean available;
int eventBase;
@ -186,6 +188,15 @@ typedef struct _GLFWlibraryX11
int versionMinor;
} xkb;
struct {
GLboolean available;
int majorOpcode;
int eventBase;
int errorBase;
int versionMajor;
int versionMinor;
} xi;
struct {
int count;
int timeout;
@ -204,25 +215,6 @@ typedef struct _GLFWlibraryX11
int versionMinor;
} 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;

View File

@ -28,7 +28,6 @@
#include "internal.h"
#include <X11/cursorfont.h>
#include <X11/Xmd.h>
#include <sys/select.h>
@ -58,22 +57,6 @@ typedef struct
#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
//
static int getWindowState(_GLFWwindow* window)
@ -200,12 +183,11 @@ static void changeWindowState(_GLFWwindow* window, Atom state, int action)
}
// 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)
{
const char* prefix = "file://";
char** paths = NULL;
char** names = NULL;
char* line;
*count = 0;
@ -214,7 +196,7 @@ static char** parseUriList(char* text, int* count)
{
text = NULL;
if (line[0] == '#')
if (*line == '#')
continue;
if (strncmp(line, prefix, strlen(prefix)) == 0)
@ -222,27 +204,27 @@ static char** parseUriList(char* text, int* count)
(*count)++;
char* path = calloc(strlen(line) + 1, 1);
paths = realloc(paths, *count * sizeof(char*));
paths[*count - 1] = path;
char* name = calloc(strlen(line) + 1, 1);
names = realloc(names, *count * sizeof(char*));
names[*count - 1] = name;
while (*line)
{
if (line[0] == '%' && line[1] && line[2])
{
const char digits[3] = { line[1], line[2], '\0' };
*path = strtol(digits, NULL, 16);
*name = strtol(digits, NULL, 16);
line += 2;
}
else
*path = *line;
*name = *line;
path++;
name++;
line++;
}
}
return paths;
return names;
}
// Create the X11 window (and its colormap)
@ -429,7 +411,6 @@ static GLboolean createWindow(_GLFWwindow* window,
XFree(hint);
}
#if defined(_GLFW_HAS_XINPUT)
if (_glfw.x11.xi.available)
{
// Select for XInput2 events
@ -444,7 +425,6 @@ static GLboolean createWindow(_GLFWwindow* window,
XISelectEvents(_glfw.x11.display, window->x11.handle, &eventmask, 1);
}
#endif /*_GLFW_HAS_XINPUT*/
if (_glfw.x11.XdndAware)
{
@ -455,6 +435,27 @@ static GLboolean createWindow(_GLFWwindow* window,
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 (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_ABOVE)
@ -628,7 +629,7 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
XChangeProperty(_glfw.x11.display,
request->requestor,
request->property,
_glfw.x11.NULL_,
_glfw.x11._NULL,
32,
PropModeReplace,
NULL,
@ -700,8 +701,9 @@ static void pushSelectionToManager(_GLFWwindow* window)
{
XEvent event;
while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
{
if (!XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
continue;
switch (event.type)
{
case SelectionRequest:
@ -727,9 +729,6 @@ static void pushSelectionToManager(_GLFWwindow* window)
}
}
}
selectDisplayConnection(NULL);
}
}
// Enter full screen mode
@ -1008,7 +1007,7 @@ static void processEvent(XEvent *event)
// Additional buttons after 7 are treated as regular buttons
// We subtract 4 to fill the gap left by scroll input above
_glfwInputMouseClick(window,
event->xbutton.button - Button1 - 4,
event->xbutton.button - 4,
GLFW_PRESS,
mods);
}
@ -1046,7 +1045,7 @@ static void processEvent(XEvent *event)
// Additional buttons after 7 are treated as regular buttons
// We subtract 4 to fill the gap left by scroll input above
_glfwInputMouseClick(window,
event->xbutton.button - Button1 - 4,
event->xbutton.button - 4,
GLFW_RELEASE,
mods);
}
@ -1055,11 +1054,6 @@ static void processEvent(XEvent *event)
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);
break;
}
@ -1222,13 +1216,13 @@ static void processEvent(XEvent *event)
if (result)
{
int i, count;
char** paths = parseUriList(data, &count);
char** names = parseUriList(data, &count);
_glfwInputDrop(window, count, (const char**) paths);
_glfwInputDrop(window, count, (const char**) names);
for (i = 0; i < count; i++)
free(paths[i]);
free(paths);
free(names[i]);
free(names);
}
XFree(data);
@ -1315,7 +1309,6 @@ static void processEvent(XEvent *event)
case DestroyNotify:
return;
#if defined(_GLFW_HAS_XINPUT)
case GenericEvent:
{
if (event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
@ -1361,7 +1354,6 @@ static void processEvent(XEvent *event)
XFreeEventData(_glfw.x11.display, &event->xcookie);
break;
}
#endif /*_GLFW_HAS_XINPUT*/
default:
{
@ -1455,8 +1447,8 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
if (window->x11.handle)
{
if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
window->x11.handle)
if (window->x11.handle ==
XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD))
{
pushSelectionToManager(window);
}
@ -1604,56 +1596,6 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
if (_glfw.x11.NET_FRAME_EXTENTS == None)
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,
_glfw.x11.NET_FRAME_EXTENTS,
XA_CARDINAL,
@ -1679,8 +1621,9 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
// Override-redirect windows cannot be iconified or restored, as those
// tasks are performed by the window manager
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Iconification of full screen windows requires a WM that supports EWMH");
_glfwInputError(GLFW_API_UNAVAILABLE,
"X11: Iconification of full screen windows requires "
"a WM that supports EWMH");
return;
}
@ -1694,8 +1637,9 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{
// Override-redirect windows cannot be iconified or restored, as those
// tasks are performed by the window manager
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Iconification of full screen windows requires a WM that supports EWMH");
_glfwInputError(GLFW_API_UNAVAILABLE,
"X11: Iconification of full screen windows requires "
"a WM that supports EWMH");
return;
}
@ -1764,7 +1708,19 @@ void _glfwPlatformPollEvents(void)
void _glfwPlatformWaitEvents(void)
{
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();
}
@ -1778,7 +1734,7 @@ void _glfwPlatformPostEmptyEvent(void)
event.type = ClientMessage;
event.xclient.window = window->x11.handle;
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);
XFlush(_glfw.x11.display);
@ -1840,8 +1796,14 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{
cursor->x11.handle = XCreateFontCursor(_glfw.x11.display,
translateCursorShape(shape));
const unsigned int native = translateCursorShape(shape);
if (!native)
{
_glfwInputError(GLFW_INVALID_ENUM, "X11: Invalid standard cursor");
return GL_FALSE;
}
cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
if (!cursor->x11.handle)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
@ -1884,7 +1846,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
window->x11.handle)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Failed to become owner of clipboard selection");
"X11: Failed to become owner of the clipboard selection");
}
}
@ -1921,7 +1883,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
// XCheckTypedEvent is used instead of XIfEvent in order not to lock
// other threads out from the display during the entire wait period
while (!XCheckTypedEvent(_glfw.x11.display, SelectionNotify, &event))
selectDisplayConnection(NULL);
;
if (event.xselection.property == None)
continue;
@ -1947,7 +1909,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
if (_glfw.x11.clipboardString == NULL)
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"X11: Failed to convert clipboard to string");
"X11: Failed to convert selection to string");
}
return _glfw.x11.clipboardString;

View File

@ -1,5 +1,5 @@
link_libraries(glfw)
link_libraries(glfw "${OPENGL_glu_LIBRARY}")
if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL)
@ -28,7 +28,7 @@ add_executable(gamma gamma.c ${GETOPT})
add_executable(glfwinfo glfwinfo.c ${GETOPT})
add_executable(iconify iconify.c ${GETOPT})
add_executable(joysticks joysticks.c)
add_executable(monitors monitors.c ${GETOPT})
add_executable(modes modes.c ${GETOPT})
add_executable(peter peter.c)
add_executable(reopen reopen.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(CONSOLE_BINARIES clipboard defaults events fsaa gamma glfwinfo
iconify joysticks monitors peter reopen cursor)
iconify joysticks modes peter reopen cursor)
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
FOLDER "GLFW3/Tests")
@ -76,7 +76,6 @@ endif()
if (APPLE)
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/AppleInfo.plist")
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
endif()

View File

@ -27,6 +27,7 @@
//
//========================================================================
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.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));
}
static void drop_callback(GLFWwindow* window, int count, const char** paths)
static void drop_callback(GLFWwindow* window, int count, const char** names)
{
int i;
Slot* slot = glfwGetWindowUserPointer(window);
@ -407,7 +407,7 @@ static void drop_callback(GLFWwindow* window, int count, const char** paths)
counter++, slot->number, glfwGetTime());
for (i = 0; i < count; i++)
printf(" %i: \"%s\"\n", i, paths[i]);
printf(" %i: \"%s\"\n", i, names[i]);
}
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)
{
int i, width, height, offset = 0;
int i, width, height;
glfwGetFramebufferSize(window, &width, &height);
@ -126,9 +126,8 @@ static void draw_joysticks(GLFWwindow* window)
if (j->present)
{
draw_joystick(j,
0, offset * height / joystick_count,
0, i * height / joystick_count,
width, height / joystick_count);
offset++;
}
}
}

View File

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

View File

@ -22,7 +22,7 @@ void Application::init()
}
void Application::initLevel() {
this->level = Level(levelXmlPath, farPlane);
this->level = Level(levelXmlPath);
level.getPhysics()->init(geometryPath);
// Don't change this!
ignoredMouseUpdates = 0;

View File

@ -12,7 +12,7 @@ using namespace ACGL::OpenGL;
const double lightUpdateDelay = 0.5f;
const double windUpdateDelay = 0.5f;
const int maxShadowSampleCount = 26;
const int maxShadowSampleCount = 15;
Graphics::Graphics(glm::uvec2 windowSize, float nearPlane,
float farPlane, int cube_size,
@ -21,24 +21,9 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane,
std::string screenContinuePath) {
this->windowSize = windowSize;
this->nearPlane = nearPlane;
if (farPlane > 0) {
this->farPlane = farPlane;
}
else {
this->farPlane = 0;
}
if (cube_size > 0) {
this->cube_size = cube_size;
}
else {
this->cube_size = 0;
}
if (maxShadowRenderCount < maxShadowSampleCount) {
this->maxShadowRenderCount = maxShadowRenderCount;
}
else {
this->maxShadowRenderCount = 0;
}
this->loadingScreenPath = screenPath;
this->loadingScreenContinuePath = screenContinuePath;
gameStart = false;
@ -157,6 +142,8 @@ void Graphics::init(Level* level) {
framebuffer_directional.at(i)->validate();
}
// always generate and bind all cube maps, because otherwise the shader won't work
depth_cubeMaps = std::vector<ACGL::OpenGL::SharedTextureCubeMap>(maxShadowSampleCount);
for (unsigned int i = 0; i<depth_cubeMaps.size(); i++) {
@ -226,7 +213,6 @@ void Graphics::init(Level* level) {
#ifdef SAXUM_DEBUG
std::cout << "There were " << Material::getAllTextures()->size()
<< " materials used in this level." << std::endl;
cout << "There are " << level->checkMaxSurroundingLights() << " max surrounding lights." << endl;
#endif
initShadowRenderQueue();
@ -364,25 +350,25 @@ void Graphics::render(double time)
std::vector<std::tuple<std::shared_ptr<Light>, int, int>> renderQueue =
std::vector<std::tuple<std::shared_ptr<Light>, int, int>>(maxShadowRenderCount);
for(unsigned int i = 0; i<shadowRenderQueue.size(); i++) {
bool enqueued = false;
for(unsigned int j = 0; j<renderQueue.size(); j++){
if (shadowRenderQueue.at(i).currentPriority > std::get<1>(renderQueue.at(j))){
if (renderQueue.at(j) != renderQueue.back()) {
if (j<renderQueue.size() - 2) {
renderQueue.at(j+1) = renderQueue.at(j);
}
renderQueue.at(j) = std::make_tuple(shadowRenderQueue.at(i).light, shadowRenderQueue.at(i).currentPriority, i);
enqueued = true;
break;
}
}
if (enqueued) {
shadowRenderQueue.at(i).currentPriority = 0;
}
// reset currentPriority
for(unsigned int i = 0; i<renderQueue.size(); i++) {
shadowRenderQueue.at(std::get<2>(renderQueue.at(i))).currentPriority = 0;
}
depthCubeShader->use();
// render depth textures for point lights
glViewport(0, 0, cube_size, cube_size);
depthCubeShader->use();
glm::mat4 depthProjectionMatrix_pointlights = glm::perspective(1.571f, (float)cube_size/(float)cube_size, 0.1f, 50.0f);
glm::vec3 looking_directions[6] = {glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(-1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f),
glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, -1.0f)};
@ -398,7 +384,7 @@ void Graphics::render(double time)
glm::vec3 position = glm::vec3(0.0f);
if (std::get<0>(renderQueue.at(i_pointlight))->isFlame()) {
position = std::get<0>(renderQueue.at(i_pointlight))->getPosition();
position = glm::vec3(position.x - 0.75f*wind.y, position.y, position.z + 0.75f*wind.x);
position = glm::vec3(position.x + 0.75f*wind.x, position.y, position.z + 0.75f*wind.y);
}
else {
position = std::get<0>(renderQueue.at(i_pointlight))->getPosition();
@ -648,7 +634,7 @@ void Graphics::render(double time)
void Graphics::updateLights() {
std::vector<std::shared_ptr<Light>> oldClosestLights = std::vector<std::shared_ptr<Light>>(*closestLights);
closestLights = level->getClosestLights(maxShadowSampleCount);
closestLights = level->getClosestLights();
if (closestLights->size() > 0) {
lightingShader->use();
lightingShader->setUniform("lightCount", (int) closestLights->size());
@ -872,7 +858,7 @@ void Graphics::enqueueObjects(std::vector<std::vector<Object*>>* queue){
}
void Graphics::initShadowRenderQueue() {
closestLights = level->getClosestLights(maxShadowSampleCount);
closestLights = level->getClosestLights();
int maxLights = min((int)closestLights->size(), maxShadowSampleCount);
shadowRenderQueue = std::vector<ShadowRenderQueueSlot>(maxLights);
glViewport(0, 0, cube_size, cube_size);

View File

@ -1,13 +1,13 @@
#include "level.hh"
#include "loader.hh"
#include <string>
#include "graphics.hh"
Level::Level(std::string xmlFilePath, float farPlane) {
Level::Level(std::string xmlFilePath) {
// default value
skydomeSize = 50.0f;
physics = Physics();
this->xmlFilePath = xmlFilePath;
this->farPlane = farPlane;
}
Level::Level() {
@ -51,22 +51,6 @@ void Level::load() {
this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f);
}
int Level::checkMaxSurroundingLights() {
int maxSurroundingLights = 0;
for(unsigned int i = 0; i<lights.size(); i++) {
int thisSurroundingLights = 0;
for(unsigned int j = 0; j<lights.size(); j++) {
if (glm::distance(lights.at(i)->getPosition(), lights.at(j)->getPosition()) < skydomeSize) {
thisSurroundingLights++;
}
}
if (thisSurroundingLights > maxSurroundingLights) {
maxSurroundingLights = thisSurroundingLights;
}
}
return maxSurroundingLights;
}
void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::vec3 center, int chunkRenderDistance, glm::mat4* viewProjectionMatrix,
std::vector<glm::mat4>* shadowVPs) {
@ -469,14 +453,14 @@ bool Level::compareLightDistances(shared_ptr<Light> a, shared_ptr<Light> b) {
}
}
std::vector<shared_ptr<Light>>* Level::getClosestLights(unsigned int maximumAmount) {
std::vector<shared_ptr<Light>>* Level::getClosestLights() {
closestLights = std::vector<shared_ptr<Light>>(lights);
std::sort(closestLights.begin(),
closestLights.end(),
[this](shared_ptr<Light> a, shared_ptr<Light> b) {return compareLightDistances(a, b); });
if (lights.size() > maximumAmount) {
if (lights.size() > 15) {
closestLights = std::vector<shared_ptr<Light>>(&closestLights[0],
&closestLights[maximumAmount]);
&closestLights[15]);
}
// sort pointers for faster comparisons
std::sort(closestLights.begin(), closestLights.end());

View File

@ -26,7 +26,7 @@ class Graphics;
class Level {
public:
Level(std::string xmlFilePath, float farPlane);
Level(std::string xmlFilePath);
Level();
~Level();
void load();
@ -86,8 +86,7 @@ class Level {
void addToSpecificChunk(Object* object, int xPosition, int zPosition);
void enqueueObjects(Graphics* graphics);
void sortObjects(int textureCount);
std::vector<shared_ptr<Light>>* getClosestLights(unsigned int maximumAmount);
int checkMaxSurroundingLights();
std::vector<shared_ptr<Light>>* getClosestLights();
private:
std::vector<Chunk*> getSurroundingChunks(glm::vec3 center, int chunkRenderDistance);
lua_State* luaState=nullptr;