mirror of
https://github.com/glfw/glfw.git
synced 2025-10-02 21:00:57 +00:00
Merge branch 'master' of github.com:glfw/glfw into feature-dnd
Conflicts: src/cocoa_window.m src/x11_window.c
This commit is contained in:
commit
431a222319
2
.gitignore
vendored
2
.gitignore
vendored
@ -21,7 +21,7 @@ cmake_uninstall.cmake
|
|||||||
docs/Doxyfile
|
docs/Doxyfile
|
||||||
docs/html
|
docs/html
|
||||||
docs/warnings.txt
|
docs/warnings.txt
|
||||||
src/config.h
|
src/glfw_config.h
|
||||||
src/glfw3.pc
|
src/glfw3.pc
|
||||||
src/glfwConfig.cmake
|
src/glfwConfig.cmake
|
||||||
src/glfwConfigVersion.cmake
|
src/glfwConfigVersion.cmake
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
This directory contains a collection of toolchain definitions for
|
|
||||||
cross-compiling for Windows using MinGW on various other systems.
|
|
||||||
|
|
||||||
To use these files you add a special parameter when configuring the source tree:
|
|
||||||
|
|
||||||
cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> .
|
|
||||||
|
|
||||||
The exact file to use depends on the prefix used by the MinGW binaries on your
|
|
||||||
system. You can usually see this in the /usr directory, i.e. the Ubuntu
|
|
||||||
MinGW-w64 packages have /usr/x86_64-w64-mingw32 for the 64-bit compilers, so the
|
|
||||||
correct invocation would be:
|
|
||||||
|
|
||||||
cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .
|
|
||||||
|
|
||||||
For more details see this article:
|
|
||||||
|
|
||||||
http://www.paraview.org/Wiki/CMake_Cross_Compiling
|
|
||||||
|
|
@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.8)
|
|||||||
|
|
||||||
set(GLFW_VERSION_MAJOR "3")
|
set(GLFW_VERSION_MAJOR "3")
|
||||||
set(GLFW_VERSION_MINOR "0")
|
set(GLFW_VERSION_MINOR "0")
|
||||||
set(GLFW_VERSION_PATCH "2")
|
set(GLFW_VERSION_PATCH "4")
|
||||||
set(GLFW_VERSION_EXTRA "")
|
set(GLFW_VERSION_EXTRA "")
|
||||||
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
|
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
|
||||||
set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}")
|
set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}")
|
||||||
@ -13,9 +13,15 @@ set(LIB_SUFFIX "" CACHE STRING "Takes an empty string or 64. Directory where lib
|
|||||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
|
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
|
||||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
|
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
|
||||||
|
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
|
||||||
option(GLFW_INSTALL "Generate installation target" ON)
|
option(GLFW_INSTALL "Generate installation target" ON)
|
||||||
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
|
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
option(GLFW_USE_DWM_SWAP_INTERVAL "Set swap interval even when DWM compositing is enabled" OFF)
|
||||||
|
option(GLFW_USE_OPTIMUS_HPG "Force use of high-performance GPU on Optimus systems" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
|
option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
|
||||||
option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON)
|
option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON)
|
||||||
@ -68,11 +74,13 @@ endif()
|
|||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
set(DOXYGEN_SKIP_DOT TRUE)
|
if (GLFW_BUILD_DOCS)
|
||||||
find_package(Doxygen)
|
set(DOXYGEN_SKIP_DOT TRUE)
|
||||||
|
find_package(Doxygen)
|
||||||
|
|
||||||
if (GLFW_DOCUMENT_INTERNALS)
|
if (GLFW_DOCUMENT_INTERNALS)
|
||||||
set(GLFW_INTERNAL_DOCS "${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox")
|
set(GLFW_INTERNAL_DOCS "${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -151,6 +159,20 @@ if (_GLFW_WIN32)
|
|||||||
set(_GLFW_NO_DLOAD_WINMM 1)
|
set(_GLFW_NO_DLOAD_WINMM 1)
|
||||||
list(APPEND glfw_LIBRARIES winmm)
|
list(APPEND glfw_LIBRARIES winmm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_USE_DWM_SWAP_INTERVAL)
|
||||||
|
set(_GLFW_USE_DWM_SWAP_INTERVAL 1)
|
||||||
|
endif()
|
||||||
|
if (GLFW_USE_OPTIMUS_HPG)
|
||||||
|
set(_GLFW_USE_OPTIMUS_HPG 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
||||||
|
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
||||||
|
# win32_platform.h. We define them here until a saner solution can be found
|
||||||
|
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
||||||
|
add_definitions(-DUNICODE)
|
||||||
|
add_definitions(-DWINVER=0x0501)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -192,7 +214,13 @@ if (_GLFW_X11)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS ${X11_Xinput_INCLUDE_PATH})
|
list(APPEND glfw_INCLUDE_DIRS ${X11_Xinput_INCLUDE_PATH})
|
||||||
|
|
||||||
|
if (X11_Xinput_LIB)
|
||||||
list(APPEND glfw_LIBRARIES ${X11_Xinput_LIB})
|
list(APPEND glfw_LIBRARIES ${X11_Xinput_LIB})
|
||||||
|
else()
|
||||||
|
# Backwards compatibility (bug in CMake 2.8.7)
|
||||||
|
list(APPEND glfw_LIBRARIES Xi)
|
||||||
|
endif()
|
||||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xi")
|
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xi")
|
||||||
|
|
||||||
# Check for Xf86VidMode (fallback gamma control)
|
# Check for Xf86VidMode (fallback gamma control)
|
||||||
@ -257,23 +285,15 @@ if (_GLFW_GLX)
|
|||||||
|
|
||||||
# Check for dlopen support as a fallback
|
# Check for dlopen support as a fallback
|
||||||
|
|
||||||
find_library(DL_LIBRARY dl)
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
|
||||||
mark_as_advanced(DL_LIBRARY)
|
|
||||||
if (DL_LIBRARY)
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY})
|
|
||||||
else()
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_function_exists(dlopen _GLFW_HAS_DLOPEN)
|
check_function_exists(dlopen _GLFW_HAS_DLOPEN)
|
||||||
|
|
||||||
if (NOT _GLFW_HAS_DLOPEN)
|
if (NOT _GLFW_HAS_DLOPEN)
|
||||||
message(FATAL_ERROR "No entry point retrieval mechanism found")
|
message(FATAL_ERROR "No entry point retrieval mechanism found")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DL_LIBRARY)
|
if (CMAKE_DL_LIBS)
|
||||||
list(APPEND glfw_LIBRARIES ${DL_LIBRARY})
|
list(APPEND glfw_LIBRARIES ${CMAKE_DL_LIBS})
|
||||||
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -ldl")
|
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -l${CMAKE_DL_LIBS}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -331,13 +351,15 @@ if (_GLFW_COCOA AND _GLFW_NSGL)
|
|||||||
find_library(COCOA_FRAMEWORK Cocoa)
|
find_library(COCOA_FRAMEWORK Cocoa)
|
||||||
find_library(IOKIT_FRAMEWORK IOKit)
|
find_library(IOKIT_FRAMEWORK IOKit)
|
||||||
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
|
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
|
||||||
|
find_library(CORE_VIDEO_FRAMEWORK CoreVideo)
|
||||||
list(APPEND glfw_LIBRARIES ${COCOA_FRAMEWORK}
|
list(APPEND glfw_LIBRARIES ${COCOA_FRAMEWORK}
|
||||||
${OPENGL_gl_LIBRARY}
|
${OPENGL_gl_LIBRARY}
|
||||||
${IOKIT_FRAMEWORK}
|
${IOKIT_FRAMEWORK}
|
||||||
${CORE_FOUNDATION_FRAMEWORK})
|
${CORE_FOUNDATION_FRAMEWORK}
|
||||||
|
${CORE_VIDEO_FRAMEWORK})
|
||||||
|
|
||||||
set(GLFW_PKG_DEPS "")
|
set(GLFW_PKG_DEPS "")
|
||||||
set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation")
|
set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -361,8 +383,8 @@ endif()
|
|||||||
configure_file(${GLFW_SOURCE_DIR}/docs/Doxyfile.in
|
configure_file(${GLFW_SOURCE_DIR}/docs/Doxyfile.in
|
||||||
${GLFW_BINARY_DIR}/docs/Doxyfile @ONLY)
|
${GLFW_BINARY_DIR}/docs/Doxyfile @ONLY)
|
||||||
|
|
||||||
configure_file(${GLFW_SOURCE_DIR}/src/config.h.in
|
configure_file(${GLFW_SOURCE_DIR}/src/glfw_config.h.in
|
||||||
${GLFW_BINARY_DIR}/src/config.h @ONLY)
|
${GLFW_BINARY_DIR}/src/glfw_config.h @ONLY)
|
||||||
|
|
||||||
configure_file(${GLFW_SOURCE_DIR}/src/glfwConfig.cmake.in
|
configure_file(${GLFW_SOURCE_DIR}/src/glfwConfig.cmake.in
|
||||||
${GLFW_BINARY_DIR}/src/glfwConfig.cmake @ONLY)
|
${GLFW_BINARY_DIR}/src/glfwConfig.cmake @ONLY)
|
||||||
@ -388,7 +410,7 @@ if (GLFW_BUILD_TESTS)
|
|||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DOXYGEN_FOUND)
|
if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
|
||||||
add_subdirectory(docs)
|
add_subdirectory(docs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
153
README.md
153
README.md
@ -6,112 +6,75 @@ GLFW is a free, Open Source, portable library for OpenGL and OpenGL ES
|
|||||||
application development. It provides a simple, platform-independent API for
|
application development. It provides a simple, platform-independent API for
|
||||||
creating windows and contexts, reading input, handling events, etc.
|
creating windows and contexts, reading input, handling events, etc.
|
||||||
|
|
||||||
Version 3.0.2 is *not yet described*. As this is a patch release, there are no
|
Version 3.0.4 is *not yet described*. As this is a patch release, there are no
|
||||||
API changes.
|
API changes.
|
||||||
|
|
||||||
If you are new to GLFW, you may find the
|
If you are new to GLFW, you may find the
|
||||||
[introductory tutorial](http://www.glfw.org/docs/3.0/quick.html) for GLFW
|
[introductory tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW
|
||||||
3 useful. If you have used GLFW 2 in the past, there is a
|
3 useful. If you have used GLFW 2 in the past, there is a
|
||||||
[transition guide](http://www.glfw.org/docs/3.0/moving.html) for moving to the
|
[transition guide](http://www.glfw.org/docs/latest/moving.html) for moving to
|
||||||
GLFW 3 API.
|
the GLFW 3 API.
|
||||||
|
|
||||||
|
|
||||||
## Compiling GLFW
|
## Compiling GLFW
|
||||||
|
|
||||||
To compile GLFW and the accompanying example programs, you will need the
|
See the [Compiling GLFW](http://www.glfw.org/docs/latest/compile.html) guide in
|
||||||
[CMake](http://www.cmake.org/) build system.
|
the GLFW documentation.
|
||||||
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
|
|
||||||
#### X11 dependencies
|
|
||||||
|
|
||||||
To compile GLFW for X11 and GLX, you need to have the X and OpenGL header
|
|
||||||
packages installed. For example, on Ubuntu and other distributions based on
|
|
||||||
Debian GNU/Linux, you need to install the `xorg-dev` and `libglu1-mesa-dev`
|
|
||||||
packages. Note that using header files from Mesa *will not* tie your binary to
|
|
||||||
the Mesa implementation of OpenGL.
|
|
||||||
|
|
||||||
|
|
||||||
### CMake options
|
|
||||||
|
|
||||||
There are a number of CMake build options for GLFW, although not all are
|
|
||||||
available on all supported platforms. Some of these are de facto standards
|
|
||||||
among CMake users and so have no `GLFW_` prefix.
|
|
||||||
|
|
||||||
|
|
||||||
#### Shared options
|
|
||||||
|
|
||||||
`BUILD_SHARED_LIBS` determines whether GLFW is built as a static
|
|
||||||
library or as a DLL / shared library / dynamic library.
|
|
||||||
|
|
||||||
`LIB_SUFFIX` affects where the GLFW shared /dynamic library is
|
|
||||||
installed. If it is empty, it is installed to `$PREFIX/lib`. If it is set to
|
|
||||||
`64`, it is installed to `$PREFIX/lib64`.
|
|
||||||
|
|
||||||
`GLFW_BUILD_EXAMPLES` determines whether the GLFW examples are built
|
|
||||||
along with the library.
|
|
||||||
|
|
||||||
`GLFW_BUILD_TESTS` determines whether the GLFW test programs are
|
|
||||||
built along with the library.
|
|
||||||
|
|
||||||
|
|
||||||
#### Mac OS X specific options
|
|
||||||
|
|
||||||
`GLFW_USE_CHDIR` determines whether `glfwInit` changes the current
|
|
||||||
directory of bundled applications to the `Contents/Resources` directory.
|
|
||||||
|
|
||||||
`GLFW_USE_MENUBAR` determines whether the first call to
|
|
||||||
`glfwCreateWindow` sets up a minimal menu bar.
|
|
||||||
|
|
||||||
`GLFW_BUILD_UNIVERSAL` determines whether to build Universal Binaries.
|
|
||||||
|
|
||||||
|
|
||||||
#### Windows specific options
|
|
||||||
|
|
||||||
`USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the
|
|
||||||
static library version of the Visual C++ runtime library.
|
|
||||||
|
|
||||||
|
|
||||||
#### EGL specific options
|
|
||||||
|
|
||||||
`GLFW_USE_EGL` determines whether to use EGL instead of the platform-specific
|
|
||||||
context creation API. Note that EGL is not yet provided on all supported
|
|
||||||
platforms.
|
|
||||||
|
|
||||||
`GLFW_CLIENT_LIBRARY` determines which client API library to use. If set to
|
|
||||||
`opengl` the OpenGL library is used, if set to `glesv1` for the OpenGL ES 1.x
|
|
||||||
library is used, or if set to `glesv2` the OpenGL ES 2.0 library is used. The
|
|
||||||
selected library and its header files must be present on the system for this to
|
|
||||||
work.
|
|
||||||
|
|
||||||
|
|
||||||
## Installing GLFW
|
|
||||||
|
|
||||||
A rudimentary installation target is provided for all supported platforms via
|
|
||||||
CMake.
|
|
||||||
|
|
||||||
|
|
||||||
## Using GLFW
|
## Using GLFW
|
||||||
|
|
||||||
See the [GLFW 3.0 documentation](http://www.glfw.org/docs/3.0/).
|
See the
|
||||||
|
[Building programs that use GLFW](http://www.glfw.org/docs/latest/build.html)
|
||||||
|
guide in the GLFW documentation.
|
||||||
|
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
- Bugfix: The `-Wall` flag was not used with Clang and other GCC compatibles
|
- Added the `GLFW_BUILD_DOCS` CMake option for controlling whether the
|
||||||
- Bugfix: The default for `GLFW_ALPHA_BITS` was set to zero
|
documentation is built
|
||||||
- [Win32] Bugfix: The clipboard string was not freed on terminate
|
- Added the `_GLFW_USE_CONFIG_H` configuration macro for controlling whether to
|
||||||
- [Win32] Bugfix: Entry points for OpenGL 1.0 and 1.1 functions were not
|
include the configuration header
|
||||||
returned by `glfwGetProcAddress`
|
- Moved version number macro to `internal.h` for easier manual compilation
|
||||||
- [Win32] Bugfix: The user32 and dwmapi module handles were not freed on
|
- Renamed configuration header to `glfw_config.h` to avoid conflicts
|
||||||
library termination
|
- Bugfix: The `glfw3.pc` file did not respect the `LIB_SUFFIX` CMake option
|
||||||
- [Cocoa] Bugfix: The clipboard string was not freed on terminate
|
- Bugfix: The `joysticks` test would segfault if a controller had no axes
|
||||||
- [Cocoa] Bugfix: Selectors were used that are not declared by the 10.6 SDK
|
- [Win32] Bugfix: Removed joystick axis value negation left over from GLFW 2
|
||||||
- [X11] Bugfix: Override-redirect windows were resized to the desired instead
|
- [Win32] Bugfix: Restoring windows using the Win+D hot key did not trigger the
|
||||||
of the actual resolution of the selected video mode
|
focus callback
|
||||||
- [X11] Bugfix: Screensaver override for full screen windows had a possible
|
- [Win32] Bugfix: The disabled cursor mode clip rectangle was updated for
|
||||||
race condition
|
unfocused windows
|
||||||
|
- [Win32] Bugfix: Cursor was not properly re-centered over odd-sized windows
|
||||||
|
- [Win32] Bugfix: Negative window positions were reported incorrectly
|
||||||
|
- [Cocoa] Added dependency on CoreVideo framework for refresh rate retrieval
|
||||||
|
- [Cocoa] Enabled Lion full screen for resizable windowed mode windows
|
||||||
|
- [Cocoa] Moved to Cocoa API for application transformation and activation
|
||||||
|
- [Cocoa] Bugfix: The `GLFW_KEY_GRAVE_ACCENT` key was reported as
|
||||||
|
`GLFW_KEY_WORLD_1` and vice versa
|
||||||
|
- [Cocoa] Bugfix: The `GLFW_KEY_F13` key was reported as
|
||||||
|
`GLFW_KEY_PRINT_SCREEN`
|
||||||
|
- [Cocoa] Bugfix: Implicit conversion from `NSUInteger` to int caused warnings
|
||||||
|
with Xcode 5
|
||||||
|
- [Cocoa] Bugfix: Use of undeclared selectors with `@selector` caused warnings
|
||||||
|
with Xcode 5
|
||||||
|
- [Cocoa] Bugfix: The cursor remained visible if moved onto client area after
|
||||||
|
having been set to hidden outside it
|
||||||
|
- [Cocoa] Bugfix: The refresh rate was zero for all modes of certain monitors
|
||||||
|
- [Cocoa] Bugfix: The `install_name` field of the dynamic library was not set
|
||||||
|
- [Cocoa] Bugfix: Full screen windows were never reported as having focus
|
||||||
|
- [Cocoa] Bugfix: A superfluous I/O flag test prevented video modes from being
|
||||||
|
listed for Thunderbolt monitor
|
||||||
|
- [Cocoa] Bugfix: Retrieving the name of some external displays caused segfault
|
||||||
|
- [Cocoa] Bugfix: The 10.9 SDK defines `GLintptrARB` and `GLsizeiptrARB`
|
||||||
|
differently from the Khronos `glext.h`
|
||||||
|
- [Cocoa] Bugfix: Creating hidden windows would steal application focus
|
||||||
|
- [Cocoa] Bugfix: Controllers were reported as having zero buttons and axes
|
||||||
|
- [Cocoa] Bugfix: Removed joystick axis value negation left over from GLFW 2
|
||||||
|
- [X11] Added setting of the `WM_CLASS` property to the initial window title
|
||||||
|
- [X11] Added support for `_NET_WM_BYPASS_COMPOSITOR`
|
||||||
|
- [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2
|
||||||
|
- [X11] Bugfix: The position of hidden windows was ignored by Metacity
|
||||||
|
and Compiz
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
@ -141,13 +104,16 @@ skills.
|
|||||||
|
|
||||||
- Bobyshev Alexander
|
- Bobyshev Alexander
|
||||||
- artblanc
|
- artblanc
|
||||||
|
- arturo
|
||||||
- Matt Arsenault
|
- Matt Arsenault
|
||||||
- Keith Bauer
|
- Keith Bauer
|
||||||
- John Bartholomew
|
- John Bartholomew
|
||||||
- Niklas Behrens
|
- Niklas Behrens
|
||||||
- Niklas Bergström
|
- Niklas Bergström
|
||||||
|
- Doug Binks
|
||||||
- blanco
|
- blanco
|
||||||
- Lambert Clara
|
- Lambert Clara
|
||||||
|
- Andrew Corrigan
|
||||||
- Noel Cower
|
- Noel Cower
|
||||||
- Jarrod Davis
|
- Jarrod Davis
|
||||||
- Olivier Delannoy
|
- Olivier Delannoy
|
||||||
@ -178,13 +144,18 @@ skills.
|
|||||||
- Marcel Metz
|
- Marcel Metz
|
||||||
- Kenneth Miller
|
- Kenneth Miller
|
||||||
- Bruce Mitchener
|
- Bruce Mitchener
|
||||||
|
- Jack Moffitt
|
||||||
- Jeff Molofee
|
- Jeff Molofee
|
||||||
- Jon Morton
|
- Jon Morton
|
||||||
|
- Pierre Moulon
|
||||||
- Julian Møller
|
- Julian Møller
|
||||||
|
- Kamil Nowakowski
|
||||||
- Ozzy
|
- Ozzy
|
||||||
|
- Andri Pálsson
|
||||||
- Peoro
|
- Peoro
|
||||||
- Braden Pellett
|
- Braden Pellett
|
||||||
- Arturo J. Pérez
|
- Arturo J. Pérez
|
||||||
|
- Pieroman
|
||||||
- Jorge Rodriguez
|
- Jorge Rodriguez
|
||||||
- Ed Ropple
|
- Ed Ropple
|
||||||
- Riku Salminen
|
- Riku Salminen
|
||||||
@ -192,6 +163,7 @@ skills.
|
|||||||
- Matt Sealey
|
- Matt Sealey
|
||||||
- SephiRok
|
- SephiRok
|
||||||
- Steve Sexton
|
- Steve Sexton
|
||||||
|
- Systemcluster
|
||||||
- Dmitri Shuralyov
|
- Dmitri Shuralyov
|
||||||
- Daniel Skorupski
|
- Daniel Skorupski
|
||||||
- Bradley Smith
|
- Bradley Smith
|
||||||
@ -202,6 +174,7 @@ skills.
|
|||||||
- TTK-Bandit
|
- TTK-Bandit
|
||||||
- Sergey Tikhomirov
|
- Sergey Tikhomirov
|
||||||
- Samuli Tuomola
|
- Samuli Tuomola
|
||||||
|
- urraka
|
||||||
- Jari Vetoniemi
|
- Jari Vetoniemi
|
||||||
- Simon Voordouw
|
- Simon Voordouw
|
||||||
- Torsten Walluhn
|
- Torsten Walluhn
|
||||||
|
20000
deps/GL/glext.h
vendored
20000
deps/GL/glext.h
vendored
File diff suppressed because it is too large
Load Diff
1277
deps/GL/glxext.h
vendored
1277
deps/GL/glxext.h
vendored
File diff suppressed because it is too large
Load Diff
1212
deps/GL/wglext.h
vendored
1212
deps/GL/wglext.h
vendored
File diff suppressed because it is too large
Load Diff
@ -659,6 +659,7 @@ INPUT = @GLFW_INTERNAL_DOCS@ \
|
|||||||
@GLFW_SOURCE_DIR@/docs/news.dox \
|
@GLFW_SOURCE_DIR@/docs/news.dox \
|
||||||
@GLFW_SOURCE_DIR@/docs/quick.dox \
|
@GLFW_SOURCE_DIR@/docs/quick.dox \
|
||||||
@GLFW_SOURCE_DIR@/docs/moving.dox \
|
@GLFW_SOURCE_DIR@/docs/moving.dox \
|
||||||
|
@GLFW_SOURCE_DIR@/docs/compile.dox \
|
||||||
@GLFW_SOURCE_DIR@/docs/build.dox \
|
@GLFW_SOURCE_DIR@/docs/build.dox \
|
||||||
@GLFW_SOURCE_DIR@/docs/context.dox \
|
@GLFW_SOURCE_DIR@/docs/context.dox \
|
||||||
@GLFW_SOURCE_DIR@/docs/monitor.dox \
|
@GLFW_SOURCE_DIR@/docs/monitor.dox \
|
||||||
@ -899,13 +900,13 @@ HTML_FILE_EXTENSION = .html
|
|||||||
# have to redo this when upgrading to a newer version of doxygen or when
|
# have to redo this when upgrading to a newer version of doxygen or when
|
||||||
# changing the value of configuration settings such as GENERATE_TREEVIEW!
|
# changing the value of configuration settings such as GENERATE_TREEVIEW!
|
||||||
|
|
||||||
HTML_HEADER =
|
HTML_HEADER = @GLFW_SOURCE_DIR@/docs/header.html
|
||||||
|
|
||||||
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
|
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
|
||||||
# each generated HTML page. If it is left blank doxygen will generate a
|
# each generated HTML page. If it is left blank doxygen will generate a
|
||||||
# standard footer.
|
# standard footer.
|
||||||
|
|
||||||
HTML_FOOTER =
|
HTML_FOOTER = @GLFW_SOURCE_DIR@/docs/footer.html
|
||||||
|
|
||||||
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
|
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
|
||||||
# style sheet that is used by each HTML page. It can be used to
|
# style sheet that is used by each HTML page. It can be used to
|
||||||
@ -924,7 +925,7 @@ HTML_STYLESHEET =
|
|||||||
# robust against future updates. Doxygen will copy the style sheet file to
|
# robust against future updates. Doxygen will copy the style sheet file to
|
||||||
# the output directory.
|
# the output directory.
|
||||||
|
|
||||||
HTML_EXTRA_STYLESHEET =
|
HTML_EXTRA_STYLESHEET = @GLFW_SOURCE_DIR@/docs/extra.css
|
||||||
|
|
||||||
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
||||||
# other source files which should be copied to the HTML output directory. Note
|
# other source files which should be copied to the HTML output directory. Note
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
/*!
|
/*!
|
||||||
|
|
||||||
@page build Building programs using GLFW
|
@page build Building programs that use GLFW
|
||||||
|
|
||||||
@tableofcontents
|
@tableofcontents
|
||||||
|
|
||||||
This is about compiling and linking programs that use GLFW. For information on
|
This is about compiling and linking programs that use GLFW. For information on
|
||||||
how to *write* such programs, start with the [introductory tutorial](@ref quick).
|
how to write such programs, start with the [introductory tutorial](@ref quick).
|
||||||
|
For information on how to compile the GLFW library itself, see the @ref compile
|
||||||
|
guide.
|
||||||
|
|
||||||
|
|
||||||
@section build_include Including the GLFW header file
|
@section build_include Including the GLFW header file
|
||||||
@ -158,7 +160,7 @@ If you are using the static library version of GLFW, use the
|
|||||||
@subsection build_link_pkgconfig With pkg-config on OS X or other Unix
|
@subsection build_link_pkgconfig With pkg-config on OS X or other Unix
|
||||||
|
|
||||||
GLFW supports [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/),
|
GLFW supports [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/),
|
||||||
and `glfw3.pc` file is generated when the GLFW library is built and installed
|
and the `glfw3.pc` file is generated when the GLFW library is built and installed
|
||||||
along with it.
|
along with it.
|
||||||
|
|
||||||
A typical compile and link command-line when using the static may look like this:
|
A typical compile and link command-line when using the static may look like this:
|
||||||
@ -189,7 +191,7 @@ If you are using the dynamic library version of GLFW, simply add it to the
|
|||||||
project dependencies.
|
project dependencies.
|
||||||
|
|
||||||
If you are using the static library version of GLFW, add it and the Cocoa,
|
If you are using the static library version of GLFW, add it and the Cocoa,
|
||||||
OpenGL and IOKit frameworks to the project as dependencies.
|
OpenGL, IOKit and CoreVideo frameworks to the project as dependencies.
|
||||||
|
|
||||||
|
|
||||||
@subsection build_link_osx With command-line on OS X
|
@subsection build_link_osx With command-line on OS X
|
||||||
@ -198,7 +200,7 @@ If you do not wish to use pkg-config, you need to add the required frameworks
|
|||||||
and libraries to your command-line using the `-l` and `-framework` switches,
|
and libraries to your command-line using the `-l` and `-framework` switches,
|
||||||
i.e.:
|
i.e.:
|
||||||
|
|
||||||
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit
|
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
|
||||||
|
|
||||||
Note that you do not add the `.framework` extension to a framework when adding
|
Note that you do not add the `.framework` extension to a framework when adding
|
||||||
it from the command-line.
|
it from the command-line.
|
||||||
@ -206,6 +208,6 @@ it from the command-line.
|
|||||||
The OpenGL framework contains both the OpenGL and GLU APIs, so there is nothing
|
The OpenGL framework contains both the OpenGL and GLU APIs, so there is nothing
|
||||||
special to do when using GLU. Also note that even though your machine may have
|
special to do when using GLU. Also note that even though your machine may have
|
||||||
`libGL`-style OpenGL libraries, they are for use with the X Window System and
|
`libGL`-style OpenGL libraries, they are for use with the X Window System and
|
||||||
will *not* work with the Mac OS X native version of GLFW.
|
will *not* work with the OS X native version of GLFW.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -112,19 +112,21 @@ context profiles. Where this extension is unavailable, setting the
|
|||||||
`GLFW_OPENGL_PROFILE` hint to anything but zero will cause @ref glfwCreateWindow
|
`GLFW_OPENGL_PROFILE` hint to anything but zero will cause @ref glfwCreateWindow
|
||||||
to fail.
|
to fail.
|
||||||
|
|
||||||
@section cmopat_osx OpenGL 3.2 on Mac OS X
|
@section compat_osx OpenGL 3.2 and later on OS X
|
||||||
|
|
||||||
Support for OpenGL 3.0 and above was introduced with Mac OS X 10.7, and even
|
Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then
|
||||||
then only forward-compatible OpenGL 3.2 core profile contexts are supported.
|
only forward-compatible, core profile contexts are supported. Support for
|
||||||
There is also still no mechanism for requesting debug contexts. Versions of
|
OpenGL 4.1 was introduced with OS X 10.9, also limited to forward-compatible,
|
||||||
Mac OS X earlier than 10.7 support at most OpenGL version 2.1.
|
core profile contexts. There is also still no mechanism for requesting debug
|
||||||
|
contexts. Versions of Mac OS X earlier than 10.7 support at most OpenGL
|
||||||
|
version 2.1.
|
||||||
|
|
||||||
Because of this, on Mac OS X 10.7, the `GLFW_CONTEXT_VERSION_MAJOR` and
|
Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and
|
||||||
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 3.2, the
|
`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if
|
||||||
`GLFW_OPENGL_FORWARD_COMPAT` is required for creating OpenGL 3.2 contexts, the
|
given version 3.0 or 3.1, the `GLFW_OPENGL_FORWARD_COMPAT` is required for
|
||||||
`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored and setting the
|
creating contexts for OpenGL 3.2 and later, the `GLFW_OPENGL_DEBUG_CONTEXT` hint
|
||||||
`GLFW_OPENGL_PROFILE` hint to anything except `GLFW_OPENGL_CORE_PROFILE` will
|
is ignored and setting the `GLFW_OPENGL_PROFILE` hint to anything except
|
||||||
cause @ref glfwCreateWindow to fail.
|
`GLFW_OPENGL_CORE_PROFILE` will cause @ref glfwCreateWindow to fail.
|
||||||
|
|
||||||
Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and
|
Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and
|
||||||
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, the
|
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, the
|
||||||
|
261
docs/compile.dox
Normal file
261
docs/compile.dox
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
/*!
|
||||||
|
|
||||||
|
@page compile Compiling GLFW
|
||||||
|
|
||||||
|
@tableofcontents
|
||||||
|
|
||||||
|
This is about compiling the GLFW library itself. For information on how to
|
||||||
|
build programs that use GLFW, see the @ref build guide.
|
||||||
|
|
||||||
|
|
||||||
|
@section compile_deps Dependencies
|
||||||
|
|
||||||
|
To compile GLFW and the accompanying example programs, you will need **CMake**,
|
||||||
|
which will generate the project files or makefiles for your particular
|
||||||
|
development environment. If you are on a Unix-like system such as Linux or
|
||||||
|
FreeBSD or have a package system like Fink, MacPorts, Cygwin or Homebrew, you
|
||||||
|
can simply install its CMake package. If not, you can get installers for
|
||||||
|
Windows and OS X from the [CMake website](http://www.cmake.org/).
|
||||||
|
|
||||||
|
Additional dependencies are listed below.
|
||||||
|
|
||||||
|
If you wish to compile GLFW without CMake, see @ref compile_manual.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_deps_msvc Dependencies using Visual C++ on Windows
|
||||||
|
|
||||||
|
The Microsoft Platform SDK that is installed along with Visual C++ contains all
|
||||||
|
the necessary headers, link libraries and tools except for CMake.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_deps_mingw Dependencies with MinGW or MinGW-w64 on Windows
|
||||||
|
|
||||||
|
Both the MinGW and the MinGW-w64 packages contain all the necessary headers,
|
||||||
|
link libraries and tools except for CMake.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_deps_mingw_cross Dependencies using MinGW or MinGW-w64 cross-compilation
|
||||||
|
|
||||||
|
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
|
||||||
|
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
|
||||||
|
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
|
||||||
|
like Ubuntu have the `mingw-w64` package for both.
|
||||||
|
|
||||||
|
GLFW has CMake toolchain files in the `CMake/` directory that allow for easy
|
||||||
|
cross-compilation of Windows binaries. To use these files you need to add a
|
||||||
|
special parameter when generating the project files or makefiles:
|
||||||
|
|
||||||
|
cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> .
|
||||||
|
|
||||||
|
The exact toolchain file to use depends on the prefix used by the MinGW or
|
||||||
|
MinGW-w64 binaries on your system. You can usually see this in the /usr
|
||||||
|
directory. For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages
|
||||||
|
have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct
|
||||||
|
invocation would be:
|
||||||
|
|
||||||
|
cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .
|
||||||
|
|
||||||
|
For more details see the article
|
||||||
|
[CMake Cross Compiling](http://www.paraview.org/Wiki/CMake_Cross_Compiling) on
|
||||||
|
the CMake wiki.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_deps_xcode Dependencies using Xcode on OS X
|
||||||
|
|
||||||
|
Xcode contains all necessary tools except for CMake. The necessary headers and
|
||||||
|
libraries are included in the core OS frameworks. Xcode can be downloaded from
|
||||||
|
the Mac App Store or from the ADC Member Center.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_deps_x11 Dependencies using Linux and X11
|
||||||
|
|
||||||
|
To compile GLFW for X11, you need to have the X11 and OpenGL header packages
|
||||||
|
installed, as well as the basic development tools like GCC and make. For
|
||||||
|
example, on Ubuntu and other distributions based on Debian GNU/Linux, you need
|
||||||
|
to install the `xorg-dev` and `libglu1-mesa-dev` packages. The former pulls in
|
||||||
|
all X.org header packages and the latter pulls in the Mesa OpenGL and GLU
|
||||||
|
packages. GLFW itself doesn't need or use GLU, but some of the examples do.
|
||||||
|
Note that using header files and libraries from Mesa during compilation *will
|
||||||
|
not* tie your binaries to the Mesa implementation of OpenGL.
|
||||||
|
|
||||||
|
|
||||||
|
@section compile_cmake Generating files with CMake
|
||||||
|
|
||||||
|
Once you have all necessary dependencies it is time to generate the project
|
||||||
|
files or makefiles for your development environment. CMake needs to know two
|
||||||
|
paths for this: the path to the *root* directory of the GLFW source tree (i.e.
|
||||||
|
*not* the `src` subdirectory) and the target path for the generated files and
|
||||||
|
compiled binaries. If these are the same, it is called an in-tree build,
|
||||||
|
otherwise it is called an out-of-tree build.
|
||||||
|
|
||||||
|
One of several advantages of out-of-tree builds is that you can generate files
|
||||||
|
and compile for different development environments using a single source tree.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_cmake_cli Generating files with the CMake command-line tool
|
||||||
|
|
||||||
|
To make an in-tree build, enter the *root* directory of the GLFW source tree
|
||||||
|
(i.e. *not* the `src` subdirectory) and run CMake. The current directory is
|
||||||
|
used as target path, while the path provided as an argument is used to find the
|
||||||
|
source tree.
|
||||||
|
|
||||||
|
cd <glfw-root-dir>
|
||||||
|
cmake .
|
||||||
|
|
||||||
|
To make an out-of-tree build, make another directory, enter it and run CMake
|
||||||
|
with the (relative or absolute) path to the root of the source tree as an
|
||||||
|
argument.
|
||||||
|
|
||||||
|
cd <glfw-root-dir>
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_cmake_gui Generating files with the CMake GUI
|
||||||
|
|
||||||
|
If you are using the GUI version, choose the root of the GLFW source tree as
|
||||||
|
source location and the same directory or another, empty directory as the
|
||||||
|
destination for binaries. Choose *Configure*, change any options you wish to,
|
||||||
|
*Configure* again to let the changes take effect and then *Generate*.
|
||||||
|
|
||||||
|
|
||||||
|
@section compile_options CMake options
|
||||||
|
|
||||||
|
The CMake files for GLFW provide a number of options, although not all are
|
||||||
|
available on all supported platforms. Some of these are de facto standards
|
||||||
|
among CMake users and so have no `GLFW_` prefix.
|
||||||
|
|
||||||
|
If you are using the GUI version of CMake, these are listed and can be changed
|
||||||
|
from there. If you are using the command-line version, use the `ccmake` tool.
|
||||||
|
Some package systems like Ubuntu and other distributions based on Debian
|
||||||
|
GNU/Linux have this tool in a separate `cmake-curses-gui` package.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_options_shared Shared CMake options
|
||||||
|
|
||||||
|
`BUILD_SHARED_LIBS` determines whether GLFW is built as a static
|
||||||
|
library or as a DLL / shared library / dynamic library.
|
||||||
|
|
||||||
|
`LIB_SUFFIX` affects where the GLFW shared /dynamic library is installed. If it
|
||||||
|
is empty, it is installed to `${CMAKE_INSTALL_PREFIX}/lib`. If it is set to
|
||||||
|
`64`, it is installed to `${CMAKE_INSTALL_PREFIX}/lib64`.
|
||||||
|
|
||||||
|
`GLFW_CLIENT_LIBRARY` determines which client API library to use. If set to
|
||||||
|
`opengl` the OpenGL library is used, if set to `glesv1` for the OpenGL ES 1.x
|
||||||
|
library is used, or if set to `glesv2` the OpenGL ES 2.0 library is used. The
|
||||||
|
selected library and its header files must be present on the system for this to
|
||||||
|
work.
|
||||||
|
|
||||||
|
`GLFW_BUILD_EXAMPLES` determines whether the GLFW examples are built
|
||||||
|
along with the library.
|
||||||
|
|
||||||
|
`GLFW_BUILD_TESTS` determines whether the GLFW test programs are
|
||||||
|
built along with the library.
|
||||||
|
|
||||||
|
`GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with
|
||||||
|
the library.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_options_osx OS X specific CMake options
|
||||||
|
|
||||||
|
`GLFW_USE_CHDIR` determines whether `glfwInit` changes the current
|
||||||
|
directory of bundled applications to the `Contents/Resources` directory.
|
||||||
|
|
||||||
|
`GLFW_USE_MENUBAR` determines whether the first call to
|
||||||
|
`glfwCreateWindow` sets up a minimal menu bar.
|
||||||
|
|
||||||
|
`GLFW_BUILD_UNIVERSAL` determines whether to build Universal Binaries.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_options_win32 Windows specific CMake options
|
||||||
|
|
||||||
|
`USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the
|
||||||
|
static library version of the Visual C++ runtime library. If set to `ON`, the
|
||||||
|
DLL version of the Visual C++ library is used. It is recommended to set this to
|
||||||
|
`ON`, as this keeps the executable smaller and benefits from security and bug
|
||||||
|
fix updates of the Visual C++ runtime.
|
||||||
|
|
||||||
|
`GLFW_USE_DWM_SWAP_INTERVAL` determines whether the swap interval is set even
|
||||||
|
when DWM compositing is enabled. If this is `ON`, the swap interval is set even
|
||||||
|
if DWM is enabled. It is recommended to set this to `OFF`, as doing otherwise
|
||||||
|
can lead to severe jitter.
|
||||||
|
|
||||||
|
`GLFW_USE_OPTIMUS_HPG` determines whether to export the `NvOptimusEnablement`
|
||||||
|
symbol, which forces the use of the high-performance GPU on nVidia Optimus
|
||||||
|
systems.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_options_egl EGL specific CMake options
|
||||||
|
|
||||||
|
`GLFW_USE_EGL` determines whether to use EGL instead of the platform-specific
|
||||||
|
context creation API. Note that EGL is not yet provided on all supported
|
||||||
|
platforms.
|
||||||
|
|
||||||
|
|
||||||
|
@section compile_manual Compiling GLFW manually
|
||||||
|
|
||||||
|
If you wish to compile GLFW without its CMake build environment then you will
|
||||||
|
have to do at least some of the platform detection yourself. GLFW needs
|
||||||
|
a number of configuration macros to be defined in order to know what it's being
|
||||||
|
compiled for and has many optional, platform-specific ones for various features.
|
||||||
|
|
||||||
|
When building with CMake, the `glfw_config.h` configuration header is generated
|
||||||
|
based on the current platform and CMake options. The GLFW CMake environment
|
||||||
|
defines `_GLFW_USE_CONFIG_H`, which causes this header to be included by
|
||||||
|
`internal.h`. Without this macro, GLFW will expect the necessary configuration
|
||||||
|
macros to be defined on the command-line.
|
||||||
|
|
||||||
|
Three macros *must* be defined when compiling GLFW: one for selecting the window
|
||||||
|
creation API, one selecting the context creation API and one client library.
|
||||||
|
Exactly one of each kind must be defined for GLFW to compile and link.
|
||||||
|
|
||||||
|
The window creation API is used to create windows, handle input, monitors, gamma
|
||||||
|
ramps and clipboard. The options are:
|
||||||
|
|
||||||
|
- `_GLFW_COCOA` to use the Cocoa frameworks
|
||||||
|
- `_GLFW_WIN32` to use the Win32 API
|
||||||
|
- `_GLFW_X11` to use the X Window System
|
||||||
|
|
||||||
|
The context creation API is used to enumerate pixel formats / framebuffer
|
||||||
|
configurations and to create contexts. The options are:
|
||||||
|
|
||||||
|
- `_GLFW_NSGL` to use the Cocoa OpenGL framework
|
||||||
|
- `_GLFW_WGL` to use the Win32 WGL API
|
||||||
|
- `_GLFW_GLX` to use the X11 GLX API
|
||||||
|
- `_GLFW_EGL` to use the EGL API (experimental)
|
||||||
|
|
||||||
|
The client library is the one providing the OpenGL or OpenGL ES API, which is
|
||||||
|
used by GLFW to probe the created context. This is not the same thing as the
|
||||||
|
client API, as many desktop OpenGL client libraries now expose the OpenGL ES API
|
||||||
|
through extensions. The options are:
|
||||||
|
|
||||||
|
- `_GLFW_USE_OPENGL` for the desktop OpenGL (opengl32.dll, libGL.so or
|
||||||
|
OpenGL.framework)
|
||||||
|
- `_GLFW_USE_GLESV1` for OpenGL ES 1.x (experimental)
|
||||||
|
- `_GLFW_USE_GLESV2` for OpenGL ES 2.x (experimental)
|
||||||
|
|
||||||
|
Note that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL,
|
||||||
|
as the other context creation APIs do not interface with OpenGL ES client
|
||||||
|
libraries.
|
||||||
|
|
||||||
|
If you are building GLFW as a shared library / dynamic library / DLL then you
|
||||||
|
must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it.
|
||||||
|
|
||||||
|
If you are using the X11 window creation API then you *must* also select an entry
|
||||||
|
point retrieval mechanism.
|
||||||
|
|
||||||
|
- `_GLFW_HAS_GLXGETPROCADDRESS` to use `glXGetProcAddress` (recommended)
|
||||||
|
- `_GLFW_HAS_GLXGETPROCADDRESSARB` to use `glXGetProcAddressARB` (legacy)
|
||||||
|
- `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use `glXGetProcAddressEXT` (legacy)
|
||||||
|
- `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` (fallback)
|
||||||
|
|
||||||
|
If you are using the Cocoa window creation API, the following options are
|
||||||
|
available:
|
||||||
|
|
||||||
|
- `_GLFW_USE_CHDIR` to `chdir` to the `Resources` subdirectory of the
|
||||||
|
application bundle during @ref glfwInit (recommended)
|
||||||
|
- `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window
|
||||||
|
is created (recommended)
|
||||||
|
|
||||||
|
*/
|
312
docs/extra.css
Normal file
312
docs/extra.css
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
html {
|
||||||
|
background-color:hsl(0,0%,95%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glfwheader {
|
||||||
|
font-size:16px;
|
||||||
|
height:64px;
|
||||||
|
max-width:920px;
|
||||||
|
margin:0em auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glfwheader a#glfwhome {
|
||||||
|
line-height:64px;
|
||||||
|
padding-right:48px;
|
||||||
|
float:left;
|
||||||
|
color:hsl(0,0%,40%);
|
||||||
|
font-size:2.5em;
|
||||||
|
background-image:url("http://www.glfw.org/css/arrow.png");
|
||||||
|
background-position:right top;
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glfwnavbar {
|
||||||
|
list-style-type:none;
|
||||||
|
margin-top:0px;
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glfwnavbar li {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glfwnavbar a,.glfwnavbar a:visited {
|
||||||
|
line-height:64px;
|
||||||
|
margin-left:2em;
|
||||||
|
display:block;
|
||||||
|
color:hsl(0,0%,40%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glfwheader a#glfwhome,.glfwnavbar a,.glfwnavbar a:visited {
|
||||||
|
transition:all 0.35s ease 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#titlearea,address.footer {
|
||||||
|
color:hsl(0,0%,40%);
|
||||||
|
background-color:hsl(0,0%,95%);
|
||||||
|
border-bottom:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
address.footer {
|
||||||
|
text-align:center;
|
||||||
|
padding:2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#top {
|
||||||
|
background-color:hsl(0,0%,40%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div#navrow1,div#navrow2,div#navrow3,div#navrow4 {
|
||||||
|
background-color:hsl(0,0%,40%);
|
||||||
|
background-image:none;
|
||||||
|
max-width:920px;
|
||||||
|
margin:0em auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.tablist {
|
||||||
|
min-width:700px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablist a,.tablist a:hover,.tablist li,.tablist li.current a {
|
||||||
|
background-image:none;
|
||||||
|
text-shadow:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablist a,.tablist a:visited {
|
||||||
|
color:hsl(0,0%,95%);
|
||||||
|
text-shadow:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablist li.current a {
|
||||||
|
background:linear-gradient(to bottom,hsl(34,100%,60%) 0%,hsl(24,100%,50%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(24,100%,50%);
|
||||||
|
text-shadow:0px -1px 1px hsl(24,100%,35%);
|
||||||
|
color:hsl(0,0%,100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.contents {
|
||||||
|
min-height:590px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.contents,div.header {
|
||||||
|
max-width:920px;
|
||||||
|
margin:0em auto;
|
||||||
|
padding:0em 2em 2em 2em;
|
||||||
|
background-color:hsl(0,0%,100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.header {
|
||||||
|
background-image:none;
|
||||||
|
border-bottom:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.doxtable th,dl.reflist dt,div.levels {
|
||||||
|
background:linear-gradient(to bottom,hsl(34,100%,60%) 0%,hsl(24,100%,50%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(24,100%,50%);
|
||||||
|
text-shadow:0px -1px 1px hsl(24,100%,35%);
|
||||||
|
color:hsl(0,0%,100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.reflist dt a.el,div.levels span {
|
||||||
|
color:hsl(24,100%,50%);
|
||||||
|
padding:0.2em;
|
||||||
|
border-radius:4px;
|
||||||
|
background-color:hsl(24,100%,90%);
|
||||||
|
text-shadow:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.memproto,div.qindex,div.ah {
|
||||||
|
background:linear-gradient(to bottom,hsl(34,0%,95%) 0%,hsl(24,0%,90%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(24,0%,90%);
|
||||||
|
text-shadow:0px 1px 1px hsl(24,0%,100%);
|
||||||
|
color:hsl(0,0%,10%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.memproto a {
|
||||||
|
color:hsl(24,100%,50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.memproto td.paramname {
|
||||||
|
text-shadow:0px 1px 1px hsl(24,0%,100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.memproto,div.qindex,div.ah {
|
||||||
|
border:2px solid hsl(24,0%,90%);
|
||||||
|
border-radius:4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.memdoc {
|
||||||
|
background:none;
|
||||||
|
box-shadow:none;
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.paramname {
|
||||||
|
color:hsl(24,100%,25%);
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.reflist dt {
|
||||||
|
border:2px solid hsl(24,100%,50%);
|
||||||
|
border-top-left-radius:4px;
|
||||||
|
border-top-right-radius:4px;
|
||||||
|
border-bottom:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.reflist dd {
|
||||||
|
border:2px solid hsl(24,100%,50%);
|
||||||
|
border-bottom-right-radius:4px;
|
||||||
|
border-bottom-left-radius:4px;
|
||||||
|
border-top:none;
|
||||||
|
background:none;
|
||||||
|
box-shadow:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.doxtable {
|
||||||
|
border-collapse:inherit;
|
||||||
|
border-spacing:0px;
|
||||||
|
border:2px solid hsl(24,100%,50%);
|
||||||
|
border-radius:4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.doxtable td,table.doxtable th {
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.even,.directory tr.even,table.doxtable tr:nth-child(even) {
|
||||||
|
background-color:hsl(0,0%,95%);
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color:hsl(0,0%,30%);
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
|
||||||
|
color:hsl(0,0%,10%);
|
||||||
|
border-bottom:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a,a:hover,a:visited,a:visited:hover,a.el,a.el:visited,.glfwheader a#glfwhome:hover,.tablist a:hover {
|
||||||
|
color:hsl(24,100%,50%);
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mdescLeft,.mdescRight,.memItemLeft,.memItemRight {
|
||||||
|
background-color:hsl(0,0%,95%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.directory {
|
||||||
|
border-collapse:inherit;
|
||||||
|
border-spacing:0px;
|
||||||
|
border:2px solid hsl(24,100%,50%);
|
||||||
|
border-radius:4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.directory .levels span {
|
||||||
|
color:hsl(24,100%,50%);
|
||||||
|
padding:0.1em 0.5em;
|
||||||
|
margin:auto 0.25em;
|
||||||
|
border-radius:2px;
|
||||||
|
background-color:hsl(24,100%,90%);
|
||||||
|
text-shadow:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.memSeparator {
|
||||||
|
height:2px;
|
||||||
|
border:0px;
|
||||||
|
background:linear-gradient(to right,hsl(0,0%,95%) 0%,hsl(0,0%,85%) 50%,hsl(0,0%,95%) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.note,dl.pre,dl.post,dl.invariant {
|
||||||
|
background:linear-gradient(to bottom,hsl(103,80%,90%) 0%,hsl(103,80%,85%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(103,40%,80%);
|
||||||
|
color:hsl(103,80%,10%);
|
||||||
|
border:2px solid hsl(103,40%,75%);
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.warning,dl.attention {
|
||||||
|
background:linear-gradient(to bottom,hsl(34,80%,90%) 0%,hsl(34,80%,85%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(34,40%,80%);
|
||||||
|
color:hsl(34,80%,10%);
|
||||||
|
border:2px solid hsl(34,40%,75%);
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.deprecated,dl.bug {
|
||||||
|
background:linear-gradient(to bottom,hsl(333,80%,90%) 0%,hsl(333,80%,85%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(333,40%,80%);
|
||||||
|
color:hsl(333,80%,10%);
|
||||||
|
border:2px solid hsl(333,40%,75%);
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.todo,dl.test {
|
||||||
|
background:linear-gradient(to bottom,hsl(200,80%,90%) 0%,hsl(200,80%,85%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(200,40%,80%);
|
||||||
|
color:hsl(200,80%,10%);
|
||||||
|
border:2px solid hsl(200,40%,75%);
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test {
|
||||||
|
border-radius:4px;
|
||||||
|
padding:1em;
|
||||||
|
text-shadow:0px 1px 1px hsl(0,0%,100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toc {
|
||||||
|
background:linear-gradient(to bottom,hsl(34,0%,95%) 0%,hsl(24,0%,90%) 100%);
|
||||||
|
box-shadow:inset 0px 0px 32px hsl(24,0%,90%);
|
||||||
|
text-shadow:0px 1px 1px hsl(24,0%,100%);
|
||||||
|
color:hsl(0,0%,10%);
|
||||||
|
border:2px solid hsl(24,0%,90%);
|
||||||
|
border-radius:4px;
|
||||||
|
float:none;
|
||||||
|
width:auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toc h3 {
|
||||||
|
font-size:1.17em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toc ul {
|
||||||
|
padding-left:1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toc li {
|
||||||
|
background:none;
|
||||||
|
font-size:1em;
|
||||||
|
padding-left:0em;
|
||||||
|
list-style-type:disc;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.ah {
|
||||||
|
background-image:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.fragment,pre.fragment {
|
||||||
|
background-color:hsl(0,0%,20%);
|
||||||
|
border-radius:4px;
|
||||||
|
border-width:0px;
|
||||||
|
padding:0.5em 2em;
|
||||||
|
overflow:auto;
|
||||||
|
border-left:4px solid hsl(0,0%,80%);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.line,pre.fragment {
|
||||||
|
color:hsl(60,30%,96%);
|
||||||
|
}
|
||||||
|
|
||||||
|
a.code,a.code:visited,span.preprocessor,span.comment {
|
||||||
|
color:hsl(80,76%,53%);
|
||||||
|
}
|
||||||
|
|
||||||
|
span.keyword,span.keywordtype,span.keywordflow {
|
||||||
|
color:hsl(190,81%,67%);
|
||||||
|
}
|
||||||
|
|
||||||
|
span.stringliteral {
|
||||||
|
color:hsl(54,70%,68%);
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
background-color:hsl(0,0%,95%);
|
||||||
|
padding:0.1em;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
7
docs/footer.html
Normal file
7
docs/footer.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<address class="footer">
|
||||||
|
<p>
|
||||||
|
Last update on $date for $projectname $projectnumber
|
||||||
|
</p>
|
||||||
|
</address>
|
||||||
|
</body>
|
||||||
|
</html>
|
34
docs/header.html
Normal file
34
docs/header.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||||
|
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||||
|
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||||
|
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||||
|
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
||||||
|
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||||
|
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||||
|
$treeview
|
||||||
|
$search
|
||||||
|
$mathjax
|
||||||
|
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||||
|
$extrastylesheet
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||||
|
|
||||||
|
<!--BEGIN TITLEAREA-->
|
||||||
|
<div id="titlearea">
|
||||||
|
<div class="glfwheader">
|
||||||
|
<a href="http://www.glfw.org/" id="glfwhome">GLFW</a>
|
||||||
|
<ul class="glfwnavbar">
|
||||||
|
<li><a href="http://www.glfw.org/documentation.html">Documentation</a></li>
|
||||||
|
<li><a href="http://www.glfw.org/download.html">Download</a></li>
|
||||||
|
<li><a href="http://www.glfw.org/media.html">Media</a></li>
|
||||||
|
<li><a href="http://www.glfw.org/community.html">Community</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--END TITLEAREA-->
|
||||||
|
<!-- end header part -->
|
@ -105,8 +105,8 @@ Examples: `clearScrollOffsets`
|
|||||||
@section internals_config Configuration macros
|
@section internals_config Configuration macros
|
||||||
|
|
||||||
GLFW uses a number of configuration macros to select at compile time which
|
GLFW uses a number of configuration macros to select at compile time which
|
||||||
interfaces and code paths to use. They are defined in the config.h header file,
|
interfaces and code paths to use. They are defined in the glfw_config.h header file,
|
||||||
which is generated from the `config.h.in` file by CMake.
|
which is generated from the `glfw_config.h.in` file by CMake.
|
||||||
|
|
||||||
Configuration macros the same style as tokens in the public interface, except
|
Configuration macros the same style as tokens in the public interface, except
|
||||||
with a leading underscore.
|
with a leading underscore.
|
||||||
|
@ -11,7 +11,9 @@ existing applications and does not lay claim to the main loop.
|
|||||||
This is the documentation for version 3.0, which has [many new features](@ref news).
|
This is the documentation for version 3.0, which has [many new features](@ref news).
|
||||||
|
|
||||||
There is a [quick tutorial](@ref quick) for people new to GLFW, which shows how
|
There is a [quick tutorial](@ref quick) for people new to GLFW, which shows how
|
||||||
to write a small but complete program.
|
to write a small but complete program, and guides for
|
||||||
|
[compiling GLFW](@ref compile) and
|
||||||
|
[building programs that use GLFW](@ref build).
|
||||||
|
|
||||||
If you have used GLFW 2.x in the past, there is a
|
If you have used GLFW 2.x in the past, there is a
|
||||||
[transition guide](@ref moving) that explains what has changed and how to update
|
[transition guide](@ref moving) that explains what has changed and how to update
|
||||||
|
@ -125,6 +125,14 @@ or something else, are nowadays expected to be good desktop citizens and allow
|
|||||||
these hotkeys to function even when running in full screen mode.
|
these hotkeys to function even when running in full screen mode.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection moving_opened Window open parameter
|
||||||
|
|
||||||
|
The `GLFW_OPENED` window parameter has been removed. As long as the
|
||||||
|
[window object](@ref window_object) is around, the window is "open". To detect
|
||||||
|
when the user attempts to close the window, see @ref glfwWindowShouldClose and
|
||||||
|
the [close callback](@ref GLFWwindowclosefun).
|
||||||
|
|
||||||
|
|
||||||
@subsection moving_autopoll Automatic polling of events
|
@subsection moving_autopoll Automatic polling of events
|
||||||
|
|
||||||
GLFW 3 does not automatically poll for events on @ref glfwSwapBuffers, which
|
GLFW 3 does not automatically poll for events on @ref glfwSwapBuffers, which
|
||||||
@ -168,13 +176,24 @@ similar to that of GLFW 2.
|
|||||||
|
|
||||||
@subsection moving_window_close Window closing
|
@subsection moving_window_close Window closing
|
||||||
|
|
||||||
Window closing is now just an event like any other. GLFW 3 windows won't
|
Window closing initiated by the user is now just an event like any other.
|
||||||
disappear from underfoot even when no close callback is set; instead the
|
Unlike GLFW 2, windows and contexts created with GLFW 3 will not disappear from
|
||||||
window's close flag is set. You can query this flag using @ref
|
underfoot. Each window now has a close flag, which is set when the user
|
||||||
glfwWindowShouldClose, or capture close events by setting a close callback. The
|
attempts to close it. By default, nothing else happens and the window stays
|
||||||
close flag can be modified from any point in your program using @ref
|
open and visible. It is then up to you to either destroy the window, take some
|
||||||
|
other action or simply ignore the request. You can query the close flag at any
|
||||||
|
time with @ref glfwWindowShouldClose and set it at any time with @ref
|
||||||
glfwSetWindowShouldClose.
|
glfwSetWindowShouldClose.
|
||||||
|
|
||||||
|
The close callback no longer returns a value. Instead, it is called after the
|
||||||
|
close flag has been set so it can override its value, if it chooses to, before
|
||||||
|
event processing completes. You may however not call @ref glfwDestroyWindow
|
||||||
|
from the close callback (or any other window related callback).
|
||||||
|
|
||||||
|
GLFW itself never clears the close flag, allowing you to set it for other
|
||||||
|
reasons for the window to close as well, for example the user choosing Quit from
|
||||||
|
the main menu.
|
||||||
|
|
||||||
|
|
||||||
@subsection moving_context Explicit context management
|
@subsection moving_context Explicit context management
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ For more information on how to use CMake, see the
|
|||||||
[CMake manual](http://cmake.org/cmake/help/documentation.html).
|
[CMake manual](http://cmake.org/cmake/help/documentation.html).
|
||||||
|
|
||||||
|
|
||||||
@subsection new_30_multiwnd Multi-window support
|
@subsection news_30_multiwnd Multi-window support
|
||||||
|
|
||||||
GLFW now supports the creation of multiple windows, each with their own OpenGL
|
GLFW now supports the creation of multiple windows, each with their own OpenGL
|
||||||
or OpenGL ES context, and all window functions now take a window handle. Event
|
or OpenGL ES context, and all window functions now take a window handle. Event
|
||||||
@ -79,7 +79,7 @@ through CMake options.
|
|||||||
GLFW now supports high-DPI monitors on both Windows and OS X, giving windows full
|
GLFW now supports high-DPI monitors on both Windows and OS X, giving windows full
|
||||||
resolution framebuffers where other UI elements are scaled up. To achieve this,
|
resolution framebuffers where other UI elements are scaled up. To achieve this,
|
||||||
@ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have been
|
@ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have been
|
||||||
added. These work with pixels, while the rest of the GLFW API work with screen
|
added. These work with pixels, while the rest of the GLFW API works with screen
|
||||||
coordinates.
|
coordinates.
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,4 +302,7 @@ the screen, rendering a triangle and processing events until the user closes the
|
|||||||
window. It can be found in the source distribution as `examples/simple.c`, and
|
window. It can be found in the source distribution as `examples/simple.c`, and
|
||||||
is by default compiled along with all other examples when you build GLFW.
|
is by default compiled along with all other examples when you build GLFW.
|
||||||
|
|
||||||
|
To learn more about how to compile and link programs that use GLFW, see
|
||||||
|
@ref build.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +62,14 @@ Once this function is called, no more events will be delivered for that window
|
|||||||
and its handle becomes invalid.
|
and its handle becomes invalid.
|
||||||
|
|
||||||
|
|
||||||
|
@section window_userptr Window user pointer
|
||||||
|
|
||||||
|
Each window has a user pointer that can be set with @ref
|
||||||
|
glfwSetWindowUserPointer and fetched with @ref glfwGetWindowUserPointer. This
|
||||||
|
can be used for any purpose you need and will not modified by GLFW throughout
|
||||||
|
the life-time of the window.
|
||||||
|
|
||||||
|
|
||||||
@section window_hints Window creation hints
|
@section window_hints Window creation hints
|
||||||
|
|
||||||
There are a number of hints that can be set before the creation of a window and
|
There are a number of hints that can be set before the creation of a window and
|
||||||
@ -440,7 +448,9 @@ context is an OpenGL debug context, or `GL_FALSE` otherwise.
|
|||||||
The `GLFW_OPENGL_PROFILE` attribute indicates the OpenGL profile used by the
|
The `GLFW_OPENGL_PROFILE` attribute indicates the OpenGL profile used by the
|
||||||
context. This is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE`
|
context. This is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE`
|
||||||
if the context uses a known profile, or `GLFW_OPENGL_ANY_PROFILE` if the
|
if the context uses a known profile, or `GLFW_OPENGL_ANY_PROFILE` if the
|
||||||
OpenGL profile is unknown or the context is for another client API.
|
OpenGL profile is unknown or the context is for another client API. Note that
|
||||||
|
the returned profile may not match the profile bits of the context flags, as
|
||||||
|
GLFW will try other means of detecting the profile when no bits are set.
|
||||||
|
|
||||||
The `GLFW_CONTEXT_ROBUSTNESS` attribute indicates the robustness strategy
|
The `GLFW_CONTEXT_ROBUSTNESS` attribute indicates the robustness strategy
|
||||||
used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or
|
used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or
|
||||||
@ -477,8 +487,10 @@ zero can be useful for benchmarking purposes, when it is not desirable to
|
|||||||
measure the time it takes to wait for the vertical retrace. However, a swap
|
measure the time it takes to wait for the vertical retrace. However, a swap
|
||||||
interval of one lets you avoid tearing.
|
interval of one lets you avoid tearing.
|
||||||
|
|
||||||
Note that not all OpenGL implementations properly implement this function, in
|
Note that this may not work on all machines, as some drivers have
|
||||||
which case @ref glfwSwapInterval will have no effect. Some drivers also have
|
user-controlled settings that override any swap interval the application
|
||||||
user settings that override requests by GLFW.
|
requests. It is also by default disabled on Windows Vista and later when using
|
||||||
|
DWM (Aero), as using it there sometimes leads to severe jitter. You can
|
||||||
|
forcibly enable it for machines using DWM using @ref compile_options_win32.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -644,7 +644,7 @@ int main(int argc, char** argv)
|
|||||||
/* main loop */
|
/* main loop */
|
||||||
frame = 0;
|
frame = 0;
|
||||||
iter = 0;
|
iter = 0;
|
||||||
dt = last_update_time = glfwGetTime();
|
last_update_time = glfwGetTime();
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* GLFW - An OpenGL library
|
* GLFW 3.0 - www.glfw.org
|
||||||
* API version: 3.0
|
* A library for OpenGL, window and input
|
||||||
* WWW: http://www.glfw.org/
|
|
||||||
*------------------------------------------------------------------------
|
*------------------------------------------------------------------------
|
||||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
* Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
* Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -132,45 +131,12 @@ extern "C" {
|
|||||||
#define GLFW_CALLBACK_DEFINED
|
#define GLFW_CALLBACK_DEFINED
|
||||||
#endif /* CALLBACK */
|
#endif /* CALLBACK */
|
||||||
|
|
||||||
/* Most <GL/glu.h> variants on Windows need wchar_t */
|
/* Most GL/glu.h variants on Windows need wchar_t
|
||||||
#if defined(_WIN32)
|
* OpenGL/gl.h blocks the definition of ptrdiff_t by glext.h on OS X */
|
||||||
|
#if !defined(GLFW_INCLUDE_NONE)
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ---------------- GLFW related system specific defines ----------------- */
|
|
||||||
|
|
||||||
#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
|
|
||||||
#error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
|
|
||||||
|
|
||||||
/* We are building a Win32 DLL */
|
|
||||||
#define GLFWAPI __declspec(dllexport)
|
|
||||||
|
|
||||||
#elif defined(_WIN32) && defined(GLFW_DLL)
|
|
||||||
|
|
||||||
/* We are calling a Win32 DLL */
|
|
||||||
#if defined(__LCC__)
|
|
||||||
#define GLFWAPI extern
|
|
||||||
#else
|
|
||||||
#define GLFWAPI __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
|
|
||||||
|
|
||||||
#define GLFWAPI __attribute__((visibility("default")))
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* We are either building/calling a static lib or we are non-win32 */
|
|
||||||
#define GLFWAPI
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
|
|
||||||
|
|
||||||
/* Include the chosen client API headers.
|
/* Include the chosen client API headers.
|
||||||
*/
|
*/
|
||||||
#if defined(__APPLE_CC__)
|
#if defined(__APPLE_CC__)
|
||||||
@ -200,6 +166,41 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
|
||||||
|
/* GLFW_DLL is defined by users of GLFW when compiling programs that will link
|
||||||
|
* to the DLL 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 must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
|
||||||
|
|
||||||
|
/* We are building a Win32 DLL */
|
||||||
|
#define GLFWAPI __declspec(dllexport)
|
||||||
|
|
||||||
|
#elif defined(_WIN32) && defined(GLFW_DLL)
|
||||||
|
|
||||||
|
/* We are calling a Win32 DLL */
|
||||||
|
#if defined(__LCC__)
|
||||||
|
#define GLFWAPI extern
|
||||||
|
#else
|
||||||
|
#define GLFWAPI __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
|
||||||
|
|
||||||
|
#define GLFWAPI __attribute__((visibility("default")))
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* We are either building/calling a static lib or we are non-win32 */
|
||||||
|
#define GLFWAPI
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* GLFW API tokens
|
* GLFW API tokens
|
||||||
@ -226,7 +227,7 @@ extern "C" {
|
|||||||
* API changes.
|
* API changes.
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
#define GLFW_VERSION_REVISION 2
|
#define GLFW_VERSION_REVISION 4
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
/*! @name Key and button actions
|
/*! @name Key and button actions
|
||||||
@ -705,8 +706,8 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
|
|||||||
* This is the function signature for cursor position callback functions.
|
* This is the function signature for cursor position callback functions.
|
||||||
*
|
*
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] xpos The new x-coordinate of the cursor.
|
* @param[in] xpos The new x-coordinate, in screen coordinates, of the cursor.
|
||||||
* @param[in] ypos The new y-coordinate of the cursor.
|
* @param[in] ypos The new y-coordinate, in screen coordinates, of the cursor.
|
||||||
*
|
*
|
||||||
* @sa glfwSetCursorPosCallback
|
* @sa glfwSetCursorPosCallback
|
||||||
*
|
*
|
||||||
@ -764,7 +765,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
|
|||||||
* This is the function signature for Unicode character callback functions.
|
* This is the function signature for Unicode character callback functions.
|
||||||
*
|
*
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] character The Unicode code point of the character.
|
* @param[in] codepoint The Unicode code point of the character.
|
||||||
*
|
*
|
||||||
* @sa glfwSetCharCallback
|
* @sa glfwSetCharCallback
|
||||||
*
|
*
|
||||||
@ -805,7 +806,7 @@ typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
|
|||||||
*
|
*
|
||||||
* @ingroup monitor
|
* @ingroup monitor
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct GLFWvidmode
|
||||||
{
|
{
|
||||||
/*! The width, in screen coordinates, of the video mode.
|
/*! The width, in screen coordinates, of the video mode.
|
||||||
*/
|
*/
|
||||||
@ -835,7 +836,7 @@ typedef struct
|
|||||||
*
|
*
|
||||||
* @ingroup monitor
|
* @ingroup monitor
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct GLFWgammaramp
|
||||||
{
|
{
|
||||||
/*! An array of value describing the response of the red channel.
|
/*! An array of value describing the response of the red channel.
|
||||||
*/
|
*/
|
||||||
@ -876,10 +877,7 @@ typedef struct
|
|||||||
*
|
*
|
||||||
* @note This function may only be called from the main thread.
|
* @note This function may only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @note This function may take several seconds to complete on some systems,
|
* @note **OS X:** This function will change the current directory of the
|
||||||
* while on other systems it may take only a fraction of a second to complete.
|
|
||||||
*
|
|
||||||
* @note **Mac OS X:** This function will change the current directory of the
|
|
||||||
* application to the `Contents/Resources` subdirectory of the application's
|
* application to the `Contents/Resources` subdirectory of the application's
|
||||||
* bundle, if present.
|
* bundle, if present.
|
||||||
*
|
*
|
||||||
@ -1245,17 +1243,26 @@ GLFWAPI void glfwWindowHint(int target, int hint);
|
|||||||
* to not share resources.
|
* to not share resources.
|
||||||
* @return The handle of the created window, or `NULL` if an error occurred.
|
* @return The handle of the created window, or `NULL` if an error occurred.
|
||||||
*
|
*
|
||||||
|
* @remarks **Windows:** Window creation will fail if the Microsoft GDI
|
||||||
|
* software OpenGL implementation is the only one available.
|
||||||
|
*
|
||||||
* @remarks **Windows:** If the executable has an icon resource named
|
* @remarks **Windows:** If the executable has an icon resource named
|
||||||
* `GLFW_ICON,` it will be set as the icon for the window. If no such icon is
|
* `GLFW_ICON,` it will be set as the icon for the window. If no such icon is
|
||||||
* present, the `IDI_WINLOGO` icon will be used instead.
|
* present, the `IDI_WINLOGO` icon will be used instead.
|
||||||
*
|
*
|
||||||
* @remarks **Mac OS X:** The GLFW window has no icon, as it is not a document
|
* @remarks **OS X:** The GLFW window has no icon, as it is not a document
|
||||||
* window, but the dock icon will be the same as the application bundle's icon.
|
* window, but the dock icon will be the same as the application bundle's icon.
|
||||||
* Also, the first time a window is opened the menu bar is populated with
|
* Also, the first time a window is opened the menu bar is populated with
|
||||||
* common commands like Hide, Quit and About. The (minimal) about dialog uses
|
* common commands like Hide, Quit and About. The (minimal) about dialog uses
|
||||||
* information from the application's bundle. For more information on bundles,
|
* information from the application's bundle. For more information on bundles,
|
||||||
* see the Bundle Programming Guide provided by Apple.
|
* see the Bundle Programming Guide provided by Apple.
|
||||||
*
|
*
|
||||||
|
* @remarks **X11:** There is no mechanism for setting the window icon yet.
|
||||||
|
*
|
||||||
|
* @remarks The swap interval is not set during window creation, but is left at
|
||||||
|
* the default value for that platform. For more information, see @ref
|
||||||
|
* glfwSwapInterval.
|
||||||
|
*
|
||||||
* @note This function may only be called from the main thread.
|
* @note This function may only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa glfwDestroyWindow
|
* @sa glfwDestroyWindow
|
||||||
@ -1293,6 +1300,8 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
|
|||||||
* @param[in] window The window to query.
|
* @param[in] window The window to query.
|
||||||
* @return The value of the close flag.
|
* @return The value of the close flag.
|
||||||
*
|
*
|
||||||
|
* @remarks This function may be called from secondary threads.
|
||||||
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
|
GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
|
||||||
@ -1306,6 +1315,8 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
|
|||||||
* @param[in] window The window whose flag to change.
|
* @param[in] window The window whose flag to change.
|
||||||
* @param[in] value The new value.
|
* @param[in] value The new value.
|
||||||
*
|
*
|
||||||
|
* @remarks This function may be called from secondary threads.
|
||||||
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
|
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
|
||||||
@ -1363,10 +1374,6 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
|
|||||||
*
|
*
|
||||||
* @note The window manager may put limits on what positions are allowed.
|
* @note The window manager may put limits on what positions are allowed.
|
||||||
*
|
*
|
||||||
* @bug **X11:** Some window managers ignore the set position of hidden (i.e.
|
|
||||||
* unmapped) windows, instead placing them where it thinks is appropriate once
|
|
||||||
* they are shown.
|
|
||||||
*
|
|
||||||
* @sa glfwGetWindowPos
|
* @sa glfwGetWindowPos
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
@ -1376,7 +1383,8 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
|
|||||||
/*! @brief Retrieves the size of the client area of the specified window.
|
/*! @brief Retrieves the size of the client area of the specified window.
|
||||||
*
|
*
|
||||||
* This function retrieves the size, in screen coordinates, of the client area
|
* This function retrieves the size, in screen coordinates, of the client area
|
||||||
* of the specified window.
|
* of the specified window. If you wish to retrieve the size of the
|
||||||
|
* framebuffer in pixels, see @ref glfwGetFramebufferSize.
|
||||||
*
|
*
|
||||||
* @param[in] window The window whose size to retrieve.
|
* @param[in] window The window whose size to retrieve.
|
||||||
* @param[out] width Where to store the width, in screen coordinates, of the
|
* @param[out] width Where to store the width, in screen coordinates, of the
|
||||||
@ -1417,7 +1425,8 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
|
|||||||
/*! @brief Retrieves the size of the framebuffer of the specified window.
|
/*! @brief Retrieves the size of the framebuffer of the specified window.
|
||||||
*
|
*
|
||||||
* This function retrieves the size, in pixels, of the framebuffer of the
|
* This function retrieves the size, in pixels, of the framebuffer of the
|
||||||
* specified window.
|
* specified window. If you wish to retrieve the size of the window in screen
|
||||||
|
* coordinates, see @ref glfwGetWindowSize.
|
||||||
*
|
*
|
||||||
* @param[in] window The window whose framebuffer to query.
|
* @param[in] window The window whose framebuffer to query.
|
||||||
* @param[out] width Where to store the width, in pixels, of the framebuffer,
|
* @param[out] width Where to store the width, in pixels, of the framebuffer,
|
||||||
@ -1600,7 +1609,10 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind
|
|||||||
* @return The previously set callback, or `NULL` if no callback was set or an
|
* @return The previously set callback, or `NULL` if no callback was set or an
|
||||||
* error occurred.
|
* error occurred.
|
||||||
*
|
*
|
||||||
* @remarks **Mac OS X:** Selecting Quit from the application menu will
|
* @par New in GLFW 3
|
||||||
|
* The close callback no longer returns a value.
|
||||||
|
*
|
||||||
|
* @remarks **OS X:** Selecting Quit from the application menu will
|
||||||
* trigger the close callback for all windows.
|
* trigger the close callback for all windows.
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
@ -1827,7 +1839,8 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
|
|||||||
/*! @brief Retrieves the last reported cursor position, relative to the client
|
/*! @brief Retrieves the last reported cursor position, relative to the client
|
||||||
* area of the window.
|
* area of the window.
|
||||||
*
|
*
|
||||||
* This function returns the last reported position of the cursor to the
|
* This function returns the last reported position of the cursor, in screen
|
||||||
|
* coordinates, relative to the upper-left corner of the client area of the
|
||||||
* specified window.
|
* specified window.
|
||||||
*
|
*
|
||||||
* If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
|
* If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
|
||||||
@ -1850,11 +1863,13 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
|
GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
|
||||||
|
|
||||||
/*! @brief Sets the position of the cursor, relative to the client area of the window.
|
/*! @brief Sets the position of the cursor, relative to the client area of the
|
||||||
|
* window.
|
||||||
*
|
*
|
||||||
* This function sets the position of the cursor. The specified window must be
|
* This function sets the position, in screen coordinates, of the cursor
|
||||||
* focused. If the window does not have focus when this function is called, it
|
* relative to the upper-left corner of the client area of the specified
|
||||||
* fails silently.
|
* window. The window must be focused. If the window does not have focus when
|
||||||
|
* this function is called, it fails silently.
|
||||||
*
|
*
|
||||||
* If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
|
* If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
|
||||||
* position is unbounded and limited only by the minimum and maximum values of
|
* position is unbounded and limited only by the minimum and maximum values of
|
||||||
@ -1862,9 +1877,9 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
|
|||||||
*
|
*
|
||||||
* @param[in] window The desired window.
|
* @param[in] window The desired window.
|
||||||
* @param[in] xpos The desired x-coordinate, relative to the left edge of the
|
* @param[in] xpos The desired x-coordinate, relative to the left edge of the
|
||||||
* client area, or `NULL`.
|
* client area.
|
||||||
* @param[in] ypos The desired y-coordinate, relative to the top edge of the
|
* @param[in] ypos The desired y-coordinate, relative to the top edge of the
|
||||||
* client area, or `NULL`.
|
* client area.
|
||||||
*
|
*
|
||||||
* @sa glfwGetCursorPos
|
* @sa glfwGetCursorPos
|
||||||
*
|
*
|
||||||
@ -1950,7 +1965,8 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmo
|
|||||||
*
|
*
|
||||||
* This function sets the cursor position callback of the specified window,
|
* This function sets the cursor position callback of the specified window,
|
||||||
* which is called when the cursor is moved. The callback is provided with the
|
* which is called when the cursor is moved. The callback is provided with the
|
||||||
* position relative to the upper-left corner of the client area of the window.
|
* position, in screen coordinates, relative to the upper-left corner of the
|
||||||
|
* client area of the window.
|
||||||
*
|
*
|
||||||
* @param[in] window The window whose callback to set.
|
* @param[in] window The window whose callback to set.
|
||||||
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
|
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
|
||||||
@ -2226,6 +2242,11 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
|
|||||||
*
|
*
|
||||||
* @remarks This function may be called from secondary threads.
|
* @remarks This function may be called from secondary threads.
|
||||||
*
|
*
|
||||||
|
* @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.
|
||||||
|
*
|
||||||
* @note Some GPU drivers do not honor the requested swap interval, either
|
* @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
|
* because of user settings that override the request or due to bugs in the
|
||||||
* driver.
|
* driver.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* GLFW - An OpenGL library
|
* GLFW 3.0 - www.glfw.org
|
||||||
* API version: 3.0
|
* A library for OpenGL, window and input
|
||||||
* WWW: http://www.glfw.org/
|
|
||||||
*------------------------------------------------------------------------
|
*------------------------------------------------------------------------
|
||||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
* Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
* Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
@ -3,7 +3,9 @@ include_directories(${GLFW_SOURCE_DIR}/src
|
|||||||
${GLFW_BINARY_DIR}/src
|
${GLFW_BINARY_DIR}/src
|
||||||
${glfw_INCLUDE_DIRS})
|
${glfw_INCLUDE_DIRS})
|
||||||
|
|
||||||
set(common_HEADERS ${GLFW_BINARY_DIR}/src/config.h internal.h
|
add_definitions(-D_GLFW_USE_CONFIG_H)
|
||||||
|
|
||||||
|
set(common_HEADERS ${GLFW_BINARY_DIR}/src/glfw_config.h internal.h
|
||||||
${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h
|
${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h
|
||||||
${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h)
|
${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h)
|
||||||
set(common_SOURCES clipboard.c context.c gamma.c init.c input.c joystick.c
|
set(common_SOURCES clipboard.c context.c gamma.c init.c input.c joystick.c
|
||||||
@ -72,7 +74,8 @@ if (BUILD_SHARED_LIBS)
|
|||||||
set(glfw_CFLAGS "")
|
set(glfw_CFLAGS "")
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(glfw PROPERTIES
|
set_target_properties(glfw PROPERTIES
|
||||||
COMPILE_FLAGS "${glfw_CFLAGS} -fno-common")
|
COMPILE_FLAGS "${glfw_CFLAGS} -fno-common"
|
||||||
|
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(glfw ${glfw_LIBRARIES})
|
target_link_libraries(glfw ${glfw_LIBRARIES})
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa/NSOpenGL
|
|
||||||
// API Version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
@ -125,7 +122,7 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
const char* version = _GLFW_VERSION_FULL " Cocoa"
|
const char* version = _GLFW_VERSION_NUMBER " Cocoa"
|
||||||
#if defined(_GLFW_NSGL)
|
#if defined(_GLFW_NSGL)
|
||||||
" NSGL"
|
" NSGL"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa
|
|
||||||
// API Version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
||||||
@ -254,9 +251,6 @@ static void pollJoystickEvents(void)
|
|||||||
joystick->axes[i] = value;
|
joystick->axes[i] = value;
|
||||||
else
|
else
|
||||||
joystick->axes[i] = (2.f * (value - axis->minReport) / readScale) - 1.f;
|
joystick->axes[i] = (2.f * (value - axis->minReport) / readScale) - 1.f;
|
||||||
|
|
||||||
if (i & 1)
|
|
||||||
joystick->axes[i] = -joystick->axes[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(joystick->hatElements); i++)
|
for (i = 0; i < CFArrayGetCount(joystick->hatElements); i++)
|
||||||
@ -322,8 +316,9 @@ void _glfwInitJoysticks(void)
|
|||||||
|
|
||||||
while ((ioHIDDeviceObject = IOIteratorNext(objectIterator)))
|
while ((ioHIDDeviceObject = IOIteratorNext(objectIterator)))
|
||||||
{
|
{
|
||||||
|
CFMutableDictionaryRef propsRef = NULL;
|
||||||
|
CFTypeRef valueRef = NULL;
|
||||||
kern_return_t result;
|
kern_return_t result;
|
||||||
CFTypeRef valueRef = 0;
|
|
||||||
|
|
||||||
IOCFPlugInInterface** ppPlugInInterface = NULL;
|
IOCFPlugInInterface** ppPlugInInterface = NULL;
|
||||||
HRESULT plugInResult = S_OK;
|
HRESULT plugInResult = S_OK;
|
||||||
@ -332,26 +327,29 @@ void _glfwInitJoysticks(void)
|
|||||||
long usagePage, usage;
|
long usagePage, usage;
|
||||||
|
|
||||||
// Check device type
|
// Check device type
|
||||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
result = IORegistryEntryCreateCFProperties(ioHIDDeviceObject,
|
||||||
CFSTR(kIOHIDPrimaryUsagePageKey),
|
&propsRef,
|
||||||
kCFAllocatorDefault,
|
kCFAllocatorDefault,
|
||||||
kNilOptions);
|
kNilOptions);
|
||||||
|
|
||||||
|
if (result != kIOReturnSuccess)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsagePageKey));
|
||||||
if (valueRef)
|
if (valueRef)
|
||||||
{
|
{
|
||||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage);
|
CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage);
|
||||||
if (usagePage != kHIDPage_GenericDesktop)
|
if (usagePage != kHIDPage_GenericDesktop)
|
||||||
{
|
{
|
||||||
// This device is not relevant to GLFW
|
// This device is not relevant to GLFW
|
||||||
|
CFRelease(valueRef);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(valueRef);
|
CFRelease(valueRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsageKey));
|
||||||
CFSTR(kIOHIDPrimaryUsageKey),
|
|
||||||
kCFAllocatorDefault,
|
|
||||||
kNilOptions);
|
|
||||||
if (valueRef)
|
if (valueRef)
|
||||||
{
|
{
|
||||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usage);
|
CFNumberGetValue(valueRef, kCFNumberLongType, &usage);
|
||||||
@ -361,6 +359,7 @@ void _glfwInitJoysticks(void)
|
|||||||
usage != kHIDUsage_GD_MultiAxisController))
|
usage != kHIDUsage_GD_MultiAxisController))
|
||||||
{
|
{
|
||||||
// This device is not relevant to GLFW
|
// This device is not relevant to GLFW
|
||||||
|
CFRelease(valueRef);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,10 +395,7 @@ void _glfwInitJoysticks(void)
|
|||||||
joystick);
|
joystick);
|
||||||
|
|
||||||
// Get product string
|
// Get product string
|
||||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDProductKey));
|
||||||
CFSTR(kIOHIDProductKey),
|
|
||||||
kCFAllocatorDefault,
|
|
||||||
kNilOptions);
|
|
||||||
if (valueRef)
|
if (valueRef)
|
||||||
{
|
{
|
||||||
CFStringGetCString(valueRef,
|
CFStringGetCString(valueRef,
|
||||||
@ -413,10 +409,7 @@ void _glfwInitJoysticks(void)
|
|||||||
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
|
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
|
||||||
joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL);
|
joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL);
|
||||||
|
|
||||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDElementKey));
|
||||||
CFSTR(kIOHIDElementKey),
|
|
||||||
kCFAllocatorDefault,
|
|
||||||
kNilOptions);
|
|
||||||
if (CFGetTypeID(valueRef) == CFArrayGetTypeID())
|
if (CFGetTypeID(valueRef) == CFArrayGetTypeID())
|
||||||
{
|
{
|
||||||
CFRange range = { 0, CFArrayGetCount(valueRef) };
|
CFRange range = { 0, CFArrayGetCount(valueRef) };
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -34,6 +31,9 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <IOKit/graphics/IOGraphicsLib.h>
|
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||||
|
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||||
|
#include <CoreVideo/CVBase.h>
|
||||||
|
#include <CoreVideo/CVDisplayLink.h>
|
||||||
|
|
||||||
|
|
||||||
// Get the name of the specified display
|
// Get the name of the specified display
|
||||||
@ -49,9 +49,11 @@ static const char* getDisplayName(CGDirectDisplayID displayID)
|
|||||||
kIODisplayOnlyPreferredName);
|
kIODisplayOnlyPreferredName);
|
||||||
names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
||||||
|
|
||||||
if (!CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
|
if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
|
||||||
(const void**) &value))
|
(const void**) &value))
|
||||||
{
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to retrieve display name");
|
||||||
|
|
||||||
CFRelease(info);
|
CFRelease(info);
|
||||||
return strdup("Unknown");
|
return strdup("Unknown");
|
||||||
}
|
}
|
||||||
@ -77,9 +79,6 @@ static GLboolean modeIsGood(CGDisplayModeRef mode)
|
|||||||
if (flags & kDisplayModeInterlacedFlag)
|
if (flags & kDisplayModeInterlacedFlag)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
if (flags & kDisplayModeTelevisionFlag)
|
|
||||||
return GL_FALSE;
|
|
||||||
|
|
||||||
if (flags & kDisplayModeStretchedFlag)
|
if (flags & kDisplayModeStretchedFlag)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
@ -97,13 +96,21 @@ static GLboolean modeIsGood(CGDisplayModeRef mode)
|
|||||||
|
|
||||||
// Convert Core Graphics display mode to GLFW video mode
|
// Convert Core Graphics display mode to GLFW video mode
|
||||||
//
|
//
|
||||||
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode)
|
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
||||||
|
CVDisplayLinkRef link)
|
||||||
{
|
{
|
||||||
GLFWvidmode result;
|
GLFWvidmode result;
|
||||||
result.width = CGDisplayModeGetWidth(mode);
|
result.width = (int) CGDisplayModeGetWidth(mode);
|
||||||
result.height = CGDisplayModeGetHeight(mode);
|
result.height = (int) CGDisplayModeGetHeight(mode);
|
||||||
result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);
|
result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);
|
||||||
|
|
||||||
|
if (result.refreshRate == 0)
|
||||||
|
{
|
||||||
|
const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
|
||||||
|
if (!(time.flags & kCVTimeIsIndefinite))
|
||||||
|
result.refreshRate = (int) (time.timeScale / (double) time.timeValue);
|
||||||
|
}
|
||||||
|
|
||||||
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
||||||
|
|
||||||
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
|
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
|
||||||
@ -337,6 +344,9 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
CFArrayRef modes;
|
CFArrayRef modes;
|
||||||
CFIndex count, i;
|
CFIndex count, i;
|
||||||
GLFWvidmode* result;
|
GLFWvidmode* result;
|
||||||
|
CVDisplayLinkRef link;
|
||||||
|
|
||||||
|
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
||||||
|
|
||||||
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||||
count = CFArrayGetCount(modes);
|
count = CFArrayGetCount(modes);
|
||||||
@ -351,21 +361,28 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||||
if (modeIsGood(mode))
|
if (modeIsGood(mode))
|
||||||
{
|
{
|
||||||
result[*found] = vidmodeFromCGDisplayMode(mode);
|
result[*found] = vidmodeFromCGDisplayMode(mode, link);
|
||||||
(*found)++;
|
(*found)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(modes);
|
CFRelease(modes);
|
||||||
|
|
||||||
|
CVDisplayLinkRelease(link);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||||
{
|
{
|
||||||
CGDisplayModeRef displayMode;
|
CGDisplayModeRef displayMode;
|
||||||
|
CVDisplayLinkRef link;
|
||||||
|
|
||||||
|
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
||||||
|
|
||||||
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
||||||
*mode = vidmodeFromCGDisplayMode(displayMode);
|
*mode = vidmodeFromCGDisplayMode(displayMode, link);
|
||||||
CGDisplayModeRelease(displayMode);
|
CGDisplayModeRelease(displayMode);
|
||||||
|
|
||||||
|
CVDisplayLinkRelease(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa
|
|
||||||
// API Version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
@ -108,8 +105,6 @@ typedef struct _GLFWlibraryNS
|
|||||||
id autoreleasePool;
|
id autoreleasePool;
|
||||||
id cursor;
|
id cursor;
|
||||||
|
|
||||||
GLboolean cursorHidden;
|
|
||||||
|
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
|
|
||||||
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];
|
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa
|
|
||||||
// API Version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -33,6 +33,25 @@
|
|||||||
#include <crt_externs.h>
|
#include <crt_externs.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Center the cursor in the view of the window
|
||||||
|
//
|
||||||
|
static void centerCursor(_GLFWwindow *window)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||||
|
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the cursor to match the specified cursor mode
|
||||||
|
//
|
||||||
|
static void setModeCursor(_GLFWwindow* window, int mode)
|
||||||
|
{
|
||||||
|
if (mode == GLFW_CURSOR_NORMAL)
|
||||||
|
[[NSCursor arrowCursor] set];
|
||||||
|
else
|
||||||
|
[(NSCursor*) _glfw.ns.cursor set];
|
||||||
|
}
|
||||||
|
|
||||||
// Enter fullscreen mode
|
// Enter fullscreen mode
|
||||||
//
|
//
|
||||||
static void enterFullscreenMode(_GLFWwindow* window)
|
static void enterFullscreenMode(_GLFWwindow* window)
|
||||||
@ -42,8 +61,18 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||||||
|
|
||||||
_glfwSetVideoMode(window->monitor, &window->videoMode);
|
_glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||||
|
|
||||||
|
NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
[NSNumber numberWithBool:NO],
|
||||||
|
NSFullScreenModeAllScreens,
|
||||||
|
nil];
|
||||||
|
|
||||||
[window->ns.view enterFullScreenMode:window->monitor->ns.screen
|
[window->ns.view enterFullScreenMode:window->monitor->ns.screen
|
||||||
withOptions:nil];
|
withOptions:options];
|
||||||
|
|
||||||
|
// HACK: Synthesize focus event as window does not become key when the view
|
||||||
|
// is made full screen
|
||||||
|
// TODO: Remove this when moving to a full screen window
|
||||||
|
_glfwInputWindowFocus(window, GL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave fullscreen mode
|
// Leave fullscreen mode
|
||||||
@ -53,6 +82,11 @@ static void leaveFullscreenMode(_GLFWwindow* window)
|
|||||||
if (![window->ns.view isInFullScreenMode])
|
if (![window->ns.view isInFullScreenMode])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// HACK: Synthesize focus event as window does not become key when the view
|
||||||
|
// is made full screen
|
||||||
|
// TODO: Remove this when moving to a full screen window
|
||||||
|
_glfwInputWindowFocus(window, GL_FALSE);
|
||||||
|
|
||||||
_glfwRestoreVideoMode(window->monitor);
|
_glfwRestoreVideoMode(window->monitor);
|
||||||
|
|
||||||
// Exit full screen after the video restore to avoid a nasty display
|
// Exit full screen after the video restore to avoid a nasty display
|
||||||
@ -74,7 +108,7 @@ static float transformY(float y)
|
|||||||
static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
||||||
{
|
{
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
if ([window->ns.view respondsToSelector:@selector(convertRectToBacking:)])
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||||
return [window->ns.view convertRectToBacking:contentRect];
|
return [window->ns.view convertRectToBacking:contentRect];
|
||||||
else
|
else
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
@ -97,13 +131,6 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
|||||||
|
|
||||||
@implementation GLFWWindowDelegate
|
@implementation GLFWWindowDelegate
|
||||||
|
|
||||||
static void centerCursor(_GLFWwindow *window)
|
|
||||||
{
|
|
||||||
int width, height;
|
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
|
||||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow
|
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
@ -162,14 +189,13 @@ static void centerCursor(_GLFWwindow *window)
|
|||||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
_glfwInputWindowFocus(window, GL_TRUE);
|
_glfwInputWindowFocus(window, GL_TRUE);
|
||||||
|
_glfwPlatformSetCursorMode(window, window->cursorMode);
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
|
||||||
centerCursor(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidResignKey:(NSNotification *)notification
|
- (void)windowDidResignKey:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
_glfwInputWindowFocus(window, GL_FALSE);
|
_glfwInputWindowFocus(window, GL_FALSE);
|
||||||
|
_glfwPlatformSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -220,7 +246,7 @@ static void centerCursor(_GLFWwindow *window)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// Translates Mac OS X key modifiers into GLFW ones
|
// Translates OS X key modifiers into GLFW ones
|
||||||
//
|
//
|
||||||
static int translateFlags(NSUInteger flags)
|
static int translateFlags(NSUInteger flags)
|
||||||
{
|
{
|
||||||
@ -238,12 +264,11 @@ static int translateFlags(NSUInteger flags)
|
|||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translates a Mac OS X keycode to a GLFW keycode
|
// Translates a OS X keycode to a GLFW keycode
|
||||||
//
|
//
|
||||||
static int translateKey(unsigned int key)
|
static int translateKey(unsigned int key)
|
||||||
{
|
{
|
||||||
// Keyboard symbol translation table
|
// Keyboard symbol translation table
|
||||||
// TODO: Need to find mappings for F13-F15, volume down/up/mute, and eject.
|
|
||||||
static const unsigned int table[128] =
|
static const unsigned int table[128] =
|
||||||
{
|
{
|
||||||
/* 00 */ GLFW_KEY_A,
|
/* 00 */ GLFW_KEY_A,
|
||||||
@ -256,7 +281,7 @@ static int translateKey(unsigned int key)
|
|||||||
/* 07 */ GLFW_KEY_X,
|
/* 07 */ GLFW_KEY_X,
|
||||||
/* 08 */ GLFW_KEY_C,
|
/* 08 */ GLFW_KEY_C,
|
||||||
/* 09 */ GLFW_KEY_V,
|
/* 09 */ GLFW_KEY_V,
|
||||||
/* 0a */ GLFW_KEY_GRAVE_ACCENT,
|
/* 0a */ GLFW_KEY_WORLD_1,
|
||||||
/* 0b */ GLFW_KEY_B,
|
/* 0b */ GLFW_KEY_B,
|
||||||
/* 0c */ GLFW_KEY_Q,
|
/* 0c */ GLFW_KEY_Q,
|
||||||
/* 0d */ GLFW_KEY_W,
|
/* 0d */ GLFW_KEY_W,
|
||||||
@ -296,7 +321,7 @@ static int translateKey(unsigned int key)
|
|||||||
/* 2f */ GLFW_KEY_PERIOD,
|
/* 2f */ GLFW_KEY_PERIOD,
|
||||||
/* 30 */ GLFW_KEY_TAB,
|
/* 30 */ GLFW_KEY_TAB,
|
||||||
/* 31 */ GLFW_KEY_SPACE,
|
/* 31 */ GLFW_KEY_SPACE,
|
||||||
/* 32 */ GLFW_KEY_WORLD_1,
|
/* 32 */ GLFW_KEY_GRAVE_ACCENT,
|
||||||
/* 33 */ GLFW_KEY_BACKSPACE,
|
/* 33 */ GLFW_KEY_BACKSPACE,
|
||||||
/* 34 */ GLFW_KEY_UNKNOWN,
|
/* 34 */ GLFW_KEY_UNKNOWN,
|
||||||
/* 35 */ GLFW_KEY_ESCAPE,
|
/* 35 */ GLFW_KEY_ESCAPE,
|
||||||
@ -351,7 +376,7 @@ static int translateKey(unsigned int key)
|
|||||||
/* 66 */ GLFW_KEY_UNKNOWN,
|
/* 66 */ GLFW_KEY_UNKNOWN,
|
||||||
/* 67 */ GLFW_KEY_F11,
|
/* 67 */ GLFW_KEY_F11,
|
||||||
/* 68 */ GLFW_KEY_UNKNOWN,
|
/* 68 */ GLFW_KEY_UNKNOWN,
|
||||||
/* 69 */ GLFW_KEY_PRINT_SCREEN,
|
/* 69 */ GLFW_KEY_F13,
|
||||||
/* 6a */ GLFW_KEY_F16,
|
/* 6a */ GLFW_KEY_F16,
|
||||||
/* 6b */ GLFW_KEY_F14,
|
/* 6b */ GLFW_KEY_F14,
|
||||||
/* 6c */ GLFW_KEY_UNKNOWN,
|
/* 6c */ GLFW_KEY_UNKNOWN,
|
||||||
@ -458,6 +483,11 @@ static int translateKey(unsigned int key)
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)cursorUpdate:(NSEvent *)event
|
||||||
|
{
|
||||||
|
setModeCursor(window, window->cursorMode);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)event
|
- (void)mouseDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
@ -516,7 +546,7 @@ static int translateKey(unsigned int key)
|
|||||||
- (void)otherMouseDown:(NSEvent *)event
|
- (void)otherMouseDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
[event buttonNumber],
|
(int) [event buttonNumber],
|
||||||
GLFW_PRESS,
|
GLFW_PRESS,
|
||||||
translateFlags([event modifierFlags]));
|
translateFlags([event modifierFlags]));
|
||||||
}
|
}
|
||||||
@ -529,7 +559,7 @@ static int translateKey(unsigned int key)
|
|||||||
- (void)otherMouseUp:(NSEvent *)event
|
- (void)otherMouseUp:(NSEvent *)event
|
||||||
{
|
{
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
[event buttonNumber],
|
(int) [event buttonNumber],
|
||||||
GLFW_RELEASE,
|
GLFW_RELEASE,
|
||||||
translateFlags([event modifierFlags]));
|
translateFlags([event modifierFlags]));
|
||||||
}
|
}
|
||||||
@ -561,7 +591,8 @@ static int translateKey(unsigned int key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
|
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
|
||||||
NSTrackingActiveAlways |
|
NSTrackingActiveInKeyWindow |
|
||||||
|
NSTrackingCursorUpdate |
|
||||||
NSTrackingInVisibleRect;
|
NSTrackingInVisibleRect;
|
||||||
|
|
||||||
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
||||||
@ -579,9 +610,6 @@ static int translateKey(unsigned int key)
|
|||||||
const int mods = translateFlags([event modifierFlags]);
|
const int mods = translateFlags([event modifierFlags]);
|
||||||
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
||||||
|
|
||||||
if (mods & GLFW_MOD_SUPER)
|
|
||||||
return;
|
|
||||||
|
|
||||||
NSString* characters = [event characters];
|
NSString* characters = [event characters];
|
||||||
NSUInteger i, length = [characters length];
|
NSUInteger i, length = [characters length];
|
||||||
|
|
||||||
@ -616,22 +644,31 @@ static int translateKey(unsigned int key)
|
|||||||
|
|
||||||
- (void)scrollWheel:(NSEvent *)event
|
- (void)scrollWheel:(NSEvent *)event
|
||||||
{
|
{
|
||||||
double deltaX = [event deltaX];
|
double deltaX, deltaY;
|
||||||
double deltaY = [event deltaY];
|
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||||
|
{
|
||||||
|
deltaX = [event scrollingDeltaX];
|
||||||
|
deltaY = [event scrollingDeltaY];
|
||||||
|
|
||||||
|
if ([event hasPreciseScrollingDeltas])
|
||||||
|
{
|
||||||
|
deltaX *= 0.1;
|
||||||
|
deltaY *= 0.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
{
|
||||||
|
deltaX = [event deltaX];
|
||||||
|
deltaY = [event deltaY];
|
||||||
|
}
|
||||||
|
|
||||||
if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
|
if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
|
||||||
_glfwInputScroll(window, deltaX, deltaY);
|
_glfwInputScroll(window, deltaX, deltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// arturoc: this makes the cursor dissapear when the window is
|
|
||||||
// resized or received a drag operation
|
|
||||||
/*- (void)resetCursorRects
|
|
||||||
{
|
|
||||||
[self discardCursorRects];
|
|
||||||
[self addCursorRect:[self bounds] cursor:_glfw.ns.cursor];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask])
|
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask])
|
||||||
@ -738,7 +775,7 @@ static int translateKey(unsigned int key)
|
|||||||
//
|
//
|
||||||
static NSString* findAppName(void)
|
static NSString* findAppName(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
size_t i;
|
||||||
NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
||||||
|
|
||||||
// Keys to search for as potential application names
|
// Keys to search for as potential application names
|
||||||
@ -817,7 +854,7 @@ static void createMenuBar(void)
|
|||||||
[NSApp setWindowsMenu:windowMenu];
|
[NSApp setWindowsMenu:windowMenu];
|
||||||
[windowMenuItem setSubmenu:windowMenu];
|
[windowMenuItem setSubmenu:windowMenu];
|
||||||
|
|
||||||
[windowMenu addItemWithTitle:@"Miniaturize"
|
[windowMenu addItemWithTitle:@"Minimize"
|
||||||
action:@selector(performMiniaturize:)
|
action:@selector(performMiniaturize:)
|
||||||
keyEquivalent:@"m"];
|
keyEquivalent:@"m"];
|
||||||
[windowMenu addItemWithTitle:@"Zoom"
|
[windowMenu addItemWithTitle:@"Zoom"
|
||||||
@ -828,9 +865,23 @@ static void createMenuBar(void)
|
|||||||
action:@selector(arrangeInFront:)
|
action:@selector(arrangeInFront:)
|
||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
|
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||||
|
{
|
||||||
|
// TODO: Make this appear at the bottom of the menu (for consistency)
|
||||||
|
|
||||||
|
[windowMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
[[windowMenu addItemWithTitle:@"Enter Full Screen"
|
||||||
|
action:@selector(toggleFullScreen:)
|
||||||
|
keyEquivalent:@"f"]
|
||||||
|
setKeyEquivalentModifierMask:NSControlKeyMask | NSCommandKeyMask];
|
||||||
|
}
|
||||||
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
|
||||||
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
|
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
|
||||||
// to get the application menu working properly.
|
// to get the application menu working properly.
|
||||||
[NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu];
|
SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
|
||||||
|
[NSApp performSelector:setAppleMenuSelector withObject:appMenu];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _GLFW_USE_MENUBAR */
|
#endif /* _GLFW_USE_MENUBAR */
|
||||||
@ -845,13 +896,8 @@ static GLboolean initializeAppKit(void)
|
|||||||
// Implicitly create shared NSApplication instance
|
// Implicitly create shared NSApplication instance
|
||||||
[GLFWApplication sharedApplication];
|
[GLFWApplication sharedApplication];
|
||||||
|
|
||||||
// If we get here, the application is unbundled
|
// In case we are unbundled, make us a proper UI application
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
|
||||||
|
|
||||||
// Having the app in front of the terminal window is also generally
|
|
||||||
// handy. There is an NSApplication API to do this, but...
|
|
||||||
SetFrontProcess(&psn);
|
|
||||||
|
|
||||||
#if defined(_GLFW_USE_MENUBAR)
|
#if defined(_GLFW_USE_MENUBAR)
|
||||||
// Menu bar setup must go between sharedApplication above and
|
// Menu bar setup must go between sharedApplication above and
|
||||||
@ -898,19 +944,23 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
if ([window->ns.view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)])
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||||
|
{
|
||||||
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
||||||
|
|
||||||
|
if (wndconfig->resizable)
|
||||||
|
[window->ns.object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||||
|
}
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
|
||||||
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
||||||
[window->ns.object setContentView:window->ns.view];
|
[window->ns.object setContentView:window->ns.view];
|
||||||
[window->ns.object setDelegate:window->ns.delegate];
|
[window->ns.object setDelegate:window->ns.delegate];
|
||||||
[window->ns.object setAcceptsMouseMovedEvents:YES];
|
[window->ns.object setAcceptsMouseMovedEvents:YES];
|
||||||
[window->ns.object disableCursorRects];
|
|
||||||
[window->ns.object center];
|
[window->ns.object center];
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
if ([window->ns.object respondsToSelector:@selector(setRestorable:)])
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||||
[window->ns.object setRestorable:NO];
|
[window->ns.object setRestorable:NO];
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
|
||||||
@ -1007,8 +1057,9 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||||
{
|
{
|
||||||
const NSRect frameRect =
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
[window->ns.object frameRectForContentRect:NSMakeRect(x, y, 0, 0)];
|
const NSRect dummyRect = NSMakeRect(x, transformY(y + contentRect.size.height), 0, 0);
|
||||||
|
const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
|
||||||
[window->ns.object setFrameOrigin:frameRect.origin];
|
[window->ns.object setFrameOrigin:frameRect.origin];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1053,6 +1104,12 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
// Make us the active application
|
||||||
|
// HACK: This has been moved here from initializeAppKit to prevent
|
||||||
|
// applications using only hidden windows from being activated, but
|
||||||
|
// should probably not be done every time any window is shown
|
||||||
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
|
|
||||||
[window->ns.object makeKeyAndOrderFront:nil];
|
[window->ns.object makeKeyAndOrderFront:nil];
|
||||||
_glfwInputWindowVisibility(window, GL_TRUE);
|
_glfwInputWindowVisibility(window, GL_TRUE);
|
||||||
}
|
}
|
||||||
@ -1097,6 +1154,8 @@ void _glfwPlatformWaitEvents(void)
|
|||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
|
setModeCursor(window, window->cursorMode);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
CGDisplayMoveCursorToPoint(window->monitor->ns.displayID,
|
CGDisplayMoveCursorToPoint(window->monitor->ns.displayID,
|
||||||
@ -1115,37 +1174,15 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
|||||||
|
|
||||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||||
{
|
{
|
||||||
if (mode == GLFW_CURSOR_HIDDEN)
|
setModeCursor(window, mode);
|
||||||
{
|
|
||||||
[window->ns.object enableCursorRects];
|
|
||||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[window->ns.object disableCursorRects];
|
|
||||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == GLFW_CURSOR_DISABLED)
|
if (mode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
CGAssociateMouseAndMouseCursorPosition(false);
|
CGAssociateMouseAndMouseCursorPosition(false);
|
||||||
|
centerCursor(window);
|
||||||
if (!_glfw.ns.cursorHidden)
|
|
||||||
{
|
|
||||||
[NSCursor hide];
|
|
||||||
_glfw.ns.cursorHidden = GL_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
CGAssociateMouseAndMouseCursorPosition(true);
|
CGAssociateMouseAndMouseCursorPosition(true);
|
||||||
|
|
||||||
if (_glfw.ns.cursorHidden)
|
|
||||||
{
|
|
||||||
[NSCursor unhide];
|
|
||||||
_glfw.ns.cursorHidden = GL_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -101,7 +98,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
|||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0 ||
|
if ((wndconfig->glMajor < 1 || wndconfig->glMinor < 0) ||
|
||||||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 5) ||
|
(wndconfig->glMajor == 1 && wndconfig->glMinor > 5) ||
|
||||||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 1) ||
|
(wndconfig->glMajor == 2 && wndconfig->glMinor > 1) ||
|
||||||
(wndconfig->glMajor == 3 && wndconfig->glMinor > 3))
|
(wndconfig->glMajor == 3 && wndconfig->glMinor > 3))
|
||||||
@ -405,8 +402,8 @@ GLboolean _glfwRefreshContextAttribs(void)
|
|||||||
else if (glfwExtensionSupported("GL_ARB_debug_output"))
|
else if (glfwExtensionSupported("GL_ARB_debug_output"))
|
||||||
{
|
{
|
||||||
// HACK: This is a workaround for older drivers (pre KHR_debug)
|
// HACK: This is a workaround for older drivers (pre KHR_debug)
|
||||||
// not setting the debug bit in the context flags for debug
|
// not setting the debug bit in the context flags for
|
||||||
// contexts
|
// debug contexts
|
||||||
window->glDebug = GL_TRUE;
|
window->glDebug = GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,6 +419,14 @@ GLboolean _glfwRefreshContextAttribs(void)
|
|||||||
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
|
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||||
else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
|
else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
|
||||||
window->glProfile = GLFW_OPENGL_CORE_PROFILE;
|
window->glProfile = GLFW_OPENGL_CORE_PROFILE;
|
||||||
|
else if (glfwExtensionSupported("GL_ARB_compatibility"))
|
||||||
|
{
|
||||||
|
// HACK: This is a workaround for the compatibility profile bit
|
||||||
|
// not being set in the context flags if an OpenGL 3.2+
|
||||||
|
// context was created without having requested a specific
|
||||||
|
// version
|
||||||
|
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read back robustness strategy
|
// Read back robustness strategy
|
||||||
@ -569,7 +574,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension == NULL || *extension == '\0')
|
if (!extension || *extension == '\0')
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE, NULL);
|
_glfwInputError(GLFW_INVALID_VALUE, NULL);
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -580,12 +585,16 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
|||||||
// Check if extension is in the old style OpenGL extensions string
|
// Check if extension is in the old style OpenGL extensions string
|
||||||
|
|
||||||
extensions = glGetString(GL_EXTENSIONS);
|
extensions = glGetString(GL_EXTENSIONS);
|
||||||
if (extensions != NULL)
|
if (!extensions)
|
||||||
{
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Failed to retrieve extension string");
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (_glfwStringInExtensionString(extension, extensions))
|
if (_glfwStringInExtensionString(extension, extensions))
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#if defined(_GLFW_USE_OPENGL)
|
#if defined(_GLFW_USE_OPENGL)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -598,11 +607,16 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
|||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (strcmp((const char*) window->GetStringi(GL_EXTENSIONS, i),
|
const char* en = (const char*) window->GetStringi(GL_EXTENSIONS, i);
|
||||||
extension) == 0)
|
if (!en)
|
||||||
{
|
{
|
||||||
return GL_TRUE;
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Failed to retrieve extension string %i", i);
|
||||||
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(en, extension) == 0)
|
||||||
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // _GLFW_USE_OPENGL
|
#endif // _GLFW_USE_OPENGL
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 EGL - www.glfw.org
|
||||||
// Platform: EGL
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -246,7 +243,7 @@ void _glfwTerminateContextAPI(void)
|
|||||||
{ \
|
{ \
|
||||||
attribs[index++] = attribName; \
|
attribs[index++] = attribName; \
|
||||||
attribs[index++] = attribValue; \
|
attribs[index++] = attribValue; \
|
||||||
assert(index < sizeof(attribs) / sizeof(attribs[0])); \
|
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for creation of the OpenGL context
|
// Prepare for creation of the OpenGL context
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 EGL - www.glfw.org
|
||||||
// Platform: EGL
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
exec_prefix=${prefix}
|
exec_prefix=${prefix}
|
||||||
includedir=${prefix}/include
|
includedir=${prefix}/include
|
||||||
libdir=${exec_prefix}/lib
|
libdir=${exec_prefix}/lib@LIB_SUFFIX@
|
||||||
|
|
||||||
Name: GLFW
|
Name: GLFW
|
||||||
Description: A portable library for OpenGL, window and input
|
Description: A portable library for OpenGL, window and input
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
@ -26,13 +23,15 @@
|
|||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// As config.h.in, this file is used by CMake to produce the config.h shared
|
// As glfw_config.h.in, this file is used by CMake to produce the
|
||||||
// configuration header file. If you are adding a feature requiring
|
// glfw_config.h configuration header file. If you are adding a feature
|
||||||
// conditional compilation, this is the proper place to add the macros.
|
// requiring conditional compilation, this is where to add the macro.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// As config.h, this file defines compile-time build options and macros for
|
// As glfw_config.h, this file defines compile-time option macros for a
|
||||||
// all platforms supported by GLFW. As this is a generated file, don't modify
|
// specific platform and development environment. If you are using the
|
||||||
// it. Instead, you should modify the config.h.in file.
|
// GLFW CMake files, modify glfw_config.h.in instead of this file. If you
|
||||||
|
// are using your own build system, make this file define the appropriate
|
||||||
|
// macros in whatever way is suitable.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
// Define this to 1 if building GLFW for X11
|
// Define this to 1 if building GLFW for X11
|
||||||
@ -56,6 +55,10 @@
|
|||||||
|
|
||||||
// Define this to 1 to disable dynamic loading of winmm
|
// Define this to 1 to disable dynamic loading of winmm
|
||||||
#cmakedefine _GLFW_NO_DLOAD_WINMM
|
#cmakedefine _GLFW_NO_DLOAD_WINMM
|
||||||
|
// Define this to 1 if glfwSwapInterval should ignore DWM compositing status
|
||||||
|
#cmakedefine _GLFW_USE_DWM_SWAP_INTERVAL
|
||||||
|
// Define this to 1 to force use of high-performance GPU on Optimus systems
|
||||||
|
#cmakedefine _GLFW_USE_OPTIMUS_HPG
|
||||||
|
|
||||||
// Define this to 1 if glXGetProcAddress is available
|
// Define this to 1 if glXGetProcAddress is available
|
||||||
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
|
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
|
||||||
@ -78,6 +81,3 @@
|
|||||||
// Define this to 1 if using OpenGL ES 2.0 as the client library
|
// Define this to 1 if using OpenGL ES 2.0 as the client library
|
||||||
#cmakedefine _GLFW_USE_GLESV2
|
#cmakedefine _GLFW_USE_GLESV2
|
||||||
|
|
||||||
// The GLFW version as used by glfwGetVersionString
|
|
||||||
#define _GLFW_VERSION_FULL "@GLFW_VERSION_FULL@"
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 GLX - www.glfw.org
|
||||||
// Platform: X11/GLX
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -45,14 +42,6 @@ void (*glXGetProcAddressEXT(const GLubyte* procName))();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Error handler used when creating a context
|
|
||||||
//
|
|
||||||
static int errorHandler(Display *display, XErrorEvent* event)
|
|
||||||
{
|
|
||||||
_glfw.glx.errorCode = event->error_code;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the specified attribute of the specified GLXFBConfig
|
// Returns the specified attribute of the specified GLXFBConfig
|
||||||
// NOTE: Do not call this unless we have found GLX 1.3+ or GLX_SGIX_fbconfig
|
// NOTE: Do not call this unless we have found GLX 1.3+ or GLX_SGIX_fbconfig
|
||||||
//
|
//
|
||||||
@ -352,7 +341,7 @@ void _glfwTerminateContextAPI(void)
|
|||||||
{ \
|
{ \
|
||||||
attribs[index++] = attribName; \
|
attribs[index++] = attribName; \
|
||||||
attribs[index++] = attribValue; \
|
attribs[index++] = attribValue; \
|
||||||
assert(index < sizeof(attribs) / sizeof(attribs[0])); \
|
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for creation of the OpenGL context
|
// Prepare for creation of the OpenGL context
|
||||||
@ -397,7 +386,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
!_glfw.glx.ARB_create_context_profile ||
|
!_glfw.glx.ARB_create_context_profile ||
|
||||||
!_glfw.glx.EXT_create_context_es2_profile)
|
!_glfw.glx.EXT_create_context_es2_profile)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
"GLX: OpenGL ES requested but "
|
"GLX: OpenGL ES requested but "
|
||||||
"GLX_EXT_create_context_es2_profile is unavailable");
|
"GLX_EXT_create_context_es2_profile is unavailable");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -427,8 +416,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.glx.errorCode = Success;
|
_glfwGrabXErrorHandler();
|
||||||
XSetErrorHandler(errorHandler);
|
|
||||||
|
|
||||||
if (_glfw.glx.ARB_create_context)
|
if (_glfw.glx.ARB_create_context)
|
||||||
{
|
{
|
||||||
@ -469,8 +457,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||||
{
|
{
|
||||||
// NOTE: Only request an explicitly versioned context when
|
// NOTE: Only request an explicitly versioned context when
|
||||||
// necessary, as explicitly requesting version 1.0 does not always
|
// necessary, as explicitly requesting version 1.0 does not
|
||||||
// return the highest available version
|
// always return the highest available version
|
||||||
|
|
||||||
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
||||||
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
||||||
@ -497,9 +485,10 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (window->glx.context == NULL)
|
if (window->glx.context == NULL)
|
||||||
{
|
{
|
||||||
// HACK: This is a fallback for the broken Mesa implementation of
|
// HACK: This is a fallback for the broken Mesa implementation of
|
||||||
// GLX_ARB_create_context_profile, which fails default 1.0 context
|
// GLX_ARB_create_context_profile, which fails default 1.0
|
||||||
// creation with a GLXBadProfileARB error in violation of the spec
|
// context creation with a GLXBadProfileARB error in violation
|
||||||
if (_glfw.glx.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
|
// of the extension spec
|
||||||
|
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
|
||||||
wndconfig->clientAPI == GLFW_OPENGL_API &&
|
wndconfig->clientAPI == GLFW_OPENGL_API &&
|
||||||
wndconfig->glProfile == GLFW_OPENGL_ANY_PROFILE &&
|
wndconfig->glProfile == GLFW_OPENGL_ANY_PROFILE &&
|
||||||
wndconfig->glForward == GL_FALSE)
|
wndconfig->glForward == GL_FALSE)
|
||||||
@ -511,19 +500,11 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
window->glx.context = createLegacyContext(window, native, share);
|
window->glx.context = createLegacyContext(window, native, share);
|
||||||
|
|
||||||
XSetErrorHandler(NULL);
|
_glfwReleaseXErrorHandler();
|
||||||
|
|
||||||
if (window->glx.context == NULL)
|
if (window->glx.context == NULL)
|
||||||
{
|
{
|
||||||
char buffer[8192];
|
_glfwInputXError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context");
|
||||||
XGetErrorText(_glfw.x11.display,
|
|
||||||
_glfw.glx.errorCode,
|
|
||||||
buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"GLX: Failed to create context: %s",
|
|
||||||
buffer);
|
|
||||||
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 GLX - www.glfw.org
|
||||||
// Platform: X11/GLX
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -97,9 +94,6 @@ typedef struct _GLFWlibraryGLX
|
|||||||
// TLS key for per-thread current context/window
|
// TLS key for per-thread current context/window
|
||||||
pthread_key_t current;
|
pthread_key_t current;
|
||||||
|
|
||||||
// GLX error code received by Xlib error callback
|
|
||||||
int errorCode;
|
|
||||||
|
|
||||||
// GLX extensions
|
// GLX extensions
|
||||||
PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
|
PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
|
||||||
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||||
|
14
src/init.c
14
src/init.c
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -133,7 +130,7 @@ GLFWAPI int glfwInit(void)
|
|||||||
_glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
|
_glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
|
||||||
if (_glfw.monitors == NULL)
|
if (_glfw.monitors == NULL)
|
||||||
{
|
{
|
||||||
_glfwErrorCallback(GLFW_PLATFORM_ERROR, "No monitors found");
|
_glfwInputError(GLFW_PLATFORM_ERROR, "No monitors found");
|
||||||
_glfwPlatformTerminate();
|
_glfwPlatformTerminate();
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
@ -153,6 +150,8 @@ GLFWAPI void glfwTerminate(void)
|
|||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
|
||||||
|
|
||||||
// Close all remaining windows
|
// Close all remaining windows
|
||||||
while (_glfw.windowListHead)
|
while (_glfw.windowListHead)
|
||||||
glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
|
glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
|
||||||
@ -192,8 +191,7 @@ GLFWAPI const char* glfwGetVersionString(void)
|
|||||||
|
|
||||||
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
|
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
|
||||||
{
|
{
|
||||||
GLFWerrorfun previous = _glfwErrorCallback;
|
_GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun);
|
||||||
_glfwErrorCallback = cbfun;
|
return cbfun;
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
69
src/input.c
69
src/input.c
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -38,7 +35,7 @@
|
|||||||
//
|
//
|
||||||
static void setCursorMode(_GLFWwindow* window, int newMode)
|
static void setCursorMode(_GLFWwindow* window, int newMode)
|
||||||
{
|
{
|
||||||
int oldMode;
|
const int oldMode = window->cursorMode;
|
||||||
|
|
||||||
if (newMode != GLFW_CURSOR_NORMAL &&
|
if (newMode != GLFW_CURSOR_NORMAL &&
|
||||||
newMode != GLFW_CURSOR_HIDDEN &&
|
newMode != GLFW_CURSOR_HIDDEN &&
|
||||||
@ -48,10 +45,11 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldMode = window->cursorMode;
|
|
||||||
if (oldMode == newMode)
|
if (oldMode == newMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
window->cursorMode = newMode;
|
||||||
|
|
||||||
if (window == _glfw.focusedWindow)
|
if (window == _glfw.focusedWindow)
|
||||||
{
|
{
|
||||||
if (oldMode == GLFW_CURSOR_DISABLED)
|
if (oldMode == GLFW_CURSOR_DISABLED)
|
||||||
@ -74,8 +72,6 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
|
|||||||
|
|
||||||
_glfwPlatformSetCursorMode(window, newMode);
|
_glfwPlatformSetCursorMode(window, newMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
window->cursorMode = newMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set sticky keys mode for the specified window
|
// Set sticky keys mode for the specified window
|
||||||
@ -152,16 +148,13 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
|||||||
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwInputChar(_GLFWwindow* window, unsigned int character)
|
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint)
|
||||||
{
|
{
|
||||||
if (character == -1)
|
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
||||||
return;
|
|
||||||
|
|
||||||
if (character < 32 || (character > 126 && character < 160))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window->callbacks.character)
|
if (window->callbacks.character)
|
||||||
window->callbacks.character((GLFWwindow*) window, character);
|
window->callbacks.character((GLFWwindow*) window, codepoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
||||||
@ -358,77 +351,53 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
|||||||
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWkeyfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.key, cbfun);
|
||||||
previous = window->callbacks.key;
|
return cbfun;
|
||||||
window->callbacks.key = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
|
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWcharfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.character, cbfun);
|
||||||
previous = window->callbacks.character;
|
return cbfun;
|
||||||
window->callbacks.character = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
||||||
GLFWmousebuttonfun cbfun)
|
GLFWmousebuttonfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWmousebuttonfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun);
|
||||||
previous = window->callbacks.mouseButton;
|
return cbfun;
|
||||||
window->callbacks.mouseButton = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||||
GLFWcursorposfun cbfun)
|
GLFWcursorposfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWcursorposfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun);
|
||||||
previous = window->callbacks.cursorPos;
|
return cbfun;
|
||||||
window->callbacks.cursorPos = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
|
GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
|
||||||
GLFWcursorenterfun cbfun)
|
GLFWcursorenterfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWcursorenterfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun);
|
||||||
previous = window->callbacks.cursorEnter;
|
return cbfun;
|
||||||
window->callbacks.cursorEnter = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
|
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
|
||||||
GLFWscrollfun cbfun)
|
GLFWscrollfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWscrollfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun);
|
||||||
previous = window->callbacks.scroll;
|
return cbfun;
|
||||||
window->callbacks.scroll = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
|
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -32,7 +29,11 @@
|
|||||||
#define _internal_h_
|
#define _internal_h_
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#if defined(_GLFW_USE_CONFIG_H)
|
||||||
|
#include "glfw_config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _GLFW_VERSION_NUMBER "3.0.4"
|
||||||
|
|
||||||
#if defined(_GLFW_USE_OPENGL)
|
#if defined(_GLFW_USE_OPENGL)
|
||||||
// This is the default for glfw3.h
|
// This is the default for glfw3.h
|
||||||
@ -120,6 +121,15 @@ typedef struct _GLFWmonitor _GLFWmonitor;
|
|||||||
return x; \
|
return x; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Swaps the provided pointers
|
||||||
|
#define _GLFW_SWAP_POINTERS(x, y) \
|
||||||
|
{ \
|
||||||
|
void* t; \
|
||||||
|
t = x; \
|
||||||
|
x = y; \
|
||||||
|
y = t; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Internal types
|
// Internal types
|
||||||
@ -299,7 +309,10 @@ struct _GLFWlibrary
|
|||||||
|
|
||||||
_GLFWmonitor** monitors;
|
_GLFWmonitor** monitors;
|
||||||
int monitorCount;
|
int monitorCount;
|
||||||
GLFWmonitorfun monitorCallback;
|
|
||||||
|
struct {
|
||||||
|
GLFWmonitorfun monitor;
|
||||||
|
} callbacks;
|
||||||
|
|
||||||
// This is defined in the window API's platform.h
|
// This is defined in the window API's platform.h
|
||||||
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
|
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
|
||||||
@ -616,10 +629,10 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
|||||||
|
|
||||||
/*! @brief Notifies shared code of a Unicode character input event.
|
/*! @brief Notifies shared code of a Unicode character input event.
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] character The Unicode code point of the input character.
|
* @param[in] codepoint The Unicode code point of the input character.
|
||||||
* @ingroup event
|
* @ingroup event
|
||||||
*/
|
*/
|
||||||
void _glfwInputChar(_GLFWwindow* window, unsigned int character);
|
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint);
|
||||||
|
|
||||||
/*! @brief Notifies shared code of a scroll event.
|
/*! @brief Notifies shared code of a scroll event.
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
@ -750,11 +763,18 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
|
|||||||
*/
|
*/
|
||||||
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
||||||
|
|
||||||
/*! @ingroup utility
|
/*! @brief Allocates and returns a monitor object with the specified name
|
||||||
|
* and dimensions.
|
||||||
|
* @param[in] name The name of the monitor.
|
||||||
|
* @param[in] widthMM The width, in mm, of the monitor's display area.
|
||||||
|
* @param[in] heightMM The height, in mm, of the monitor's display area.
|
||||||
|
* @return The newly created object.
|
||||||
|
* @ingroup utility
|
||||||
*/
|
*/
|
||||||
_GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM);
|
_GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM);
|
||||||
|
|
||||||
/*! @ingroup utility
|
/*! @brief Frees a monitor object and any data associated with it.
|
||||||
|
* @ingroup utility
|
||||||
*/
|
*/
|
||||||
void _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
void _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL framework
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -144,8 +141,8 @@ void _glfwInputMonitorChange(void)
|
|||||||
window->monitor = NULL;
|
window->monitor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.monitorCallback)
|
if (_glfw.callbacks.monitor)
|
||||||
_glfw.monitorCallback((GLFWmonitor*) monitors[i], GLFW_DISCONNECTED);
|
_glfw.callbacks.monitor((GLFWmonitor*) monitors[i], GLFW_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find and report newly connected monitors (not in the old list)
|
// Find and report newly connected monitors (not in the old list)
|
||||||
@ -166,8 +163,8 @@ void _glfwInputMonitorChange(void)
|
|||||||
if (j < monitorCount)
|
if (j < monitorCount)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (_glfw.monitorCallback)
|
if (_glfw.callbacks.monitor)
|
||||||
_glfw.monitorCallback((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED);
|
_glfw.callbacks.monitor((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwDestroyMonitors(monitors, monitorCount);
|
_glfwDestroyMonitors(monitors, monitorCount);
|
||||||
@ -328,12 +325,9 @@ GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
|||||||
|
|
||||||
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
||||||
{
|
{
|
||||||
GLFWmonitorfun previous;
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);
|
||||||
previous = _glfw.monitorCallback;
|
return cbfun;
|
||||||
_glfw.monitorCallback = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
|
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: Cocoa/NSOpenGL
|
|
||||||
// API Version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
@ -43,7 +40,7 @@ int _glfwInitContextAPI(void)
|
|||||||
if (pthread_key_create(&_glfw.nsgl.current, NULL) != 0)
|
if (pthread_key_create(&_glfw.nsgl.current, NULL) != 0)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"NSOpenGL: Failed to create context TLS");
|
"NSGL: Failed to create context TLS");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +71,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
unsigned int attributeCount = 0;
|
unsigned int attributeCount = 0;
|
||||||
|
|
||||||
// Mac OS X needs non-zero color size, so set resonable values
|
// OS X needs non-zero color size, so set resonable values
|
||||||
int colorBits = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits;
|
int colorBits = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits;
|
||||||
if (colorBits == 0)
|
if (colorBits == 0)
|
||||||
colorBits = 24;
|
colorBits = 24;
|
||||||
@ -84,18 +81,16 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSOpenGL: This API does not support OpenGL ES");
|
"NSGL: This API does not support OpenGL ES");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
// Fail if any OpenGL version above 2.1 other than 3.2 was requested
|
if (wndconfig->glMajor == 3 && wndconfig->glMinor < 2)
|
||||||
if (wndconfig->glMajor > 3 ||
|
|
||||||
(wndconfig->glMajor == 3 && wndconfig->glMinor != 2))
|
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSOpenGL: The targeted version of Mac OS X does not "
|
"NSGL: The targeted version of OS X does not "
|
||||||
"support any OpenGL version above 2.1 except 3.2");
|
"support OpenGL 3.0 or 3.1");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,18 +99,18 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (!wndconfig->glForward)
|
if (!wndconfig->glForward)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSOpenGL: The targeted version of Mac OS X only "
|
"NSGL: The targeted version of OS X only "
|
||||||
"supports OpenGL 3.2 contexts if they are "
|
"supports OpenGL 3.2 and later versions if they "
|
||||||
"forward-compatible");
|
"are forward-compatible");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE)
|
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSOpenGL: The targeted version of Mac OS X only "
|
"NSGL: The targeted version of OS X only "
|
||||||
"supports OpenGL 3.2 contexts if they use the "
|
"supports OpenGL 3.2 and later versions if they "
|
||||||
"core profile");
|
"use the core profile");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +119,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (wndconfig->glMajor > 2)
|
if (wndconfig->glMajor > 2)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSOpenGL: The targeted version of Mac OS X does not "
|
"NSGL: The targeted version of OS X does not "
|
||||||
"support OpenGL version 3.0 or above");
|
"support OpenGL version 3.0 or above");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
@ -134,7 +129,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (wndconfig->glRobustness)
|
if (wndconfig->glRobustness)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSOpenGL: Mac OS X does not support OpenGL robustness "
|
"NSGL: OS X does not support OpenGL robustness "
|
||||||
"strategies");
|
"strategies");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
@ -195,7 +190,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (window->nsgl.pixelFormat == nil)
|
if (window->nsgl.pixelFormat == nil)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"NSOpenGL: Failed to create OpenGL pixel format");
|
"NSGL: Failed to create OpenGL pixel format");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +205,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
if (window->nsgl.context == nil)
|
if (window->nsgl.context == nil)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"NSOpenGL: Failed to create OpenGL context");
|
"NSGL: Failed to create OpenGL context");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 OS X - www.glfw.org
|
||||||
// Platform: NSOpenGL
|
|
||||||
// API Version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 WGL - www.glfw.org
|
||||||
// Platform: Win32/WGL
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -332,7 +329,7 @@ void _glfwTerminateContextAPI(void)
|
|||||||
{ \
|
{ \
|
||||||
attribs[index++] = attribName; \
|
attribs[index++] = attribName; \
|
||||||
attribs[index++] = attribValue; \
|
attribs[index++] = attribValue; \
|
||||||
assert(index < sizeof(attribs) / sizeof(attribs[0])); \
|
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for creation of the OpenGL context
|
// Prepare for creation of the OpenGL context
|
||||||
@ -532,7 +529,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
|
|||||||
!window->wgl.ARB_create_context_profile ||
|
!window->wgl.ARB_create_context_profile ||
|
||||||
!window->wgl.EXT_create_context_es2_profile)
|
!window->wgl.EXT_create_context_es2_profile)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
"WGL: OpenGL ES requested but "
|
"WGL: OpenGL ES requested but "
|
||||||
"WGL_ARB_create_context_es2_profile is unavailable");
|
"WGL_ARB_create_context_es2_profile is unavailable");
|
||||||
return _GLFW_RECREATION_IMPOSSIBLE;
|
return _GLFW_RECREATION_IMPOSSIBLE;
|
||||||
@ -600,12 +597,14 @@ void _glfwPlatformSwapInterval(int interval)
|
|||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
||||||
|
|
||||||
|
#if !defined(_GLFW_USE_DWM_SWAP_INTERVAL)
|
||||||
if (_glfwIsCompositionEnabled())
|
if (_glfwIsCompositionEnabled())
|
||||||
{
|
{
|
||||||
// Don't enabled vsync when desktop compositing is enabled, as it leads
|
// Don't enabled vsync when desktop compositing is enabled, as it leads
|
||||||
// to frame jitter
|
// to frame jitter
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (window->wgl.EXT_swap_control)
|
if (window->wgl.EXT_swap_control)
|
||||||
window->wgl.SwapIntervalEXT(interval);
|
window->wgl.SwapIntervalEXT(interval);
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 WGL - www.glfw.org
|
||||||
// Platform: WGL
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: Win32
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: Win32
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: Win32/WGL
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -39,6 +36,15 @@
|
|||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_GLFW_USE_OPTIMUS_HPG)
|
||||||
|
|
||||||
|
// Applications exporting this symbol with this value will be automatically
|
||||||
|
// directed to the high-performance GPU on nVidia Optimus systems
|
||||||
|
//
|
||||||
|
GLFWAPI DWORD NvOptimusEnablement = 0x00000001;
|
||||||
|
|
||||||
|
#endif // _GLFW_USE_OPTIMUS_HPG
|
||||||
|
|
||||||
#if defined(_GLFW_BUILD_DLL)
|
#if defined(_GLFW_BUILD_DLL)
|
||||||
|
|
||||||
// GLFW DLL entry point
|
// GLFW DLL entry point
|
||||||
@ -240,7 +246,7 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
const char* version = _GLFW_VERSION_FULL " Win32"
|
const char* version = _GLFW_VERSION_NUMBER " Win32"
|
||||||
#if defined(_GLFW_WGL)
|
#if defined(_GLFW_WGL)
|
||||||
" WGL"
|
" WGL"
|
||||||
#elif defined(_GLFW_EGL)
|
#elif defined(_GLFW_EGL)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: Win32
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -100,7 +97,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
axes[(*count)++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax);
|
axes[(*count)++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax);
|
||||||
axes[(*count)++] = -calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax);
|
axes[(*count)++] = calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax);
|
||||||
|
|
||||||
if (jc.wCaps & JOYCAPS_HASZ)
|
if (jc.wCaps & JOYCAPS_HASZ)
|
||||||
axes[(*count)++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax);
|
axes[(*count)++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax);
|
||||||
@ -112,7 +109,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
|||||||
axes[(*count)++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax);
|
axes[(*count)++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax);
|
||||||
|
|
||||||
if (jc.wCaps & JOYCAPS_HASV)
|
if (jc.wCaps & JOYCAPS_HASV)
|
||||||
axes[(*count)++] = -calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax);
|
axes[(*count)++] = calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax);
|
||||||
|
|
||||||
return axes;
|
return axes;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: X11 (Unix)
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: Win32
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -55,10 +52,15 @@
|
|||||||
#define UNICODE
|
#define UNICODE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW requires Windows XP
|
// GLFW requires Windows XP or later
|
||||||
#ifndef WINVER
|
#if WINVER < 0x0501
|
||||||
|
#undef WINVER
|
||||||
#define WINVER 0x0501
|
#define WINVER 0x0501
|
||||||
#endif
|
#endif
|
||||||
|
#if _WIN32_WINNT < 0x0501
|
||||||
|
#undef _WIN32_WINNT
|
||||||
|
#define _WIN32_WINNT 0x0501
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
@ -155,7 +157,7 @@ typedef struct _GLFWwindowWin32
|
|||||||
GLboolean cursorCentered;
|
GLboolean cursorCentered;
|
||||||
GLboolean cursorInside;
|
GLboolean cursorInside;
|
||||||
GLboolean cursorHidden;
|
GLboolean cursorHidden;
|
||||||
double oldCursorX, oldCursorY;
|
int oldCursorX, oldCursorY;
|
||||||
} _GLFWwindowWin32;
|
} _GLFWwindowWin32;
|
||||||
|
|
||||||
|
|
||||||
@ -174,8 +176,7 @@ typedef struct _GLFWlibraryWin32
|
|||||||
struct {
|
struct {
|
||||||
GLboolean hasPC;
|
GLboolean hasPC;
|
||||||
double resolution;
|
double resolution;
|
||||||
unsigned int t0_32;
|
unsigned __int64 base;
|
||||||
__int64 t0_64;
|
|
||||||
} timer;
|
} timer;
|
||||||
|
|
||||||
#ifndef _GLFW_NO_DLOAD_WINMM
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: Win32
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -31,6 +28,21 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Return raw time
|
||||||
|
//
|
||||||
|
static unsigned __int64 getRawTime(void)
|
||||||
|
{
|
||||||
|
if (_glfw.win32.timer.hasPC)
|
||||||
|
{
|
||||||
|
unsigned __int64 time;
|
||||||
|
QueryPerformanceCounter((LARGE_INTEGER*) &time);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return (unsigned __int64) _glfw_timeGetTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -39,20 +51,20 @@
|
|||||||
//
|
//
|
||||||
void _glfwInitTimer(void)
|
void _glfwInitTimer(void)
|
||||||
{
|
{
|
||||||
__int64 freq;
|
unsigned __int64 frequency;
|
||||||
|
|
||||||
if (QueryPerformanceFrequency((LARGE_INTEGER*) &freq))
|
if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
|
||||||
{
|
{
|
||||||
_glfw.win32.timer.hasPC = GL_TRUE;
|
_glfw.win32.timer.hasPC = GL_TRUE;
|
||||||
_glfw.win32.timer.resolution = 1.0 / (double) freq;
|
_glfw.win32.timer.resolution = 1.0 / (double) frequency;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &_glfw.win32.timer.t0_64);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_glfw.win32.timer.hasPC = GL_FALSE;
|
_glfw.win32.timer.hasPC = GL_FALSE;
|
||||||
_glfw.win32.timer.resolution = 0.001; // winmm resolution is 1 ms
|
_glfw.win32.timer.resolution = 0.001; // winmm resolution is 1 ms
|
||||||
_glfw.win32.timer.t0_32 = _glfw_timeGetTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfw.win32.timer.base = getRawTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -62,30 +74,13 @@ void _glfwInitTimer(void)
|
|||||||
|
|
||||||
double _glfwPlatformGetTime(void)
|
double _glfwPlatformGetTime(void)
|
||||||
{
|
{
|
||||||
double t;
|
return (double) (getRawTime() - _glfw.win32.timer.base) *
|
||||||
__int64 t_64;
|
_glfw.win32.timer.resolution;
|
||||||
|
|
||||||
if (_glfw.win32.timer.hasPC)
|
|
||||||
{
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &t_64);
|
|
||||||
t = (double)(t_64 - _glfw.win32.timer.t0_64);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
t = (double)(_glfw_timeGetTime() - _glfw.win32.timer.t0_32);
|
|
||||||
|
|
||||||
return t * _glfw.win32.timer.resolution;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetTime(double t)
|
void _glfwPlatformSetTime(double time)
|
||||||
{
|
{
|
||||||
__int64 t_64;
|
_glfw.win32.timer.base = getRawTime() -
|
||||||
|
(unsigned __int64) (time / _glfw.win32.timer.resolution);
|
||||||
if (_glfw.win32.timer.hasPC)
|
|
||||||
{
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &t_64);
|
|
||||||
_glfw.win32.timer.t0_64 = t_64 - (__int64) (t / _glfw.win32.timer.resolution);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_glfw.win32.timer.t0_32 = _glfw_timeGetTime() - (int)(t * 1000.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 Win32 - www.glfw.org
|
||||||
// Platform: Win32/WGL
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -392,12 +389,23 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
BOOL iconified = HIWORD(wParam) ? TRUE : FALSE;
|
BOOL iconified = HIWORD(wParam) ? TRUE : FALSE;
|
||||||
|
|
||||||
if (focused && iconified)
|
if (focused && iconified)
|
||||||
|
{
|
||||||
|
if (window->iconified && _glfw.focusedWindow != window)
|
||||||
|
{
|
||||||
|
// This is a workaround for window restoration using the
|
||||||
|
// Win+D hot key leading to windows being told they're
|
||||||
|
// focused and iconified and then never told they're
|
||||||
|
// restored
|
||||||
|
iconified = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// This is a workaround for window iconification using the
|
// This is a workaround for window iconification using the
|
||||||
// taskbar leading to windows being told they're focused and
|
// taskbar leading to windows being told they're focused and
|
||||||
// iconified and then never told they're defocused
|
// iconified and then never told they're defocused
|
||||||
focused = FALSE;
|
focused = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!focused && _glfw.focusedWindow == window)
|
if (!focused && _glfw.focusedWindow == window)
|
||||||
{
|
{
|
||||||
@ -485,6 +493,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
|
case WM_SYSCHAR:
|
||||||
{
|
{
|
||||||
_glfwInputChar(window, (unsigned int) wParam);
|
_glfwInputChar(window, (unsigned int) wParam);
|
||||||
return 0;
|
return 0;
|
||||||
@ -597,7 +606,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
if (newCursorX != window->win32.oldCursorX ||
|
if (newCursorX != window->win32.oldCursorX ||
|
||||||
newCursorY != window->win32.oldCursorY)
|
newCursorY != window->win32.oldCursorY)
|
||||||
{
|
{
|
||||||
double x, y;
|
int x, y;
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
@ -658,8 +667,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED &&
|
||||||
|
_glfw.focusedWindow == window)
|
||||||
|
{
|
||||||
updateClipRect(window);
|
updateClipRect(window);
|
||||||
|
}
|
||||||
|
|
||||||
_glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
|
_glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
|
||||||
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
|
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
|
||||||
@ -668,10 +680,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED &&
|
||||||
|
_glfw.focusedWindow == window)
|
||||||
|
{
|
||||||
updateClipRect(window);
|
updateClipRect(window);
|
||||||
|
}
|
||||||
|
|
||||||
_glfwInputWindowPos(window, LOWORD(lParam), HIWORD(lParam));
|
// NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
|
||||||
|
// those macros do not handle negative window positions correctly
|
||||||
|
_glfwInputWindowPos(window,
|
||||||
|
GET_X_LPARAM(lParam),
|
||||||
|
GET_Y_LPARAM(lParam));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,8 +702,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_HIDDEN &&
|
if (window->cursorMode != GLFW_CURSOR_NORMAL &&
|
||||||
window->win32.handle == GetForegroundWindow() &&
|
_glfw.focusedWindow == window &&
|
||||||
LOWORD(lParam) == HTCLIENT)
|
LOWORD(lParam) == HTCLIENT)
|
||||||
{
|
{
|
||||||
SetCursor(NULL);
|
SetCursor(NULL);
|
||||||
@ -941,7 +960,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
// First we clear the current context (the one we just created)
|
// First we clear the current context (the one we just created)
|
||||||
// This is usually done by glfwDestroyWindow, but as we're not doing
|
// This is usually done by glfwDestroyWindow, but as we're not doing
|
||||||
// full window destruction, it's duplicated here
|
// full GLFW window destruction, it's duplicated here
|
||||||
_glfwPlatformMakeContextCurrent(NULL);
|
_glfwPlatformMakeContextCurrent(NULL);
|
||||||
|
|
||||||
// Next destroy the Win32 window and WGL context (without resetting or
|
// Next destroy the Win32 window and WGL context (without resetting or
|
||||||
@ -1143,8 +1162,8 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
|||||||
ClientToScreen(window->win32.handle, &pos);
|
ClientToScreen(window->win32.handle, &pos);
|
||||||
SetCursorPos(pos.x, pos.y);
|
SetCursorPos(pos.x, pos.y);
|
||||||
|
|
||||||
window->win32.oldCursorX = xpos;
|
window->win32.oldCursorX = (int) xpos;
|
||||||
window->win32.oldCursorY = ypos;
|
window->win32.oldCursorY = (int) ypos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||||
|
71
src/window.c
71
src/window.c
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 - www.glfw.org
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -158,7 +155,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
if (width <= 0 || height <= 0)
|
if (width <= 0 || height <= 0)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid window size");
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid window size");
|
||||||
return GL_FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up desired framebuffer config
|
// Set up desired framebuffer config
|
||||||
@ -196,7 +193,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
|
|
||||||
// Check the OpenGL bits of the window config
|
// Check the OpenGL bits of the window config
|
||||||
if (!_glfwIsValidContextConfig(&wndconfig))
|
if (!_glfwIsValidContextConfig(&wndconfig))
|
||||||
return GL_FALSE;
|
return NULL;
|
||||||
|
|
||||||
window = calloc(1, sizeof(_GLFWwindow));
|
window = calloc(1, sizeof(_GLFWwindow));
|
||||||
window->next = _glfw.windowListHead;
|
window->next = _glfw.windowListHead;
|
||||||
@ -229,7 +226,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GL_FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent((GLFWwindow*) window);
|
glfwMakeContextCurrent((GLFWwindow*) window);
|
||||||
@ -239,7 +236,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GL_FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the context against the requested parameters
|
// Verify the context against the requested parameters
|
||||||
@ -247,7 +244,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GL_FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clearing the front buffer to black to avoid garbage pixels left over
|
// Clearing the front buffer to black to avoid garbage pixels left over
|
||||||
@ -604,91 +601,63 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
|
|||||||
GLFWwindowposfun cbfun)
|
GLFWwindowposfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWwindowposfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
|
||||||
previous = window->callbacks.pos;
|
return cbfun;
|
||||||
window->callbacks.pos = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
|
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
|
||||||
GLFWwindowsizefun cbfun)
|
GLFWwindowsizefun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWwindowsizefun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
|
||||||
previous = window->callbacks.size;
|
return cbfun;
|
||||||
window->callbacks.size = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
|
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
|
||||||
GLFWwindowclosefun cbfun)
|
GLFWwindowclosefun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWwindowclosefun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
|
||||||
previous = window->callbacks.close;
|
return cbfun;
|
||||||
window->callbacks.close = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
|
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
|
||||||
GLFWwindowrefreshfun cbfun)
|
GLFWwindowrefreshfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWwindowrefreshfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
|
||||||
previous = window->callbacks.refresh;
|
return cbfun;
|
||||||
window->callbacks.refresh = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
|
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
|
||||||
GLFWwindowfocusfun cbfun)
|
GLFWwindowfocusfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWwindowfocusfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
|
||||||
previous = window->callbacks.focus;
|
return cbfun;
|
||||||
window->callbacks.focus = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
||||||
GLFWwindowiconifyfun cbfun)
|
GLFWwindowiconifyfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWwindowiconifyfun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
|
||||||
previous = window->callbacks.iconify;
|
return cbfun;
|
||||||
window->callbacks.iconify = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
|
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
|
||||||
GLFWframebuffersizefun cbfun)
|
GLFWframebuffersizefun cbfun)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
GLFWframebuffersizefun previous;
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
|
||||||
previous = window->callbacks.fbsize;
|
return cbfun;
|
||||||
window->callbacks.fbsize = cbfun;
|
|
||||||
return previous;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwPollEvents(void)
|
GLFWAPI void glfwPollEvents(void)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
@ -273,11 +270,11 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
||||||
_glfw.x11.COMPOUND_STRING,
|
_glfw.x11.COMPOUND_STRING,
|
||||||
XA_STRING };
|
XA_STRING };
|
||||||
const int formatCount = sizeof(formats) / sizeof(formats[0]);
|
const size_t formatCount = sizeof(formats) / sizeof(formats[0]);
|
||||||
|
|
||||||
if (_glfwFindWindowByHandle(XGetSelectionOwner(_glfw.x11.display,
|
if (_glfwFindWindowByHandle(XGetSelectionOwner(_glfw.x11.display,
|
||||||
_glfw.x11.CLIPBOARD)))
|
_glfw.x11.CLIPBOARD)))
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
//
|
//
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11/GLX
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -52,7 +49,7 @@ static int translateKey(int keyCode)
|
|||||||
// Note: This way we always force "NumLock = ON", which is intentional
|
// Note: This way we always force "NumLock = ON", which is intentional
|
||||||
// since the returned key code should correspond to a physical
|
// since the returned key code should correspond to a physical
|
||||||
// location.
|
// location.
|
||||||
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 1, 0);
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 1);
|
||||||
switch (keySym)
|
switch (keySym)
|
||||||
{
|
{
|
||||||
case XK_KP_0: return GLFW_KEY_KP_0;
|
case XK_KP_0: return GLFW_KEY_KP_0;
|
||||||
@ -412,6 +409,8 @@ static void detectEWMH(void)
|
|||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING");
|
||||||
_glfw.x11.NET_ACTIVE_WINDOW =
|
_glfw.x11.NET_ACTIVE_WINDOW =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
|
||||||
|
_glfw.x11.NET_WM_BYPASS_COMPOSITOR =
|
||||||
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_BYPASS_COMPOSITOR");
|
||||||
|
|
||||||
XFree(supportedAtoms);
|
XFree(supportedAtoms);
|
||||||
|
|
||||||
@ -568,7 +567,7 @@ static Cursor createNULLCursor(void)
|
|||||||
XColor col;
|
XColor col;
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
|
|
||||||
// TODO: Add error checks
|
_glfwGrabXErrorHandler();
|
||||||
|
|
||||||
cursormask = XCreatePixmap(_glfw.x11.display, _glfw.x11.root, 1, 1, 1);
|
cursormask = XCreatePixmap(_glfw.x11.display, _glfw.x11.root, 1, 1, 1);
|
||||||
xgc.function = GXclear;
|
xgc.function = GXclear;
|
||||||
@ -583,6 +582,14 @@ static Cursor createNULLCursor(void)
|
|||||||
XFreePixmap(_glfw.x11.display, cursormask);
|
XFreePixmap(_glfw.x11.display, cursormask);
|
||||||
XFreeGC(_glfw.x11.display, gc);
|
XFreeGC(_glfw.x11.display, gc);
|
||||||
|
|
||||||
|
_glfwReleaseXErrorHandler();
|
||||||
|
|
||||||
|
if (cursor == None)
|
||||||
|
{
|
||||||
|
_glfwInputXError(GLFW_PLATFORM_ERROR,
|
||||||
|
"X11: Failed to create null cursor");
|
||||||
|
}
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,6 +604,47 @@ static void terminateDisplay(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X error handler
|
||||||
|
//
|
||||||
|
static int errorHandler(Display *display, XErrorEvent* event)
|
||||||
|
{
|
||||||
|
_glfw.x11.errorCode = event->error_code;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Install the X error handler
|
||||||
|
//
|
||||||
|
void _glfwGrabXErrorHandler(void)
|
||||||
|
{
|
||||||
|
_glfw.x11.errorCode = Success;
|
||||||
|
XSetErrorHandler(errorHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the X error handler
|
||||||
|
//
|
||||||
|
void _glfwReleaseXErrorHandler(void)
|
||||||
|
{
|
||||||
|
// Synchronize to make sure all commands are processed
|
||||||
|
XSync(_glfw.x11.display, False);
|
||||||
|
XSetErrorHandler(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Report X error
|
||||||
|
//
|
||||||
|
void _glfwInputXError(int error, const char* message)
|
||||||
|
{
|
||||||
|
char buffer[8192];
|
||||||
|
XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
|
||||||
|
buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
_glfwInputError(error, "%s: %s", message, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
@ -649,7 +697,7 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
const char* version = _GLFW_VERSION_FULL " X11"
|
const char* version = _GLFW_VERSION_NUMBER " X11"
|
||||||
#if defined(_GLFW_GLX)
|
#if defined(_GLFW_GLX)
|
||||||
" GLX"
|
" GLX"
|
||||||
#elif defined(_GLFW_EGL)
|
#elif defined(_GLFW_EGL)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -128,15 +125,6 @@ static void pollJoystickEvents(void)
|
|||||||
case JS_EVENT_AXIS:
|
case JS_EVENT_AXIS:
|
||||||
_glfw.x11.joystick[i].axes[e.number] =
|
_glfw.x11.joystick[i].axes[e.number] =
|
||||||
(float) e.value / 32767.0f;
|
(float) e.value / 32767.0f;
|
||||||
|
|
||||||
// We need to change the sign for the Y axes, so that
|
|
||||||
// positive = up/forward, according to the GLFW spec.
|
|
||||||
if (e.number & 1)
|
|
||||||
{
|
|
||||||
_glfw.x11.joystick[i].axes[e.number] =
|
|
||||||
-_glfw.x11.joystick[i].axes[e.number];
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JS_EVENT_BUTTON:
|
case JS_EVENT_BUTTON:
|
||||||
@ -162,7 +150,8 @@ static void pollJoystickEvents(void)
|
|||||||
void _glfwInitJoysticks(void)
|
void _glfwInitJoysticks(void)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
int i, joy = 0;
|
int joy = 0;
|
||||||
|
size_t i;
|
||||||
regex_t regex;
|
regex_t regex;
|
||||||
DIR* dir;
|
DIR* dir;
|
||||||
const char* dirs[] =
|
const char* dirs[] =
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11 (Unix)
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -114,6 +111,10 @@ void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bestMode == ci->mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (monitor->x11.oldMode == None)
|
||||||
monitor->x11.oldMode = ci->mode;
|
monitor->x11.oldMode = ci->mode;
|
||||||
|
|
||||||
XRRSetCrtcConfig(_glfw.x11.display,
|
XRRSetCrtcConfig(_glfw.x11.display,
|
||||||
@ -140,6 +141,9 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
|||||||
XRRScreenResources* sr;
|
XRRScreenResources* sr;
|
||||||
XRRCrtcInfo* ci;
|
XRRCrtcInfo* ci;
|
||||||
|
|
||||||
|
if (monitor->x11.oldMode == None)
|
||||||
|
return;
|
||||||
|
|
||||||
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
|
||||||
@ -154,6 +158,8 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
|||||||
|
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
|
|
||||||
|
monitor->x11.oldMode = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
@ -120,6 +117,7 @@ typedef struct _GLFWlibraryX11
|
|||||||
Atom NET_WM_PING;
|
Atom NET_WM_PING;
|
||||||
Atom NET_WM_STATE;
|
Atom NET_WM_STATE;
|
||||||
Atom NET_WM_STATE_FULLSCREEN;
|
Atom NET_WM_STATE_FULLSCREEN;
|
||||||
|
Atom NET_WM_BYPASS_COMPOSITOR;
|
||||||
Atom NET_ACTIVE_WINDOW;
|
Atom NET_ACTIVE_WINDOW;
|
||||||
Atom MOTIF_WM_HINTS;
|
Atom MOTIF_WM_HINTS;
|
||||||
|
|
||||||
@ -155,6 +153,9 @@ typedef struct _GLFWlibraryX11
|
|||||||
// True if window manager supports EWMH
|
// True if window manager supports EWMH
|
||||||
GLboolean hasEWMH;
|
GLboolean hasEWMH;
|
||||||
|
|
||||||
|
// Error code received by the X error handler
|
||||||
|
int errorCode;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GLboolean available;
|
GLboolean available;
|
||||||
int eventBase;
|
int eventBase;
|
||||||
@ -274,4 +275,9 @@ unsigned long _glfwGetWindowProperty(Window window,
|
|||||||
Atom type,
|
Atom type,
|
||||||
unsigned char** value);
|
unsigned char** value);
|
||||||
|
|
||||||
|
// X11 error handler
|
||||||
|
void _glfwGrabXErrorHandler(void);
|
||||||
|
void _glfwReleaseXErrorHandler(void);
|
||||||
|
void _glfwInputXError(int error, const char* message);
|
||||||
|
|
||||||
#endif // _x11_platform_h_
|
#endif // _x11_platform_h_
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW - An OpenGL library
|
// GLFW 3.0 X11 - www.glfw.org
|
||||||
// Platform: X11
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://www.glfw.org/
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
131
src/x11_window.c
131
src/x11_window.c
@ -132,13 +132,15 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
if (wndconfig->monitor == NULL)
|
if (wndconfig->monitor == NULL)
|
||||||
{
|
{
|
||||||
// HACK: This is a workaround for windows without a background pixel
|
// HACK: This is a workaround for windows without a background pixel
|
||||||
// not getting any decorations on certain older versions of Compiz
|
// not getting any decorations on certain older versions of
|
||||||
// running on Intel hardware
|
// Compiz running on Intel hardware
|
||||||
wa.background_pixel = BlackPixel(_glfw.x11.display,
|
wa.background_pixel = BlackPixel(_glfw.x11.display,
|
||||||
_glfw.x11.screen);
|
_glfw.x11.screen);
|
||||||
wamask |= CWBackPixel;
|
wamask |= CWBackPixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfwGrabXErrorHandler();
|
||||||
|
|
||||||
window->x11.handle = XCreateWindow(_glfw.x11.display,
|
window->x11.handle = XCreateWindow(_glfw.x11.display,
|
||||||
_glfw.x11.root,
|
_glfw.x11.root,
|
||||||
0, 0,
|
0, 0,
|
||||||
@ -150,12 +152,12 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
wamask,
|
wamask,
|
||||||
&wa);
|
&wa);
|
||||||
|
|
||||||
|
_glfwReleaseXErrorHandler();
|
||||||
|
|
||||||
if (!window->x11.handle)
|
if (!window->x11.handle)
|
||||||
{
|
{
|
||||||
// TODO: Handle all the various error codes here and translate them
|
_glfwInputXError(GLFW_PLATFORM_ERROR,
|
||||||
// to GLFW errors
|
"X11: Failed to create window");
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to create window");
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,13 +208,13 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
// The WM_DELETE_WINDOW ICCCM protocol
|
// The WM_DELETE_WINDOW ICCCM protocol
|
||||||
// Basic window close notification protocol
|
// Basic window close notification protocol
|
||||||
if (_glfw.x11.WM_DELETE_WINDOW != None)
|
if (_glfw.x11.WM_DELETE_WINDOW)
|
||||||
protocols[count++] = _glfw.x11.WM_DELETE_WINDOW;
|
protocols[count++] = _glfw.x11.WM_DELETE_WINDOW;
|
||||||
|
|
||||||
// The _NET_WM_PING EWMH protocol
|
// The _NET_WM_PING EWMH protocol
|
||||||
// Tells the WM to ping the GLFW window and flag the application as
|
// Tells the WM to ping the GLFW window and flag the application as
|
||||||
// unresponsive if the WM doesn't get a reply within a few seconds
|
// unresponsive if the WM doesn't get a reply within a few seconds
|
||||||
if (_glfw.x11.NET_WM_PING != None)
|
if (_glfw.x11.NET_WM_PING)
|
||||||
protocols[count++] = _glfw.x11.NET_WM_PING;
|
protocols[count++] = _glfw.x11.NET_WM_PING;
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
@ -222,7 +224,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_PID != None)
|
if (_glfw.x11.NET_WM_PID)
|
||||||
{
|
{
|
||||||
const pid_t pid = getpid();
|
const pid_t pid = getpid();
|
||||||
|
|
||||||
@ -259,6 +261,14 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
hints->flags |= PPosition;
|
hints->flags |= PPosition;
|
||||||
_glfwPlatformGetMonitorPos(wndconfig->monitor, &hints->x, &hints->y);
|
_glfwPlatformGetMonitorPos(wndconfig->monitor, &hints->x, &hints->y);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// HACK: Explicitly setting PPosition to any value causes some WMs,
|
||||||
|
// notably Compiz and Metacity, to honor the position of
|
||||||
|
// unmapped windows set by XMoveWindow
|
||||||
|
hints->flags |= PPosition;
|
||||||
|
hints->x = hints->y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!wndconfig->resizable)
|
if (!wndconfig->resizable)
|
||||||
{
|
{
|
||||||
@ -271,6 +281,19 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
XFree(hints);
|
XFree(hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set ICCCM WM_CLASS property
|
||||||
|
// HACK: Until a mechanism for specifying the application name is added, the
|
||||||
|
// initial window title is used as the window class name
|
||||||
|
if (strlen(wndconfig->title))
|
||||||
|
{
|
||||||
|
XClassHint* hint = XAllocClassHint();
|
||||||
|
hint->res_name = (char*) wndconfig->title;
|
||||||
|
hint->res_class = (char*) wndconfig->title;
|
||||||
|
|
||||||
|
XSetClassHint(_glfw.x11.display, window->x11.handle, hint);
|
||||||
|
XFree(hint);
|
||||||
|
}
|
||||||
|
|
||||||
if (_glfw.x11.xi.available)
|
if (_glfw.x11.xi.available)
|
||||||
{
|
{
|
||||||
// Select for XInput2 events
|
// Select for XInput2 events
|
||||||
@ -387,15 +410,22 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||||||
|
|
||||||
_glfwSetVideoMode(window->monitor, &window->videoMode);
|
_glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||||
|
|
||||||
if (_glfw.x11.hasEWMH &&
|
if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR)
|
||||||
_glfw.x11.NET_WM_STATE != None &&
|
{
|
||||||
_glfw.x11.NET_WM_STATE_FULLSCREEN != None)
|
const unsigned long value = 1;
|
||||||
|
|
||||||
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
|
_glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (unsigned char*) &value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
_glfwPlatformGetMonitorPos(window->monitor, &x, &y);
|
_glfwPlatformGetMonitorPos(window->monitor, &x, &y);
|
||||||
_glfwPlatformSetWindowPos(window, x, y);
|
_glfwPlatformSetWindowPos(window, x, y);
|
||||||
|
|
||||||
if (_glfw.x11.NET_ACTIVE_WINDOW != None)
|
if (_glfw.x11.NET_ACTIVE_WINDOW)
|
||||||
{
|
{
|
||||||
// Ask the window manager to raise and focus the GLFW window
|
// Ask the window manager to raise and focus the GLFW window
|
||||||
// Only focused windows with the _NET_WM_STATE_FULLSCREEN state end
|
// Only focused windows with the _NET_WM_STATE_FULLSCREEN state end
|
||||||
@ -475,9 +505,16 @@ static void leaveFullscreenMode(_GLFWwindow* window)
|
|||||||
_glfw.x11.saver.exposure);
|
_glfw.x11.saver.exposure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.x11.hasEWMH &&
|
if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR)
|
||||||
_glfw.x11.NET_WM_STATE != None &&
|
{
|
||||||
_glfw.x11.NET_WM_STATE_FULLSCREEN != None)
|
const unsigned long value = 0;
|
||||||
|
|
||||||
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
|
_glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (unsigned char*) &value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
|
||||||
{
|
{
|
||||||
// Ask the window manager to make the GLFW window a normal window
|
// Ask the window manager to make the GLFW window a normal window
|
||||||
// Normal windows usually have frames and other decorations
|
// Normal windows usually have frames and other decorations
|
||||||
@ -502,7 +539,6 @@ static void leaveFullscreenMode(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Process the specified X event
|
// Process the specified X event
|
||||||
//
|
//
|
||||||
static void processEvent(XEvent *event)
|
static void processEvent(XEvent *event)
|
||||||
@ -525,11 +561,12 @@ static void processEvent(XEvent *event)
|
|||||||
{
|
{
|
||||||
const int key = translateKey(event->xkey.keycode);
|
const int key = translateKey(event->xkey.keycode);
|
||||||
const int mods = translateState(event->xkey.state);
|
const int mods = translateState(event->xkey.state);
|
||||||
|
const int character = translateChar(&event->xkey);
|
||||||
|
|
||||||
_glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods);
|
_glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods);
|
||||||
|
|
||||||
if (!(mods & GLFW_MOD_CONTROL) && !(mods & GLFW_MOD_ALT))
|
if (character != -1)
|
||||||
_glfwInputChar(window, translateChar(&event->xkey));
|
_glfwInputChar(window, character);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -564,6 +601,16 @@ static void processEvent(XEvent *event)
|
|||||||
else if (event->xbutton.button == Button7)
|
else if (event->xbutton.button == Button7)
|
||||||
_glfwInputScroll(window, 1.0, 0.0);
|
_glfwInputScroll(window, 1.0, 0.0);
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 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 - 4,
|
||||||
|
GLFW_PRESS,
|
||||||
|
mods);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,6 +639,15 @@ static void processEvent(XEvent *event)
|
|||||||
GLFW_RELEASE,
|
GLFW_RELEASE,
|
||||||
mods);
|
mods);
|
||||||
}
|
}
|
||||||
|
else if (event->xbutton.button > Button7)
|
||||||
|
{
|
||||||
|
// 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 - 4,
|
||||||
|
GLFW_RELEASE,
|
||||||
|
mods);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,7 +742,7 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
_glfwInputWindowCloseRequest(window);
|
_glfwInputWindowCloseRequest(window);
|
||||||
}
|
}
|
||||||
else if (_glfw.x11.NET_WM_PING != None &&
|
else if (_glfw.x11.NET_WM_PING &&
|
||||||
(Atom) event->xclient.data.l[0] == _glfw.x11.NET_WM_PING)
|
(Atom) event->xclient.data.l[0] == _glfw.x11.NET_WM_PING)
|
||||||
{
|
{
|
||||||
// The window manager is pinging the application to ensure it's
|
// The window manager is pinging the application to ensure it's
|
||||||
@ -1012,7 +1068,7 @@ unsigned long _glfwGetWindowProperty(Window window,
|
|||||||
&bytesAfter,
|
&bytesAfter,
|
||||||
value);
|
value);
|
||||||
|
|
||||||
if (type != AnyPropertyType && actualType != type)
|
if (actualType != type)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return itemCount;
|
return itemCount;
|
||||||
@ -1088,7 +1144,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
|||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_NAME != None)
|
if (_glfw.x11.NET_WM_NAME)
|
||||||
{
|
{
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
_glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
|
_glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
|
||||||
@ -1096,7 +1152,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
|||||||
(unsigned char*) title, strlen(title));
|
(unsigned char*) title, strlen(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_ICON_NAME != None)
|
if (_glfw.x11.NET_WM_ICON_NAME)
|
||||||
{
|
{
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
_glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
|
_glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
|
||||||
@ -1109,24 +1165,25 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
|||||||
{
|
{
|
||||||
Window child;
|
Window child;
|
||||||
int x, y;
|
int x, y;
|
||||||
int left=0;
|
|
||||||
int top=0;
|
|
||||||
|
|
||||||
|
|
||||||
XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
|
XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
|
||||||
0, 0, &x, &y, &child);
|
0, 0, &x, &y, &child);
|
||||||
|
|
||||||
if(child)
|
if (child)
|
||||||
{
|
{
|
||||||
|
int left, top;
|
||||||
|
|
||||||
XTranslateCoordinates(_glfw.x11.display, window->x11.handle, child,
|
XTranslateCoordinates(_glfw.x11.display, window->x11.handle, child,
|
||||||
0, 0, &left, &top, &child);
|
0, 0, &left, &top, &child);
|
||||||
}
|
|
||||||
|
|
||||||
|
x -= left;
|
||||||
|
y -= top;
|
||||||
|
}
|
||||||
|
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = x;
|
*xpos = x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = y-top;
|
*ypos = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||||
@ -1233,24 +1290,12 @@ void _glfwPlatformPollEvents(void)
|
|||||||
processEvent(&event);
|
processEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether the cursor has moved inside an focused window that has
|
_GLFWwindow* window = _glfw.focusedWindow;
|
||||||
// captured the cursor (because then it needs to be re-centered)
|
if (window && window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
|
|
||||||
_GLFWwindow* window;
|
|
||||||
window = _glfw.focusedWindow;
|
|
||||||
if (window)
|
|
||||||
{
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||||
_glfwPlatformSetCursorPos(window, width / 2, height / 2);
|
_glfwPlatformSetCursorPos(window, width / 2, height / 2);
|
||||||
|
|
||||||
// NOTE: This is a temporary fix. It works as long as you use
|
|
||||||
// offsets accumulated over the course of a frame, instead of
|
|
||||||
// performing the necessary actions per callback call.
|
|
||||||
XFlush(_glfw.x11.display);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ set(TINYCTHREAD ${GLFW_SOURCE_DIR}/deps/tinycthread.h
|
|||||||
|
|
||||||
add_executable(clipboard clipboard.c ${GETOPT})
|
add_executable(clipboard clipboard.c ${GETOPT})
|
||||||
add_executable(defaults defaults.c)
|
add_executable(defaults defaults.c)
|
||||||
add_executable(events events.c)
|
add_executable(events events.c ${GETOPT})
|
||||||
add_executable(fsaa fsaa.c ${GETOPT})
|
add_executable(fsaa fsaa.c ${GETOPT})
|
||||||
add_executable(gamma gamma.c ${GETOPT})
|
add_executable(gamma gamma.c ${GETOPT})
|
||||||
add_executable(glfwinfo glfwinfo.c ${GETOPT})
|
add_executable(glfwinfo glfwinfo.c ${GETOPT})
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
// These must match the input mode defaults
|
// These must match the input mode defaults
|
||||||
static GLboolean closeable = GL_TRUE;
|
static GLboolean closeable = GL_TRUE;
|
||||||
|
|
||||||
@ -226,12 +228,12 @@ static const char* get_mods_name(int mods)
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* get_character_string(int character)
|
static const char* get_character_string(int codepoint)
|
||||||
{
|
{
|
||||||
// This assumes UTF-8, which is stupid
|
// This assumes UTF-8, which is stupid
|
||||||
static char result[6 + 1];
|
static char result[6 + 1];
|
||||||
|
|
||||||
int length = wctomb(result, character);
|
int length = wctomb(result, codepoint);
|
||||||
if (length == -1)
|
if (length == -1)
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|
||||||
@ -370,13 +372,13 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void char_callback(GLFWwindow* window, unsigned int character)
|
static void char_callback(GLFWwindow* window, unsigned int codepoint)
|
||||||
{
|
{
|
||||||
printf("%08x at %0.3f: Character 0x%08x (%s) input\n",
|
printf("%08x at %0.3f: Character 0x%08x (%s) input\n",
|
||||||
counter++,
|
counter++,
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
character,
|
codepoint,
|
||||||
get_character_string(character));
|
get_character_string(codepoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void monitor_callback(GLFWmonitor* monitor, int event)
|
void monitor_callback(GLFWmonitor* monitor, int event)
|
||||||
@ -406,10 +408,11 @@ void monitor_callback(GLFWmonitor* monitor, int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
int width, height;
|
GLFWmonitor* monitor = NULL;
|
||||||
|
int ch, width, height;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
@ -420,7 +423,17 @@ int main(void)
|
|||||||
|
|
||||||
printf("Library initialized\n");
|
printf("Library initialized\n");
|
||||||
|
|
||||||
window = glfwCreateWindow(640, 480, "Event Linter", NULL, NULL);
|
while ((ch = getopt(argc, argv, "f")) != -1)
|
||||||
|
{
|
||||||
|
switch (ch)
|
||||||
|
{
|
||||||
|
case 'f':
|
||||||
|
monitor = glfwGetPrimaryMonitor();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window = glfwCreateWindow(640, 480, "Event Linter", monitor, NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
@ -54,9 +54,16 @@
|
|||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: glfwinfo [-h] [-a API] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
printf("Usage: glfwinfo [-h] [-a API] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
||||||
printf("available APIs: " API_OPENGL " " API_OPENGL_ES "\n");
|
printf("Options:\n");
|
||||||
printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT "\n");
|
printf(" -a the client API to use (" API_OPENGL " or " API_OPENGL_ES ")\n");
|
||||||
printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
|
printf(" -d request a debug context\n");
|
||||||
|
printf(" -f require a forward-compatible context\n");
|
||||||
|
printf(" -h show this help\n");
|
||||||
|
printf(" -l list all client API extensions after context creation\n");
|
||||||
|
printf(" -m the major number of the requred client API version\n");
|
||||||
|
printf(" -n the minor number of the requred client API version\n");
|
||||||
|
printf(" -p the OpenGL profile to use (" PROFILE_NAME_CORE " or " PROFILE_NAME_COMPAT ")\n");
|
||||||
|
printf(" -r the robustness strategy to use (" STRATEGY_NAME_NONE " or " STRATEGY_NAME_LOSE ")\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
static void error_callback(int error, const char* description)
|
||||||
@ -186,9 +193,6 @@ int main(int argc, char** argv)
|
|||||||
GLint flags, mask;
|
GLint flags, mask;
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
|
||||||
if (!valid_version())
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "a:dfhlm:n:p:r:")) != -1)
|
while ((ch = getopt(argc, argv, "a:dfhlm:n:p:r:")) != -1)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
@ -249,11 +253,11 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
// Initialize GLFW and create window
|
// Initialize GLFW and create window
|
||||||
|
|
||||||
|
if (!valid_version())
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
|
@ -64,14 +64,12 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
|||||||
static void draw_joystick(Joystick* j, int x, int y, int width, int height)
|
static void draw_joystick(Joystick* j, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int axis_width, axis_height;
|
const int axis_height = 3 * height / 4;
|
||||||
int button_width, button_height;
|
const int button_height = height / 4;
|
||||||
|
|
||||||
axis_width = width / j->axis_count;
|
if (j->axis_count)
|
||||||
axis_height = 3 * height / 4;
|
{
|
||||||
|
const int axis_width = width / j->axis_count;
|
||||||
button_width = width / j->button_count;
|
|
||||||
button_height = height / 4;
|
|
||||||
|
|
||||||
for (i = 0; i < j->axis_count; i++)
|
for (i = 0; i < j->axis_count; i++)
|
||||||
{
|
{
|
||||||
@ -89,6 +87,11 @@ static void draw_joystick(Joystick* j, int x, int y, int width, int height)
|
|||||||
x + (i + 1) * axis_width,
|
x + (i + 1) * axis_width,
|
||||||
y + 5 + (int) (value * (axis_height - 5)));
|
y + 5 + (int) (value * (axis_height - 5)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j->button_count)
|
||||||
|
{
|
||||||
|
const int button_width = width / j->button_count;
|
||||||
|
|
||||||
for (i = 0; i < j->button_count; i++)
|
for (i = 0; i < j->button_count; i++)
|
||||||
{
|
{
|
||||||
@ -102,6 +105,7 @@ static void draw_joystick(Joystick* j, int x, int y, int width, int height)
|
|||||||
x + (i + 1) * button_width,
|
x + (i + 1) * button_width,
|
||||||
y + axis_height + button_height);
|
y + axis_height + button_height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_joysticks(GLFWwindow* window)
|
static void draw_joysticks(GLFWwindow* window)
|
||||||
|
@ -218,9 +218,6 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -57,8 +56,6 @@ static int thread_main(void* data)
|
|||||||
const Thread* thread = (const Thread*) data;
|
const Thread* thread = (const Thread*) data;
|
||||||
|
|
||||||
glfwMakeContextCurrent(thread->window);
|
glfwMakeContextCurrent(thread->window);
|
||||||
assert(glfwGetCurrentContext() == thread->window);
|
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
@ -118,8 +115,6 @@ int main(void)
|
|||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
assert(glfwGetCurrentContext() == NULL);
|
|
||||||
|
|
||||||
glfwWaitEvents();
|
glfwWaitEvents();
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user