diff options
author | Dmitri Shuralyov <shurcooL@gmail.com> | 2014-10-26 10:54:37 -0700 |
---|---|---|
committer | Dmitri Shuralyov <shurcooL@gmail.com> | 2015-02-21 18:51:42 -0800 |
commit | d4f8ffbe3018c1c80f7ed21b33990f801de83171 (patch) | |
tree | 081abbf188327a69d7575435da650b710b590773 | |
parent | 232b70ec221ae0b8209120640afbd9a377bb65c5 (diff) | |
download | glfw-d4f8ffbe3018c1c80f7ed21b33990f801de83171.tar.gz |
Update to glfw/glfw@3b9a14f.
Remove glfw_joystick.c, glfw_time.c files since they were removed in
GLFW C library.
Remove unnecessary CMake, example, documentation and test files of GLFW
C library.
85 files changed, 1583 insertions, 15104 deletions
diff --git a/GLFW_C_REVISION.txt b/GLFW_C_REVISION.txt index 6a5dfa8..3b98cb5 100644 --- a/GLFW_C_REVISION.txt +++ b/GLFW_C_REVISION.txt @@ -1 +1 @@ -e57b8212ceeca0c4a990d388bdf7044a579f4d9b +3b9a14fc9c3845afc7b8788a62435bdc02a7daaf diff --git a/glfw/.gitignore b/glfw/.gitignore deleted file mode 100644 index 3e206b4..0000000 --- a/glfw/.gitignore +++ /dev/null @@ -1,74 +0,0 @@ -# External junk -.DS_Store -_ReSharper* -*.opensdf -*.sdf -*.dir -*.vcxproj* -*.sln -Win32 -Debug -Release - -# CMake files -Makefile -CMakeCache.txt -CMakeFiles -cmake_install.cmake -cmake_uninstall.cmake - -# Generated files -docs/Doxyfile -docs/html -docs/warnings.txt -src/glfw_config.h -src/glfw3.pc -src/glfwConfig.cmake -src/glfwConfigVersion.cmake - -# Compiled binaries -src/libglfw.so -src/libglfw.so.3 -src/libglfw.so.3.0 -src/libglfw.dylib -src/libglfw.dylib -src/libglfw.3.dylib -src/libglfw.3.0.dylib -src/libglfw3.a -src/glfw3.lib -src/glfw3.dll -src/glfw3dll.lib -src/glfw3dll.a -examples/*.app -examples/*.exe -examples/boing -examples/gears -examples/heightmap -examples/particles -examples/splitview -examples/simple -examples/wave -tests/*.app -tests/*.exe -tests/accuracy -tests/clipboard -tests/cursor -tests/cursoranim -tests/defaults -tests/empty -tests/events -tests/fsaa -tests/gamma -tests/glfwinfo -tests/iconify -tests/joysticks -tests/modes -tests/peter -tests/reopen -tests/sharing -tests/tearing -tests/threads -tests/title -tests/version -tests/windows - diff --git a/glfw/CMake/amd64-mingw32msvc.cmake b/glfw/CMake/amd64-mingw32msvc.cmake deleted file mode 100644 index 705e251..0000000 --- a/glfw/CMake/amd64-mingw32msvc.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# Define the environment for cross compiling from Linux to Win64 -SET(CMAKE_SYSTEM_NAME Windows) -SET(CMAKE_SYSTEM_VERSION 1) -SET(CMAKE_C_COMPILER "amd64-mingw32msvc-gcc") -SET(CMAKE_CXX_COMPILER "amd64-mingw32msvc-g++") -SET(CMAKE_RC_COMPILER "amd64-mingw32msvc-windres") -SET(CMAKE_RANLIB "amd64-mingw32msvc-ranlib") - -# Configure the behaviour of the find commands -SET(CMAKE_FIND_ROOT_PATH "/usr/amd64-mingw32msvc") -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/glfw/CMake/i586-mingw32msvc.cmake b/glfw/CMake/i586-mingw32msvc.cmake deleted file mode 100644 index 393ddbd..0000000 --- a/glfw/CMake/i586-mingw32msvc.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# Define the environment for cross compiling from Linux to Win32 -SET(CMAKE_SYSTEM_NAME Windows) -SET(CMAKE_SYSTEM_VERSION 1) -SET(CMAKE_C_COMPILER "i586-mingw32msvc-gcc") -SET(CMAKE_CXX_COMPILER "i586-mingw32msvc-g++") -SET(CMAKE_RC_COMPILER "i586-mingw32msvc-windres") -SET(CMAKE_RANLIB "i586-mingw32msvc-ranlib") - -# Configure the behaviour of the find commands -SET(CMAKE_FIND_ROOT_PATH "/usr/i586-mingw32msvc") -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/glfw/CMake/i686-pc-mingw32.cmake b/glfw/CMake/i686-pc-mingw32.cmake deleted file mode 100644 index 9a46aef..0000000 --- a/glfw/CMake/i686-pc-mingw32.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# Define the environment for cross compiling from Linux to Win32 -SET(CMAKE_SYSTEM_NAME Windows) # Target system name -SET(CMAKE_SYSTEM_VERSION 1) -SET(CMAKE_C_COMPILER "i686-pc-mingw32-gcc") -SET(CMAKE_CXX_COMPILER "i686-pc-mingw32-g++") -SET(CMAKE_RC_COMPILER "i686-pc-mingw32-windres") -SET(CMAKE_RANLIB "i686-pc-mingw32-ranlib") - -#Configure the behaviour of the find commands -SET(CMAKE_FIND_ROOT_PATH "/opt/mingw/usr/i686-pc-mingw32") -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/glfw/CMake/i686-w64-mingw32.cmake b/glfw/CMake/i686-w64-mingw32.cmake deleted file mode 100644 index 9bd6093..0000000 --- a/glfw/CMake/i686-w64-mingw32.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# Define the environment for cross compiling from Linux to Win32 -SET(CMAKE_SYSTEM_NAME Windows) # Target system name -SET(CMAKE_SYSTEM_VERSION 1) -SET(CMAKE_C_COMPILER "i686-w64-mingw32-gcc") -SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-g++") -SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres") -SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib") - -# Configure the behaviour of the find commands -SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32") -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/glfw/CMake/modules/FindEGL.cmake b/glfw/CMake/modules/FindEGL.cmake deleted file mode 100644 index 0929c92..0000000 --- a/glfw/CMake/modules/FindEGL.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Find EGL -# -# EGL_INCLUDE_DIR -# EGL_LIBRARY -# EGL_FOUND - -find_path(EGL_INCLUDE_DIR NAMES EGL/egl.h) - -set(EGL_NAMES ${EGL_NAMES} egl EGL) -find_library(EGL_LIBRARY NAMES ${EGL_NAMES}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR) - -mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY) - diff --git a/glfw/CMake/modules/FindGLESv1.cmake b/glfw/CMake/modules/FindGLESv1.cmake deleted file mode 100644 index 3c77929..0000000 --- a/glfw/CMake/modules/FindGLESv1.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Find GLESv1 -# -# GLESv1_INCLUDE_DIR -# GLESv1_LIBRARY -# GLESv1_FOUND - -find_path(GLESv1_INCLUDE_DIR NAMES GLES/gl.h) - -set(GLESv1_NAMES ${GLESv1_NAMES} GLESv1_CM) -find_library(GLESv1_LIBRARY NAMES ${GLESv1_NAMES}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GLESv1 DEFAULT_MSG GLESv1_LIBRARY GLESv1_INCLUDE_DIR) - -mark_as_advanced(GLESv1_INCLUDE_DIR GLESv1_LIBRARY) - diff --git a/glfw/CMake/modules/FindGLESv2.cmake b/glfw/CMake/modules/FindGLESv2.cmake deleted file mode 100644 index 0a2f810..0000000 --- a/glfw/CMake/modules/FindGLESv2.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Find GLESv2 -# -# GLESv2_INCLUDE_DIR -# GLESv2_LIBRARY -# GLESv2_FOUND - -find_path(GLESv2_INCLUDE_DIR NAMES GLES2/gl2.h) - -set(GLESv2_NAMES ${GLESv2_NAMES} GLESv2) -find_library(GLESv2_LIBRARY NAMES ${GLESv2_NAMES}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GLESv2 DEFAULT_MSG GLESv2_LIBRARY GLESv2_INCLUDE_DIR) - -mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY) - diff --git a/glfw/CMake/modules/FindWayland.cmake b/glfw/CMake/modules/FindWayland.cmake deleted file mode 100644 index 71f5167..0000000 --- a/glfw/CMake/modules/FindWayland.cmake +++ /dev/null @@ -1,66 +0,0 @@ -# Try to find Wayland on a Unix system -# -# This will define: -# -# WAYLAND_FOUND - True if Wayland is found -# WAYLAND_LIBRARIES - Link these to use Wayland -# WAYLAND_INCLUDE_DIR - Include directory for Wayland -# WAYLAND_DEFINITIONS - Compiler flags for using Wayland -# -# In addition the following more fine grained variables will be defined: -# -# WAYLAND_CLIENT_FOUND WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES -# WAYLAND_SERVER_FOUND WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES -# WAYLAND_EGL_FOUND WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES -# -# Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org> -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -IF (NOT WIN32) - IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES) - # In the cache already - SET(WAYLAND_FIND_QUIETLY TRUE) - ENDIF () - - # Use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - FIND_PACKAGE(PkgConfig) - PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor) - - SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS}) - - FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) - FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) - FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) - FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) - - FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) - FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) - FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) - FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) - - set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR}) - - set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES}) - - list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR) - - include(FindPackageHandleStandardArgs) - - FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT DEFAULT_MSG WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER DEFAULT_MSG WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIR) - - MARK_AS_ADVANCED( - WAYLAND_INCLUDE_DIR WAYLAND_LIBRARIES - WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES - WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES - WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES - WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES - ) - -ENDIF () diff --git a/glfw/CMake/modules/FindXKBCommon.cmake b/glfw/CMake/modules/FindXKBCommon.cmake deleted file mode 100644 index 0f571ee..0000000 --- a/glfw/CMake/modules/FindXKBCommon.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# - Try to find XKBCommon -# Once done, this will define -# -# XKBCOMMON_FOUND - System has XKBCommon -# XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories -# XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon -# XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon - -find_package(PkgConfig) -pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon) -set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER}) - -find_path(XKBCOMMON_INCLUDE_DIR - NAMES xkbcommon/xkbcommon.h - HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS} -) - -find_library(XKBCOMMON_LIBRARY - NAMES xkbcommon - HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS} -) - -set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY}) -set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS}) -set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(XKBCommon DEFAULT_MSG - XKBCOMMON_LIBRARY - XKBCOMMON_INCLUDE_DIR -) - -mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR) - diff --git a/glfw/CMake/x86_64-w64-mingw32.cmake b/glfw/CMake/x86_64-w64-mingw32.cmake deleted file mode 100644 index 84b2c70..0000000 --- a/glfw/CMake/x86_64-w64-mingw32.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# Define the environment for cross compiling from Linux to Win32 -SET(CMAKE_SYSTEM_NAME Windows) # Target system name -SET(CMAKE_SYSTEM_VERSION 1) -SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc") -SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++") -SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres") -SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib") - -# Configure the behaviour of the find commands -SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32") -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/glfw/CMakeLists.txt b/glfw/CMakeLists.txt deleted file mode 100644 index bc338bc..0000000 --- a/glfw/CMakeLists.txt +++ /dev/null @@ -1,491 +0,0 @@ -project(GLFW C) - -cmake_minimum_required(VERSION 2.8) - -set(GLFW_VERSION_MAJOR "3") -set(GLFW_VERSION_MINOR "1") -set(GLFW_VERSION_PATCH "0") -set(GLFW_VERSION_EXTRA "") -set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}") -set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}") -set(LIB_SUFFIX "" CACHE STRING "Takes an empty string or 64. Directory where lib will be installed: lib or lib64") - -option(BUILD_SHARED_LIBS "Build shared libraries" OFF) -option(GLFW_BUILD_EXAMPLES "Build the GLFW example 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_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) - 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_MENUBAR "Populate the menu bar on first window creation" ON) - option(GLFW_USE_RETINA "Use the full resolution of Retina displays" ON) -else() - option(GLFW_USE_EGL "Use EGL for context creation" OFF) -endif() - -if (UNIX AND NOT APPLE) - option(GLFW_USE_WAYLAND "Use Wayland for context creation (implies EGL as well)" OFF) -endif() - -if (MSVC) - option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON) -endif() - -if (BUILD_SHARED_LIBS) - set(_GLFW_BUILD_DLL 1) -endif() - -if (GLFW_USE_WAYLAND) - set(GLFW_USE_EGL ON) -endif() - -if (GLFW_USE_EGL) - set(GLFW_CLIENT_LIBRARY "opengl" CACHE STRING - "The client library to use; one of opengl, glesv1 or glesv2") - - if (${GLFW_CLIENT_LIBRARY} STREQUAL "opengl") - set(_GLFW_USE_OPENGL 1) - elseif (${GLFW_CLIENT_LIBRARY} STREQUAL "glesv1") - set(_GLFW_USE_GLESV1 1) - elseif (${GLFW_CLIENT_LIBRARY} STREQUAL "glesv2") - set(_GLFW_USE_GLESV2 1) - else() - message(FATAL_ERROR "Unsupported client library") - endif() - - set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake/modules") - find_package(EGL REQUIRED) - - if (NOT _GLFW_USE_OPENGL) - set(GLFW_BUILD_EXAMPLES OFF) - set(GLFW_BUILD_TESTS OFF) - message(STATUS "NOTE: Examples and tests require OpenGL") - endif() -else() - set(_GLFW_USE_OPENGL 1) -endif() - -if (_GLFW_USE_OPENGL) - find_package(OpenGL REQUIRED) -elseif (_GLFW_USE_GLESV1) - find_package(GLESv1 REQUIRED) -elseif (_GLFW_USE_GLESV2) - find_package(GLESv2 REQUIRED) -endif() - -find_package(Threads REQUIRED) - -if (GLFW_BUILD_DOCS) - set(DOXYGEN_SKIP_DOT TRUE) - find_package(Doxygen) - - if (GLFW_DOCUMENT_INTERNALS) - set(GLFW_INTERNAL_DOCS "${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox") - endif() -endif() - -#-------------------------------------------------------------------- -# Set compiler specific flags -#-------------------------------------------------------------------- -if (UNIX) - add_definitions(-Wall) - - if (BUILD_SHARED_LIBS) - add_definitions(-fvisibility=hidden) - endif() -endif() - -if (MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - - if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL) - foreach (flag CMAKE_C_FLAGS - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELWITHDEBINFO) - - if (${flag} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") - endif() - if (${flag} MATCHES "/MDd") - string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}") - endif() - - endforeach() - endif() -endif() - -#-------------------------------------------------------------------- -# Detect and select backend APIs -#-------------------------------------------------------------------- -if (WIN32) - set(_GLFW_WIN32 1) - message(STATUS "Using Win32 for window creation") - - if (GLFW_USE_EGL) - set(_GLFW_EGL 1) - message(STATUS "Using EGL for context creation") - else() - set(_GLFW_WGL 1) - message(STATUS "Using WGL for context creation") - endif() -elseif (APPLE) - set(_GLFW_COCOA 1) - message(STATUS "Using Cocoa for window creation") - set(_GLFW_NSGL 1) - message(STATUS "Using NSGL for context creation") -elseif (UNIX) - if (GLFW_USE_WAYLAND) - set(_GLFW_WAYLAND 1) - message(STATUS "Using Wayland for window creation") - else() - set(_GLFW_X11 1) - message(STATUS "Using X11 for window creation") - endif() - - if (GLFW_USE_EGL) - set(_GLFW_EGL 1) - message(STATUS "Using EGL for context creation") - else() - set(_GLFW_GLX 1) - message(STATUS "Using GLX for context creation") - endif() -else() - message(FATAL_ERROR "No supported platform was detected") -endif() - -#-------------------------------------------------------------------- -# Use Win32 for window creation -#-------------------------------------------------------------------- -if (_GLFW_WIN32) - - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lgdi32") - - 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. - if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - add_definitions(-DUNICODE -DWINVER=0x0501) - endif() -endif() - -#-------------------------------------------------------------------- -# Use WGL for context creation -#-------------------------------------------------------------------- -if (_GLFW_WGL) - - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lopengl32") - - list(APPEND glfw_INCLUDE_DIRS "${OPENGL_INCLUDE_DIR}") - list(APPEND glfw_LIBRARIES "${OPENGL_gl_LIBRARY}") -endif() - -#-------------------------------------------------------------------- -# Use X11 for window creation -#-------------------------------------------------------------------- -if (_GLFW_X11) - - find_package(X11 REQUIRED) - - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} x11") - - # Set up library and include paths - list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}") - list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}") - if (UNIX AND NOT APPLE) - list(APPEND glfw_LIBRARIES "${RT_LIBRARY}") - endif() - - # Check for XRandR (modern resolution switching and gamma control) - if (NOT X11_Xrandr_FOUND) - message(FATAL_ERROR "The RandR library and headers were not found") - endif() - - list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}") - list(APPEND glfw_LIBRARIES "${X11_Xrandr_LIB}") - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xrandr") - - # Check for XInput (high-resolution cursor motion) - if (NOT X11_Xinput_FOUND) - message(FATAL_ERROR "The XInput library and headers were not found") - endif() - - list(APPEND glfw_INCLUDE_DIRS "${X11_Xinput_INCLUDE_PATH}") - - if (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") - - # Check for Xf86VidMode (fallback gamma control) - if (NOT X11_xf86vmode_FOUND) - message(FATAL_ERROR "The Xf86VidMode library and headers were not found") - endif() - - list(APPEND glfw_INCLUDE_DIRS "${X11_xf86vmode_INCLUDE_PATH}") - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xxf86vm") - - if (X11_Xxf86vm_LIB) - list(APPEND glfw_LIBRARIES "${X11_Xxf86vm_LIB}") - else() - # Backwards compatibility (see CMake bug 0006976) - list(APPEND glfw_LIBRARIES Xxf86vm) - endif() - - # Check for Xkb (X keyboard extension) - if (NOT X11_Xkb_FOUND) - message(FATAL_ERROR "The X keyboard extension headers were not found") - endif() - - list(APPEND glfw_INCLUDE_DIR "${X11_Xkb_INCLUDE_PATH}") - - find_library(RT_LIBRARY rt) - mark_as_advanced(RT_LIBRARY) - if (RT_LIBRARY) - list(APPEND glfw_LIBRARIES "${RT_LIBRARY}") - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lrt") - endif() - - find_library(MATH_LIBRARY m) - mark_as_advanced(MATH_LIBRARY) - if (MATH_LIBRARY) - list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}") - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lm") - endif() - - # Check for Xcursor - if (NOT X11_Xcursor_FOUND) - message(FATAL_ERROR "The Xcursor libraries and headers were not found") - endif() - - list(APPEND glfw_INCLUDE_DIR "${X11_Xcursor_INCLUDE_PATH}") - list(APPEND glfw_LIBRARIES "${X11_Xcursor_LIB}") - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xcursor") - -endif() - -#-------------------------------------------------------------------- -# Use Wayland for window creation -#-------------------------------------------------------------------- -if (_GLFW_WAYLAND) - find_package(Wayland REQUIRED) - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} wayland-egl") - - list(APPEND glfw_INCLUDE_DIRS "${WAYLAND_INCLUDE_DIR}") - list(APPEND glfw_LIBRARIES "${WAYLAND_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}") - - find_package(XKBCommon REQUIRED) - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xkbcommon") - list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}") - list(APPEND glfw_LIBRARIES "${XKBCOMMON_LIBRARY}") - - find_library(MATH_LIBRARY m) - mark_as_advanced(MATH_LIBRARY) - if (MATH_LIBRARY) - list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}") - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lm") - endif() -endif() - -#-------------------------------------------------------------------- -# Use GLX for context creation -#-------------------------------------------------------------------- -if (_GLFW_GLX) - - list(APPEND glfw_INCLUDE_DIRS "${OPENGL_INCLUDE_DIR}") - list(APPEND glfw_LIBRARIES "${OPENGL_gl_LIBRARY}") - - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} gl") - - include(CheckFunctionExists) - - set(CMAKE_REQUIRED_LIBRARIES "${OPENGL_gl_LIBRARY}") - check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS) - check_function_exists(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB) - check_function_exists(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT) - - if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND - NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND - NOT _GLFW_HAS_GLXGETPROCADDRESSEXT) - message(WARNING "No glXGetProcAddressXXX variant found") - - # Check for dlopen support as a fallback - - set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_DL_LIBS}") - check_function_exists(dlopen _GLFW_HAS_DLOPEN) - if (NOT _GLFW_HAS_DLOPEN) - message(FATAL_ERROR "No entry point retrieval mechanism found") - endif() - - if (CMAKE_DL_LIBS) - list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}") - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -l${CMAKE_DL_LIBS}") - endif() - endif() - -endif() - -#-------------------------------------------------------------------- -# Use EGL for context creation -#-------------------------------------------------------------------- -if (_GLFW_EGL) - - list(APPEND glfw_INCLUDE_DIRS "${EGL_INCLUDE_DIR}") - list(APPEND glfw_LIBRARIES "${EGL_LIBRARY}") - - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl") - - if (_GLFW_USE_OPENGL) - list(APPEND glfw_LIBRARIES "${OPENGL_gl_LIBRARY}") - list(APPEND glfw_INCLUDE_DIRS "${OPENGL_INCLUDE_DIR}") - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} gl") - elseif (_GLFW_USE_GLESV1) - list(APPEND glfw_LIBRARIES "${GLESv1_LIBRARY}") - list(APPEND glfw_INCLUDE_DIRS "${GLESv1_INCLUDE_DIR}") - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} glesv1_cm") - elseif (_GLFW_USE_GLESV2) - list(APPEND glfw_LIBRARIES "${GLESv2_LIBRARY}") - list(APPEND glfw_INCLUDE_DIRS "${GLESv2_INCLUDE_DIR}") - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} glesv2") - endif() - -endif() - -#-------------------------------------------------------------------- -# Use Cocoa for window creation and NSOpenGL for context creation -#-------------------------------------------------------------------- -if (_GLFW_COCOA AND _GLFW_NSGL) - - if (GLFW_USE_MENUBAR) - set(_GLFW_USE_MENUBAR 1) - endif() - - if (GLFW_USE_CHDIR) - set(_GLFW_USE_CHDIR 1) - endif() - - if (GLFW_USE_RETINA) - set(_GLFW_USE_RETINA 1) - endif() - - if (GLFW_BUILD_UNIVERSAL) - message(STATUS "Building GLFW as Universal Binaries") - set(CMAKE_OSX_ARCHITECTURES i386;x86_64) - else() - message(STATUS "Building GLFW only for the native architecture") - endif() - - # Set up library and include paths - find_library(COCOA_FRAMEWORK Cocoa) - find_library(IOKIT_FRAMEWORK IOKit) - find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) - find_library(CORE_VIDEO_FRAMEWORK CoreVideo) - list(APPEND glfw_LIBRARIES "${COCOA_FRAMEWORK}" - "${OPENGL_gl_LIBRARY}" - "${IOKIT_FRAMEWORK}" - "${CORE_FOUNDATION_FRAMEWORK}" - "${CORE_VIDEO_FRAMEWORK}") - - set(GLFW_PKG_DEPS "") - set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo") -endif() - -#-------------------------------------------------------------------- -# Export GLFW library dependencies -#-------------------------------------------------------------------- -set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW") - -#-------------------------------------------------------------------- -# Choose library output name -#-------------------------------------------------------------------- -if (BUILD_SHARED_LIBS AND UNIX) - # On Unix-like systems, shared libraries can use the soname system. - set(GLFW_LIB_NAME glfw) -else() - set(GLFW_LIB_NAME glfw3) -endif() - -#-------------------------------------------------------------------- -# Create generated files -#-------------------------------------------------------------------- -if (GLFW_BUILD_DOCS) - configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in" - "${GLFW_BINARY_DIR}/docs/Doxyfile" @ONLY) -endif() - -configure_file("${GLFW_SOURCE_DIR}/src/glfw_config.h.in" - "${GLFW_BINARY_DIR}/src/glfw_config.h" @ONLY) - -configure_file("${GLFW_SOURCE_DIR}/src/glfwConfig.cmake.in" - "${GLFW_BINARY_DIR}/src/glfwConfig.cmake" @ONLY) - -configure_file("${GLFW_SOURCE_DIR}/src/glfwConfigVersion.cmake.in" - "${GLFW_BINARY_DIR}/src/glfwConfigVersion.cmake" @ONLY) - -configure_file("${GLFW_SOURCE_DIR}/src/glfw3.pc.in" - "${GLFW_BINARY_DIR}/src/glfw3.pc" @ONLY) - -#-------------------------------------------------------------------- -# Add subdirectories -#-------------------------------------------------------------------- -add_subdirectory(src) - -if (GLFW_BUILD_EXAMPLES) - add_subdirectory(examples) -endif() - -if (GLFW_BUILD_TESTS) - add_subdirectory(tests) -endif() - -if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS) - add_subdirectory(docs) -endif() - -#-------------------------------------------------------------------- -# Install files other than the library -# The library is installed by src/CMakeLists.txt -#-------------------------------------------------------------------- -if (GLFW_INSTALL) - install(DIRECTORY include/GLFW DESTINATION include - FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h) - - install(FILES "${GLFW_BINARY_DIR}/src/glfwConfig.cmake" - "${GLFW_BINARY_DIR}/src/glfwConfigVersion.cmake" - DESTINATION lib${LIB_SUFFIX}/cmake/glfw) - - install(EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}/cmake/glfw) - install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" - DESTINATION lib${LIB_SUFFIX}/pkgconfig) - - # Only generate this target if no higher-level project already has - if (NOT TARGET uninstall) - configure_file("${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${GLFW_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) - - add_custom_target(uninstall - "${CMAKE_COMMAND}" -P - "${GLFW_BINARY_DIR}/cmake_uninstall.cmake") - endif() -endif() - diff --git a/glfw/README.md b/glfw/README.md deleted file mode 100644 index 6d03b7c..0000000 --- a/glfw/README.md +++ /dev/null @@ -1,239 +0,0 @@ -# GLFW - -## Introduction - -GLFW is a free, Open Source, multi-platform library for OpenGL and OpenGL ES -application development. It provides a simple, platform-independent API for -creating windows and contexts, reading input, handling events, etc. - -Version 3.1 is *not yet described*. - -If you are new to GLFW, you may find the -[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 -[transition guide](http://www.glfw.org/docs/latest/moving.html) for moving to -the GLFW 3 API. - -Note that a number of source files have been added or renamed in 3.1, which may -require you to update any custom build files you have. - - -## Compiling GLFW - -See the [Compiling GLFW](http://www.glfw.org/docs/latest/compile.html) guide in -the GLFW documentation. - - -## Using GLFW - -See the -[Building programs that use GLFW](http://www.glfw.org/docs/latest/build.html) -guide in the GLFW documentation. - - -## Dependencies - -GLFW bundles a number of dependencies in the `deps/` directory. - - - [Khronos extension headers](https://www.opengl.org/registry/) for API - extension symbols used by GLFW - - [getopt\_port](https://github.com/kimgr/getopt_port/) for examples - with command-line options - - [TinyCThread](https://gitorious.org/tinythread/tinycthread/) for threaded - examples - - An OpenGL 3.2 core loader generated by - [glad](https://github.com/Dav1dde/glad) for examples using modern OpenGL - - -## Changelog - - - Added `GLFWcursor` custom system cursor handle - - Added `glfwCreateCursor`, `glfwDestroyCursor` and `glfwSetCursor` for - managing custom system cursors - - Added `GLFWimage` struct for passing 32-bit RGBA images - - Added native monitor handle access to native API - - Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files - - Added `glfwPostEmptyEvent` for allowing secondary threads to cause - `glfwWaitEvents` to return - - Added `empty` test program for verifying posting of empty events - - Added `glfwSetCharModsCallback` for receiving character events with modifiers - - Added `glfwGetWindowFrameSize` for retrieving the size of the frame around - the client area of a window - - Added `GLFW_AUTO_ICONIFY` for controlling whether full screen windows - automatically iconify (and restore the previous video mode) on focus loss - - Added `GLFW_DONT_CARE` for indicating that any value is acceptable - - Added `GLFW_DOUBLEBUFFER` for controlling whether to use double buffering - - Added `GLFW_CONTEXT_RELEASE_BEHAVIOR` and values - `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` and - `GLFW_RELEASE_BEHAVIOR_NONE` for `GL_KHR_context_flush_control` support - - Added `GLFW_INCLUDE_ES31` for including the OpenGL ES 3.1 header - - Added `GLFW_FLOATING` for creating always-on-top windowed mode windows - - Added `GLFW_FOCUSED` window hint for controlling initial input focus - - Added *partial and experimental* support for Wayland - - Bugfix: The debug context attribute was set from `GL_ARB_debug_output` even - when a debug context had not been requested - - Bugfix: The particles example was not linked against the threading library - - Bugfix: The cursor was not positioned over newly created full screen windows - - [Cocoa] Added `_GLFW_USE_RETINA` to control whether windows will use the full - resolution on Retina displays - - [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen - recorders to fail - - [Cocoa] Bugfix: Some Core Foundation objects were leaked during joystick - enumeration and termination - - [Cocoa] Bugfix: One copy of each display name string was leaked - - [Cocoa] Bugfix: Monitor enumeration caused a segfault if no `NSScreen` was - found for a given `CGDisplay` - - [Cocoa] Bugfix: Modifier key events were lost if the corresponding modifier - bit field was unchanged - - [Cocoa] Bugfix: Joystick enumeration took hundreds of ms on some systems - - [Cocoa] Bugfix: The cursor was hidden when the user resized a GLFW window - - [Win32] Enabled generation of pkg-config file for MinGW - - [Win32] Removed option to require explicitly linking against `winmm.dll` - - [Win32] Bugfix: Failure to load winmm or its functions was not reported to - the error callback - - [Win32] Bugfix: Some keys were reported based on the current layout instead - of their physical location - - [Win32] Bugfix: Maximized hidden windows were restored by `glfwShowWindow` - - [Win32] Bugfix: Context re-creation was not triggered by sRGB hint - - [Win32] Bugfix: Full screen windows were incorrectly sized and placed on some - systems - - [Win32] Bugfix: Gamma ramp functions acted on entire desktop instead of the - specified monitor - - [Win32] Bugfix: The wrong incorrect physical size was returned for - non-primary monitors - - [X11] Added run-time support for systems lacking the XKB extension - - [X11] Made GLX 1.3 the minimum supported version - - [X11] Replaced `XRRGetScreenResources` with `XRRGetScreenResourcesCurrent` - for monitor property retrieval - - [X11] Bugfix: The case of finding no usable CRTCs was not detected - - [X11] Bugfix: Detection of broken Nvidia RandR gamma support did not verify - that at least one CRTC was present - - [X11] Bugfix: A stale `_NET_SUPPORTING_WM_CHECK` root window property would - cause an uncaught `BadWindow` error - - [X11] Bugfix: No check was made for the presence of GLX 1.3 when - `GLX_SGIX_fbconfig` was unavailable - - [X11] Bugfix: The message type of ICCCM protocol events was not checked - - [X11] Bugfix: `glfwDestroyWindow` did not flush the output buffer - - [X11] Bugfix: Window frame interactions were reported as focus events - - [X11] Bugfix: Workaround for legacy Compiz caused flickering during resize - - [X11] Bugfix: The name pointer of joysticks were not cleared on disconnection - - [X11] Bugfix: Video mode dimensions were not rotated to match the CRTC - - -## Contact - -The official website for GLFW is [glfw.org](http://www.glfw.org/). There you -can find the latest version of GLFW, as well as news, documentation and other -information about the project. - -If you have questions related to the use of GLFW, we have a -[support forum](https://sourceforge.net/p/glfw/discussion/247562/), and the IRC -channel `#glfw` on [Freenode](http://freenode.net/). - -If you have a bug to report, a patch to submit or a feature you'd like to -request, please file it in the -[issue tracker](https://github.com/glfw/glfw/issues) on GitHub. - -Finally, if you're interested in helping out with the development of GLFW or -porting it to your favorite platform, we have an occasionally active -[developer's mailing list](https://lists.stacken.kth.se/mailman/listinfo/glfw-dev), -or you could join us on `#glfw`. - - -## Acknowledgements - -GLFW exists because people around the world donated their time and lent their -skills. - - - Bobyshev Alexander - - artblanc - - arturo - - Matt Arsenault - - Keith Bauer - - John Bartholomew - - Niklas Behrens - - Niklas Bergström - - Doug Binks - - blanco - - Martin Capitanio - - Lambert Clara - - Andrew Corrigan - - Noel Cower - - Jarrod Davis - - Olivier Delannoy - - Paul R. Deppe - - Michael Dickens - - Jonathan Dummer - - Ralph Eastwood - - Michael Fogleman - - Gerald Franz - - GeO4d - - Marcus Geelnard - - Eloi Marín Gratacós - - Stefan Gustavson - - Sylvain Hellegouarch - - Matthew Henry - - heromyth - - Paul Holden - - Toni Jovanoski - - Arseny Kapoulkine - - Osman Keskin - - Cameron King - - Peter Knut - - Robin Leffmann - - Glenn Lewis - - Shane Liesegang - - Дмитри Малышев - - Martins Mozeiko - - Tristam MacDonald - - Hans Mackowiak - - Kyle McDonald - - David Medlock - - Jonathan Mercier - - Marcel Metz - - Kenneth Miller - - Bruce Mitchener - - Jack Moffitt - - Jeff Molofee - - Jon Morton - - Pierre Moulon - - Julian Møller - - Kamil Nowakowski - - Ozzy - - Andri Pálsson - - Peoro - - Braden Pellett - - Arturo J. Pérez - - Pieroman - - Jorge Rodriguez - - Ed Ropple - - Riku Salminen - - Sebastian Schuberth - - Matt Sealey - - SephiRok - - Steve Sexton - - Systemcluster - - Dmitri Shuralyov - - Daniel Skorupski - - Bradley Smith - - Julian Squires - - Johannes Stein - - Justin Stoecker - - Nathan Sweet - - TTK-Bandit - - Sergey Tikhomirov - - Samuli Tuomola - - urraka - - Jari Vetoniemi - - Ricardo Vieira - - Simon Voordouw - - Torsten Walluhn - - Jay Weisskopf - - Frank Wille - - yuriks - - Santi Zupancic - - Jonas Ådahl - - Lasse Öörni - - All the unmentioned and anonymous contributors in the GLFW community, for bug - reports, patches, feedback, testing and encouragement - diff --git a/glfw/cmake_uninstall.cmake.in b/glfw/cmake_uninstall.cmake.in deleted file mode 100644 index 4ea57b1..0000000 --- a/glfw/cmake_uninstall.cmake.in +++ /dev/null @@ -1,29 +0,0 @@ - -if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") -endif() - -file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) -string(REGEX REPLACE "\n" ";" files "${files}") - -foreach (file ${files}) - message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") - if (EXISTS "$ENV{DESTDIR}${file}") - exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval) - if (NOT "${rm_retval}" STREQUAL 0) - MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") - endif() - elseif (IS_SYMLINK "$ENV{DESTDIR}${file}") - EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval) - if (NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"") - endif() - else() - message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") - endif() -endforeach() - diff --git a/glfw/docs/CMakeLists.txt b/glfw/docs/CMakeLists.txt deleted file mode 100644 index 45a6162..0000000 --- a/glfw/docs/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -add_custom_target(docs ALL ${DOXYGEN_EXECUTABLE} - WORKING_DIRECTORY ${GLFW_BINARY_DIR}/docs - COMMENT "Generating HTML documentation" VERBATIM) - diff --git a/glfw/docs/Doxyfile.in b/glfw/docs/Doxyfile.in deleted file mode 100644 index 5af0948..0000000 --- a/glfw/docs/Doxyfile.in +++ /dev/null @@ -1,1862 +0,0 @@ -# Doxyfile 1.8.3.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = "GLFW" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = @GLFW_VERSION_FULL@ - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "A multi-platform library for OpenGL, window and input" - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = @GLFW_BINARY_DIR@/docs - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = NO - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = YES - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES (the -# default) will make doxygen replace the get and set methods by a property in -# the documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = YES - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if section-label ... \endif -# and \cond section-label ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command <command> <input-file>, where <command> is the value of -# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. Do not use -# file names with spaces, bibtex cannot handle them. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = @GLFW_BINARY_DIR@/docs/warnings.txt - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = @GLFW_INTERNAL_DOCS@ \ - @GLFW_SOURCE_DIR@/include/GLFW/glfw3.h \ - @GLFW_SOURCE_DIR@/include/GLFW/glfw3native.h \ - @GLFW_SOURCE_DIR@/docs/main.dox \ - @GLFW_SOURCE_DIR@/docs/news.dox \ - @GLFW_SOURCE_DIR@/docs/moving.dox \ - @GLFW_SOURCE_DIR@/docs/quick.dox \ - @GLFW_SOURCE_DIR@/docs/compile.dox \ - @GLFW_SOURCE_DIR@/docs/build.dox \ - @GLFW_SOURCE_DIR@/docs/intro.dox \ - @GLFW_SOURCE_DIR@/docs/context.dox \ - @GLFW_SOURCE_DIR@/docs/monitor.dox \ - @GLFW_SOURCE_DIR@/docs/window.dox \ - @GLFW_SOURCE_DIR@/docs/input.dox \ - @GLFW_SOURCE_DIR@/docs/compat.dox - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = *.h *.dox - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = APIENTRY GLFWAPI - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = @GLFW_SOURCE_DIR@/examples - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command <filter> <input-file>, where <filter> -# is the value of the INPUT_FILTER tag, and <input-file> is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page (index.html). -# This can be useful if you have a project on for instance GitHub and want reuse -# the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = glfw GLFW_ - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = @GLFW_SOURCE_DIR@/docs/header.html - -# 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 -# standard footer. - -HTML_FOOTER = @GLFW_SOURCE_DIR@/docs/footer.html - -# 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 -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. - -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 -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> -# Qt Help Project / Custom Filters</a>. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> -# Qt Help Project / Filter Attributes</a>. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 300 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and -# SVG. The default value is HTML-CSS, which is slower, but has the best -# compatibility. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. -# There are two flavours of web server based search depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. -# See the manual for details. - -SERVER_BASED_SEARCH = NO - -# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP -# script for searching. Instead the search results are written to an XML file -# which needs to be processed by an external indexer. Doxygen will invoke an -# external search engine pointed to by the SEARCHENGINE_URL option to obtain -# the search results. Doxygen ships with an example indexer (doxyindexer) and -# search engine (doxysearch.cgi) which are based on the open source search engine -# library Xapian. See the manual for configuration details. - -EXTERNAL_SEARCH = NO - -# The SEARCHENGINE_URL should point to a search engine hosted by a web server -# which will returned the search results when EXTERNAL_SEARCH is enabled. -# Doxygen ships with an example search engine (doxysearch) which is based on -# the open source search engine library Xapian. See the manual for configuration -# details. - -SEARCHENGINE_URL = - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed -# search data is written to a file for indexing by an external tool. With the -# SEARCHDATA_FILE tag the name of this file can be specified. - -SEARCHDATA_FILE = searchdata.xml - -# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the -# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is -# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple -# projects and redirect the results back to the right project. - -EXTERNAL_SEARCH_ID = - -# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen -# projects other than the one defined by this configuration file, but that are -# all added to the same external search index. Each project needs to have a -# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id -# of to a relative location where the documentation can be found. -# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... - -EXTRA_SEARCH_MAPPINGS = - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = YES - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = GLFWAPI= \ - GLFW_EXPOSE_NATIVE_WIN32 \ - GLFW_EXPOSE_NATIVE_WGL \ - GLFW_EXPOSE_NATIVE_X11 \ - GLFW_EXPOSE_NATIVE_GLX \ - GLFW_EXPOSE_NATIVE_COCOA \ - GLFW_EXPOSE_NATIVE_NSGL \ - GLFW_EXPOSE_NATIVE_EGL - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50% before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/glfw/docs/DoxygenLayout.xml b/glfw/docs/DoxygenLayout.xml deleted file mode 100644 index 7917f91..0000000 --- a/glfw/docs/DoxygenLayout.xml +++ /dev/null @@ -1,188 +0,0 @@ -<doxygenlayout version="1.0"> - <!-- Generated by doxygen 1.8.3.1 --> - <!-- Navigation index tabs for HTML output --> - <navindex> - <tab type="mainpage" visible="yes" title="Introduction"/> - <tab type="pages" visible="yes" title="Guides" intro=""/> - <tab type="modules" visible="yes" title="Reference" intro=""/> - <tab type="namespaces" visible="yes" title=""> - <tab type="namespacelist" visible="yes" title="" intro=""/> - <tab type="namespacemembers" visible="yes" title="" intro=""/> - </tab> - <tab type="classes" visible="no" title=""> - <tab type="classlist" visible="yes" title="" intro=""/> - <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> - <tab type="hierarchy" visible="yes" title="" intro=""/> - <tab type="classmembers" visible="yes" title="" intro=""/> - </tab> - <tab type="files" visible="yes" title="Header Files"> - <tab type="filelist" visible="yes" title="" intro=""/> - <tab type="globals" visible="yes" title="" intro=""/> - </tab> - <tab type="examples" visible="yes" title="" intro=""/> - </navindex> - - <!-- Layout definition for a class page --> - <class> - <briefdescription visible="yes"/> - <includes visible="$SHOW_INCLUDE_FILES"/> - <inheritancegraph visible="$CLASS_GRAPH"/> - <collaborationgraph visible="$COLLABORATION_GRAPH"/> - <memberdecl> - <nestedclasses visible="yes" title=""/> - <publictypes title=""/> - <publicslots title=""/> - <signals title=""/> - <publicmethods title=""/> - <publicstaticmethods title=""/> - <publicattributes title=""/> - <publicstaticattributes title=""/> - <protectedtypes title=""/> - <protectedslots title=""/> - <protectedmethods title=""/> - <protectedstaticmethods title=""/> - <protectedattributes title=""/> - <protectedstaticattributes title=""/> - <packagetypes title=""/> - <packagemethods title=""/> - <packagestaticmethods title=""/> - <packageattributes title=""/> - <packagestaticattributes title=""/> - <properties title=""/> - <events title=""/> - <privatetypes title=""/> - <privateslots title=""/> - <privatemethods title=""/> - <privatestaticmethods title=""/> - <privateattributes title=""/> - <privatestaticattributes title=""/> - <friends title=""/> - <related title="" subtitle=""/> - <membergroups visible="yes"/> - </memberdecl> - <detaileddescription title=""/> - <memberdef> - <inlineclasses title=""/> - <typedefs title=""/> - <enums title=""/> - <constructors title=""/> - <functions title=""/> - <related title=""/> - <variables title=""/> - <properties title=""/> - <events title=""/> - </memberdef> - <allmemberslink visible="yes"/> - <usedfiles visible="$SHOW_USED_FILES"/> - <authorsection visible="yes"/> - </class> - - <!-- Layout definition for a namespace page --> - <namespace> - <briefdescription visible="yes"/> - <memberdecl> - <nestednamespaces visible="yes" title=""/> - <classes visible="yes" title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - <membergroups visible="yes"/> - </memberdecl> - <detaileddescription title=""/> - <memberdef> - <inlineclasses title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - </memberdef> - <authorsection visible="yes"/> - </namespace> - - <!-- Layout definition for a file page --> - <file> - <briefdescription visible="yes"/> - <includes visible="$SHOW_INCLUDE_FILES"/> - <includegraph visible="$INCLUDE_GRAPH"/> - <includedbygraph visible="$INCLUDED_BY_GRAPH"/> - <sourcelink visible="yes"/> - <memberdecl> - <classes visible="yes" title=""/> - <namespaces visible="yes" title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - <membergroups visible="yes"/> - </memberdecl> - <detaileddescription title=""/> - <memberdef> - <inlineclasses title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - </memberdef> - <authorsection/> - </file> - - <!-- Layout definition for a group page --> - <group> - <briefdescription visible="yes"/> - <detaileddescription title="Description"/> - <groupgraph visible="$GROUP_GRAPHS"/> - <memberdecl> - <nestedgroups visible="yes" title=""/> - <dirs visible="yes" title=""/> - <files visible="yes" title=""/> - <namespaces visible="yes" title=""/> - <classes visible="yes" title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <enumvalues title=""/> - <functions title=""/> - <variables title=""/> - <signals title=""/> - <publicslots title=""/> - <protectedslots title=""/> - <privateslots title=""/> - <events title=""/> - <properties title=""/> - <friends title=""/> - <membergroups visible="yes"/> - </memberdecl> - <memberdef> - <pagedocs/> - <inlineclasses title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <enumvalues title=""/> - <functions title=""/> - <variables title=""/> - <signals title=""/> - <publicslots title=""/> - <protectedslots title=""/> - <privateslots title=""/> - <events title=""/> - <properties title=""/> - <friends title=""/> - </memberdef> - <authorsection visible="yes"/> - </group> - - <!-- Layout definition for a directory page --> - <directory> - <briefdescription visible="yes"/> - <directorygraph visible="yes"/> - <memberdecl> - <dirs visible="yes"/> - <files visible="yes"/> - </memberdecl> - <detaileddescription title=""/> - </directory> -</doxygenlayout> diff --git a/glfw/docs/build.dox b/glfw/docs/build.dox deleted file mode 100644 index e9794dd..0000000 --- a/glfw/docs/build.dox +++ /dev/null @@ -1,298 +0,0 @@ -/*! - -@page build Building programs that use GLFW - -@tableofcontents - -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). -For information on how to compile the GLFW library itself, see the @ref compile -guide. - -This is not a tutorial on compilation. It assumes basic understanding of how to -compile a C program as well as how to use the specific compiler of your chosen -development environment. The compilation process should be explained in your -C programming material and the use of and options for your compiler should be -described in detail in the documentation for your development environment. - -@section build_include Including the GLFW header file - -In the files of your program where you use OpenGL or GLFW, you should include -the GLFW header file, i.e.: - -@code -#include <GLFW/glfw3.h> -@endcode - -The GLFW header declares the GLFW API and by default also includes the OpenGL -header of your development environment, which in turn defines all the constants, -types and function prototypes of the OpenGL API. - -The GLFW header also defines everything necessary for your OpenGL header to -function. For example, under Windows you are normally required to include -`windows.h` before the OpenGL header. This would make your source file tied -to Windows and pollute your code's namespace with the whole Win32 API. - -Instead, the GLFW header takes care of this for you, not by including -`windows.h`, but by duplicating only the very few necessary parts of it. It -does this only when needed, so if `windows.h` *is* included, the GLFW header -does not try to redefine those symbols. - -In other words: - - - Do *not* include the OpenGL headers yourself, as GLFW does this for you - - Do *not* include `windows.h` or other platform-specific headers unless you - plan on using those APIs directly - - If you *do* need to include such headers, do it *before* including - the GLFW one and it will detect this - -If you are using an OpenGL extension loading library such as -[glad](https://github.com/Dav1dde/glad), the extension loader header should -either be included *before* the GLFW one, or the `GLFW_INCLUDE_NONE` macro -(described below) should be defined. - - -@subsection build_macros GLFW header option macros - -These macros may be defined before the inclusion of the GLFW header and affect -its behavior. - -`GLFW_DLL` is required on Windows when using the GLFW DLL, to tell the compiler -that the GLFW functions are defined in a DLL. - -The following macros control which client API header is included. - -`GLFW_INCLUDE_GLCOREARB` makes the header include the modern `GL/glcorearb.h` -header (`OpenGL/gl3.h` on OS X) instead of the regular OpenGL header. - -`GLFW_INCLUDE_ES1` makes the header include the OpenGL ES 1.x `GLES/gl.h` header -instead of the regular OpenGL header. - -`GLFW_INCLUDE_ES2` makes the header include the OpenGL ES 2.0 `GLES2/gl2.h` -header instead of the regular OpenGL header. - -`GLFW_INCLUDE_ES3` makes the header include the OpenGL ES 3.0 `GLES3/gl3.h` -header instead of the regular OpenGL header. - -`GLFW_INCLUDE_ES31` makes the header include the OpenGL ES 3.1 `GLES3/gl31.h` -header instead of the regular OpenGL header. - -`GLFW_INCLUDE_NONE` makes the header not include any client API header. This is -useful in combination with an extension loading library. - -If none of the above inclusion macros are defined, the standard OpenGL header is -included. - -`GLFW_INCLUDE_GLU` makes the header include the GLU header *in addition to* the -header selected above. This should only be used with legacy code. GLU has been -deprecated and should not be used in new code. - -@note GLFW does not provide any of the API headers mentioned above. They must -be provided by your development environment or your OpenGL or OpenGL ES SDK. - - -@section build_link Link with the right libraries - -GLFW is essentially a wrapper of various platform-specific APIs and therefore -needs to link against many different system libraries. If you are using GLFW as -a shared library / dynamic library / DLL then it takes care of these links. -However, if you are using GLFW as a static library then your executable will -need to link against these libraries. - -On Windows and OS X, the list of system libraries is static and can be -hard-coded into your build environment. See the section for your development -environment below. On Linux and other Unix-like operating systems, the list -varies but can be retrieved in various ways as described below. - -This is not a tutorial on linking. It assumes basic understanding of how to -link a C program as well as how to use the specific linker of your chosen -development environment. The linking process should be explained in your -C programming material and the use of and options for your linker should be -described in detail in the documentation for your development environment. - -A good general introduction to linking is -[Beginner's Guide to Linkers](http://www.lurklurk.org/linkers/linkers.html) by -David Drysdale. - - -@subsection build_link_win32 With MinGW or Visual C++ on Windows - -The static version of the GLFW library is named `glfw3`. When using this -version, it is also necessary to link with some libraries that GLFW uses. - -When linking a program under Windows that uses the static version of GLFW, you -must link with `opengl32`. On some versions of MinGW, you must also explicitly -link with `gdi32`, while other versions of MinGW include it in the set of -default libraries along with other dependencies like `user32` and `kernel32`. -If you are using GLU, you must also link with `glu32`. - -The link library for the GLFW DLL is named `glfw3dll`. When compiling a program -that uses the DLL version of GLFW, you need to define the `GLFW_DLL` macro -*before* any inclusion of the GLFW header. This can be done either with -a compiler switch or by defining it in your source code. - -A program using the GLFW DLL does not need to link against any of its -dependencies, but you still have to link against `opengl32` if your program uses -OpenGL and `glu32` if it uses GLU. - - -@subsection build_link_cmake_source With CMake and GLFW source - -With just a few changes to your `CMakeLists.txt` you can have the GLFW source -tree built along with your application. - -Firstly, add the root directory of the GLFW source tree to your project. This -will add the `glfw` target and the necessary cache variables to your project. - -@code{.cmake} -add_subdirectory(path/to/glfw) -@endcode - -To be able to include the GLFW header from your code, you need to tell the -compiler where to find it. - -@code{.cmake} -include_directories(path/to/glfw/include) -@endcode - -Once GLFW has been added to the project, the `GLFW_LIBRARIES` cache variable -contains all link-time dependencies of GLFW as it is currently configured. To -link against GLFW, link against them and the `glfw` target. - -@code{.cmake} -target_link_libraries(myapp glfw ${GLFW_LIBRARIES}) -@endcode - -Note that `GLFW_LIBRARIES` does not include GLU, as GLFW does not use it. If -your application needs GLU, you can add it to the list of dependencies with the -`OPENGL_glu_LIBRARY` cache variable, which is implicitly created when the GLFW -CMake files look for OpenGL. - -@code{.cmake} -target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES}) -@endcode - - -@subsection build_link_cmake_pkgconfig With CMake on Unix and installed GLFW binaries - -CMake can import settings from pkg-config, which GLFW supports. When you -installed GLFW, the pkg-config file `glfw3.pc` was installed along with it. - -First you need to find the PkgConfig package. If this fails, you may need to -install the pkg-config package for your distribution. - -@code{.cmake} -find_package(PkgConfig REQUIRED) -@endcode - -This creates the CMake commands to find pkg-config packages. Then you need to -find the GLFW package. - -@code{.cmake} -pkg_search_module(GLFW REQUIRED glfw3) -@endcode - -This creates the CMake variables you need to use GLFW. To be able to include -the GLFW header, you need to tell your compiler where it is. - -@code{.cmake} -include_directories(${GLFW_INCLUDE_DIRS}) -@endcode - -You also need to link against the correct libraries. If you are using the -shared library version of GLFW, use the `GLFW_LIBRARIES` variable. - -@code{.cmake} -target_link_libraries(simple ${GLFW_LIBRARIES}) -@endcode - -If you are using the static library version of GLFW, use the -`GLFW_STATIC_LIBRARIES` variable instead. - -@code{.cmake} -target_link_libraries(simple ${GLFW_STATIC_LIBRARIES}) -@endcode - - -@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/), -and the `glfw3.pc` pkf-config file is generated when the GLFW library is built -and is installed along with it. A pkg-config file describes all necessary -compile-time and link-time flags and dependencies needed to use a library. When -they are updated or if they differ between systems, you will get the correct -ones automatically. - -A typical compile and link command-line when using the static version of the -GLFW library may look like this: - -@code{.sh} -cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --static --libs glfw3` -@endcode - -If you are using the shared version of the GLFW library, simply omit the -`--static` flag. - -@code{.sh} -cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3` -@endcode - -You can also use the `glfw3.pc` file without installing it first, by using the -`PKG_CONFIG_PATH` environment variable. - -@code{.sh} -env PKG_CONFIG_PATH=path/to/glfw/src cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3` -@endcode - -The dependencies do not include GLU, as GLFW does not need it. On OS X, GLU is -built into the OpenGL framework, so if you need GLU you don't need to do -anything extra. If you need GLU and are using Linux or BSD, you should add the -`glu` pkg-config module. - -@code{.sh} -cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --libs glfw3 glu` -@endcode - -If you are using the static version of the GLFW library, make sure you don't link statically against GLU. - -@code{.sh} -cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --static --libs glfw3` `pkg-config --libs glu` -@endcode - - -@subsection build_link_xcode With Xcode on OS X - -If you are using the dynamic library version of GLFW, simply add it to the -project dependencies. - -If you are using the static library version of GLFW, add it and the Cocoa, -OpenGL, IOKit and CoreVideo frameworks to the project as dependencies. They can -all be found in `/System/Library/Frameworks`. - - -@subsection build_link_osx With command-line on OS X - -It is recommended that you use [pkg-config](@ref build_link_pkgconfig) when -building from the command line on OS X. That way you will get any new -dependencies added automatically. If you still wish to build manually, you need -to add the required frameworks and libraries to your command-line yourself using -the `-l` and `-framework` switches. - -If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do: - -@code{.sh} -cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -@endcode - -If you are using the static library, named `libglfw3.a`, substitute `-lglfw3` -for `-lglfw`. - -Note that you do not add the `.framework` extension to a framework when linking -against it from the command-line. - -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 -`libGL`-style OpenGL libraries, they are for use with the X Window System and -will *not* work with the OS X native version of GLFW. - -*/ diff --git a/glfw/docs/compat.dox b/glfw/docs/compat.dox deleted file mode 100644 index e797e11..0000000 --- a/glfw/docs/compat.dox +++ /dev/null @@ -1,176 +0,0 @@ -/*! - -@page compat Standards conformance - -@tableofcontents - -This chapter describes the various API extensions used by this version of GLFW. -It lists what are essentially implementation details, but which are nonetheless -vital knowledge for developers wishing to deploy their applications on machines -with varied specifications. - -Note that the information in this appendix is not a part of the API -specification but merely list some of the preconditions for certain parts of the -API to function on a given machine. As such, any part of it may change in -future versions without this being considered a breaking API change. - -@section compat_x11 X11 extensions, protocols and IPC standards - -As GLFW uses Xlib, directly, without any intervening toolkit -library, it has sole responsibility for interacting well with the many and -varied window managers in use on Unix-like systems. In order for applications -and window managers to work well together, a number of standards and -conventions have been developed that regulate behavior outside the scope of the -X11 API; most importantly the -[Inter-Client Communication Conventions Manual](http://www.tronche.com/gui/x/icccm/) -(ICCCM) and -[Extended Window Manager Hints](http://standards.freedesktop.org/wm-spec/wm-spec-latest.html) -(EWMH) standards. - -GLFW uses the `_MOTIF_WM_HINTS` window property to support borderless windows. -If the running window manager does not support this property, the -`GLFW_DECORATED` hint will have no effect. - -GLFW uses the ICCCM `WM_DELETE_WINDOW` protocol to intercept the user -attempting to close the GLFW window. If the running window manager does not -support this protocol, the close callback will never be called. - -GLFW uses the EWMH `_NET_WM_PING` protocol, allowing the window manager notify -the user when the application has stopped responding, i.e. when it has ceased to -process events. If the running window manager does not support this protocol, -the user will not be notified if the application locks up. - -GLFW uses the EWMH `_NET_WM_STATE_FULLSCREEN` window state to tell the window -manager to make the GLFW window full screen. If the running window manager does -not support this state, full screen windows may not work properly. GLFW has -a fallback code path in case this state is unavailable, but every window manager -behaves slightly differently in this regard. - -GLFW uses the EWMH `_NET_WM_BYPASS_COMPOSITOR` window property to tell a -compositing window manager to un-redirect full screen GLFW windows. If the -running window manager uses compositing but does not support this property then -additional copying may be performed for each buffer swap of full screen windows. - -GLFW uses the -[clipboard manager protocol](http://www.freedesktop.org/wiki/ClipboardManager/) -to push a clipboard string (i.e. selection) owned by a GLFW window about to be -destroyed to the clipboard manager. If there is no running clipboard manager, -the clipboard string will be unavailable once the window has been destroyed. - -GLFW uses the -[X drag-and-drop protocol](http://www.freedesktop.org/wiki/Specifications/XDND/) -to provide file drop events. If the application originating the drag does not -support this protocol, drag and drop will not work. - -GLFW uses the XInput 2 extension to provide sub-pixel cursor motion events. If -the running X server does not support this version of this extension, cursor -motion will be snapped to the pixel grid. - -GLFW uses the XRandR 1.3 extension to provide multi-monitor support. If the -running X server does not support this version of this extension, multi-monitor -support will not function and only a single, desktop-spanning monitor will be -reported. - -GLFW uses the XRandR 1.3 and Xf86vidmode extensions to provide gamma ramp -support. If the running X server does not support either or both of these -extensions, gamma ramp support will not function. - -GLFW requires the Xkb extension with detectable auto-repeat to provide keyboard -input. If the running X server does not support this extension, a non-Xkb -fallback path is used. - -@section compat_glx GLX extensions - -The GLX API is the default API used to create OpenGL contexts on Unix-like -systems using the X Window System. - -GLFW uses the `GLXFBConfig` API to enumerate and select framebuffer pixel -formats. This requires GLX 1.3 or greater. - -GLFW uses the `GLX_MESA_swap_control,` `GLX_EXT_swap_control` and -`GLX_SGI_swap_control` extensions to provide vertical retrace synchronization -(or "vsync"), in that order of preference. Where none of these extension are -available, calling @ref glfwSwapInterval will have no effect. - -GLFW uses the `GLX_ARB_multisample` extension to create contexts with -multisampling anti-aliasing. Where this extension is unavailable, the -`GLFW_SAMPLES` hint will have no effect. - -GLFW uses the `GLX_ARB_create_context` extension when available, even when -creating OpenGL contexts of version 2.1 and below. Where this extension is -unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` -hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint -will have no effect, and setting the `GLFW_OPENGL_PROFILE` or -`GLFW_OPENGL_FORWARD_COMPAT` hints to a non-zero value will cause @ref -glfwCreateWindow to fail. - -GLFW uses the `GLX_ARB_create_context_profile` extension to provide support for -context profiles. Where this extension is unavailable, setting the -`GLFW_OPENGL_PROFILE` hint to anything but zero, or setting `GLFW_CLIENT_API` to -anything but `GLFW_OPENGL_API` will cause @ref glfwCreateWindow to fail. - -GLFW uses the `GLX_ARB_context_flush_control` extension to provide control over -whether a context is flushed when it is released (made non-current). Where this -extension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no -effect and the context will always be flushed when released. - -@section compat_wgl WGL extensions - -The WGL API is used to create OpenGL contexts on Microsoft Windows and other -implementations of the Win32 API, such as Wine. - -GLFW uses either the `WGL_EXT_extension_string` or the -`WGL_ARB_extension_string` extension to check for the presence of all other WGL -extensions listed below. If both are available, the EXT one is preferred. If -neither is available, no other extensions are used and many GLFW features -related to context creation will have no effect or cause errors when used. - -GLFW uses the `WGL_EXT_swap_control` extension to provide vertical retrace -synchronization (or 'vsync'). Where this extension is unavailable, calling @ref -glfwSwapInterval will have no effect. - -GLFW uses the `WGL_ARB_pixel_format` and `WGL_ARB_multisample` extensions to -create contexts with multisampling anti-aliasing. Where these extensions are -unavailable, the `GLFW_SAMPLES` hint will have no effect. - -GLFW uses the `WGL_ARB_create_context` extension when available, even when -creating OpenGL contexts of version 2.1 and below. Where this extension is -unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` -hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint -will have no effect, and setting the `GLFW_OPENGL_PROFILE` or -`GLFW_OPENGL_FORWARD_COMPAT` hints to a non-zero value will cause @ref -glfwCreateWindow to fail. - -GLFW uses the `WGL_ARB_create_context_profile` extension to provide support for -context profiles. Where this extension is unavailable, setting the -`GLFW_OPENGL_PROFILE` hint to anything but zero will cause @ref glfwCreateWindow -to fail. - -GLFW uses the `WGL_ARB_context_flush_control` extension to provide control over -whether a context is flushed when it is released (made non-current). Where this -extension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no -effect and the context will always be flushed when released. - -@section compat_osx OpenGL 3.2 and later on OS X - -Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then -only forward-compatible, core profile contexts are supported. Support for -OpenGL 4.1 was introduced with OS X 10.9, also limited to forward-compatible, -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 OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and -`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if -given version 3.0 or 3.1, the `GLFW_OPENGL_FORWARD_COMPAT` hint must be set to -non-zero and the `GLFW_OPENGL_PROFILE` hint must be set to -`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts and the -`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored. - -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, -setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to -a non-default value will cause @ref glfwCreateWindow to fail and the -`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored. - -*/ diff --git a/glfw/docs/compile.dox b/glfw/docs/compile.dox deleted file mode 100644 index ef53e54..0000000 --- a/glfw/docs/compile.dox +++ /dev/null @@ -1,267 +0,0 @@ -/*! - -@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 projects using CMake 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_USE_RETINA` determines whether windows will use the full resolution of -Retina displays. - -`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 - - `_GLFW_WAYLAND` to use the Wayland API (experimental and incomplete) - -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 - -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) - - `_GLFW_USE_RETINA` to have windows use the full resolution of Retina displays - (recommended) - -*/ diff --git a/glfw/docs/context.dox b/glfw/docs/context.dox deleted file mode 100644 index ccca60c..0000000 --- a/glfw/docs/context.dox +++ /dev/null @@ -1,260 +0,0 @@ -/*! - -@page context Context handling guide - -@tableofcontents - -The primary purpose of GLFW is to provide a simple interface to window -management and OpenGL and OpenGL ES context creation. GLFW supports -multiple windows, with each window having its own context. - - -@section context_object Context handles - -The @ref GLFWwindow object encapsulates both a [window](@ref window) and -a context. It is created with @ref glfwCreateWindow and destroyed with @ref -glfwDestroyWindow or @ref glfwTerminate. As the window and context are -inseparably linked, the object pointer is used as both a context and window -handle. - - -@section context_hints Context creation hints - -There are a number of hints, specified using @ref glfwWindowHint, related to -what kind of context is created. See -[context related hints](@ref window_hints_ctx) in the window handling guide. - - -@section context_sharing Context object sharing - -When creating a window and context with @ref glfwCreateWindow, you can specify -another window whose context the new one should share its objects with. Object -sharing is implemented by the operating system and graphics driver and is -described in the OpenGL and OpenGL ES documentation. On platforms where it is -possible to choose which types of objects are shared, GLFW requests that all are -shared. - - -@section context_current Current context - -Before you can make OpenGL or OpenGL ES calls, you need to have a current -context of the proper type. The context encapsulates all render state and all -objects like textures and shaders. - -A context is made current with @ref glfwMakeContextCurrent. - -@code -glfwMakeContextCurrent(window); -@endcode - -The current context is returned by @ref glfwGetCurrentContext. - -@code -GLFWwindow* window = glfwGetCurrentContext(); -@endcode - -@note A context must only be current for a single thread at a time, and a thread -must only have a single context current at a time. - - -@section context_swap Swapping buffers - -Buffer swapping is part of the window and framebuffer, not the context. See -@ref window_swap in the window handling guide. - - -@section context_glext OpenGL and OpenGL ES extensions - -One of the benefits of OpenGL and OpenGL ES are their extensibility. -Hardware vendors may include extensions in their implementations that extend the -API before that functionality is included in a new version of the OpenGL or -OpenGL ES specification, and some extensions are never included and remain -as extensions until they become obsolete. - -An extension is defined by: - -- An extension name (e.g. `GL_ARB_debug_output`) -- New OpenGL tokens (e.g. `GL_DEBUG_SEVERITY_HIGH_ARB`) -- New OpenGL functions (e.g. `glGetDebugMessageLogARB`) - -Note the `ARB` affix, which stands for Architecture Review Board and is used -for official extensions. The extension above was created by the ARB, but there -are many different affixes, like `NV` for Nvidia and `AMD` for, well, AMD. Any -group may also use the generic `EXT` affix. Lists of extensions, together with -their specifications, can be found at the -[OpenGL Registry](http://www.opengl.org/registry/) and -[OpenGL ES Registry](https://www.khronos.org/registry/gles/). - - -@subsection context_glext_auto Using an extension loader library - -This is the easiest and best way to load extensions and newer versions of the -OpenGL or OpenGL ES API. One such library is -[glad](https://github.com/Dav1dde/glad) and there are several others. They will -take care of all the details of declaring and loading everything you need. - -The following example will use glad, but other extension loader libraries work -similary. - -First you need to generate the source files using the glad Python script. This -example generates a loader for any version of OpenGL, which is the default for -both GLFW and glad, but loaders for OpenGL ES, as well as loaders for specific -API versions and extension sets can be generated. The generated files are -written to the `output` directory. - -@code{.sh} -python main.py --no-loader --out-path output -@endcode - -@note The `--no-loader` option is used because GLFW already provides a function -for loading OpenGL and OpenGL ES function pointers and glad can use this instead -of having to add its own. - -Add the generated `output/src/glad.c`, `output/include/glad/glad.h` and -`output/include/KHR/khrplatform.h` files to your build. Then you need to -include the glad header file, which will replace the OpenGL header of your -development environment. - -@code -#include <glad/glad.h> -#include <GLFW/glfw3.h> -@endcode - -Finally you need to initialize glad once you have a matching current context. - -@code -window = glfwCreateWindow(640, 480, "My Window", NULL, NULL); -if (!window) -{ - ... -} - -glfwMakeContextCurrent(window); - -gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); -@endcode - -Once glad has been loaded, you have access to all OpenGL core and extension -functions supported by the context you created and you are ready to start -rendering. - -You can specify a minimum required OpenGL or OpenGL ES version with -[context hints](@ref window_hints_ctx). If your needs are more complex, you can -check the actual OpenGL or OpenGL ES version with -[context attributes](@ref window_attribs_context), or you can check whether -a specific version is supported by the current context with the -`GLAD_GL_VERSION_x_x` booleans. - -@code -if (GLAD_GL_VERSION_3_2) -{ - // Call OpenGL 3.2+ specific code -} -@endcode - -To check whether a specific extension is supported, use the `GLAD_GL_xxx` -booleans. - -@code -if (GLAD_GL_ARB_debug_output) -{ - // Use GL_ARB_debug_output -} -@endcode - - -@subsection context_glext_manual Loading extensions manually - -To use a certain extension, you must first check whether the context supports -that extension and then, if it introduces new functions, retrieve the pointers -to those functions. GLFW provides @ref glfwExtensionSupported and @ref -glfwGetProcAddress for manual loading of extensions and new API functions. - -@note It is strongly recommended that you use an existing extension loader -library like [glad](https://github.com/Dav1dde/glad) instead of loading -manually. Extension loading is a solved problem and you will gain nothing from -solving it again by hand. - - -@subsubsection context_glext_header The glext.h header - -The `glext.h` header is a continually updated file that defines the interfaces -for all OpenGL extensions. The latest version of this can always be found at -the [OpenGL Registry](http://www.opengl.org/registry/). It it strongly -recommended that you use your own copy, as the one shipped with your development -environment may be several years out of date and may not include the extensions -you wish to use. - -The header defines function pointer types for all functions of all extensions it -supports. These have names like `PFNGLGETDEBUGMESSAGELOGARB` (for -`glGetDebugMessageLogARB`), i.e. the name is made uppercase and `PFN` (pointer -to function) and `PROC` (procedure) are added to the ends. - - -@subsubsection context_glext_string Checking for extensions - -A given machine may not actually support the extension (it may have older -drivers or a graphics card that lacks the necessary hardware features), so it -is necessary to check whether the context supports the extension. This is done -with @ref glfwExtensionSupported. - -@code -if (glfwExtensionSupported("GL_ARB_debug_output")) -{ - // The extension is supported by the current context -} -@endcode - -The argument is a null terminated ASCII string with the extension name. If the -extension is supported, @ref glfwExtensionSupported returns non-zero, otherwise -it returns zero. - - -@subsubsection context_glext_proc Fetching function pointers - -Many extensions, though not all, require the use of new OpenGL functions. -These functions often do not have entry points in the client API libraries of -your operating system, making it necessary to fetch them at run time. You can -retreive pointers to these functions with @ref glfwGetProcAddress. - -@code -PFNGLGETDEBUGMESSAGELOGARB pfnGetDebugMessageLog = glfwGetProcAddress("glGetDebugMessageLogARB"); -@endcode - -In general, you should avoid giving the function pointer variables the (exact) -same name as the function, as this may confuse your linker. Instead, you can -use a different prefix, like above, or some other naming scheme. - -Now that all the pieces have been introduced, here is what they might look like -when used together. - -@code -#include "glext.h" - -#define glGetDebugMessageLogARB pfnGetDebugMessageLog -PFNGLGETDEBUGMESSAGELOGARB pfnGetDebugMessageLog; - -// Flag indicating whether the extension is supported -int has_debug_output = 0; - -void load_extensions(void) -{ - if (glfwExtensionSupported("GL_ARB_debug_output")) - { - pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARB) glfwGetProcAddress("glGetDebugMessageLogARB"); - if (pfnGetDebugMessageLog) - { - // Both the extension name and the function pointer are present - has_debug_output = 1; - } - } -} - -void some_function(void) -{ - // Now the extension function can be called as usual - glGetDebugMessageLogARB(...); -} -@endcode - -*/ diff --git a/glfw/docs/extra.css b/glfw/docs/extra.css deleted file mode 100644 index 2f55d7f..0000000 --- a/glfw/docs/extra.css +++ /dev/null @@ -1 +0,0 @@ -#navrow1,#navrow2,#navrow3,#navrow4,.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,hr,.memSeparator{border:none}.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code{background:#f2f2f2}body{color:#4d4d4d}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}.glfwheader{font-size:16px;height:64px;max-width:920px;min-width:800px;padding:0 32px;margin:0 auto}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url("http://www.glfw.org/css/arrow.png") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#navrow1,#navrow2,#navrow3,#navrow4{max-width:920px;min-width:800px;margin:0 auto;font-size:13px}.tablist{height:36px;display:block;position:relative}.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a{color:#f2f2f2}.tablist li.current a{background:linear-gradient(to bottom, #ffa733 0, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;color:#fff}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:none;width:auto}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,.tablist a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe599}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e5c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e599bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce5}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:0 1px 1px #fff}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px} diff --git a/glfw/docs/extra.less b/glfw/docs/extra.less deleted file mode 100644 index 9e4a6c9..0000000 --- a/glfw/docs/extra.less +++ /dev/null @@ -1,351 +0,0 @@ -// NOTE: Please use this file to perform modifications on default style sheets. -// -// You need to install a few Ruby gems to generate extra.css from this file: -// gem install less therubyracer -// -// Run this command to regenerate extra.css after you're finished with changes: -// lessc --compress extra.less > extra.css -// -// Alternatively you can use online services to regenerate extra.css. - - -// Default text color for page contents -@default-text-color: hsl(0,0%,30%); - -// Page header, footer, table rows, inline codes and definition lists -@header-footer-background-color: hsl(0,0%,95%); - -// Page header, footer links and navigation bar background -@header-footer-link-color: hsl(0,0%,40%); - -// Doxygen navigation bar links -@navbar-link-color: @header-footer-background-color; - -// Page content background color -@content-background-color: hsl(0,0%,100%); - -// Bold, italic, h1, h2, ... and table of contents -@heading-color: hsl(0,0%,10%); - -// Function, enum and macro definition separator -@def-separator-color: @header-footer-background-color; - -// Base color hue -@base-hue: 24; - -// Default color used for links -@default-link-color: hsl(@base-hue,100%,50%); - -// Doxygen navigation bar active tab -@tab-text-color: hsl(0,0%,100%); -@tab-background-color1: @default-link-color; -@tab-background-color2: lighten(spin(@tab-background-color1, 10), 10%); - -// Table borders -@default-border-color: @default-link-color; - -// Table header -@table-text-color: @tab-text-color; -@table-background-color1: @tab-background-color1; -@table-background-color2: @tab-background-color2; - -// Table of contents, data structure index and prototypes -@toc-background-color1: hsl(0,0%,90%); -@toc-background-color2: lighten(@toc-background-color1, 5%); - -// Function prototype parameters color -@prototype-param-color: darken(@default-link-color, 25%); - -// Message box color: note, pre, post and invariant -@box-note-color: hsl(103,80%,85%); - -// Message box color: warning and attention -@box-warning-color: hsl(34,80%,85%); - -// Message box color: deprecated and bug -@box-bug-color: hsl(333,80%,85%); - -// Message box color: todo and test -@box-todo-color: hsl(200,80%,85%); - -// Message box helper function -.message-box(@base-color) { - background:linear-gradient(to bottom,lighten(@base-color, 5%) 0%,@base-color 100%); - box-shadow:inset 0 0 32px darken(@base-color, 5%); - color:darken(@base-color, 67%); - border:2px solid desaturate(darken(@base-color, 10%), 20%); -} - - -#navrow1,#navrow2,#navrow3,#navrow4,.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code { - background:none; -} - -#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,hr,.memSeparator { - border:none; -} - -.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.reflist dt a.el,.levels span,.directory .levels span { - text-shadow:none; -} - -.memdoc,dl.reflist dd { - box-shadow:none; -} - -div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code { - padding:0; -} - -#nav-path,.directory .levels,span.lineno { - display:none; -} - -html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code { - background:@header-footer-background-color; -} - -body { - color:@default-text-color; -} - -h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em { - color:@heading-color; - border-bottom:none; -} - -.glfwheader { - font-size:16px; - height:64px; - max-width:920px; - min-width:800px; - padding:0 32px; - margin:0 auto; -} - -#glfwhome { - line-height:64px; - padding-right:48px; - color:@header-footer-link-color; - font-size:2.5em; - background:url("http://www.glfw.org/css/arrow.png") no-repeat right; -} - -.glfwnavbar { - list-style-type:none; - margin:0 auto; - float:right; -} - -#glfwhome,.glfwnavbar li { - float:left; -} - -.glfwnavbar a,.glfwnavbar a:visited { - line-height:64px; - margin-left:2em; - display:block; - color:@header-footer-link-color; -} - -#glfwhome,.glfwnavbar a,.glfwnavbar a:visited { - transition:.35s ease; -} - -#titlearea,.footer { - color:@header-footer-link-color; -} - -address.footer { - text-align:center; - padding:2em; - margin-top:3em; -} - -#top { - background:@header-footer-link-color; -} - -#navrow1,#navrow2,#navrow3,#navrow4 { - max-width:920px; - min-width:800px; - margin:0 auto; - font-size:13px; -} - -.tablist { - height:36px; - display:block; - position:relative; -} - -.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a { - color:@navbar-link-color; -} - -.tablist li.current a { - background:linear-gradient(to bottom,@tab-background-color2 0%,@tab-background-color1 100%); - box-shadow:inset 0 0 32px @tab-background-color1; - text-shadow:0 -1px 1px darken(@tab-background-color1, 15%); - color:@tab-text-color; -} - -.contents { - min-height:590px; -} - -div.contents,div.header { - max-width:920px; - margin:0 auto; - padding:0 32px; - background:@content-background-color none; -} - -table.doxtable th,dl.reflist dt { - background:linear-gradient(to bottom,@table-background-color2 0%,@table-background-color1 100%); - box-shadow:inset 0 0 32px @table-background-color1; - text-shadow:0 -1px 1px darken(@table-background-color1, 15%); - color:@table-text-color; -} - -dl.reflist dt a.el { - color:@default-link-color; - padding:.2em; - border-radius:4px; - background-color:lighten(@default-link-color, 40%); -} - -div.toc { - float:none; - width:auto; -} - -div.toc h3 { - font-size:1.17em; -} - -div.toc ul { - padding-left:1.5em; -} - -div.toc li { - font-size:1em; - padding-left:0; - list-style-type:disc; -} - -div.toc,.memproto,div.qindex,div.ah { - background:linear-gradient(to bottom,@toc-background-color2 0%,@toc-background-color1 100%); - box-shadow:inset 0 0 32px @toc-background-color1; - text-shadow:0 1px 1px lighten(@toc-background-color2, 10%); - color:@heading-color; - border:2px solid @toc-background-color1; - border-radius:4px; -} - -.paramname { - color:@prototype-param-color; -} - -dl.reflist dt { - border:2px solid @default-border-color; - border-top-left-radius:4px; - border-top-right-radius:4px; - border-bottom:none; -} - -dl.reflist dd { - border:2px solid @default-border-color; - border-bottom-right-radius:4px; - border-bottom-left-radius:4px; - border-top:none; -} - -table.doxtable { - border-collapse:inherit; - border-spacing:0; - border:2px solid @default-border-color; - border-radius:4px; -} - -a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,.tablist a:hover,span.lineno a:hover { - color:@default-link-color; - text-decoration:none; -} - -div.directory { - border-collapse:inherit; - border-spacing:0; - border:2px solid @default-border-color; - border-radius:4px; -} - -hr,.memSeparator { - height:2px; - background:linear-gradient(to right,@def-separator-color 0%,darken(@def-separator-color, 10%) 50%,@def-separator-color 100%); -} - -dl.note,dl.pre,dl.post,dl.invariant { - .message-box(@box-note-color); -} - -dl.warning,dl.attention { - .message-box(@box-warning-color); -} - -dl.deprecated,dl.bug { - .message-box(@box-bug-color); -} - -dl.todo,dl.test { - .message-box(@box-todo-color); -} - -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:0 1px 1px hsl(0,0%,100%); -} - -.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited { - color:inherit; -} - -div.line { - line-height:inherit; -} - -div.fragment,pre.fragment { - background:hsl(0,0%,95%); - border-radius:4px; - border:none; - padding:1em; - overflow:auto; - border-left:4px solid hsl(0,0%,80%); -} - -.lineno a,.lineno a:visited,.line,pre.fragment { - color:@default-text-color; -} - -span.preprocessor,span.comment { - color:hsl(193,100%,30%); -} - -a.code,a.code:visited { - color:hsl(18,100%,45%); -} - -span.keyword,span.keywordtype,span.keywordflow { - color:darken(@default-text-color, 5%); - font-weight:bold; -} - -span.stringliteral { - color:hsl(261,100%,30%); -} - -code { - padding:.1em; - border-radius:4px; -} diff --git a/glfw/docs/footer.html b/glfw/docs/footer.html deleted file mode 100644 index b0434ca..0000000 --- a/glfw/docs/footer.html +++ /dev/null @@ -1,7 +0,0 @@ -<address class="footer"> -<p> -Last update on $date for $projectname $projectnumber -</p> -</address> -</body> -</html> diff --git a/glfw/docs/header.html b/glfw/docs/header.html deleted file mode 100644 index 9759d8b..0000000 --- a/glfw/docs/header.html +++ /dev/null @@ -1,34 +0,0 @@ -<!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 --> diff --git a/glfw/docs/input.dox b/glfw/docs/input.dox deleted file mode 100644 index 759ce22..0000000 --- a/glfw/docs/input.dox +++ /dev/null @@ -1,13 +0,0 @@ -/*! - -@page input Input handling guide - -@tableofcontents - -@section input_key Keyboard input - -@section input_mouse Mouse input - -@section input_joy Joystick input - -*/ diff --git a/glfw/docs/internal.dox b/glfw/docs/internal.dox deleted file mode 100644 index 0389af6..0000000 --- a/glfw/docs/internal.dox +++ /dev/null @@ -1,116 +0,0 @@ -/*! - -@page internals Internal structure - -@tableofcontents - -There are several interfaces inside GLFW. Each interface has its own area of -responsibility and its own naming conventions. - - -@section internals_public Public interface - -The most well-known is the public interface, described in the glfw3.h header -file. This is implemented in source files shared by all platforms and these -files contain no platform-specific code. This code usually ends up calling the -platform and internal interfaces to do the actual work. - -The public interface uses the OpenGL naming conventions except with GLFW and -glfw instead of GL and gl. For struct members, where OpenGL sets no precedent, -it use headless camel case. - -Examples: @ref glfwCreateWindow, @ref GLFWwindow, @ref GLFWvidmode.redBits, -`GLFW_RED_BITS` - - -@section internals_native Native interface - -The [native interface](@ref native) is a small set of publicly available -but platform-specific functions, described in the glfw3native.h header file and -used to gain access to the underlying window, context and (on some platforms) -display handles used by the platform interface. - -The function names of the native interface are similar to those of the public -interface, but embeds the name of the interface that the returned handle is -from. - -Examples: @ref glfwGetX11Window, @ref glfwGetWGLContext - - -@section internals_internal Internal interface - -The internal interface consists of utility functions used by all other -interfaces. It is shared code implemented in the same shared source files as -the public and event interfaces. The internal interface is described in the -internal.h header file. - -The internal interface is in charge of GLFW's global data, which it stores in -a `_GLFWlibrary` struct named `_glfw`. - -The internal interface uses the same style as the public interface, except all -global names have a leading underscore. - -Examples: @ref _glfwIsValidContextConfig, @ref _GLFWwindow, `_glfw.currentRamp` - - -@section internals_platform Platform interface - -The platform interface implements all platform-specific operations as a service -to the public interface. This includes event processing. The platform -interface is never directly called by application code and never directly calls -application-provided callbacks. It is also prohibited from modifying the -platform-independent part of the internal structs. Instead, it calls the event -interface when events interesting to GLFW are received. - -The platform interface mirrors those parts of the public interface that needs to -perform platform-specific operations on some or all platforms. The are also -named the same except that the glfw function prefix is replaced by -_glfwPlatform. - -Examples: @ref _glfwPlatformCreateWindow - -The platform interface also defines structs that contain platform-specific -global and per-object state. Their names mirror those of the internal -interface, except that an interface-specific suffix is added. - -Examples: `_GLFWwindowX11`, `_GLFWcontextWGL` - -These structs are incorporated as members into the internal interface structs -using special macros that name them after the specific interface used. This -prevents shared code from accidentally using these members. - -Examples: `window.win32.handle`, `_glfw.x11.display` - - -@section internals_event Event interface - -The event interface is implemented in the same shared source files as the public -interface and is responsible for delivering the events it receives to the -application, either via callbacks, via window state changes or both. - -The function names of the event interface use a `_glfwInput` prefix and the -ObjectEvent pattern. - -Examples: @ref _glfwInputWindowFocus, @ref _glfwInputCursorMotion - - -@section internals_static Static functions - -Static functions may be used by any interface and have no prefixes or suffixes. -These use headless camel case. - -Examples: `clearScrollOffsets` - - -@section internals_config Configuration macros - -GLFW uses a number of configuration macros to select at compile time which -interfaces and code paths to use. They are defined in the glfw_config.h header file, -which is generated from the `glfw_config.h.in` file by CMake. - -Configuration macros the same style as tokens in the public interface, except -with a leading underscore. - -Examples: `_GLFW_HAS_GLXGETPROCADDRESS` - -*/ diff --git a/glfw/docs/intro.dox b/glfw/docs/intro.dox deleted file mode 100644 index 2de2c8b..0000000 --- a/glfw/docs/intro.dox +++ /dev/null @@ -1,166 +0,0 @@ -/*! - -@page intro Introduction to the GLFW API - -@tableofcontents - -This guide will introduce the basic concepts of GLFW and describes -initialization, error handling and version management. There are other guides -for the various areas of the GLFW API. - - - @ref window - - @ref context - - @ref monitor - - @ref input - - -@section intro_init Initialization and termination - -Before most GLFW functions may be called, the library must be initialized. -This initialization checks what features are available on the machine, -enumerates monitors and joysticks, initializes the timer and performs any -required platform-specific initialization. - -Only the following functions may be called before the library has been -successfully initialized. - - - @ref glfwGetVersion - - @ref glfwGetVersionString - - @ref glfwSetErrorCallback - - @ref glfwInit - - @ref glfwTerminate - -Calling any other function before that time will cause a `GLFW_NOT_INITIALIZED` -error. - - -@subsection intro_init_init Initializing GLFW - -The library is initialized with @ref glfwInit, which returns `GL_FALSE` if an -error occurred. - -@code -if (!glfwInit()) -{ - // Handle initialization failure -} -@endcode - -If any part of initialization fails, all remaining bits are terminated as if -@ref glfwTerminate was called. The library only needs to be initialized once -and additional calls to an already initialized library will simply return -`GL_TRUE` immediately. - -Once the library has been successfully initialized, it should be terminated -before the application exits. - - -@subsection intro_init_terminate Terminating GLFW - -Before your application exits, you should terminate the GLFW library if it has -been initialized. This is done with @ref glfwTerminate. - -@code -glfwTerminate(); -@endcode - -This will destroy any remaining window, monitor and cursor objects, restore any -modified gamma ramps, re-enable the screensaver if it had been disabled and free -any resources allocated by GLFW. - -Once the library is terminated, it is as if it had never been initialized and -you will need to initialize it again before being able to use GLFW. If the -library had not been successfully initialized or had already been terminated, -additional calls return immediately. - - -@section intro_error Error handling - -Some GLFW functions have return values that indicate an error, but this is often -not very helpful when trying to figure out *why* the error occurred. Also, far -from all GLFW functions have such return values. - -This is where the error callback comes in. This callback is called whenever an -error occurs. It is set with @ref glfwSetErrorCallback, a function that may be -called before @ref glfwInit and after @ref glfwTerminate. - -@code -glfwSetErrorCallback(error_callback); -@endcode - -The error callback receives a human-readable description of the error and (when -possible) its cause. The description is a regular C string using the UTF-8 -encoding. The callback is also provided with an [error code](@ref errors). - -@code -void error_callback(int error, const char* description) -{ - puts(description); -} -@endcode - -The error code indicates the general category of the error. Some error codes, -such as `GLFW_NOT_INITIALIZED` has only a single meaning, whereas others like -`GLFW_PLATFORM_ERROR` are used for many different errors. - -@note The description string is only valid until the error callback returns, as -it may have been generated specifically for that error. This lets GLFW provide -much more specific error descriptions but means you must make a copy if you want -to keep the description string. - - -@section intro_version Version management - -GLFW provides mechanisms for identifying what version of GLFW your application -was compiled against as well as what version it is currently using. The GLFW -API is binary-compatible with later minor versions, i.e. an executable using the -3.0 API will be able to use a version 3.2 DLL. - -As long as an executable does not use any newer functions, it can also use an -older minor version DLL, although any window hints or other tokens added since -that older version will cause errors to be reported. - - -@subsection intro_version_compile Compile-time version - -The compile-time version of GLFW is provided by the GLFW header with the -`GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros. - - -@subsection intro_version_runtime Run-time version - -The run-time version can be retrieved with @ref glfwGetVersion, a function that -may be called before @ref glfwInit and after @ref glfwTerminate - -@code -int major, minor, revision; -glfwGetVersion(&major, &minor, &revision); -@endcode - - -@subsection intro_version_string Version string - -GLFW 3 also provides a compile-time generated version string that describes the -version, platform, compiler and any platform-specific compile-time options. -This is primarily intended for submitting bug reports, to allow developers to -see which code paths are enabled in a binary. - -The version string is returned by @ref glfwGetVersionString, a function that may -be called before @ref glfwInit and after @ref glfwTerminate. - -The format of the string is as follows: - - The version of GLFW - - The name of the window system API - - The name of the context creation API - - Any additional options or APIs - -For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL -back ends, the version string may look something like this: - - 3.0.0 Win32 WGL MinGW - -@note Do not parse the version string to find the GLFW library version. The -@ref glfwGetVersion function provides the version of the library binary in -numeric form. - -*/ diff --git a/glfw/docs/main.dox b/glfw/docs/main.dox deleted file mode 100644 index a2d41ea..0000000 --- a/glfw/docs/main.dox +++ /dev/null @@ -1,22 +0,0 @@ -/*! - -@mainpage notitle - -@section main_intro Introduction - -GLFW is a free, Open Source, multi-platform library for opening a window, -creating an OpenGL context and managing input. It is easy to integrate into -existing applications and does not lay claim to the main loop. - -This is the documentation for version 3.1, which has [many new features](@ref news). - -There is a [quick tutorial](@ref quick) for people new to GLFW, which shows how -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 -[transition guide](@ref moving) that explains what has changed and how to update -existing code to use the new API. - -*/ diff --git a/glfw/docs/monitor.dox b/glfw/docs/monitor.dox deleted file mode 100644 index ddc8754..0000000 --- a/glfw/docs/monitor.dox +++ /dev/null @@ -1,156 +0,0 @@ -/*! - -@page monitor Multi-monitor guide - -@tableofcontents - - -@section monitor_objects Monitor objects - -A monitor object represents a currently connected monitor and is represented as -a pointer to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type -@ref GLFWmonitor. Monitor objects cannot be created or destroyed by the -application and retain their addresses until the monitors they represent are -disconnected or until the library is [terminated](@ref intro_init_terminate). - -Each monitor has a human-readable name, a current video mode, a list of -supported video modes, a virtual position, an estimated physical size and -a gamma ramp. - -The virtual position of a monitor is in screen coordinates and, together with -the current video mode, describes the viewports that the connected monitors -provide into the virtual desktop that spans them. - - -@subsection monitor_monitors Retrieving monitors - -The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's -preferred monitor and is usually the one with global UI elements like task bar -or menu bar. - -@code -GLFWmonitor* primary = glfwGetPrimaryMonitor(); -@endcode - -You can retrieve all currently connected monitors with @ref glfwGetMonitors. -The primary monitor is always the first monitor in the returned array. - -@code -int count; -GLFWmonitor** monitors = glfwGetMonitors(&count); -@endcode - -@note Monitors other than the primary monitor may be moved to a different index -in the array if another monitor is disconnected. - - -@section monitor_properties Monitor properties - -@subsection monitor_modes Video modes - -Although GLFW generally does a good job at selecting a suitable video -mode for you when you open a full screen window, it is sometimes useful to -know exactly which modes are available on a certain system. For example, -you may want to present the user with a list of video modes to select -from. To get a list of available video modes, you can use the function -@ref glfwGetVideoModes. - -@code -int count; -GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); -@endcode - -To get the current video mode of a monitor call @ref glfwGetVideoMode. - -@code -const GLFWvidmode* mode = glfwGetVideoMode(monitor); -@endcode - - -@subsection monitor_size Physical size - -The physical size in millimetres of a monitor, or an estimation of it, can be -retrieved with @ref glfwGetMonitorPhysicalSize. - -@code -int widthMM, heightMM; -glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); -@endcode - -This can, for example, be used together with the current video mode to calculate -the DPI of a monitor. - -@code -const double dpi = mode->width / (widthMM / 25.4); -@endcode - - -@subsection monitor_pos Virtual position - -The position of the monitor on the virtual desktop, in screen coordinates, can -be retrieved with @ref glfwGetMonitorPos. - -@code -int xpos, ypos; -glfwGetMonitorPos(monitor, &xpos, &ypos); -@endcode - - -@subsection monitor_name Human-readable name - -The human-readable name of a monitor is returned by @ref glfwGetMonitorName. -It is a regular C string using the UTF-8 encoding. - -@code -const char* name = glfwGetMonitorName(monitor); -@endcode - -@note Monitor names are not guaranteed to be unique. Two monitors of the same -model and make may have the same name. Only the address of a monitor object is -guaranteed to be unique. - - -@subsection monitor_gamma Gamma ramp - -The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts -a monitor handle and a pointer to a @ref GLFWgammaramp structure. - -@code -GLFWgammaramp ramp; -unsigned short red[256], green[256], blue[256]; - -ramp.size = 256; -ramp.red = red; -ramp.green = green; -ramp.blue = blue; - -for (i = 0; i < ramp.size; i++) -{ - // Fill out gamma ramp arrays as desired -} - -glfwSetGammaRamp(monitor, &ramp); -@endcode - -The gamma ramp data is copied before the function returns, so there is no need -to keep it around once the ramp has been set. - -@note It is recommended to use gamma ramps of size 256, as that is the size -supported by virtually all graphics cards on all platforms. - -The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. The -returned structure and its arrays are allocated and freed by GLFW. - -@code -const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor); -@endcode - -If you wish to set a regular gamma ramp, you can have GLFW calculate it for you -from the desired exponent with @ref glfwSetGamma, which in turn calls @ref -glfwSetGammaRamp with the resulting ramp. - -@code -glfwSetGamma(monitor, 1.0); -@endcode - -*/ diff --git a/glfw/docs/moving.dox b/glfw/docs/moving.dox deleted file mode 100644 index e08a4b5..0000000 --- a/glfw/docs/moving.dox +++ /dev/null @@ -1,487 +0,0 @@ -/*! - -@page moving Moving from GLFW 2 to 3 - -@tableofcontents - -This is a transition guide for moving from GLFW 2 to 3. It describes what has -changed or been removed, but does *not* include -[new features](@ref news) unless they are required when moving an existing code -base onto the new API. For example, the new multi-monitor functions are -required to create full screen windows with GLFW 3. - - -@section moving_removed Changed and removed features - -@subsection moving_renamed_files Renamed library and header file - -The GLFW 3 header is named @ref glfw3.h and moved to the `GLFW` directory, to -avoid collisions with the headers of other major versions. Similarly, the GLFW -3 library is named `glfw3,` except when it's installed as a shared library on -Unix-like systems, where it uses the -[soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`. - -@par Old syntax -@code -#include <GL/glfw.h> -@endcode - -@par New syntax -@code -#include <GLFW/glfw3.h> -@endcode - - -@subsection moving_threads Removal of threading functions - -The threading functions have been removed, including the per-thread sleep -function. They were fairly primitive, under-used, poorly integrated and took -time away from the focus of GLFW (i.e. context, input and window). There are -better threading libraries available and native threading support is available -in both C++11 and C11, both of which are gaining traction. - -If you wish to use the C++11 or C11 facilities but your compiler doesn't yet -support them, see the -[TinyThread++](https://gitorious.org/tinythread/tinythreadpp) and -[TinyCThread](https://gitorious.org/tinythread/tinycthread) projects created by -the original author of GLFW. These libraries implement a usable subset of the -threading APIs in C++11 and C11, and in fact some GLFW 3 test programs use -TinyCThread. - -However, GLFW 3 has better support for *use from multiple threads* than GLFW -2 had. Contexts can be made current on any thread, although only a single -thread at a time, and the documentation explicitly states which functions may be -used from any thread and which may only be used from the main thread. - -@par Removed functions -`glfwSleep`, `glfwCreateThread`, `glfwDestroyThread`, `glfwWaitThread`, -`glfwGetThreadID`, `glfwCreateMutex`, `glfwDestroyMutex`, `glfwLockMutex`, -`glfwUnlockMutex`, `glfwCreateCond`, `glfwDestroyCond`, `glfwWaitCond`, -`glfwSignalCond`, `glfwBroadcastCond` and `glfwGetNumberOfProcessors`. - - -@subsection moving_image Removal of image and texture loading - -The image and texture loading functions have been removed. They only supported -the Targa image format, making them mostly useful for beginner level examples. -To become of sufficiently high quality to warrant keeping them in GLFW 3, they -would need not only to support other formats, but also modern extensions to -OpenGL texturing. This would either add a number of external -dependencies (libjpeg, libpng, etc.), or force GLFW to ship with inline versions -of these libraries. - -As there already are libraries doing this, it is unnecessary both to duplicate -the work and to tie the duplicate to GLFW. The resulting library would also be -platform-independent, as both OpenGL and stdio are available wherever GLFW is. - -@par Removed functions -`glfwReadImage`, `glfwReadMemoryImage`, `glfwFreeImage`, `glfwLoadTexture2D`, -`glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`. - - -@subsection moving_stdcall Removal of GLFWCALL macro - -The `GLFWCALL` macro, which made callback functions use -[__stdcall](http://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows, -has been removed. GLFW is written in C, not Pascal. Removing this macro means -there's one less thing for application programmers to remember, i.e. the -requirement to mark all callback functions with `GLFWCALL`. It also simplifies -the creation of DLLs and DLL link libraries, as there's no need to explicitly -disable `@n` entry point suffixes. - -@par Old syntax -@code -void GLFWCALL callback_function(...); -@endcode - -@par New syntax -@code -void callback_function(...); -@endcode - - -@subsection moving_window_handles Window handle parameters - -Because GLFW 3 supports multiple windows, window handle parameters have been -added to all window-related GLFW functions and callbacks. The handle of -a newly created window is returned by @ref glfwCreateWindow (formerly -`glfwOpenWindow`). Window handles are pointers to the -[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow. - -@par Old syntax -@code -glfwSetWindowTitle("New Window Title"); -@endcode - -@par New syntax -@code -glfwSetWindowTitle(window, "New Window Title"); -@endcode - - -@subsection moving_monitor Explicit monitor selection - -GLFW 3 provides support for multiple monitors. To request a full screen mode window, -instead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the -window to use. The @ref glfwGetPrimaryMonitor function returns the monitor that -GLFW 2 would have selected, but there are many other -[monitor functions](@ref monitor). Monitor handles are pointers to the -[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor. - -@par Old basic full screen -@code -glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN); -@endcode - -@par New basic full screen -@code -window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL); -@endcode - -@note The framebuffer bit depth parameters of `glfwOpenWindow` have been turned -into [window hints](@ref window_hints), but as they have been given -[sane defaults](@ref window_hints_values) you rarely need to set these hints. - - -@subsection moving_autopoll Removal of automatic event polling - -GLFW 3 does not automatically poll for events on @ref glfwSwapBuffers, which -means you need to call @ref glfwPollEvents or @ref glfwWaitEvents yourself. -Unlike buffer swap, which acts on a single window, **glfwPollEvents** and -**glfwWaitEvents** process events for all windows at once. - -@par Old basic main loop -@code -while (...) -{ - // Process input - // Render output - glfwSwapBuffers(); -} -@endcode - -@par New basic main loop -@code -while (...) -{ - // Process input - // Render output - glfwSwapBuffers(window); - glfwPollEvents(); -} -@endcode - - -@subsection moving_context Explicit context management - -Each GLFW 3 window has its own OpenGL context and only you, the application -programmer, can know which context should be current on which thread at any -given time. Therefore, GLFW 3 leaves that decision to you. - -This means that you need to call @ref glfwMakeContextCurrent after creating -a window before you can call any OpenGL functions. - - -@subsection moving_hidpi Separation of window and framebuffer sizes - -Window positions and sizes now use screen coordinates, which may not be the same -as pixels on machines with high-DPI monitors. This is important as OpenGL uses -pixels, not screen coordinates. For example, the rectangle specified with -`glViewport` needs to use pixels. Therefore, framebuffer size functions have -been added. You can retrieve the size of the framebuffer of a window with @ref -glfwGetFramebufferSize function. A framebuffer size callback has also been -added, which can be set with @ref glfwSetFramebufferSizeCallback. - -@par Old basic viewport setup -@code -glfwGetWindowSize(&width, &height); -glViewport(0, 0, width, height); -@endcode - -@par New basic viewport setup -@code -glfwGetFramebufferSize(window, &width, &height); -glViewport(0, 0, width, height); -@endcode - - -@subsection moving_window_close Window closing changes - -The `GLFW_OPENED` window parameter has been removed. As long as the window has -not been destroyed, whether through @ref glfwDestroyWindow or @ref -glfwTerminate, the window is "open". - -A user attempting to close a window is now just an event like any other. Unlike -GLFW 2, windows and contexts created with GLFW 3 will never be destroyed unless -you choose them to be. Each window now has a close flag that is set to -`GL_TRUE` when the user attempts to close that window. By default, nothing else -happens and the window stays 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. - -@par Old basic main loop -@code -while (glfwGetWindowParam(GLFW_OPENED)) -{ - ... -} -@endcode - -@par New basic main loop -@code -while (!glfwWindowShouldClose(window)) -{ - ... -} -@endcode - -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). - -@par Old syntax -@code -int GLFWCALL window_close_callback(void); -@endcode - -@par New syntax -@code -void window_close_callback(GLFWwindow* window); -@endcode - -@note GLFW never clears the close flag to `GL_FALSE`, meaning you can use it -for other reasons to close the window as well, for example the user choosing -Quit from an in-game menu. - - -@subsection moving_hints Persistent window hints - -The `glfwOpenWindowHint` function has been renamed to @ref glfwWindowHint. - -Window hints are no longer reset to their default values on window creation, but -instead retain their values until modified by @ref glfwWindowHint or @ref -glfwDefaultWindowHints, or until the library is terminated and re-initialized. - - -@subsection moving_video_modes Video mode enumeration - -Video mode enumeration is now per-monitor. The @ref glfwGetVideoModes function -now returns all available modes for a specific monitor instead of requiring you -to guess how large an array you need. The `glfwGetDesktopMode` function, which -had poorly defined behavior, has been replaced by @ref glfwGetVideoMode, which -returns the current mode of a monitor. - - -@subsection moving_char_up Removal of character actions - -The action parameter of the [character callback](@ref GLFWcharfun) has been -removed. This was an artefact of the origin of GLFW, i.e. being developed in -English by a Swede. However, many keyboard layouts require more than one key to -produce characters with diacritical marks. Even the Swedish keyboard layout -requires this for uncommon cases like ü. - -@par Old syntax -@code -void GLFWCALL character_callback(int character, int action); -@endcode - -@par New syntax -@code -void character_callback(GLFWwindow* window, int character); -@endcode - - -@subsection moving_cursorpos Cursor position changes - -The `glfwGetMousePos` function has been renamed to @ref glfwGetCursorPos, -`glfwSetMousePos` to @ref glfwSetCursorPos and `glfwSetMousePosCallback` to @ref -glfwSetCursorPosCallback. - -The cursor position is now `double` instead of `int`, both for the direct -functions and for the callback. Some platforms can provide sub-pixel cursor -movement and this data is now passed on to the application where available. On -platforms where this is not provided, the decimal part is zero. - -GLFW 3 only allows you to position the cursor within a window using @ref -glfwSetCursorPos (formerly `glfwSetMousePos`) when that window is active. -Unless the window is active, the function fails silently. - - -@subsection moving_wheel Wheel position replaced by scroll offsets - -The `glfwGetMouseWheel` function has been removed. Scrolling is the input of -offsets and has no absolute position. The mouse wheel callback has been -replaced by a [scroll callback](@ref GLFWscrollfun) that receives -two-dimensional floating point scroll offsets. This allows you to receive -precise scroll data from for example modern touchpads. - -@par Old syntax -@code -void GLFWCALL mouse_wheel_callback(int position); -@endcode - -@par New syntax -@code -void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); -@endcode - -@par Removed functions -`glfwGetMouseWheel` - - -@subsection moving_repeat Key repeat action - -The `GLFW_KEY_REPEAT` enable has been removed and key repeat is always enabled -for both keys and characters. A new key action, `GLFW_REPEAT`, has been added -to allow the [key callback](@ref GLFWkeyfun) to distinguish an initial key press -from a repeat. Note that @ref glfwGetKey still returns only `GLFW_PRESS` or -`GLFW_RELEASE`. - - -@subsection moving_keys Physical key input - -GLFW 3 key tokens map to physical keys, unlike in GLFW 2 where they mapped to -the values generated by the current keyboard layout. The tokens are named -according to the values they would have using the standard US layout, but this -is only a convenience, as most programmers are assumed to know that layout. -This means that (for example) `GLFW_KEY_LEFT_BRACKET` is always a single key and -is the same key in the same place regardless of what keyboard layouts the users -of your program has. - -The key input facility was never meant for text input, although using it that -way worked slightly better in GLFW 2. If you were using it to input text, you -should be using the character callback instead, on both GLFW 2 and 3. This will -give you the characters being input, as opposed to the keys being pressed. - -GLFW 3 has key tokens for all keys on a standard 105 key keyboard, so instead of -having to remember whether to check for `'a'` or `'A'`, you now check for -`GLFW_KEY_A`. - - -@subsection moving_joystick Joystick function changes - -The `glfwGetJoystickPos` function has been renamed to @ref glfwGetJoystickAxes. - -The `glfwGetJoystickParam` function and the `GLFW_PRESENT`, `GLFW_AXES` and -`GLFW_BUTTONS` tokens have been replaced by the @ref glfwJoystickPresent -function as well as axis and button counts returned by the @ref -glfwGetJoystickAxes and @ref glfwGetJoystickButtons functions. - - -@subsection moving_mbcs Win32 MBCS support - -The Win32 port of GLFW 3 will not compile in -[MBCS mode](http://msdn.microsoft.com/en-us/library/5z097dxa.aspx). -However, because the use of the Unicode version of the Win32 API doesn't affect -the process as a whole, but only those windows created using it, it's perfectly -possible to call MBCS functions from other parts of the same application. -Therefore, even if an application using GLFW has MBCS mode code, there's no need -for GLFW itself to support it. - - -@subsection moving_windows Support for versions of Windows older than XP - -All explicit support for version of Windows older than XP has been removed. -There is no code that actively prevents GLFW 3 from running on these earlier -versions, but it uses Win32 functions that those versions lack. - -Windows XP was released in 2001, and by now (2013) it has not only -replaced almost all earlier versions of Windows, but is itself rapidly being -replaced by Windows 7 and 8. The MSDN library doesn't even provide -documentation for version older than Windows 2000, making it difficult to -maintain compatibility with these versions even if it was deemed worth the -effort. - -The Win32 API has also not stood still, and GLFW 3 uses many functions only -present on Windows XP or later. Even supporting an OS as new as XP (new -from the perspective of GLFW 2, which still supports Windows 95) requires -runtime checking for a number of functions that are present only on modern -version of Windows. - - -@subsection moving_syskeys Capture of system-wide hotkeys - -The ability to disable and capture system-wide hotkeys like Alt+Tab has been -removed. Modern applications, whether they're games, scientific visualisations -or something else, are nowadays expected to be good desktop citizens and allow -these hotkeys to function even when running in full screen mode. - - -@subsection moving_terminate Automatic termination - -GLFW 3 does not register @ref glfwTerminate with `atexit` at initialization. To -release all resources allocated by GLFW, you should call @ref glfwTerminate -yourself. Note that this destroys all windows not already destroyed with @ref -glfwDestroyWindow, invalidating all window handles you may still have. - - -@subsection moving_glu GLU header inclusion - -GLFW 3 does not by default include the GLU header and GLU itself has been -deprecated by [Khronos](https://en.wikipedia.org/wiki/Khronos_Group). **New -projects should avoid using GLU**, but if you need to compile legacy code that -has been moved to GLFW 3, you can request that the GLFW header includes it by -defining `GLFW_INCLUDE_GLU` before the inclusion of the GLFW header. - -@par Old syntax -@code -#include <GL/glfw.h> -@endcode - -@par New syntax -@code -#define GLFW_INCLUDE_GLU -#include <GLFW/glfw3.h> -@endcode - - -@section moving_tables Name change tables - - -@subsection moving_renamed_functions Renamed functions - -| GLFW 2 | GLFW 3 | Notes | -| --------------------------- | ----------------------------- | ----- | -| `glfwOpenWindow` | @ref glfwCreateWindow | All channel bit depths are now hints -| `glfwCloseWindow` | @ref glfwDestroyWindow | | -| `glfwOpenWindowHint` | @ref glfwWindowHint | Now accepts all `GLFW_*_BITS` tokens | -| `glfwEnable` | @ref glfwSetInputMode | | -| `glfwDisable` | @ref glfwSetInputMode | | -| `glfwGetMousePos` | @ref glfwGetCursorPos | | -| `glfwSetMousePos` | @ref glfwSetCursorPos | | -| `glfwSetMousePosCallback` | @ref glfwSetCursorPosCallback | | -| `glfwSetMouseWheelCallback` | @ref glfwSetScrollCallback | Accepts two-dimensional scroll offsets as doubles | -| `glfwGetJoystickPos` | @ref glfwGetJoystickAxes | | -| `glfwGetWindowParam` | @ref glfwGetWindowAttrib | | -| `glfwGetGLVersion` | @ref glfwGetWindowAttrib | Use `GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and `GLFW_CONTEXT_REVISION` | -| `glfwGetDesktopMode` | @ref glfwGetVideoMode | Returns the current mode of a monitor | -| `glfwGetJoystickParam` | @ref glfwJoystickPresent | The axis and button counts are provided by @ref glfwGetJoystickAxes and @ref glfwGetJoystickButtons | - -@subsection moving_renamed_tokens Renamed tokens - -| GLFW 2 | GLFW 3 | Notes | -| --------------------------- | ---------------------------- | ----- | -| `GLFW_OPENGL_VERSION_MAJOR` | `GLFW_CONTEXT_VERSION_MAJOR` | Renamed as it applies to OpenGL ES as well | -| `GLFW_OPENGL_VERSION_MINOR` | `GLFW_CONTEXT_VERSION_MINOR` | Renamed as it applies to OpenGL ES as well | -| `GLFW_FSAA_SAMPLES` | `GLFW_SAMPLES` | Renamed to match the OpenGL API | -| `GLFW_ACTIVE` | `GLFW_FOCUSED` | Renamed to match the window focus callback | -| `GLFW_WINDOW_NO_RESIZE` | `GLFW_RESIZABLE` | The default has been inverted | -| `GLFW_MOUSE_CURSOR` | `GLFW_CURSOR` | Used with @ref glfwSetInputMode | -| `GLFW_KEY_ESC` | `GLFW_KEY_ESCAPE` | | -| `GLFW_KEY_DEL` | `GLFW_KEY_DELETE` | | -| `GLFW_KEY_PAGEUP` | `GLFW_KEY_PAGE_UP` | | -| `GLFW_KEY_PAGEDOWN` | `GLFW_KEY_PAGE_DOWN` | | -| `GLFW_KEY_KP_NUM_LOCK` | `GLFW_KEY_NUM_LOCK` | | -| `GLFW_KEY_LCTRL` | `GLFW_KEY_LEFT_CONTROL` | | -| `GLFW_KEY_LSHIFT` | `GLFW_KEY_LEFT_SHIFT` | | -| `GLFW_KEY_LALT` | `GLFW_KEY_LEFT_ALT` | | -| `GLFW_KEY_LSUPER` | `GLFW_KEY_LEFT_SUPER` | | -| `GLFW_KEY_RCTRL` | `GLFW_KEY_RIGHT_CONTROL` | | -| `GLFW_KEY_RSHIFT` | `GLFW_KEY_RIGHT_SHIFT` | | -| `GLFW_KEY_RALT` | `GLFW_KEY_RIGHT_ALT` | | -| `GLFW_KEY_RSUPER` | `GLFW_KEY_RIGHT_SUPER` | | - -*/ diff --git a/glfw/docs/news.dox b/glfw/docs/news.dox deleted file mode 100644 index 04a6b4f..0000000 --- a/glfw/docs/news.dox +++ /dev/null @@ -1,235 +0,0 @@ -/*! - -@page news New features - -@tableofcontents - - -@section news_31 New features in version 3.1 - -@subsection news_31_cursor Custom system cursor support - -GLFW now supports creating and setting custom system cursors. They can be -created with @ref glfwCreateCursor and set with @ref glfwSetCursor. Note that -custom cursors are only visible in normal cursor mode. - - -@subsection news_31_drop File drop event support - -GLFW now provides a callback for receiving the paths of files dropped onto GLFW -windows. The callback is set with the @ref glfwSetDropCallback function. - - -@subsection news_31_emptyevent Empty event support - -GLFW now provides the @ref glfwPostEmptyEvent function for posting an empty -event from another thread to the main thread event queue, causing @ref -glfwWaitEvents to return. - - -@subsection news_31_framesize Window frame size query - -GLFW now supports querying the size, on each side, of the frame around the -client area of a window, with @ref glfwGetWindowFrameSize. - - -@subsection news_31_autoiconify Multi-monitor installation support - -GLFW now supports disabling auto-iconification of full screen windows with -[GLFW_AUTO_ICONIFY](@ref window_hints_wnd). This is intended for people -building multi-monitor installations, where you need windows to stay in full -screen despite losing focus. - - -@subsection news_31_floating Floating windows - -GLFW now supports floating windows, also called topmost or always on top, for -easier debugging, with the `GLFW_FLOATING` window hint. - - -@subsection news_31_focused Initially unfocused windows - -GLFW now supports preventing a windowed mode window from gaining input focus on -creation, with the `GLFW_FOCUSED` window hint. - - -@subsection news_31_charmods Character with modifiers callback - -GLFW now provides a callback for character events with modifier key bits. -Unlike the regular character callback, this will report character events that -will not result in a character being input, for example if the Control key is -held down. - - -@subsection news_31_egl Stable EGL support - -The support for EGL is now stable, successfully running on PandaBoards, Mesa, -ANGLE, Wayland, AMD EGL and others. - - -@section news_30 New features in version 3.0 - -@subsection news_30_cmake CMake build system - -GLFW now uses the CMake build system instead of the various makefiles and -project files used by earlier versions. CMake is available for all platforms -supported by GLFW, is present in most package systems and can generate -makefiles and/or project files for most popular development environments. - -For more information on how to use CMake, see the -[CMake manual](http://cmake.org/cmake/help/documentation.html). - - -@subsection news_30_multiwnd Multi-window support - -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 -callbacks are now per-window and are provided with the handle of the window that -received the event. The @ref glfwMakeContextCurrent function has been added to -select which context is current on a given thread. - - -@subsection news_30_multimon Multi-monitor support - -GLFW now explicitly supports multiple monitors. They can be enumerated with -@ref glfwGetMonitors, queried with @ref glfwGetVideoModes, @ref -glfwGetMonitorPos, @ref glfwGetMonitorName and @ref glfwGetMonitorPhysicalSize, -and specified at window creation to make the newly created window full screen on -that specific monitor. - - -@subsection news_30_unicode Unicode support - -All string arguments to GLFW functions and all strings returned by GLFW now use -the UTF-8 encoding. This includes the window title, error string, clipboard -text, monitor and joystick names as well as the extension function arguments (as -ASCII is a subset of UTF-8). - - -@subsection news_30_clipboard Clipboard text I/O - -GLFW now supports reading and writing plain text to and from the system -clipboard, with the @ref glfwGetClipboardString and @ref glfwSetClipboardString -functions. - - -@subsection news_30_gamma Gamma ramp support - -GLFW now supports setting and reading back the gamma ramp of monitors, with the -@ref glfwGetGammaRamp and @ref glfwSetGammaRamp functions. There is also @ref -glfwSetGamma, which generates a ramp from a gamma value and then sets it. - - -@subsection news_30_gles OpenGL ES support - -GLFW now supports the creation of OpenGL ES contexts, by setting the -`GLFW_CLIENT_API` window hint to `GLFW_OPENGL_ES_API`, where creation of such -contexts are supported. Note that GLFW *does not implement* OpenGL ES, so your -driver must provide support in a way usable by GLFW. Modern nVidia and Intel -drivers support creation of OpenGL ES context using the GLX and WGL APIs, while -AMD provides an EGL implementation instead. - - -@subsection news_30_egl (Experimental) EGL support - -GLFW now has an experimental EGL context creation back end that can be selected -through CMake options. - - -@subsection news_30_hidpi High-DPI support - -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, -@ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have been -added. These work with pixels, while the rest of the GLFW API works with screen -coordinates. This is important as OpenGL uses pixels, not screen coordinates. - - -@subsection news_30_error Error callback - -GLFW now has an error callback, which can provide your application with much -more detailed diagnostics than was previously possible. The callback is passed -an error code and a description string. - - -@subsection news_30_wndptr Per-window user pointer - -Each window now has a user-defined pointer, retrieved with @ref -glfwGetWindowUserPointer and set with @ref glfwSetWindowUserPointer, to make it -easier to integrate GLFW into C++ code. - - -@subsection news_30_iconifyfun Window iconification callback - -Each window now has a callback for iconification and restoration events, -which is set with @ref glfwSetWindowIconifyCallback. - - -@subsection news_30_wndposfun Window position callback - -Each window now has a callback for position events, which is set with @ref -glfwSetWindowPosCallback. - - -@subsection news_30_wndpos Window position query - -The position of a window can now be retrieved using @ref glfwGetWindowPos. - - -@subsection news_30_focusfun Window focus callback - -Each windows now has a callback for focus events, which is set with @ref -glfwSetWindowFocusCallback. - - -@subsection news_30_enterleave Cursor enter/leave callback - -Each window now has a callback for when the mouse cursor enters or leaves its -client area, which is set with @ref glfwSetCursorEnterCallback. - - -@subsection news_30_wndtitle Initial window title - -The title of a window is now specified at creation time, as one of the arguments -to @ref glfwCreateWindow. - - -@subsection news_30_hidden Hidden windows - -Windows can now be hidden with @ref glfwHideWindow, shown using @ref -glfwShowWindow and created initially hidden with the `GLFW_VISIBLE` window hint. -This allows for off-screen rendering in a way compatible with most drivers, as -well as moving a window to a specific position before showing it. - - -@subsection news_30_undecorated Undecorated windows - -Windowed mode windows can now be created without decorations, i.e. things like -a frame, a title bar, with the `GLFW_DECORATED` window hint. This allows for -the creation of things like splash screens. - - -@subsection news_30_keymods Modifier key bit masks - -[Modifier key bit mask](@ref mods) parameters have been added to the -[mouse button](@ref GLFWmousebuttonfun) and [key](@ref GLFWkeyfun) callbacks. - - -@subsection news_30_scancode Platform-specific scancodes - -A scancode parameter has been added to the [key callback](@ref GLFWkeyfun). Keys -that don't have a [key token](@ref keys) still get passed on with the key -parameter set to `GLFW_KEY_UNKNOWN`. These scancodes will vary between machines -and are intended to be used for key bindings. - - -@subsection news_30_jsname Joystick names - -The name of a joystick can now be retrieved using @ref glfwGetJoystickName. - - -@subsection news_30_doxygen Doxygen documentation - -You are reading it. - -*/ diff --git a/glfw/docs/quick.dox b/glfw/docs/quick.dox deleted file mode 100644 index 120ca9b..0000000 --- a/glfw/docs/quick.dox +++ /dev/null @@ -1,328 +0,0 @@ -/*! - -@page quick Getting started — A quick introduction - -@tableofcontents - -This guide will show how to write simple OpenGL applications using GLFW 3. It -will introduce a few of the most commonly used functions, but there are many -others. To see detailed documentation on any GLFW function, just click on its -name. - -This guide assumes no experience with earlier versions of GLFW. If you -have used GLFW 2.x in the past, you should also read the -[transition guide](@ref moving). - - -@section quick_include Including the GLFW header - -In the files of your program where you use OpenGL or GLFW, you need to include -the GLFW 3 header file. - -@code -#include <GLFW/glfw3.h> -@endcode - -This defines all the constants, types and function prototypes of the GLFW API. -It also includes the OpenGL header, and defines all the constants and types -necessary for it to work on your platform. - -For example, under Windows you are normally required to include `windows.h` -before including `GL/gl.h`. This would make your source file tied to Windows -and pollute your code's namespace with the whole Win32 API. - -Instead, the GLFW header takes care of this for you, not by including -`windows.h`, but rather by itself duplicating only the necessary parts of it. -It does this only where needed, so if `windows.h` *is* included, the GLFW header -does not try to redefine those symbols. - -In other words: - -- Do *not* include the OpenGL headers yourself, as GLFW does this for you -- Do *not* include `windows.h` or other platform-specific headers unless - you plan on using those APIs directly -- If you *do* need to include such headers, do it *before* including the - GLFW one and it will detect this - -Starting with version 3.0, the GLU header `glu.h` is no longer included by -default. If you wish to include it, define `GLFW_INCLUDE_GLU` before the -inclusion of the GLFW header. - -@code -#define GLFW_INCLUDE_GLU -#include <GLFW/glfw3.h> -@endcode - - -@section quick_init_term Initializing and terminating GLFW - -Before you can use most GLFW functions, the library must be initialized. This -is done with @ref glfwInit, which returns non-zero if successful, or zero if an -error occurred. - -@code -if (!glfwInit()) - exit(EXIT_FAILURE); -@endcode - -When you are done using GLFW, typically at the very end of the program, you need -to call @ref glfwTerminate. - -@code -glfwTerminate(); -@endcode - -This destroys any remaining windows and releases any other resources allocated by -GLFW. After this call, you must call @ref glfwInit again before using any GLFW -functions that require it. - - -@section quick_capture_error Setting an error callback - -Most events are reported through callbacks, whether it's a key being pressed, -a GLFW window being moved, or an error occurring. Callbacks are simply -C functions (or C++ static methods) that are called by GLFW with arguments -describing the event. - -In case @ref glfwInit or any other GLFW function fails, an error is reported to -the GLFW error callback. You can receive these reports by setting the error -callback. The callback function itself should match the signature of @ref -GLFWerrorfun. Here is a simple error callback that just prints the error -description to `stderr`. - -@code -void error_callback(int error, const char* description) -{ - fputs(description, stderr); -} -@endcode - -Setting the callback, so GLFW knows to call it, is done with @ref -glfwSetErrorCallback. This is one of the few GLFW functions that may be called -before @ref glfwInit, which lets you be notified of errors during -initialization, so you should set it before you do anything else with GLFW. - -@code -glfwSetErrorCallback(error_callback); -@endcode - - -@section quick_create_window Creating a window and context - -The window (and its context) is created with @ref glfwCreateWindow, which -returns a handle to the created window. For example, this creates a 640 by 480 -windowed mode window: - -@code -GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); -@endcode - -If window creation fails, `NULL` will be returned, so you need to check whether -it did. - -@code -if (!window) -{ - glfwTerminate(); - exit(EXIT_FAILURE); -} -@endcode - -This handle is then passed to all window related functions, and is provided to -you along with input events, so you know which window received the input. - -To create a full screen window, you need to specify which monitor the window -should use. In most cases, the user's primary monitor is a good choice. You -can get this with @ref glfwGetPrimaryMonitor. To make the above window -full screen, just pass along the monitor handle: - -@code -GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL); -@endcode - -Full screen windows cover the entire display area of a monitor, have no border -or decorations, and change the monitor's resolution to the one most closely -matching the requested window size. - -When you are done with the window, destroy it with the @ref glfwDestroyWindow -function. - -@code -glfwDestroyWindow(window); -@endcode - -Once this function is called, no more events will be delivered for that window -and its handle becomes invalid. - - -@section quick_context_current Making the OpenGL context current - -Before you can use the OpenGL API, it must have a current OpenGL context. You -make a window's context current with @ref glfwMakeContextCurrent. It will then -remain as the current context until you make another context current or until -the window owning it is destroyed. - -@code -glfwMakeContextCurrent(window); -@endcode - - -@section quick_window_close Checking the window close flag - -Each window has a flag indicating whether the window should be closed. This can -be checked with @ref glfwWindowShouldClose. - -When the user attempts to close the window, either by pressing the close widget -in the title bar or using a key combination like Alt+F4, this flag is set to 1. -Note that **the window isn't actually closed**, so you are expected to monitor -this flag and either destroy the window or give some kind of feedback to the -user. - -@code -while (!glfwWindowShouldClose(window)) -{ - // Keep running -} -@endcode - -You can be notified when user is attempting to close the window by setting -a close callback with @ref glfwSetWindowCloseCallback. The callback will be -called immediately after the close flag has been set. - -You can also set it yourself with @ref glfwSetWindowShouldClose. This can be -useful if you want to interpret other kinds of input as closing the window, like -for example pressing the escape key. - - -@section quick_key_input Receiving input events - -Each window has a large number of callbacks that can be set to receive all the -various kinds of events. To receive key press and release events, a -[key callback](@ref GLFWkeyfun) is set using @ref glfwSetKeyCallback. - -@code -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) - glfwSetWindowShouldClose(window, GL_TRUE); -} -@endcode - -For event callbacks to actually be called when an event occurs, you need to -process events as described below. - - -@section quick_render Rendering with OpenGL - -Once you have a current OpenGL context, you can use OpenGL normally. In this -tutorial, a multi-colored rotating triangle will be rendered. The framebuffer -size, needed by this example for `glViewport` and `glOrtho`, is retrieved with -@ref glfwGetFramebufferSize. - -@code -int width, height; -glfwGetFramebufferSize(window, &width, &height); -glViewport(0, 0, width, height); -@endcode - -However, you can also set a framebuffer size callback using @ref -glfwSetFramebufferSizeCallback and call `glViewport` from there. - -@code -void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} -@endcode - - -@section quick_timer Reading the timer - -For the triangle to rotate properly, a time source is needed. GLFW provides -@ref glfwGetTime, which returns the number of seconds since @ref glfwInit as -a `double`. The time source used is the most accurate on each platform and -generally has micro- or nanosecond resolution. - -@code -double time = glfwGetTime(); -@endcode - - -@section quick_swap_buffers Swapping buffers - -GLFW windows by default use double buffering. That means that you have two -rendering buffers; a front buffer and a back buffer. The front buffer is the -one being displayed and the back buffer the one you render to. - -When the entire frame has been rendered, it is time to swap the back and the -front buffers in order to display the rendered frame, and begin rendering a new -frame. This is done with @ref glfwSwapBuffers. - -@code -glfwSwapBuffers(window); -@endcode - - -@section quick_process_events Processing events - -GLFW needs to communicate regularly with the window system both in order to -receive events and to show that it hasn't locked up. Event processing must be -done regularly and is normally done each frame before rendering but after buffer -swap. - -There are two ways to process pending events. @ref glfwPollEvents processes -only those events that have already been received and then returns immediately. -This is the best choice when rendering continually, like most games do. - -@code -glfwPollEvents(); -@endcode - -If instead you only need to update your rendering once you have received new -input, @ref glfwWaitEvents is a better choice. It waits until at least one -event has been received, putting the thread to sleep in the meantime, and then -processes all received events just like @ref glfwPollEvents does. This saves -a great deal of CPU cycles and is useful for, for example, many kinds of editing -tools. - -@code -glfwWaitEvents(); -@endcode - - -@section quick_example Putting it together: A simple application - -Now that you know how to initialize GLFW, create a window and poll for -keyboard input, it's possible to create a simple program. - -@snippet simple.c code - -This program creates a 640 by 480 windowed mode window and starts a loop that -clears the screen, renders a triangle and processes events until the user either -presses Escape or closes the window. - -This program uses only a few of the many functions GLFW provides. There are -guides for each of the areas covered by GLFW. Each guide will introduce all the -functions for that category. - - - @ref intro - - @ref window - - @ref context - - @ref monitor - - @ref input - - -@section quick_build Compiling and linking the program - -The complete program above can be found in the source distribution as -`examples/simple.c` and is compiled along with all other examples when you -build GLFW. That is, if you have compiled GLFW then you have already built this -as `simple.exe` on Windows, `simple` on Linux or `simple.app` on OS X. - -This tutorial ends here. Once you have written a program that uses GLFW, you -will need to compile and link it. How to do that depends on the development -environment you are using and is best explained by the documentation for that -environment. To learn about the details that are specific to GLFW, see -@ref build. - -*/ diff --git a/glfw/docs/window.dox b/glfw/docs/window.dox deleted file mode 100644 index cf33791..0000000 --- a/glfw/docs/window.dox +++ /dev/null @@ -1,560 +0,0 @@ -/*! - -@page window Window handling guide - -@tableofcontents - -The primary purpose of GLFW is to provide a simple interface to window -management and OpenGL and OpenGL ES context creation. GLFW supports multiple -windows, which can be either a normal desktop window or a full screen window. - - -@section window_object Window handles - -The @ref GLFWwindow object encapsulates both a window and a context. They are -created with @ref glfwCreateWindow and destroyed with @ref glfwDestroyWindow (or -@ref glfwTerminate, if any remain). As the window and context are inseparably -linked, the object pointer is used as both a context and window handle. - - -@section window_creation Window creation - -The window and its context are created with @ref glfwCreateWindow, which -returns a handle to the created window object. For example, this creates a 640 -by 480 windowed mode window: - -@code -GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); -if (!window) -{ - // Handle window creation failure -} -@endcode - -If window creation fails, `NULL` will be returned, so you need to check the -return value. If creation failed, an error will have been reported to the error -callback. - -This handle is then passed to all window related functions, and is provided to -you along with input events, so you know which window received the input. - -To create a full screen window, you need to specify which monitor the window -should use. In most cases, the user's primary monitor is a good choice. For -more information about monitors, see the @ref monitor. - -@code -GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL); -@endcode - -Full screen windows cover the entire display area of a monitor, have no border -or decorations, and change the monitor's resolution to the one most closely -matching the requested window size. - -For more control over how the window and its context are created, see @ref -window_hints below. - - -@section window_destruction Window destruction - -When you are done with the window, destroy it with the @ref glfwDestroyWindow -function. - -@code -glfwDestroyWindow(window); -@endcode - -Once this function is called, no more events will be delivered for that window -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 be modified by GLFW throughout -the life-time of the window. - - -@section window_hints Window creation hints - -There are a number of hints that can be set before the creation of a window and -context. Some affect the window itself, others affect the framebuffer or -context. These hints are set to their default values each time the library is -initialized with @ref glfwInit, can be set individually with @ref glfwWindowHint -and reset all at once to their defaults with @ref glfwDefaultWindowHints. - -Note that hints need to be set *before* the creation of the window and context -you wish to have the specified attributes. - - -@subsection window_hints_hard Hard and soft constraints - -Some window hints are hard constraints. These must match the available -capabilities *exactly* for window and context creation to succeed. Hints -that are not hard constraints are matched as closely as possible, but the -resulting window and context may differ from what these hints requested. To -find out the actual attributes of the created window and context, use the -@ref glfwGetWindowAttrib function. - -The following hints are always hard constraints: -- `GLFW_STEREO` -- `GLFW_DOUBLEBUFFER` -- `GLFW_CLIENT_API` - -The following additional hints are hard constraints when requesting an OpenGL -context, but are ignored when requesting an OpenGL ES context: -- `GLFW_OPENGL_FORWARD_COMPAT` -- `GLFW_OPENGL_PROFILE` - - -@subsection window_hints_wnd Window related hints - -The `GLFW_RESIZABLE` hint specifies whether the (windowed mode) window will be -resizable *by the user*. The window will still be resizable using the @ref -glfwSetWindowSize function. This hint is ignored for full screen windows. - -The `GLFW_VISIBLE` hint specifies whether the (windowed mode) window will be -initially visible. This hint is ignored for full screen windows. - -The `GLFW_DECORATED` hint specifies whether the (windowed mode) window will have -window decorations such as a border, a close widget, etc. This hint is ignored -for full screen windows. Note that even though a window may lack a close -widget, it is usually still possible for the user to generate close events. - -The `GLFW_FOCUSED` hint specifies whether the (windowed mode) window will be -given input focus when created. This hint is ignored for full screen and -initially hidden windows. - -The `GLFW_AUTO_ICONIFY` hint specifies whether the (full screen) window -will automatically iconify and restore the previous video mode on focus loss. -This hint is ignored for windowed mode windows. - -The `GLFW_FLOATING` hint specifies whether the window will be floating above -other regular windows, also called topmost or always-on-top. This is intended -primarily for debugging purposes and cannot be used to implement proper full -screen windows. This hint is ignored for full screen windows. - - -@subsection window_hints_fb Framebuffer related hints - -The `GLFW_RED_BITS`, `GLFW_GREEN_BITS`, `GLFW_BLUE_BITS`, `GLFW_ALPHA_BITS`, -`GLFW_DEPTH_BITS` and `GLFW_STENCIL_BITS` hints specify the desired bit -depths of the various components of the default framebuffer. `GLFW_DONT_CARE` -means the application has no preference. - -The `GLFW_ACCUM_RED_BITS`, `GLFW_ACCUM_GREEN_BITS`, `GLFW_ACCUM_BLUE_BITS` -and `GLFW_ACCUM_ALPHA_BITS` hints specify the desired bit depths of the -various components of the accumulation buffer. `GLFW_DONT_CARE` means the -application has no preference. - -@note Accumulation buffers are a legacy OpenGL feature and should not be used in -new code. - -The `GLFW_AUX_BUFFERS` hint specifies the desired number of auxiliary -buffers. `GLFW_DONT_CARE` means the application has no preference. - -@note Auxiliary buffers are a legacy OpenGL feature and should not be used in -new code. - -The `GLFW_STEREO` hint specifies whether to use stereoscopic rendering. This is -a hard constraint. - -The `GLFW_SAMPLES` hint specifies the desired number of samples to use for -multisampling. Zero disables multisampling. `GLFW_DONT_CARE` means the -application has no preference. - -The `GLFW_SRGB_CAPABLE` hint specifies whether the framebuffer should be -sRGB capable. - -The `GLFW_DOUBLEBUFFER` hint specifies whether the framebuffer should be double -buffered. You nearly always want to use double buffering. This is a hard -constraint. - -The `GLFW_REFRESH_RATE` hint specifies the desired refresh rate for full screen -windows. If set to zero, the highest available refresh rate will be used. This -hint is ignored for windowed mode windows. - - -@subsection window_hints_ctx Context related hints - -The `GLFW_CLIENT_API` hint specifies which client API to create the context -for. Possible values are `GLFW_OPENGL_API` and `GLFW_OPENGL_ES_API`. This is -a hard constraint. - -The `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` hints -specify the client API version that the created context must be compatible -with. - -For OpenGL, these hints are *not* hard constraints, as they don't have to -match exactly, but @ref glfwCreateWindow will still fail if the resulting -OpenGL version is less than the one requested. It is therefore perfectly -safe to use the default of version 1.0 for legacy code and you may still -get backwards-compatible contexts of version 3.0 and above when available. - -While there is no way to ask the driver for a context of the highest supported -version, most drivers provide this when you ask GLFW for a version -1.0 context. - -For OpenGL ES, these hints are hard constraints. - -If an OpenGL context is requested, the `GLFW_OPENGL_FORWARD_COMPAT` hint -specifies whether the OpenGL context should be forward-compatible, i.e. one -where all functionality deprecated in the requested version of OpenGL is -removed. This may only be used if the requested OpenGL version is 3.0 or -above. If another client API is requested, this hint is ignored. - -@note Forward-compatibility is described in detail in the -[OpenGL Reference Manual](https://www.opengl.org/registry/). - -If an OpenGL context is requested, the `GLFW_OPENGL_DEBUG_CONTEXT` hint -specifies whether to create a debug OpenGL context, which may have -additional error and performance issue reporting functionality. If another -client API is requested, this hint is ignored. - -If an OpenGL context is requested, the `GLFW_OPENGL_PROFILE` hint specifies -which OpenGL profile to create the context for. Possible values are one of -`GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE`, or -`GLFW_OPENGL_ANY_PROFILE` to not request a specific profile. If requesting -an OpenGL version below 3.2, `GLFW_OPENGL_ANY_PROFILE` must be used. If -another client API is requested, this hint is ignored. - -@note OpenGL profiles are described in detail in the -[OpenGL Reference Manual](https://www.opengl.org/registry/). - -The `GLFW_CONTEXT_ROBUSTNESS` hint specifies the robustness strategy to be -used by the context. This can be one of `GLFW_NO_RESET_NOTIFICATION` or -`GLFW_LOSE_CONTEXT_ON_RESET`, or `GLFW_NO_ROBUSTNESS` to not request -a robustness strategy. - -The `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint specifies the release behavior to be -used by the context. Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`, -`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the -behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context -creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`, -the pipeline will be flushed whenever the context is released from being the -current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will -not be flushed on release. - -@note Context release behaviors are described in detail by the -[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt) -extension. - - -@subsection window_hints_values Supported and default values - -| Name | Default value | Supported values | -| ------------------------------- | --------------------------- | ----------------------- | -| `GLFW_RESIZABLE` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_VISIBLE` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_DECORATED` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_FOCUSED` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_AUTO_ICONIFY` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_FLOATING` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_RED_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_GREEN_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_BLUE_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_ALPHA_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_DEPTH_BITS` | 24 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_STENCIL_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_ACCUM_RED_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_ACCUM_GREEN_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_ACCUM_BLUE_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_ACCUM_ALPHA_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_AUX_BUFFERS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_SAMPLES` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_REFRESH_RATE` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` | -| `GLFW_STEREO` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_SRGB_CAPABLE` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_DOUBLEBUFFER` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_CLIENT_API` | `GLFW_OPENGL_API` | `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API` | -| `GLFW_CONTEXT_VERSION_MAJOR` | 1 | Any valid major version number of the chosen client API | -| `GLFW_CONTEXT_VERSION_MINOR` | 0 | Any valid minor version number of the chosen client API | -| `GLFW_CONTEXT_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET` | -| `GLFW_CONTEXT_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE` | -| `GLFW_OPENGL_FORWARD_COMPAT` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_OPENGL_DEBUG_CONTEXT` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` | -| `GLFW_OPENGL_PROFILE` | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE` | - - -@section window_close Window close flag - -When the user attempts to close the window, for example by clicking the close -widget or using a key chord like Alt+F4, the *close flag* of the window is set. -The window is however not actually destroyed and, unless you watch for this -state change, nothing further happens. - -The current state of the close flag is returned by @ref glfwWindowShouldClose -and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common -pattern is to use the close flag as a main loop condition. - -@code -while (!glfwWindowShouldClose(window)) -{ - render(window); - - glfwSwapBuffers(window); - glfwPollEvents(); -} -@endcode - -If you wish to be notified when the user attempts to close a window, you can set -the close callback with @ref glfwSetWindowCloseCallback. This callback is -called directly *after* the close flag has been set. - -@code -glfwSetWindowCloseCallback(window, window_close_callback); -@endcode - -The callback function can be used for example to filter close requests and clear -the close flag again unless certain conditions are met. - -@code -void window_close_callback(GLFWwindow* window) -{ - if (!time_to_close) - glfwSetWindowShouldClose(window, GL_FALSE); -} -@endcode - - -@section window_size Window size - -The size of a window can be changed with @ref glfwSetWindowSize. For windowed -mode windows, this resizes the specified window so that its *client area* has -the specified size. Note that the window system may put limitations on size. -For full screen windows, it selects and sets the video mode most closely -matching the specified size. - -@code -void glfwSetWindowSize(window, 640, 480); -@endcode - -If you wish to be notified when a window is resized, whether by the user or -the system, you can set the size callback with @ref glfwSetWindowSizeCallback. - -@code -glfwSetWindowSizeCallback(window, window_size_callback); -@endcode - -The callback function receives the new size of the client area of the window. - -@code -void window_size_callback(GLFWwindow* window, int width, int height) -{ -} -@endcode - -There is also @ref glfwGetWindowSize for directly retrieving the current size of -a window. - -@code -int width, height; -glfwGetWindowSize(window, &width, &height); -@endcode - -@note Do not pass the window size to `glViewport` or other pixel-based OpenGL -calls. The window size is in screen coordinates, not pixels. Use the -framebuffer size, which is in pixels, for pixel-based calls. - - -@section window_fbsize Window framebuffer size - -While the size of a window is measured in screen coordinates, OpenGL works with -pixels. The size you pass into `glViewport`, for example, should be in pixels -and not screen coordinates. On some platforms screen coordinates and pixels are -the same, but this is not the case on all platforms supported by GLFW. There is -a second set of functions to retrieve the size in pixels of the framebuffer of -a window. - -If you wish to be notified when the framebuffer of a window is resized, whether -by the user or the system, you can set the size callback with @ref -glfwSetFramebufferSizeCallback. - -@code -glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); -@endcode - -The callback function receives the new size of the client area of the window, -which can for example be used to update the OpenGL viewport. - -@code -void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} -@endcode - -There is also @ref glfwGetFramebufferSize for directly retrieving the current -size of the framebuffer of a window. - -@code -int width, height; -glfwGetFramebufferSize(window, &width, &height); -glViewport(0, 0, width, height); -@endcode - -Note that the size of a framebuffer may change independently of the size of -a window, for example if the window is dragged between a regular monitor and -a high-DPI one. - - -@section window_pos Window position - -The position of a windowed-mode window can be changed with @ref -glfwSetWindowPos. This moves the window so that the upper-left corner of its -client area has the specified screen coordinates. Note that the window system -may put limitations on placement. - -@code -glfwSetWindowPos(window, 100, 100); -@endcode - -If you wish to be notified when a window is moved, whether by the user or -the system, you can set the position callback with @ref glfwSetWindowPosCallback. - -@code -glfwSetWindowPosCallback(window, window_pos_callback); -@endcode - -The callback function receives the new position of the upper-left corner of its -client area. - -@code -void window_pos_callback(GLFWwindow* window, int xpos, int ypos) -{ -} -@endcode - -There is also @ref glfwGetWindowPos for directly retrieving the current position -of the client area of the window. - -@code -int xpos, ypos; -glfwGetWindowPos(window, &xpos, &ypos); -@endcode - - -@section window_title Window title - -All GLFW windows have a title, although undecorated or full screen windows may -not display it or only display it in a task bar or similar interface. To change -the title of a window, use @ref glfwSetWindowTitle. - -@code -glfwSetWindowTitle(window, "My Window"); -@endcode - -The window title is a regular C string using the UTF-8 encoding. This means -for example that, as long as your source file is encoded as UTF-8, you can use -any Unicode characters. - -@code -glfwSetWindowTitle(window, "さよなら絶望先生"); -@endcode - - -@section window_attribs Window attributes - -Windows have a number of attributes that can be returned using @ref -glfwGetWindowAttrib. Some reflect state that may change during the lifetime of -the window, while others reflect the corresponding hints and are fixed at the -time of creation. - -@code -if (glfwGetWindowAttrib(window, GLFW_FOCUSED)) -{ - // window has input focus -} -@endcode - - -@subsection window_attribs_window Window attributes - -The `GLFW_FOCUSED` attribute indicates whether the specified window currently -has input focus. - -The `GLFW_ICONIFIED` attribute indicates whether the specified window is -currently iconified, whether by the user or with @ref glfwIconifyWindow. - -The `GLFW_VISIBLE` attribute indicates whether the specified window is currently -visible. Window visibility can be controlled with @ref glfwShowWindow and @ref -glfwHideWindow and initial visibility is controlled by the -[window hint](@ref window_hints) with the same name. - -The `GLFW_RESIZABLE` attribute indicates whether the specified window is -resizable *by the user*. This is controlled by the -[window hint](@ref window_hints) with the same name. - -The `GLFW_DECORATED` attribute indicates whether the specified window has -decorations such as a border, a close widget, etc. This is controlled by the -[window hint](@ref window_hints) with the same name. - -The `GLFW_FLOATING` attribute indicates whether the specified window is -floating, also called topmost or always-on-top. This is controlled by the -[window hint](@ref window_hints) with the same name. - - -@subsection window_attribs_context Context attributes - -The `GLFW_CLIENT_API` attribute indicates the client API provided by the -window's context; either `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`. - -The `GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and -`GLFW_CONTEXT_REVISION` attributes indicate the client API version of the -window's context. - -The `GLFW_OPENGL_FORWARD_COMPAT` attribute is `GL_TRUE` if the window's -context is an OpenGL forward-compatible one, or `GL_FALSE` otherwise. - -The `GLFW_OPENGL_DEBUG_CONTEXT` attribute is `GL_TRUE` if the window's -context is an OpenGL debug context, or `GL_FALSE` otherwise. - -The `GLFW_OPENGL_PROFILE` attribute indicates the OpenGL profile used by the -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 -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 -used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or -`GLFW_NO_RESET_NOTIFICATION` if the window's context supports robustness, or -`GLFW_NO_ROBUSTNESS` otherwise. - - -@section window_swap Swapping buffers - -GLFW windows are by default double buffered. That means that you have two -rendering buffers; a front buffer and a back buffer. The front buffer is -the one being displayed and the back buffer the one you render to. - -When the entire frame has been rendered, it is time to swap the back and the -front buffers in order to display what has been rendered and begin rendering -a new frame. This is done with @ref glfwSwapBuffers. - -@code -glfwSwapBuffers(window); -@endcode - -Sometimes it can be useful to select when the buffer swap will occur. With the -function @ref glfwSwapInterval it is possible to select the minimum number of -monitor refreshes the driver should wait before swapping the buffers: - -@code -glfwSwapInterval(1); -@endcode - -If the interval is zero, the swap will take place immediately when @ref -glfwSwapBuffers is called without waiting for a refresh. Otherwise at least -interval retraces will pass between each buffer swap. Using a swap interval of -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 -interval of one lets you avoid tearing. - -Note that this may not work on all machines, as some drivers have -user-controlled settings that override any swap interval the application -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. - -*/ diff --git a/glfw/examples/CMakeLists.txt b/glfw/examples/CMakeLists.txt deleted file mode 100644 index 10e6208..0000000 --- a/glfw/examples/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ - -link_libraries(glfw "${OPENGL_glu_LIBRARY}") - -if (BUILD_SHARED_LIBS) - add_definitions(-DGLFW_DLL) - link_libraries("${OPENGL_gl_LIBRARY}" "${MATH_LIBRARY}") -else() - link_libraries(${glfw_LIBRARIES}) -endif() - -include_directories("${GLFW_SOURCE_DIR}/include" - "${GLFW_SOURCE_DIR}/deps") - -if ("${OPENGL_INCLUDE_DIR}") - include_directories("${OPENGL_INCLUDE_DIR}") -endif() - -set(GLAD "${GLFW_SOURCE_DIR}/deps/glad/glad.h" - "${GLFW_SOURCE_DIR}/deps/glad.c") -set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" - "${GLFW_SOURCE_DIR}/deps/getopt.c") -set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" - "${GLFW_SOURCE_DIR}/deps/tinycthread.c") - -if (APPLE) - # Set fancy names for bundles - add_executable(Boing MACOSX_BUNDLE boing.c) - add_executable(Gears MACOSX_BUNDLE gears.c) - add_executable(Particles MACOSX_BUNDLE particles.c ${TINYCTHREAD}) - add_executable(Simple MACOSX_BUNDLE simple.c) - add_executable("Split View" MACOSX_BUNDLE splitview.c) - add_executable(Wave MACOSX_BUNDLE wave.c) - - set_target_properties(Boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing") - set_target_properties(Gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears") - set_target_properties(Particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles") - set_target_properties(Simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple") - set_target_properties("Split View" PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Split View") - set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") -else() - # Set boring names for executables - add_executable(boing WIN32 boing.c) - add_executable(gears WIN32 gears.c) - add_executable(heightmap WIN32 heightmap.c ${GETOPT} ${GLAD}) - add_executable(particles WIN32 particles.c ${TINYCTHREAD} ${GETOPT}) - add_executable(simple WIN32 simple.c) - add_executable(splitview WIN32 splitview.c) - add_executable(wave WIN32 wave.c) -endif() - -if (APPLE) - target_link_libraries(Particles "${CMAKE_THREAD_LIBS_INIT}") -elseif (UNIX) - target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") -endif() - -if (MSVC) - set(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave) - - # Tell MSVC to use main instead of WinMain for Windows subsystem executables - set_target_properties(${WINDOWS_BINARIES} PROPERTIES - LINK_FLAGS "/ENTRY:mainCRTStartup") -endif() - -if (APPLE) - set(BUNDLE_BINARIES Boing Gears Particles Simple "Split View" Wave) - - set_target_properties(${BUNDLE_BINARIES} PROPERTIES - MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} - MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}) -endif() - diff --git a/glfw/examples/boing.c b/glfw/examples/boing.c deleted file mode 100644 index ec31359..0000000 --- a/glfw/examples/boing.c +++ /dev/null @@ -1,669 +0,0 @@ -/***************************************************************************** - * Title: GLBoing - * Desc: Tribute to Amiga Boing. - * Author: Jim Brooks <gfx@jimbrooks.org> - * Original Amiga authors were R.J. Mical and Dale Luck. - * GLFW conversion by Marcus Geelnard - * Notes: - 360' = 2*PI [radian] - * - * - Distances between objects are created by doing a relative - * Z translations. - * - * - Although OpenGL enticingly supports alpha-blending, - * the shadow of the original Boing didn't affect the color - * of the grid. - * - * - [Marcus] Changed timing scheme from interval driven to frame- - * time based animation steps (which results in much smoother - * movement) - * - * History of Amiga Boing: - * - * Boing was demonstrated on the prototype Amiga (codenamed "Lorraine") in - * 1985. According to legend, it was written ad-hoc in one night by - * R. J. Mical and Dale Luck. Because the bouncing ball animation was so fast - * and smooth, attendees did not believe the Amiga prototype was really doing - * the rendering. Suspecting a trick, they began looking around the booth for - * a hidden computer or VCR. - *****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#define GLFW_INCLUDE_GLU -#include <GLFW/glfw3.h> - - -/***************************************************************************** - * Various declarations and macros - *****************************************************************************/ - -/* Prototypes */ -void init( void ); -void display( void ); -void reshape( GLFWwindow* window, int w, int h ); -void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods ); -void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ); -void cursor_position_callback( GLFWwindow* window, double x, double y ); -void DrawBoingBall( void ); -void BounceBall( double dt ); -void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi ); -void DrawGrid( void ); - -#define RADIUS 70.f -#define STEP_LONGITUDE 22.5f /* 22.5 makes 8 bands like original Boing */ -#define STEP_LATITUDE 22.5f - -#define DIST_BALL (RADIUS * 2.f + RADIUS * 0.1f) - -#define VIEW_SCENE_DIST (DIST_BALL * 3.f + 200.f)/* distance from viewer to middle of boing area */ -#define GRID_SIZE (RADIUS * 4.5f) /* length (width) of grid */ -#define BOUNCE_HEIGHT (RADIUS * 2.1f) -#define BOUNCE_WIDTH (RADIUS * 2.1f) - -#define SHADOW_OFFSET_X -20.f -#define SHADOW_OFFSET_Y 10.f -#define SHADOW_OFFSET_Z 0.f - -#define WALL_L_OFFSET 0.f -#define WALL_R_OFFSET 5.f - -/* Animation speed (50.0 mimics the original GLUT demo speed) */ -#define ANIMATION_SPEED 50.f - -/* Maximum allowed delta time per physics iteration */ -#define MAX_DELTA_T 0.02f - -/* Draw ball, or its shadow */ -typedef enum { DRAW_BALL, DRAW_BALL_SHADOW } DRAW_BALL_ENUM; - -/* Vertex type */ -typedef struct {float x; float y; float z;} vertex_t; - -/* Global vars */ -int width, height; -GLfloat deg_rot_y = 0.f; -GLfloat deg_rot_y_inc = 2.f; -GLboolean override_pos = GL_FALSE; -GLfloat cursor_x = 0.f; -GLfloat cursor_y = 0.f; -GLfloat ball_x = -RADIUS; -GLfloat ball_y = -RADIUS; -GLfloat ball_x_inc = 1.f; -GLfloat ball_y_inc = 2.f; -DRAW_BALL_ENUM drawBallHow; -double t; -double t_old = 0.f; -double dt; - -/* Random number generator */ -#ifndef RAND_MAX - #define RAND_MAX 4095 -#endif - -/* PI */ -#ifndef M_PI - #define M_PI 3.1415926535897932384626433832795 -#endif - - -/***************************************************************************** - * Truncate a degree. - *****************************************************************************/ -GLfloat TruncateDeg( GLfloat deg ) -{ - if ( deg >= 360.f ) - return (deg - 360.f); - else - return deg; -} - -/***************************************************************************** - * Convert a degree (360-based) into a radian. - * 360' = 2 * PI - *****************************************************************************/ -double deg2rad( double deg ) -{ - return deg / 360 * (2 * M_PI); -} - -/***************************************************************************** - * 360' sin(). - *****************************************************************************/ -double sin_deg( double deg ) -{ - return sin( deg2rad( deg ) ); -} - -/***************************************************************************** - * 360' cos(). - *****************************************************************************/ -double cos_deg( double deg ) -{ - return cos( deg2rad( deg ) ); -} - -/***************************************************************************** - * Compute a cross product (for a normal vector). - * - * c = a x b - *****************************************************************************/ -void CrossProduct( vertex_t a, vertex_t b, vertex_t c, vertex_t *n ) -{ - GLfloat u1, u2, u3; - GLfloat v1, v2, v3; - - u1 = b.x - a.x; - u2 = b.y - a.y; - u3 = b.y - a.z; - - v1 = c.x - a.x; - v2 = c.y - a.y; - v3 = c.z - a.z; - - n->x = u2 * v3 - v2 * v3; - n->y = u3 * v1 - v3 * u1; - n->z = u1 * v2 - v1 * u2; -} - -/***************************************************************************** - * Calculate the angle to be passed to gluPerspective() so that a scene - * is visible. This function originates from the OpenGL Red Book. - * - * Parms : size - * The size of the segment when the angle is intersected at "dist" - * (ie at the outermost edge of the angle of vision). - * - * dist - * Distance from viewpoint to scene. - *****************************************************************************/ -GLfloat PerspectiveAngle( GLfloat size, - GLfloat dist ) -{ - GLfloat radTheta, degTheta; - - radTheta = 2.f * (GLfloat) atan2( size / 2.f, dist ); - degTheta = (180.f * radTheta) / (GLfloat) M_PI; - return degTheta; -} - - - -#define BOING_DEBUG 0 - - -/***************************************************************************** - * init() - *****************************************************************************/ -void init( void ) -{ - /* - * Clear background. - */ - glClearColor( 0.55f, 0.55f, 0.55f, 0.f ); - - glShadeModel( GL_FLAT ); -} - - -/***************************************************************************** - * display() - *****************************************************************************/ -void display(void) -{ - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glPushMatrix(); - - drawBallHow = DRAW_BALL_SHADOW; - DrawBoingBall(); - - DrawGrid(); - - drawBallHow = DRAW_BALL; - DrawBoingBall(); - - glPopMatrix(); - glFlush(); -} - - -/***************************************************************************** - * reshape() - *****************************************************************************/ -void reshape( GLFWwindow* window, int w, int h ) -{ - glViewport( 0, 0, (GLsizei)w, (GLsizei)h ); - - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - - gluPerspective( PerspectiveAngle( RADIUS * 2, 200 ), - (GLfloat)w / (GLfloat)h, - 1.0, - VIEW_SCENE_DIST ); - - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - - gluLookAt( 0.0, 0.0, VIEW_SCENE_DIST,/* eye */ - 0.0, 0.0, 0.0, /* center of vision */ - 0.0, -1.0, 0.0 ); /* up vector */ -} - -void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods ) -{ - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) - glfwSetWindowShouldClose(window, GL_TRUE); -} - -static void set_ball_pos ( GLfloat x, GLfloat y ) -{ - ball_x = (width / 2) - x; - ball_y = y - (height / 2); -} - -void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ) -{ - if (button != GLFW_MOUSE_BUTTON_LEFT) - return; - - if (action == GLFW_PRESS) - { - override_pos = GL_TRUE; - set_ball_pos(cursor_x, cursor_y); - } - else - { - override_pos = GL_FALSE; - } -} - -void cursor_position_callback( GLFWwindow* window, double x, double y ) -{ - cursor_x = (float) x; - cursor_y = (float) y; - - if ( override_pos ) - set_ball_pos(cursor_x, cursor_y); -} - -/***************************************************************************** - * Draw the Boing ball. - * - * The Boing ball is sphere in which each facet is a rectangle. - * Facet colors alternate between red and white. - * The ball is built by stacking latitudinal circles. Each circle is composed - * of a widely-separated set of points, so that each facet is noticably large. - *****************************************************************************/ -void DrawBoingBall( void ) -{ - GLfloat lon_deg; /* degree of longitude */ - double dt_total, dt2; - - glPushMatrix(); - glMatrixMode( GL_MODELVIEW ); - - /* - * Another relative Z translation to separate objects. - */ - glTranslatef( 0.0, 0.0, DIST_BALL ); - - /* Update ball position and rotation (iterate if necessary) */ - dt_total = dt; - while( dt_total > 0.0 ) - { - dt2 = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total; - dt_total -= dt2; - BounceBall( dt2 ); - deg_rot_y = TruncateDeg( deg_rot_y + deg_rot_y_inc*((float)dt2*ANIMATION_SPEED) ); - } - - /* Set ball position */ - glTranslatef( ball_x, ball_y, 0.0 ); - - /* - * Offset the shadow. - */ - if ( drawBallHow == DRAW_BALL_SHADOW ) - { - glTranslatef( SHADOW_OFFSET_X, - SHADOW_OFFSET_Y, - SHADOW_OFFSET_Z ); - } - - /* - * Tilt the ball. - */ - glRotatef( -20.0, 0.0, 0.0, 1.0 ); - - /* - * Continually rotate ball around Y axis. - */ - glRotatef( deg_rot_y, 0.0, 1.0, 0.0 ); - - /* - * Set OpenGL state for Boing ball. - */ - glCullFace( GL_FRONT ); - glEnable( GL_CULL_FACE ); - glEnable( GL_NORMALIZE ); - - /* - * Build a faceted latitude slice of the Boing ball, - * stepping same-sized vertical bands of the sphere. - */ - for ( lon_deg = 0; - lon_deg < 180; - lon_deg += STEP_LONGITUDE ) - { - /* - * Draw a latitude circle at this longitude. - */ - DrawBoingBallBand( lon_deg, - lon_deg + STEP_LONGITUDE ); - } - - glPopMatrix(); - - return; -} - - -/***************************************************************************** - * Bounce the ball. - *****************************************************************************/ -void BounceBall( double delta_t ) -{ - GLfloat sign; - GLfloat deg; - - if ( override_pos ) - return; - - /* Bounce on walls */ - if ( ball_x > (BOUNCE_WIDTH/2 + WALL_R_OFFSET ) ) - { - ball_x_inc = -0.5f - 0.75f * (GLfloat)rand() / (GLfloat)RAND_MAX; - deg_rot_y_inc = -deg_rot_y_inc; - } - if ( ball_x < -(BOUNCE_HEIGHT/2 + WALL_L_OFFSET) ) - { - ball_x_inc = 0.5f + 0.75f * (GLfloat)rand() / (GLfloat)RAND_MAX; - deg_rot_y_inc = -deg_rot_y_inc; - } - - /* Bounce on floor / roof */ - if ( ball_y > BOUNCE_HEIGHT/2 ) - { - ball_y_inc = -0.75f - 1.f * (GLfloat)rand() / (GLfloat)RAND_MAX; - } - if ( ball_y < -BOUNCE_HEIGHT/2*0.85 ) - { - ball_y_inc = 0.75f + 1.f * (GLfloat)rand() / (GLfloat)RAND_MAX; - } - - /* Update ball position */ - ball_x += ball_x_inc * ((float)delta_t*ANIMATION_SPEED); - ball_y += ball_y_inc * ((float)delta_t*ANIMATION_SPEED); - - /* - * Simulate the effects of gravity on Y movement. - */ - if ( ball_y_inc < 0 ) sign = -1.0; else sign = 1.0; - - deg = (ball_y + BOUNCE_HEIGHT/2) * 90 / BOUNCE_HEIGHT; - if ( deg > 80 ) deg = 80; - if ( deg < 10 ) deg = 10; - - ball_y_inc = sign * 4.f * (float) sin_deg( deg ); -} - - -/***************************************************************************** - * Draw a faceted latitude band of the Boing ball. - * - * Parms: long_lo, long_hi - * Low and high longitudes of slice, resp. - *****************************************************************************/ -void DrawBoingBallBand( GLfloat long_lo, - GLfloat long_hi ) -{ - vertex_t vert_ne; /* "ne" means south-east, so on */ - vertex_t vert_nw; - vertex_t vert_sw; - vertex_t vert_se; - vertex_t vert_norm; - GLfloat lat_deg; - static int colorToggle = 0; - - /* - * Iterate thru the points of a latitude circle. - * A latitude circle is a 2D set of X,Z points. - */ - for ( lat_deg = 0; - lat_deg <= (360 - STEP_LATITUDE); - lat_deg += STEP_LATITUDE ) - { - /* - * Color this polygon with red or white. - */ - if ( colorToggle ) - glColor3f( 0.8f, 0.1f, 0.1f ); - else - glColor3f( 0.95f, 0.95f, 0.95f ); -#if 0 - if ( lat_deg >= 180 ) - if ( colorToggle ) - glColor3f( 0.1f, 0.8f, 0.1f ); - else - glColor3f( 0.5f, 0.5f, 0.95f ); -#endif - colorToggle = ! colorToggle; - - /* - * Change color if drawing shadow. - */ - if ( drawBallHow == DRAW_BALL_SHADOW ) - glColor3f( 0.35f, 0.35f, 0.35f ); - - /* - * Assign each Y. - */ - vert_ne.y = vert_nw.y = (float) cos_deg(long_hi) * RADIUS; - vert_sw.y = vert_se.y = (float) cos_deg(long_lo) * RADIUS; - - /* - * Assign each X,Z with sin,cos values scaled by latitude radius indexed by longitude. - * Eg, long=0 and long=180 are at the poles, so zero scale is sin(longitude), - * while long=90 (sin(90)=1) is at equator. - */ - vert_ne.x = (float) cos_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE )); - vert_se.x = (float) cos_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo )); - vert_nw.x = (float) cos_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE )); - vert_sw.x = (float) cos_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo )); - - vert_ne.z = (float) sin_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE )); - vert_se.z = (float) sin_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo )); - vert_nw.z = (float) sin_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE )); - vert_sw.z = (float) sin_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo )); - - /* - * Draw the facet. - */ - glBegin( GL_POLYGON ); - - CrossProduct( vert_ne, vert_nw, vert_sw, &vert_norm ); - glNormal3f( vert_norm.x, vert_norm.y, vert_norm.z ); - - glVertex3f( vert_ne.x, vert_ne.y, vert_ne.z ); - glVertex3f( vert_nw.x, vert_nw.y, vert_nw.z ); - glVertex3f( vert_sw.x, vert_sw.y, vert_sw.z ); - glVertex3f( vert_se.x, vert_se.y, vert_se.z ); - - glEnd(); - -#if BOING_DEBUG - printf( "----------------------------------------------------------- \n" ); - printf( "lat = %f long_lo = %f long_hi = %f \n", lat_deg, long_lo, long_hi ); - printf( "vert_ne x = %.8f y = %.8f z = %.8f \n", vert_ne.x, vert_ne.y, vert_ne.z ); - printf( "vert_nw x = %.8f y = %.8f z = %.8f \n", vert_nw.x, vert_nw.y, vert_nw.z ); - printf( "vert_se x = %.8f y = %.8f z = %.8f \n", vert_se.x, vert_se.y, vert_se.z ); - printf( "vert_sw x = %.8f y = %.8f z = %.8f \n", vert_sw.x, vert_sw.y, vert_sw.z ); -#endif - - } - - /* - * Toggle color so that next band will opposite red/white colors than this one. - */ - colorToggle = ! colorToggle; - - /* - * This circular band is done. - */ - return; -} - - -/***************************************************************************** - * Draw the purple grid of lines, behind the Boing ball. - * When the Workbench is dropped to the bottom, Boing shows 12 rows. - *****************************************************************************/ -void DrawGrid( void ) -{ - int row, col; - const int rowTotal = 12; /* must be divisible by 2 */ - const int colTotal = rowTotal; /* must be same as rowTotal */ - const GLfloat widthLine = 2.0; /* should be divisible by 2 */ - const GLfloat sizeCell = GRID_SIZE / rowTotal; - const GLfloat z_offset = -40.0; - GLfloat xl, xr; - GLfloat yt, yb; - - glPushMatrix(); - glDisable( GL_CULL_FACE ); - - /* - * Another relative Z translation to separate objects. - */ - glTranslatef( 0.0, 0.0, DIST_BALL ); - - /* - * Draw vertical lines (as skinny 3D rectangles). - */ - for ( col = 0; col <= colTotal; col++ ) - { - /* - * Compute co-ords of line. - */ - xl = -GRID_SIZE / 2 + col * sizeCell; - xr = xl + widthLine; - - yt = GRID_SIZE / 2; - yb = -GRID_SIZE / 2 - widthLine; - - glBegin( GL_POLYGON ); - - glColor3f( 0.6f, 0.1f, 0.6f ); /* purple */ - - glVertex3f( xr, yt, z_offset ); /* NE */ - glVertex3f( xl, yt, z_offset ); /* NW */ - glVertex3f( xl, yb, z_offset ); /* SW */ - glVertex3f( xr, yb, z_offset ); /* SE */ - - glEnd(); - } - - /* - * Draw horizontal lines (as skinny 3D rectangles). - */ - for ( row = 0; row <= rowTotal; row++ ) - { - /* - * Compute co-ords of line. - */ - yt = GRID_SIZE / 2 - row * sizeCell; - yb = yt - widthLine; - - xl = -GRID_SIZE / 2; - xr = GRID_SIZE / 2 + widthLine; - - glBegin( GL_POLYGON ); - - glColor3f( 0.6f, 0.1f, 0.6f ); /* purple */ - - glVertex3f( xr, yt, z_offset ); /* NE */ - glVertex3f( xl, yt, z_offset ); /* NW */ - glVertex3f( xl, yb, z_offset ); /* SW */ - glVertex3f( xr, yb, z_offset ); /* SE */ - - glEnd(); - } - - glPopMatrix(); - - return; -} - - -/*======================================================================* - * main() - *======================================================================*/ - -int main( void ) -{ - GLFWwindow* window; - - /* Init GLFW */ - if( !glfwInit() ) - exit( EXIT_FAILURE ); - - glfwWindowHint(GLFW_DEPTH_BITS, 16); - - window = glfwCreateWindow( 400, 400, "Boing (classic Amiga demo)", NULL, NULL ); - if (!window) - { - glfwTerminate(); - exit( EXIT_FAILURE ); - } - - glfwSetFramebufferSizeCallback(window, reshape); - glfwSetKeyCallback(window, key_callback); - glfwSetMouseButtonCallback(window, mouse_button_callback); - glfwSetCursorPosCallback(window, cursor_position_callback); - - glfwMakeContextCurrent(window); - glfwSwapInterval( 1 ); - - glfwGetFramebufferSize(window, &width, &height); - reshape(window, width, height); - - glfwSetTime( 0.0 ); - - init(); - - /* Main loop */ - for (;;) - { - /* Timing */ - t = glfwGetTime(); - dt = t - t_old; - t_old = t; - - /* Draw one frame */ - display(); - - /* Swap buffers */ - glfwSwapBuffers(window); - glfwPollEvents(); - - /* Check if we are still running */ - if (glfwWindowShouldClose(window)) - break; - } - - glfwTerminate(); - exit( EXIT_SUCCESS ); -} - diff --git a/glfw/examples/gears.c b/glfw/examples/gears.c deleted file mode 100644 index 2d44596..0000000 --- a/glfw/examples/gears.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * 3-D gear wheels. This program is in the public domain. - * - * Command line options: - * -info print GL implementation information - * -exit automatically exit after 30 seconds - * - * - * Brian Paul - * - * - * Marcus Geelnard: - * - Conversion to GLFW - * - Time based rendering (frame rate independent) - * - Slightly modified camera that should work better for stereo viewing - * - * - * Camilla Berglund: - * - Removed FPS counter (this is not a benchmark) - * - Added a few comments - * - Enabled vsync - */ - - -#include <math.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <GLFW/glfw3.h> - -#ifndef M_PI -#define M_PI 3.141592654 -#endif - -/* If non-zero, the program exits after that many seconds - */ -static int autoexit = 0; - -/** - - Draw a gear wheel. You'll probably want to call this function when - building a display list since we do a lot of trig here. - - Input: inner_radius - radius of hole at center - outer_radius - radius at center of teeth - width - width of gear teeth - number of teeth - tooth_depth - depth of tooth - - **/ - -static void -gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, - GLint teeth, GLfloat tooth_depth) -{ - GLint i; - GLfloat r0, r1, r2; - GLfloat angle, da; - GLfloat u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth / 2.f; - r2 = outer_radius + tooth_depth / 2.f; - - da = 2.f * (float) M_PI / teeth / 4.f; - - glShadeModel(GL_FLAT); - - glNormal3f(0.f, 0.f, 1.f); - - /* draw front face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.f * (float) M_PI / teeth; - glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f); - glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f); - if (i < teeth) { - glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f); - glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f); - } - } - glEnd(); - - /* draw front sides of teeth */ - glBegin(GL_QUADS); - da = 2.f * (float) M_PI / teeth / 4.f; - for (i = 0; i < teeth; i++) { - angle = i * 2.f * (float) M_PI / teeth; - - glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f); - glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), width * 0.5f); - glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), width * 0.5f); - glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f); - } - glEnd(); - - glNormal3f(0.0, 0.0, -1.0); - - /* draw back face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.f * (float) M_PI / teeth; - glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f); - glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f); - if (i < teeth) { - glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f); - glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f); - } - } - glEnd(); - - /* draw back sides of teeth */ - glBegin(GL_QUADS); - da = 2.f * (float) M_PI / teeth / 4.f; - for (i = 0; i < teeth; i++) { - angle = i * 2.f * (float) M_PI / teeth; - - glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f); - glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), -width * 0.5f); - glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), -width * 0.5f); - glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f); - } - glEnd(); - - /* draw outward faces of teeth */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.f * (float) M_PI / teeth; - - glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f); - glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f); - u = r2 * (float) cos(angle + da) - r1 * (float) cos(angle); - v = r2 * (float) sin(angle + da) - r1 * (float) sin(angle); - len = (float) sqrt(u * u + v * v); - u /= len; - v /= len; - glNormal3f(v, -u, 0.0); - glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), width * 0.5f); - glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), -width * 0.5f); - glNormal3f((float) cos(angle), (float) sin(angle), 0.f); - glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), width * 0.5f); - glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), -width * 0.5f); - u = r1 * (float) cos(angle + 3 * da) - r2 * (float) cos(angle + 2 * da); - v = r1 * (float) sin(angle + 3 * da) - r2 * (float) sin(angle + 2 * da); - glNormal3f(v, -u, 0.f); - glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f); - glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f); - glNormal3f((float) cos(angle), (float) sin(angle), 0.f); - } - - glVertex3f(r1 * (float) cos(0), r1 * (float) sin(0), width * 0.5f); - glVertex3f(r1 * (float) cos(0), r1 * (float) sin(0), -width * 0.5f); - - glEnd(); - - glShadeModel(GL_SMOOTH); - - /* draw inside radius cylinder */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.f * (float) M_PI / teeth; - glNormal3f(-(float) cos(angle), -(float) sin(angle), 0.f); - glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f); - glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f); - } - glEnd(); - -} - - -static GLfloat view_rotx = 20.f, view_roty = 30.f, view_rotz = 0.f; -static GLint gear1, gear2, gear3; -static GLfloat angle = 0.f; - -/* OpenGL draw function & timing */ -static void draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glRotatef(view_rotx, 1.0, 0.0, 0.0); - glRotatef(view_roty, 0.0, 1.0, 0.0); - glRotatef(view_rotz, 0.0, 0.0, 1.0); - - glPushMatrix(); - glTranslatef(-3.0, -2.0, 0.0); - glRotatef(angle, 0.0, 0.0, 1.0); - glCallList(gear1); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(3.1f, -2.f, 0.f); - glRotatef(-2.f * angle - 9.f, 0.f, 0.f, 1.f); - glCallList(gear2); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(-3.1f, 4.2f, 0.f); - glRotatef(-2.f * angle - 25.f, 0.f, 0.f, 1.f); - glCallList(gear3); - glPopMatrix(); - - glPopMatrix(); -} - - -/* update animation parameters */ -static void animate(void) -{ - angle = 100.f * (float) glfwGetTime(); -} - - -/* change view angle, exit upon ESC */ -void key( GLFWwindow* window, int k, int s, int action, int mods ) -{ - if( action != GLFW_PRESS ) return; - - switch (k) { - case GLFW_KEY_Z: - if( mods & GLFW_MOD_SHIFT ) - view_rotz -= 5.0; - else - view_rotz += 5.0; - break; - case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GL_TRUE); - break; - case GLFW_KEY_UP: - view_rotx += 5.0; - break; - case GLFW_KEY_DOWN: - view_rotx -= 5.0; - break; - case GLFW_KEY_LEFT: - view_roty += 5.0; - break; - case GLFW_KEY_RIGHT: - view_roty -= 5.0; - break; - default: - return; - } -} - - -/* new window size */ -void reshape( GLFWwindow* window, int width, int height ) -{ - GLfloat h = (GLfloat) height / (GLfloat) width; - GLfloat xmax, znear, zfar; - - znear = 5.0f; - zfar = 30.0f; - xmax = znear * 0.5f; - - glViewport( 0, 0, (GLint) width, (GLint) height ); - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - glFrustum( -xmax, xmax, -xmax*h, xmax*h, znear, zfar ); - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - glTranslatef( 0.0, 0.0, -20.0 ); -} - - -/* program & OpenGL initialization */ -static void init(int argc, char *argv[]) -{ - static GLfloat pos[4] = {5.f, 5.f, 10.f, 0.f}; - static GLfloat red[4] = {0.8f, 0.1f, 0.f, 1.f}; - static GLfloat green[4] = {0.f, 0.8f, 0.2f, 1.f}; - static GLfloat blue[4] = {0.2f, 0.2f, 1.f, 1.f}; - GLint i; - - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - - /* make the gears */ - gear1 = glGenLists(1); - glNewList(gear1, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); - gear(1.f, 4.f, 1.f, 20, 0.7f); - glEndList(); - - gear2 = glGenLists(1); - glNewList(gear2, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); - gear(0.5f, 2.f, 2.f, 10, 0.7f); - glEndList(); - - gear3 = glGenLists(1); - glNewList(gear3, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); - gear(1.3f, 2.f, 0.5f, 10, 0.7f); - glEndList(); - - glEnable(GL_NORMALIZE); - - for ( i=1; i<argc; i++ ) { - if (strcmp(argv[i], "-info")==0) { - printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); - printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); - printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); - printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); - } - else if ( strcmp(argv[i], "-exit")==0) { - autoexit = 30; - printf("Auto Exit after %i seconds.\n", autoexit ); - } - } -} - - -/* program entry */ -int main(int argc, char *argv[]) -{ - GLFWwindow* window; - int width, height; - - if( !glfwInit() ) - { - fprintf( stderr, "Failed to initialize GLFW\n" ); - exit( EXIT_FAILURE ); - } - - glfwWindowHint(GLFW_DEPTH_BITS, 16); - - window = glfwCreateWindow( 300, 300, "Gears", NULL, NULL ); - if (!window) - { - fprintf( stderr, "Failed to open GLFW window\n" ); - glfwTerminate(); - exit( EXIT_FAILURE ); - } - - // Set callback functions - glfwSetFramebufferSizeCallback(window, reshape); - glfwSetKeyCallback(window, key); - - glfwMakeContextCurrent(window); - glfwSwapInterval( 1 ); - - glfwGetFramebufferSize(window, &width, &height); - reshape(window, width, height); - - // Parse command-line options - init(argc, argv); - - // Main loop - while( !glfwWindowShouldClose(window) ) - { - // Draw gears - draw(); - - // Update animation - animate(); - - // Swap buffers - glfwSwapBuffers(window); - glfwPollEvents(); - } - - // Terminate GLFW - glfwTerminate(); - - // Exit program - exit( EXIT_SUCCESS ); -} - diff --git a/glfw/examples/heightmap.c b/glfw/examples/heightmap.c deleted file mode 100644 index e7e35b4..0000000 --- a/glfw/examples/heightmap.c +++ /dev/null @@ -1,601 +0,0 @@ -//======================================================================== -// Heightmap example program using OpenGL 3 core profile -// Copyright (c) 2010 Olivier Delannoy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <assert.h> -#include <stddef.h> -#include "getopt.h" - -#include <glad/glad.h> -#include <GLFW/glfw3.h> - -/* Map height updates */ -#define MAX_CIRCLE_SIZE (5.0f) -#define MAX_DISPLACEMENT (1.0f) -#define DISPLACEMENT_SIGN_LIMIT (0.3f) -#define MAX_ITER (200) -#define NUM_ITER_AT_A_TIME (1) - -/* Map general information */ -#define MAP_SIZE (10.0f) -#define MAP_NUM_VERTICES (80) -#define MAP_NUM_TOTAL_VERTICES (MAP_NUM_VERTICES*MAP_NUM_VERTICES) -#define MAP_NUM_LINES (3* (MAP_NUM_VERTICES - 1) * (MAP_NUM_VERTICES - 1) + \ - 2 * (MAP_NUM_VERTICES - 1)) - - -/********************************************************************** - * Default shader programs - *********************************************************************/ - -static const char* default_vertex_shader = -"#version 150\n" -"uniform mat4 project;\n" -"uniform mat4 modelview;\n" -"in float x;\n" -"in float y;\n" -"in float z;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = project * modelview * vec4(x, y, z, 1.0);\n" -"}\n"; - -static const char* default_fragment_shader = -"#version 150\n" -"out vec4 gl_FragColor;\n" -"void main()\n" -"{\n" -" gl_FragColor = vec4(0.2, 1.0, 0.2, 1.0); \n" -"}\n"; - -/********************************************************************** - * Values for shader uniforms - *********************************************************************/ - -/* Frustum configuration */ -static GLfloat view_angle = 45.0f; -static GLfloat aspect_ratio = 4.0f/3.0f; -static GLfloat z_near = 1.0f; -static GLfloat z_far = 100.f; - -/* Projection matrix */ -static GLfloat projection_matrix[16] = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f -}; - -/* Model view matrix */ -static GLfloat modelview_matrix[16] = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f -}; - -/********************************************************************** - * Heightmap vertex and index data - *********************************************************************/ - -static GLfloat map_vertices[3][MAP_NUM_TOTAL_VERTICES]; -static GLuint map_line_indices[2*MAP_NUM_LINES]; - -/* Store uniform location for the shaders - * Those values are setup as part of the process of creating - * the shader program. They should not be used before creating - * the program. - */ -static GLuint mesh; -static GLuint mesh_vbo[4]; - -/********************************************************************** - * OpenGL helper functions - *********************************************************************/ - -/* Load a (text) file into memory and return its contents - */ -static char* read_file_content(const char* filename) -{ - FILE* fd; - size_t size = 0; - char* result = NULL; - - fd = fopen(filename, "r"); - if (fd != NULL) - { - size = fseek(fd, 0, SEEK_END); - (void) fseek(fd, 0, SEEK_SET); - - result = malloc(size + 1); - result[size] = '\0'; - if (fread(result, size, 1, fd) != 1) - { - free(result); - result = NULL; - } - (void) fclose(fd); - } - return result; -} - -/* Creates a shader object of the specified type using the specified text - */ -static GLuint make_shader(GLenum type, const char* shader_src) -{ - GLuint shader; - GLint shader_ok; - GLsizei log_length; - char info_log[8192]; - - shader = glCreateShader(type); - if (shader != 0) - { - glShaderSource(shader, 1, (const GLchar**)&shader_src, NULL); - glCompileShader(shader); - glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_ok); - if (shader_ok != GL_TRUE) - { - fprintf(stderr, "ERROR: Failed to compile %s shader\n", (type == GL_FRAGMENT_SHADER) ? "fragment" : "vertex" ); - glGetShaderInfoLog(shader, 8192, &log_length,info_log); - fprintf(stderr, "ERROR: \n%s\n\n", info_log); - glDeleteShader(shader); - shader = 0; - } - } - return shader; -} - -/* Creates a program object using the specified vertex and fragment text - */ -static GLuint make_shader_program(const char* vertex_shader_src, const char* fragment_shader_src) -{ - GLuint program = 0u; - GLint program_ok; - GLuint vertex_shader = 0u; - GLuint fragment_shader = 0u; - GLsizei log_length; - char info_log[8192]; - - vertex_shader = make_shader(GL_VERTEX_SHADER, (vertex_shader_src == NULL) ? default_vertex_shader : vertex_shader_src); - if (vertex_shader != 0u) - { - fragment_shader = make_shader(GL_FRAGMENT_SHADER, (fragment_shader_src == NULL) ? default_fragment_shader : fragment_shader_src); - if (fragment_shader != 0u) - { - /* make the program that connect the two shader and link it */ - program = glCreateProgram(); - if (program != 0u) - { - /* attach both shader and link */ - glAttachShader(program, vertex_shader); - glAttachShader(program, fragment_shader); - glLinkProgram(program); - glGetProgramiv(program, GL_LINK_STATUS, &program_ok); - - if (program_ok != GL_TRUE) - { - fprintf(stderr, "ERROR, failed to link shader program\n"); - glGetProgramInfoLog(program, 8192, &log_length, info_log); - fprintf(stderr, "ERROR: \n%s\n\n", info_log); - glDeleteProgram(program); - glDeleteShader(fragment_shader); - glDeleteShader(vertex_shader); - program = 0u; - } - } - } - else - { - fprintf(stderr, "ERROR: Unable to load fragment shader\n"); - glDeleteShader(vertex_shader); - } - } - else - { - fprintf(stderr, "ERROR: Unable to load vertex shader\n"); - } - return program; -} - -/********************************************************************** - * Geometry creation functions - *********************************************************************/ - -/* Generate vertices and indices for the heightmap - */ -static void init_map(void) -{ - int i; - int j; - int k; - GLfloat step = MAP_SIZE / (MAP_NUM_VERTICES - 1); - GLfloat x = 0.0f; - GLfloat z = 0.0f; - /* Create a flat grid */ - k = 0; - for (i = 0 ; i < MAP_NUM_VERTICES ; ++i) - { - for (j = 0 ; j < MAP_NUM_VERTICES ; ++j) - { - map_vertices[0][k] = x; - map_vertices[1][k] = 0.0f; - map_vertices[2][k] = z; - z += step; - ++k; - } - x += step; - z = 0.0f; - } -#if DEBUG_ENABLED - for (i = 0 ; i < MAP_NUM_TOTAL_VERTICES ; ++i) - { - printf ("Vertice %d (%f, %f, %f)\n", - i, map_vertices[0][i], map_vertices[1][i], map_vertices[2][i]); - - } -#endif - /* create indices */ - /* line fan based on i - * i+1 - * | / i + n + 1 - * | / - * |/ - * i --- i + n - */ - - /* close the top of the square */ - k = 0; - for (i = 0 ; i < MAP_NUM_VERTICES -1 ; ++i) - { - map_line_indices[k++] = (i + 1) * MAP_NUM_VERTICES -1; - map_line_indices[k++] = (i + 2) * MAP_NUM_VERTICES -1; - } - /* close the right of the square */ - for (i = 0 ; i < MAP_NUM_VERTICES -1 ; ++i) - { - map_line_indices[k++] = (MAP_NUM_VERTICES - 1) * MAP_NUM_VERTICES + i; - map_line_indices[k++] = (MAP_NUM_VERTICES - 1) * MAP_NUM_VERTICES + i + 1; - } - - for (i = 0 ; i < (MAP_NUM_VERTICES - 1) ; ++i) - { - for (j = 0 ; j < (MAP_NUM_VERTICES - 1) ; ++j) - { - int ref = i * (MAP_NUM_VERTICES) + j; - map_line_indices[k++] = ref; - map_line_indices[k++] = ref + 1; - - map_line_indices[k++] = ref; - map_line_indices[k++] = ref + MAP_NUM_VERTICES; - - map_line_indices[k++] = ref; - map_line_indices[k++] = ref + MAP_NUM_VERTICES + 1; - } - } - -#ifdef DEBUG_ENABLED - for (k = 0 ; k < 2 * MAP_NUM_LINES ; k += 2) - { - int beg, end; - beg = map_line_indices[k]; - end = map_line_indices[k+1]; - printf ("Line %d: %d -> %d (%f, %f, %f) -> (%f, %f, %f)\n", - k / 2, beg, end, - map_vertices[0][beg], map_vertices[1][beg], map_vertices[2][beg], - map_vertices[0][end], map_vertices[1][end], map_vertices[2][end]); - } -#endif -} - -static void generate_heightmap__circle(float* center_x, float* center_y, - float* size, float* displacement) -{ - float sign; - /* random value for element in between [0-1.0] */ - *center_x = (MAP_SIZE * rand()) / (1.0f * RAND_MAX); - *center_y = (MAP_SIZE * rand()) / (1.0f * RAND_MAX); - *size = (MAX_CIRCLE_SIZE * rand()) / (1.0f * RAND_MAX); - sign = (1.0f * rand()) / (1.0f * RAND_MAX); - sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f; - *displacement = (sign * (MAX_DISPLACEMENT * rand())) / (1.0f * RAND_MAX); -} - -/* Run the specified number of iterations of the generation process for the - * heightmap - */ -static void update_map(int num_iter) -{ - assert(num_iter > 0); - while(num_iter) - { - /* center of the circle */ - float center_x; - float center_z; - float circle_size; - float disp; - size_t ii; - generate_heightmap__circle(¢er_x, ¢er_z, &circle_size, &disp); - disp = disp / 2.0f; - for (ii = 0u ; ii < MAP_NUM_TOTAL_VERTICES ; ++ii) - { - GLfloat dx = center_x - map_vertices[0][ii]; - GLfloat dz = center_z - map_vertices[2][ii]; - GLfloat pd = (2.0f * sqrtf((dx * dx) + (dz * dz))) / circle_size; - if (fabs(pd) <= 1.0f) - { - /* tx,tz is within the circle */ - GLfloat new_height = disp + (float) (cos(pd*3.14f)*disp); - map_vertices[1][ii] += new_height; - } - } - --num_iter; - } -} - -/********************************************************************** - * OpenGL helper functions - *********************************************************************/ - -/* Create VBO, IBO and VAO objects for the heightmap geometry and bind them to - * the specified program object - */ -static void make_mesh(GLuint program) -{ - GLuint attrloc; - - glGenVertexArrays(1, &mesh); - glGenBuffers(4, mesh_vbo); - glBindVertexArray(mesh); - /* Prepare the data for drawing through a buffer inidices */ - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh_vbo[3]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint)* MAP_NUM_LINES * 2, map_line_indices, GL_STATIC_DRAW); - - /* Prepare the attributes for rendering */ - attrloc = glGetAttribLocation(program, "x"); - glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[0][0], GL_STATIC_DRAW); - glEnableVertexAttribArray(attrloc); - glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0); - - attrloc = glGetAttribLocation(program, "z"); - glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[2]); - glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[2][0], GL_STATIC_DRAW); - glEnableVertexAttribArray(attrloc); - glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0); - - attrloc = glGetAttribLocation(program, "y"); - glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[1]); - glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0], GL_DYNAMIC_DRAW); - glEnableVertexAttribArray(attrloc); - glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0); -} - -/* Update VBO vertices from source data - */ -static void update_mesh(void) -{ - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0]); -} - -/********************************************************************** - * GLFW callback functions - *********************************************************************/ - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - switch(key) - { - case GLFW_KEY_ESCAPE: - /* Exit program on Escape */ - glfwSetWindowShouldClose(window, GL_TRUE); - break; - } -} - -/* Print usage information */ -static void usage(void) -{ - printf("Usage: heightmap [-v <vertex_shader_path>] [-f <fragment_shader_path>]\n"); - printf(" heightmap [-h]\n"); -} - -int main(int argc, char** argv) -{ - GLFWwindow* window; - int ch, iter; - double dt; - double last_update_time; - int frame; - float f; - GLint uloc_modelview; - GLint uloc_project; - - char* vertex_shader_path = NULL; - char* fragment_shader_path = NULL; - char* vertex_shader_src = NULL; - char* fragment_shader_src = NULL; - GLuint shader_program; - - while ((ch = getopt(argc, argv, "f:v:h")) != -1) - { - switch (ch) - { - case 'f': - fragment_shader_path = optarg; - break; - case 'v': - vertex_shader_path = optarg; - break; - case 'h': - usage(); - exit(EXIT_SUCCESS); - default: - usage(); - exit(EXIT_FAILURE); - } - } - - if (fragment_shader_path) - { - vertex_shader_src = read_file_content(fragment_shader_path); - if (!fragment_shader_src) - { - fprintf(stderr, - "ERROR: unable to load fragment shader from '%s'\n", - fragment_shader_path); - exit(EXIT_FAILURE); - } - } - - if (vertex_shader_path) - { - vertex_shader_src = read_file_content(vertex_shader_path); - if (!vertex_shader_src) - { - fprintf(stderr, - "ERROR: unable to load vertex shader from '%s'\n", - fragment_shader_path); - exit(EXIT_FAILURE); - } - } - - if (!glfwInit()) - { - fprintf(stderr, "ERROR: Unable to initialize GLFW\n"); - usage(); - - free(vertex_shader_src); - free(fragment_shader_src); - exit(EXIT_FAILURE); - } - - glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); - - window = glfwCreateWindow(800, 600, "GLFW OpenGL3 Heightmap demo", NULL, NULL); - if (! window ) - { - fprintf(stderr, "ERROR: Unable to create the OpenGL context and associated window\n"); - usage(); - - free(vertex_shader_src); - free(fragment_shader_src); - - glfwTerminate(); - exit(EXIT_FAILURE); - } - - /* Register events callback */ - glfwSetKeyCallback(window, key_callback); - - glfwMakeContextCurrent(window); - gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); - - /* Prepare opengl resources for rendering */ - shader_program = make_shader_program(vertex_shader_src , fragment_shader_src); - free(vertex_shader_src); - free(fragment_shader_src); - - if (shader_program == 0u) - { - fprintf(stderr, "ERROR: during creation of the shader program\n"); - usage(); - - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glUseProgram(shader_program); - uloc_project = glGetUniformLocation(shader_program, "project"); - uloc_modelview = glGetUniformLocation(shader_program, "modelview"); - - /* Compute the projection matrix */ - f = 1.0f / tanf(view_angle / 2.0f); - projection_matrix[0] = f / aspect_ratio; - projection_matrix[5] = f; - projection_matrix[10] = (z_far + z_near)/ (z_near - z_far); - projection_matrix[11] = -1.0f; - projection_matrix[14] = 2.0f * (z_far * z_near) / (z_near - z_far); - glUniformMatrix4fv(uloc_project, 1, GL_FALSE, projection_matrix); - - /* Set the camera position */ - modelview_matrix[12] = -5.0f; - modelview_matrix[13] = -5.0f; - modelview_matrix[14] = -20.0f; - glUniformMatrix4fv(uloc_modelview, 1, GL_FALSE, modelview_matrix); - - /* Create mesh data */ - init_map(); - make_mesh(shader_program); - - /* Create vao + vbo to store the mesh */ - /* Create the vbo to store all the information for the grid and the height */ - - /* setup the scene ready for rendering */ - glViewport(0, 0, 800, 600); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - - /* main loop */ - frame = 0; - iter = 0; - last_update_time = glfwGetTime(); - - while (!glfwWindowShouldClose(window)) - { - ++frame; - /* render the next frame */ - glClear(GL_COLOR_BUFFER_BIT); - glDrawElements(GL_LINES, 2* MAP_NUM_LINES , GL_UNSIGNED_INT, 0); - - /* display and process events through callbacks */ - glfwSwapBuffers(window); - glfwPollEvents(); - /* Check the frame rate and update the heightmap if needed */ - dt = glfwGetTime(); - if ((dt - last_update_time) > 0.2) - { - /* generate the next iteration of the heightmap */ - if (iter < MAX_ITER) - { - update_map(NUM_ITER_AT_A_TIME); - update_mesh(); - iter += NUM_ITER_AT_A_TIME; - } - last_update_time = dt; - frame = 0; - } - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/examples/particles.c b/glfw/examples/particles.c deleted file mode 100644 index dc9e9fc..0000000 --- a/glfw/examples/particles.c +++ /dev/null @@ -1,1061 +0,0 @@ -//======================================================================== -// A simple particle engine with threaded physics -// Copyright (c) Marcus Geelnard -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> -#include <time.h> - -#include <tinycthread.h> -#include <getopt.h> - -#define GLFW_INCLUDE_GLU -#include <GLFW/glfw3.h> - -// Define tokens for GL_EXT_separate_specular_color if not already defined -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif // GL_EXT_separate_specular_color - -// Some <math.h>'s do not define M_PI -#ifndef M_PI -#define M_PI 3.141592654 -#endif - - -//======================================================================== -// Type definitions -//======================================================================== - -typedef struct -{ - float x, y, z; -} Vec3; - -// This structure is used for interleaved vertex arrays (see the -// draw_particles function) -// -// NOTE: This structure SHOULD be packed on most systems. It uses 32-bit fields -// on 32-bit boundaries, and is a multiple of 64 bits in total (6x32=3x64). If -// it does not work, try using pragmas or whatever to force the structure to be -// packed. -typedef struct -{ - GLfloat s, t; // Texture coordinates - GLuint rgba; // Color (four ubytes packed into an uint) - GLfloat x, y, z; // Vertex coordinates -} Vertex; - - -//======================================================================== -// Program control global variables -//======================================================================== - -// Window dimensions -float aspect_ratio; - -// "wireframe" flag (true if we use wireframe view) -int wireframe; - -// Thread synchronization -struct { - double t; // Time (s) - float dt; // Time since last frame (s) - int p_frame; // Particle physics frame number - int d_frame; // Particle draw frame number - cnd_t p_done; // Condition: particle physics done - cnd_t d_done; // Condition: particle draw done - mtx_t particles_lock; // Particles data sharing mutex -} thread_sync; - - -//======================================================================== -// Texture declarations (we hard-code them into the source code, since -// they are so simple) -//======================================================================== - -#define P_TEX_WIDTH 8 // Particle texture dimensions -#define P_TEX_HEIGHT 8 -#define F_TEX_WIDTH 16 // Floor texture dimensions -#define F_TEX_HEIGHT 16 - -// Texture object IDs -GLuint particle_tex_id, floor_tex_id; - -// Particle texture (a simple spot) -const unsigned char particle_texture[ P_TEX_WIDTH * P_TEX_HEIGHT ] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x11, 0x22, 0x22, 0x11, 0x00, 0x00, - 0x00, 0x11, 0x33, 0x88, 0x77, 0x33, 0x11, 0x00, - 0x00, 0x22, 0x88, 0xff, 0xee, 0x77, 0x22, 0x00, - 0x00, 0x22, 0x77, 0xee, 0xff, 0x88, 0x22, 0x00, - 0x00, 0x11, 0x33, 0x77, 0x88, 0x33, 0x11, 0x00, - 0x00, 0x00, 0x11, 0x33, 0x22, 0x11, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -// Floor texture (your basic checkered floor) -const unsigned char floor_texture[ F_TEX_WIDTH * F_TEX_HEIGHT ] = { - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0xff, 0xf0, 0xcc, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0xf0, 0xcc, 0xee, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x66, 0x30, 0x30, 0x30, 0x20, 0x30, 0x30, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xee, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0xf0, 0xf0, 0xf0, 0xf0, 0xcc, 0xf0, 0xf0, 0xf0, 0x30, 0x30, 0x55, 0x30, 0x30, 0x44, 0x30, 0x30, - 0xf0, 0xdd, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x30, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x33, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x30, 0x30, 0xf0, 0xff, 0xf0, 0xf0, 0xdd, 0xf0, 0xf0, 0xff, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x55, 0x33, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xf0, - 0x30, 0x44, 0x66, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xaa, 0xf0, 0xf0, 0xcc, 0xf0, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xff, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xdd, 0xf0, - 0x30, 0x30, 0x30, 0x77, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, -}; - - -//======================================================================== -// These are fixed constants that control the particle engine. In a -// modular world, these values should be variables... -//======================================================================== - -// Maximum number of particles -#define MAX_PARTICLES 3000 - -// Life span of a particle (in seconds) -#define LIFE_SPAN 8.f - -// A new particle is born every [BIRTH_INTERVAL] second -#define BIRTH_INTERVAL (LIFE_SPAN/(float)MAX_PARTICLES) - -// Particle size (meters) -#define PARTICLE_SIZE 0.7f - -// Gravitational constant (m/s^2) -#define GRAVITY 9.8f - -// Base initial velocity (m/s) -#define VELOCITY 8.f - -// Bounce friction (1.0 = no friction, 0.0 = maximum friction) -#define FRICTION 0.75f - -// "Fountain" height (m) -#define FOUNTAIN_HEIGHT 3.f - -// Fountain radius (m) -#define FOUNTAIN_RADIUS 1.6f - -// Minimum delta-time for particle phisics (s) -#define MIN_DELTA_T (BIRTH_INTERVAL * 0.5f) - - -//======================================================================== -// Particle system global variables -//======================================================================== - -// This structure holds all state for a single particle -typedef struct { - float x,y,z; // Position in space - float vx,vy,vz; // Velocity vector - float r,g,b; // Color of particle - float life; // Life of particle (1.0 = newborn, < 0.0 = dead) - int active; // Tells if this particle is active -} PARTICLE; - -// Global vectors holding all particles. We use two vectors for double -// buffering. -static PARTICLE particles[MAX_PARTICLES]; - -// Global variable holding the age of the youngest particle -static float min_age; - -// Color of latest born particle (used for fountain lighting) -static float glow_color[4]; - -// Position of latest born particle (used for fountain lighting) -static float glow_pos[4]; - - -//======================================================================== -// Object material and fog configuration constants -//======================================================================== - -const GLfloat fountain_diffuse[4] = { 0.7f, 1.f, 1.f, 1.f }; -const GLfloat fountain_specular[4] = { 1.f, 1.f, 1.f, 1.f }; -const GLfloat fountain_shininess = 12.f; -const GLfloat floor_diffuse[4] = { 1.f, 0.6f, 0.6f, 1.f }; -const GLfloat floor_specular[4] = { 0.6f, 0.6f, 0.6f, 1.f }; -const GLfloat floor_shininess = 18.f; -const GLfloat fog_color[4] = { 0.1f, 0.1f, 0.1f, 1.f }; - - -//======================================================================== -// Print usage information -//======================================================================== - -static void usage(void) -{ - printf("Usage: particles [-bfhs]\n"); - printf("Options:\n"); - printf(" -f Run in full screen\n"); - printf(" -h Display this help\n"); - printf(" -s Run program as single thread (default is to use two threads)\n"); - printf("\n"); - printf("Program runtime controls:\n"); - printf(" W Toggle wireframe mode\n"); - printf(" Esc Exit program\n"); -} - - -//======================================================================== -// Initialize a new particle -//======================================================================== - -static void init_particle(PARTICLE *p, double t) -{ - float xy_angle, velocity; - - // Start position of particle is at the fountain blow-out - p->x = 0.f; - p->y = 0.f; - p->z = FOUNTAIN_HEIGHT; - - // Start velocity is up (Z)... - p->vz = 0.7f + (0.3f / 4096.f) * (float) (rand() & 4095); - - // ...and a randomly chosen X/Y direction - xy_angle = (2.f * (float) M_PI / 4096.f) * (float) (rand() & 4095); - p->vx = 0.4f * (float) cos(xy_angle); - p->vy = 0.4f * (float) sin(xy_angle); - - // Scale velocity vector according to a time-varying velocity - velocity = VELOCITY * (0.8f + 0.1f * (float) (sin(0.5 * t) + sin(1.31 * t))); - p->vx *= velocity; - p->vy *= velocity; - p->vz *= velocity; - - // Color is time-varying - p->r = 0.7f + 0.3f * (float) sin(0.34 * t + 0.1); - p->g = 0.6f + 0.4f * (float) sin(0.63 * t + 1.1); - p->b = 0.6f + 0.4f * (float) sin(0.91 * t + 2.1); - - // Store settings for fountain glow lighting - glow_pos[0] = 0.4f * (float) sin(1.34 * t); - glow_pos[1] = 0.4f * (float) sin(3.11 * t); - glow_pos[2] = FOUNTAIN_HEIGHT + 1.f; - glow_pos[3] = 1.f; - glow_color[0] = p->r; - glow_color[1] = p->g; - glow_color[2] = p->b; - glow_color[3] = 1.f; - - // The particle is new-born and active - p->life = 1.f; - p->active = 1; -} - - -//======================================================================== -// Update a particle -//======================================================================== - -#define FOUNTAIN_R2 (FOUNTAIN_RADIUS+PARTICLE_SIZE/2)*(FOUNTAIN_RADIUS+PARTICLE_SIZE/2) - -static void update_particle(PARTICLE *p, float dt) -{ - // If the particle is not active, we need not do anything - if (!p->active) - return; - - // The particle is getting older... - p->life -= dt * (1.f / LIFE_SPAN); - - // Did the particle die? - if (p->life <= 0.f) - { - p->active = 0; - return; - } - - // Apply gravity - p->vz = p->vz - GRAVITY * dt; - - // Update particle position - p->x = p->x + p->vx * dt; - p->y = p->y + p->vy * dt; - p->z = p->z + p->vz * dt; - - // Simple collision detection + response - if (p->vz < 0.f) - { - // Particles should bounce on the fountain (with friction) - if ((p->x * p->x + p->y * p->y) < FOUNTAIN_R2 && - p->z < (FOUNTAIN_HEIGHT + PARTICLE_SIZE / 2)) - { - p->vz = -FRICTION * p->vz; - p->z = FOUNTAIN_HEIGHT + PARTICLE_SIZE / 2 + - FRICTION * (FOUNTAIN_HEIGHT + - PARTICLE_SIZE / 2 - p->z); - } - - // Particles should bounce on the floor (with friction) - else if (p->z < PARTICLE_SIZE / 2) - { - p->vz = -FRICTION * p->vz; - p->z = PARTICLE_SIZE / 2 + - FRICTION * (PARTICLE_SIZE / 2 - p->z); - } - } -} - - -//======================================================================== -// The main frame for the particle engine. Called once per frame. -//======================================================================== - -static void particle_engine(double t, float dt) -{ - int i; - float dt2; - - // Update particles (iterated several times per frame if dt is too large) - while (dt > 0.f) - { - // Calculate delta time for this iteration - dt2 = dt < MIN_DELTA_T ? dt : MIN_DELTA_T; - - for (i = 0; i < MAX_PARTICLES; i++) - update_particle(&particles[i], dt2); - - min_age += dt2; - - // Should we create any new particle(s)? - while (min_age >= BIRTH_INTERVAL) - { - min_age -= BIRTH_INTERVAL; - - // Find a dead particle to replace with a new one - for (i = 0; i < MAX_PARTICLES; i++) - { - if (!particles[i].active) - { - init_particle(&particles[i], t + min_age); - update_particle(&particles[i], min_age); - break; - } - } - } - - dt -= dt2; - } -} - - -//======================================================================== -// Draw all active particles. We use OpenGL 1.1 vertex -// arrays for this in order to accelerate the drawing. -//======================================================================== - -#define BATCH_PARTICLES 70 // Number of particles to draw in each batch - // (70 corresponds to 7.5 KB = will not blow - // the L1 data cache on most CPUs) -#define PARTICLE_VERTS 4 // Number of vertices per particle - -static void draw_particles(GLFWwindow* window, double t, float dt) -{ - int i, particle_count; - Vertex vertex_array[BATCH_PARTICLES * PARTICLE_VERTS]; - Vertex* vptr; - float alpha; - GLuint rgba; - Vec3 quad_lower_left, quad_lower_right; - GLfloat mat[16]; - PARTICLE* pptr; - - // Here comes the real trick with flat single primitive objects (s.c. - // "billboards"): We must rotate the textured primitive so that it - // always faces the viewer (is coplanar with the view-plane). - // We: - // 1) Create the primitive around origo (0,0,0) - // 2) Rotate it so that it is coplanar with the view plane - // 3) Translate it according to the particle position - // Note that 1) and 2) is the same for all particles (done only once). - - // Get modelview matrix. We will only use the upper left 3x3 part of - // the matrix, which represents the rotation. - glGetFloatv(GL_MODELVIEW_MATRIX, mat); - - // 1) & 2) We do it in one swift step: - // Although not obvious, the following six lines represent two matrix/ - // vector multiplications. The matrix is the inverse 3x3 rotation - // matrix (i.e. the transpose of the same matrix), and the two vectors - // represent the lower left corner of the quad, PARTICLE_SIZE/2 * - // (-1,-1,0), and the lower right corner, PARTICLE_SIZE/2 * (1,-1,0). - // The upper left/right corners of the quad is always the negative of - // the opposite corners (regardless of rotation). - quad_lower_left.x = (-PARTICLE_SIZE / 2) * (mat[0] + mat[1]); - quad_lower_left.y = (-PARTICLE_SIZE / 2) * (mat[4] + mat[5]); - quad_lower_left.z = (-PARTICLE_SIZE / 2) * (mat[8] + mat[9]); - quad_lower_right.x = (PARTICLE_SIZE / 2) * (mat[0] - mat[1]); - quad_lower_right.y = (PARTICLE_SIZE / 2) * (mat[4] - mat[5]); - quad_lower_right.z = (PARTICLE_SIZE / 2) * (mat[8] - mat[9]); - - // Don't update z-buffer, since all particles are transparent! - glDepthMask(GL_FALSE); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - // Select particle texture - if (!wireframe) - { - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, particle_tex_id); - } - - // Set up vertex arrays. We use interleaved arrays, which is easier to - // handle (in most situations) and it gives a linear memeory access - // access pattern (which may give better performance in some - // situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords, - // 4 ubytes for color and 3 floats for vertex coord (in that order). - // Most OpenGL cards / drivers are optimized for this format. - glInterleavedArrays(GL_T2F_C4UB_V3F, 0, vertex_array); - - // Wait for particle physics thread to be done - mtx_lock(&thread_sync.particles_lock); - while (!glfwWindowShouldClose(window) && - thread_sync.p_frame <= thread_sync.d_frame) - { - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_nsec += 100000000; - cnd_timedwait(&thread_sync.p_done, &thread_sync.particles_lock, &ts); - } - - // Store the frame time and delta time for the physics thread - thread_sync.t = t; - thread_sync.dt = dt; - - // Update frame counter - thread_sync.d_frame++; - - // Loop through all particles and build vertex arrays. - particle_count = 0; - vptr = vertex_array; - pptr = particles; - - for (i = 0; i < MAX_PARTICLES; i++) - { - if (pptr->active) - { - // Calculate particle intensity (we set it to max during 75% - // of its life, then it fades out) - alpha = 4.f * pptr->life; - if (alpha > 1.f) - alpha = 1.f; - - // Convert color from float to 8-bit (store it in a 32-bit - // integer using endian independent type casting) - ((GLubyte*) &rgba)[0] = (GLubyte)(pptr->r * 255.f); - ((GLubyte*) &rgba)[1] = (GLubyte)(pptr->g * 255.f); - ((GLubyte*) &rgba)[2] = (GLubyte)(pptr->b * 255.f); - ((GLubyte*) &rgba)[3] = (GLubyte)(alpha * 255.f); - - // 3) Translate the quad to the correct position in modelview - // space and store its parameters in vertex arrays (we also - // store texture coord and color information for each vertex). - - // Lower left corner - vptr->s = 0.f; - vptr->t = 0.f; - vptr->rgba = rgba; - vptr->x = pptr->x + quad_lower_left.x; - vptr->y = pptr->y + quad_lower_left.y; - vptr->z = pptr->z + quad_lower_left.z; - vptr ++; - - // Lower right corner - vptr->s = 1.f; - vptr->t = 0.f; - vptr->rgba = rgba; - vptr->x = pptr->x + quad_lower_right.x; - vptr->y = pptr->y + quad_lower_right.y; - vptr->z = pptr->z + quad_lower_right.z; - vptr ++; - - // Upper right corner - vptr->s = 1.f; - vptr->t = 1.f; - vptr->rgba = rgba; - vptr->x = pptr->x - quad_lower_left.x; - vptr->y = pptr->y - quad_lower_left.y; - vptr->z = pptr->z - quad_lower_left.z; - vptr ++; - - // Upper left corner - vptr->s = 0.f; - vptr->t = 1.f; - vptr->rgba = rgba; - vptr->x = pptr->x - quad_lower_right.x; - vptr->y = pptr->y - quad_lower_right.y; - vptr->z = pptr->z - quad_lower_right.z; - vptr ++; - - // Increase count of drawable particles - particle_count ++; - } - - // If we have filled up one batch of particles, draw it as a set - // of quads using glDrawArrays. - if (particle_count >= BATCH_PARTICLES) - { - // The first argument tells which primitive type we use (QUAD) - // The second argument tells the index of the first vertex (0) - // The last argument is the vertex count - glDrawArrays(GL_QUADS, 0, PARTICLE_VERTS * particle_count); - particle_count = 0; - vptr = vertex_array; - } - - // Next particle - pptr++; - } - - // We are done with the particle data - mtx_unlock(&thread_sync.particles_lock); - cnd_signal(&thread_sync.d_done); - - // Draw final batch of particles (if any) - glDrawArrays(GL_QUADS, 0, PARTICLE_VERTS * particle_count); - - // Disable vertex arrays (Note: glInterleavedArrays implicitly called - // glEnableClientState for vertex, texture coord and color arrays) - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - - glDepthMask(GL_TRUE); -} - - -//======================================================================== -// Fountain geometry specification -//======================================================================== - -#define FOUNTAIN_SIDE_POINTS 14 -#define FOUNTAIN_SWEEP_STEPS 32 - -static const float fountain_side[FOUNTAIN_SIDE_POINTS * 2] = -{ - 1.2f, 0.f, 1.f, 0.2f, 0.41f, 0.3f, 0.4f, 0.35f, - 0.4f, 1.95f, 0.41f, 2.f, 0.8f, 2.2f, 1.2f, 2.4f, - 1.5f, 2.7f, 1.55f,2.95f, 1.6f, 3.f, 1.f, 3.f, - 0.5f, 3.f, 0.f, 3.f -}; - -static const float fountain_normal[FOUNTAIN_SIDE_POINTS * 2] = -{ - 1.0000f, 0.0000f, 0.6428f, 0.7660f, 0.3420f, 0.9397f, 1.0000f, 0.0000f, - 1.0000f, 0.0000f, 0.3420f,-0.9397f, 0.4226f,-0.9063f, 0.5000f,-0.8660f, - 0.7660f,-0.6428f, 0.9063f,-0.4226f, 0.0000f,1.00000f, 0.0000f,1.00000f, - 0.0000f,1.00000f, 0.0000f,1.00000f -}; - - -//======================================================================== -// Draw a fountain -//======================================================================== - -static void draw_fountain(void) -{ - static GLuint fountain_list = 0; - double angle; - float x, y; - int m, n; - - // The first time, we build the fountain display list - if (!fountain_list) - { - fountain_list = glGenLists(1); - glNewList(fountain_list, GL_COMPILE_AND_EXECUTE); - - glMaterialfv(GL_FRONT, GL_DIFFUSE, fountain_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, fountain_specular); - glMaterialf(GL_FRONT, GL_SHININESS, fountain_shininess); - - // Build fountain using triangle strips - for (n = 0; n < FOUNTAIN_SIDE_POINTS - 1; n++) - { - glBegin(GL_TRIANGLE_STRIP); - for (m = 0; m <= FOUNTAIN_SWEEP_STEPS; m++) - { - angle = (double) m * (2.0 * M_PI / (double) FOUNTAIN_SWEEP_STEPS); - x = (float) cos(angle); - y = (float) sin(angle); - - // Draw triangle strip - glNormal3f(x * fountain_normal[n * 2 + 2], - y * fountain_normal[n * 2 + 2], - fountain_normal[n * 2 + 3]); - glVertex3f(x * fountain_side[n * 2 + 2], - y * fountain_side[n * 2 + 2], - fountain_side[n * 2 +3 ]); - glNormal3f(x * fountain_normal[n * 2], - y * fountain_normal[n * 2], - fountain_normal[n * 2 + 1]); - glVertex3f(x * fountain_side[n * 2], - y * fountain_side[n * 2], - fountain_side[n * 2 + 1]); - } - - glEnd(); - } - - glEndList(); - } - else - glCallList(fountain_list); -} - - -//======================================================================== -// Recursive function for building variable tesselated floor -//======================================================================== - -static void tessellate_floor(float x1, float y1, float x2, float y2, int depth) -{ - float delta, x, y; - - // Last recursion? - if (depth >= 5) - delta = 999999.f; - else - { - x = (float) (fabs(x1) < fabs(x2) ? fabs(x1) : fabs(x2)); - y = (float) (fabs(y1) < fabs(y2) ? fabs(y1) : fabs(y2)); - delta = x*x + y*y; - } - - // Recurse further? - if (delta < 0.1f) - { - x = (x1 + x2) * 0.5f; - y = (y1 + y2) * 0.5f; - tessellate_floor(x1, y1, x, y, depth + 1); - tessellate_floor(x, y1, x2, y, depth + 1); - tessellate_floor(x1, y, x, y2, depth + 1); - tessellate_floor(x, y, x2, y2, depth + 1); - } - else - { - glTexCoord2f(x1 * 30.f, y1 * 30.f); - glVertex3f( x1 * 80.f, y1 * 80.f, 0.f); - glTexCoord2f(x2 * 30.f, y1 * 30.f); - glVertex3f( x2 * 80.f, y1 * 80.f, 0.f); - glTexCoord2f(x2 * 30.f, y2 * 30.f); - glVertex3f( x2 * 80.f, y2 * 80.f, 0.f); - glTexCoord2f(x1 * 30.f, y2 * 30.f); - glVertex3f( x1 * 80.f, y2 * 80.f, 0.f); - } -} - - -//======================================================================== -// Draw floor. We build the floor recursively and let the tessellation in the -// center (near x,y=0,0) be high, while the tessellation around the edges be -// low. -//======================================================================== - -static void draw_floor(void) -{ - static GLuint floor_list = 0; - - if (!wireframe) - { - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, floor_tex_id); - } - - // The first time, we build the floor display list - if (!floor_list) - { - floor_list = glGenLists(1); - glNewList(floor_list, GL_COMPILE_AND_EXECUTE); - - glMaterialfv(GL_FRONT, GL_DIFFUSE, floor_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular); - glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess); - - // Draw floor as a bunch of triangle strips (high tesselation - // improves lighting) - glNormal3f(0.f, 0.f, 1.f); - glBegin(GL_QUADS); - tessellate_floor(-1.f, -1.f, 0.f, 0.f, 0); - tessellate_floor( 0.f, -1.f, 1.f, 0.f, 0); - tessellate_floor( 0.f, 0.f, 1.f, 1.f, 0); - tessellate_floor(-1.f, 0.f, 0.f, 1.f, 0); - glEnd(); - - glEndList(); - } - else - glCallList(floor_list); - - glDisable(GL_TEXTURE_2D); - -} - - -//======================================================================== -// Position and configure light sources -//======================================================================== - -static void setup_lights(void) -{ - float l1pos[4], l1amb[4], l1dif[4], l1spec[4]; - float l2pos[4], l2amb[4], l2dif[4], l2spec[4]; - - // Set light source 1 parameters - l1pos[0] = 0.f; l1pos[1] = -9.f; l1pos[2] = 8.f; l1pos[3] = 1.f; - l1amb[0] = 0.2f; l1amb[1] = 0.2f; l1amb[2] = 0.2f; l1amb[3] = 1.f; - l1dif[0] = 0.8f; l1dif[1] = 0.4f; l1dif[2] = 0.2f; l1dif[3] = 1.f; - l1spec[0] = 1.f; l1spec[1] = 0.6f; l1spec[2] = 0.2f; l1spec[3] = 0.f; - - // Set light source 2 parameters - l2pos[0] = -15.f; l2pos[1] = 12.f; l2pos[2] = 1.5f; l2pos[3] = 1.f; - l2amb[0] = 0.f; l2amb[1] = 0.f; l2amb[2] = 0.f; l2amb[3] = 1.f; - l2dif[0] = 0.2f; l2dif[1] = 0.4f; l2dif[2] = 0.8f; l2dif[3] = 1.f; - l2spec[0] = 0.2f; l2spec[1] = 0.6f; l2spec[2] = 1.f; l2spec[3] = 0.f; - - glLightfv(GL_LIGHT1, GL_POSITION, l1pos); - glLightfv(GL_LIGHT1, GL_AMBIENT, l1amb); - glLightfv(GL_LIGHT1, GL_DIFFUSE, l1dif); - glLightfv(GL_LIGHT1, GL_SPECULAR, l1spec); - glLightfv(GL_LIGHT2, GL_POSITION, l2pos); - glLightfv(GL_LIGHT2, GL_AMBIENT, l2amb); - glLightfv(GL_LIGHT2, GL_DIFFUSE, l2dif); - glLightfv(GL_LIGHT2, GL_SPECULAR, l2spec); - glLightfv(GL_LIGHT3, GL_POSITION, glow_pos); - glLightfv(GL_LIGHT3, GL_DIFFUSE, glow_color); - glLightfv(GL_LIGHT3, GL_SPECULAR, glow_color); - - glEnable(GL_LIGHT1); - glEnable(GL_LIGHT2); - glEnable(GL_LIGHT3); -} - - -//======================================================================== -// Main rendering function -//======================================================================== - -static void draw_scene(GLFWwindow* window, double t) -{ - double xpos, ypos, zpos, angle_x, angle_y, angle_z; - static double t_old = 0.0; - float dt; - - // Calculate frame-to-frame delta time - dt = (float) (t - t_old); - t_old = t; - - glClearColor(0.1f, 0.1f, 0.1f, 1.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(65.0, aspect_ratio, 1.0, 60.0); - - // Setup camera - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - // Rotate camera - angle_x = 90.0 - 10.0; - angle_y = 10.0 * sin(0.3 * t); - angle_z = 10.0 * t; - glRotated(-angle_x, 1.0, 0.0, 0.0); - glRotated(-angle_y, 0.0, 1.0, 0.0); - glRotated(-angle_z, 0.0, 0.0, 1.0); - - // Translate camera - xpos = 15.0 * sin((M_PI / 180.0) * angle_z) + - 2.0 * sin((M_PI / 180.0) * 3.1 * t); - ypos = -15.0 * cos((M_PI / 180.0) * angle_z) + - 2.0 * cos((M_PI / 180.0) * 2.9 * t); - zpos = 4.0 + 2.0 * cos((M_PI / 180.0) * 4.9 * t); - glTranslated(-xpos, -ypos, -zpos); - - glFrontFace(GL_CCW); - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); - - setup_lights(); - glEnable(GL_LIGHTING); - - glEnable(GL_FOG); - glFogi(GL_FOG_MODE, GL_EXP); - glFogf(GL_FOG_DENSITY, 0.05f); - glFogfv(GL_FOG_COLOR, fog_color); - - draw_floor(); - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - glDepthMask(GL_TRUE); - - draw_fountain(); - - glDisable(GL_LIGHTING); - glDisable(GL_FOG); - - // Particles must be drawn after all solid objects have been drawn - draw_particles(window, t, dt); - - // Z-buffer not needed anymore - glDisable(GL_DEPTH_TEST); -} - - -//======================================================================== -// Window resize callback function -//======================================================================== - -static void resize_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); - aspect_ratio = height ? width / (float) height : 1.f; -} - - -//======================================================================== -// Key callback functions -//======================================================================== - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action == GLFW_PRESS) - { - switch (key) - { - case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GL_TRUE); - break; - case GLFW_KEY_W: - wireframe = !wireframe; - glPolygonMode(GL_FRONT_AND_BACK, - wireframe ? GL_LINE : GL_FILL); - break; - default: - break; - } - } -} - - -//======================================================================== -// Thread for updating particle physics -//======================================================================== - -static int physics_thread_main(void* arg) -{ - GLFWwindow* window = arg; - - for (;;) - { - mtx_lock(&thread_sync.particles_lock); - - // Wait for particle drawing to be done - while (!glfwWindowShouldClose(window) && - thread_sync.p_frame > thread_sync.d_frame) - { - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_nsec += 100000000; - cnd_timedwait(&thread_sync.d_done, &thread_sync.particles_lock, &ts); - } - - if (glfwWindowShouldClose(window)) - break; - - // Update particles - particle_engine(thread_sync.t, thread_sync.dt); - - // Update frame counter - thread_sync.p_frame++; - - // Unlock mutex and signal drawing thread - mtx_unlock(&thread_sync.particles_lock); - cnd_signal(&thread_sync.p_done); - } - - return 0; -} - - -//======================================================================== -// main -//======================================================================== - -int main(int argc, char** argv) -{ - int ch, width, height; - thrd_t physics_thread = 0; - GLFWwindow* window; - GLFWmonitor* monitor = NULL; - - if (!glfwInit()) - { - fprintf(stderr, "Failed to initialize GLFW\n"); - exit(EXIT_FAILURE); - } - - while ((ch = getopt(argc, argv, "fh")) != -1) - { - switch (ch) - { - case 'f': - monitor = glfwGetPrimaryMonitor(); - break; - case 'h': - usage(); - exit(EXIT_SUCCESS); - } - } - - if (monitor) - { - const GLFWvidmode* mode = glfwGetVideoMode(monitor); - - glfwWindowHint(GLFW_RED_BITS, mode->redBits); - glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); - glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); - glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); - - width = mode->width; - height = mode->height; - } - else - { - width = 640; - height = 480; - } - - window = glfwCreateWindow(width, height, "Particle Engine", monitor, NULL); - if (!window) - { - fprintf(stderr, "Failed to create GLFW window\n"); - glfwTerminate(); - exit(EXIT_FAILURE); - } - - if (monitor) - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwSetWindowSizeCallback(window, resize_callback); - glfwSetKeyCallback(window, key_callback); - - // Set initial aspect ratio - glfwGetWindowSize(window, &width, &height); - resize_callback(window, width, height); - - // Upload particle texture - glGenTextures(1, &particle_tex_id); - glBindTexture(GL_TEXTURE_2D, particle_tex_id); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, P_TEX_WIDTH, P_TEX_HEIGHT, - 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, particle_texture); - - // Upload floor texture - glGenTextures(1, &floor_tex_id); - glBindTexture(GL_TEXTURE_2D, floor_tex_id); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, F_TEX_WIDTH, F_TEX_HEIGHT, - 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, floor_texture); - - if (glfwExtensionSupported("GL_EXT_separate_specular_color")) - { - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, - GL_SEPARATE_SPECULAR_COLOR_EXT); - } - - // Set filled polygon mode as default (not wireframe) - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - wireframe = 0; - - // Set initial times - thread_sync.t = 0.0; - thread_sync.dt = 0.001f; - thread_sync.p_frame = 0; - thread_sync.d_frame = 0; - - mtx_init(&thread_sync.particles_lock, mtx_timed); - cnd_init(&thread_sync.p_done); - cnd_init(&thread_sync.d_done); - - if (thrd_create(&physics_thread, physics_thread_main, window) != thrd_success) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetTime(0.0); - - while (!glfwWindowShouldClose(window)) - { - draw_scene(window, glfwGetTime()); - - glfwSwapBuffers(window); - glfwPollEvents(); - } - - thrd_join(physics_thread, NULL); - - glfwDestroyWindow(window); - glfwTerminate(); - - exit(EXIT_SUCCESS); -} - diff --git a/glfw/examples/simple.c b/glfw/examples/simple.c deleted file mode 100644 index 89eaa02..0000000 --- a/glfw/examples/simple.c +++ /dev/null @@ -1,101 +0,0 @@ -//======================================================================== -// Simple GLFW example -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -//! [code] - -#include <GLFW/glfw3.h> - -#include <stdlib.h> -#include <stdio.h> - -static void error_callback(int error, const char* description) -{ - fputs(description, stderr); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) - glfwSetWindowShouldClose(window, GL_TRUE); -} - -int main(void) -{ - GLFWwindow* window; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - - glfwSetKeyCallback(window, key_callback); - - while (!glfwWindowShouldClose(window)) - { - float ratio; - int width, height; - - glfwGetFramebufferSize(window, &width, &height); - ratio = width / (float) height; - - glViewport(0, 0, width, height); - glClear(GL_COLOR_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f); - glMatrixMode(GL_MODELVIEW); - - glLoadIdentity(); - glRotatef((float) glfwGetTime() * 50.f, 0.f, 0.f, 1.f); - - glBegin(GL_TRIANGLES); - glColor3f(1.f, 0.f, 0.f); - glVertex3f(-0.6f, -0.4f, 0.f); - glColor3f(0.f, 1.f, 0.f); - glVertex3f(0.6f, -0.4f, 0.f); - glColor3f(0.f, 0.f, 1.f); - glVertex3f(0.f, 0.6f, 0.f); - glEnd(); - - glfwSwapBuffers(window); - glfwPollEvents(); - } - - glfwDestroyWindow(window); - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - -//! [code] diff --git a/glfw/examples/splitview.c b/glfw/examples/splitview.c deleted file mode 100644 index 30b093b..0000000 --- a/glfw/examples/splitview.c +++ /dev/null @@ -1,511 +0,0 @@ -//======================================================================== -// This is an example program for the GLFW library -// -// The program uses a "split window" view, rendering four views of the -// same scene in one window (e.g. uesful for 3D modelling software). This -// demo uses scissors to separete the four different rendering areas from -// each other. -// -// (If the code seems a little bit strange here and there, it may be -// because I am not a friend of orthogonal projections) -//======================================================================== - -#define GLFW_INCLUDE_GLU -#include <GLFW/glfw3.h> - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - - -//======================================================================== -// Global variables -//======================================================================== - -// Mouse position -static double xpos = 0, ypos = 0; - -// Window size -static int width, height; - -// Active view: 0 = none, 1 = upper left, 2 = upper right, 3 = lower left, -// 4 = lower right -static int active_view = 0; - -// Rotation around each axis -static int rot_x = 0, rot_y = 0, rot_z = 0; - -// Do redraw? -static int do_redraw = 1; - - -//======================================================================== -// Draw a solid torus (use a display list for the model) -//======================================================================== - -#define TORUS_MAJOR 1.5 -#define TORUS_MINOR 0.5 -#define TORUS_MAJOR_RES 32 -#define TORUS_MINOR_RES 32 - -static void drawTorus(void) -{ - static GLuint torus_list = 0; - int i, j, k; - double s, t, x, y, z, nx, ny, nz, scale, twopi; - - if (!torus_list) - { - // Start recording displaylist - torus_list = glGenLists(1); - glNewList(torus_list, GL_COMPILE_AND_EXECUTE); - - // Draw torus - twopi = 2.0 * M_PI; - for (i = 0; i < TORUS_MINOR_RES; i++) - { - glBegin(GL_QUAD_STRIP); - for (j = 0; j <= TORUS_MAJOR_RES; j++) - { - for (k = 1; k >= 0; k--) - { - s = (i + k) % TORUS_MINOR_RES + 0.5; - t = j % TORUS_MAJOR_RES; - - // Calculate point on surface - x = (TORUS_MAJOR + TORUS_MINOR * cos(s * twopi / TORUS_MINOR_RES)) * cos(t * twopi / TORUS_MAJOR_RES); - y = TORUS_MINOR * sin(s * twopi / TORUS_MINOR_RES); - z = (TORUS_MAJOR + TORUS_MINOR * cos(s * twopi / TORUS_MINOR_RES)) * sin(t * twopi / TORUS_MAJOR_RES); - - // Calculate surface normal - nx = x - TORUS_MAJOR * cos(t * twopi / TORUS_MAJOR_RES); - ny = y; - nz = z - TORUS_MAJOR * sin(t * twopi / TORUS_MAJOR_RES); - scale = 1.0 / sqrt(nx*nx + ny*ny + nz*nz); - nx *= scale; - ny *= scale; - nz *= scale; - - glNormal3f((float) nx, (float) ny, (float) nz); - glVertex3f((float) x, (float) y, (float) z); - } - } - - glEnd(); - } - - // Stop recording displaylist - glEndList(); - } - else - { - // Playback displaylist - glCallList(torus_list); - } -} - - -//======================================================================== -// Draw the scene (a rotating torus) -//======================================================================== - -static void drawScene(void) -{ - const GLfloat model_diffuse[4] = {1.0f, 0.8f, 0.8f, 1.0f}; - const GLfloat model_specular[4] = {0.6f, 0.6f, 0.6f, 1.0f}; - const GLfloat model_shininess = 20.0f; - - glPushMatrix(); - - // Rotate the object - glRotatef((GLfloat) rot_x * 0.5f, 1.0f, 0.0f, 0.0f); - glRotatef((GLfloat) rot_y * 0.5f, 0.0f, 1.0f, 0.0f); - glRotatef((GLfloat) rot_z * 0.5f, 0.0f, 0.0f, 1.0f); - - // Set model color (used for orthogonal views, lighting disabled) - glColor4fv(model_diffuse); - - // Set model material (used for perspective view, lighting enabled) - glMaterialfv(GL_FRONT, GL_DIFFUSE, model_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, model_specular); - glMaterialf(GL_FRONT, GL_SHININESS, model_shininess); - - // Draw torus - drawTorus(); - - glPopMatrix(); -} - - -//======================================================================== -// Draw a 2D grid (used for orthogonal views) -//======================================================================== - -static void drawGrid(float scale, int steps) -{ - int i; - float x, y; - - glPushMatrix(); - - // Set background to some dark bluish grey - glClearColor(0.05f, 0.05f, 0.2f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT); - - // Setup modelview matrix (flat XY view) - glLoadIdentity(); - gluLookAt(0.0, 0.0, 1.0, - 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0); - - // We don't want to update the Z-buffer - glDepthMask(GL_FALSE); - - // Set grid color - glColor3f(0.0f, 0.5f, 0.5f); - - glBegin(GL_LINES); - - // Horizontal lines - x = scale * 0.5f * (float) (steps - 1); - y = -scale * 0.5f * (float) (steps - 1); - for (i = 0; i < steps; i++) - { - glVertex3f(-x, y, 0.0f); - glVertex3f(x, y, 0.0f); - y += scale; - } - - // Vertical lines - x = -scale * 0.5f * (float) (steps - 1); - y = scale * 0.5f * (float) (steps - 1); - for (i = 0; i < steps; i++) - { - glVertex3f(x, -y, 0.0f); - glVertex3f(x, y, 0.0f); - x += scale; - } - - glEnd(); - - // Enable Z-buffer writing again - glDepthMask(GL_TRUE); - - glPopMatrix(); -} - - -//======================================================================== -// Draw all views -//======================================================================== - -static void drawAllViews(void) -{ - const GLfloat light_position[4] = {0.0f, 8.0f, 8.0f, 1.0f}; - const GLfloat light_diffuse[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - const GLfloat light_specular[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - const GLfloat light_ambient[4] = {0.2f, 0.2f, 0.3f, 1.0f}; - double aspect; - - // Calculate aspect of window - if (height > 0) - aspect = (double) width / (double) height; - else - aspect = 1.0; - - // Clear screen - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - // Enable scissor test - glEnable(GL_SCISSOR_TEST); - - // Enable depth test - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - - // ** ORTHOGONAL VIEWS ** - - // For orthogonal views, use wireframe rendering - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - - // Enable line anti-aliasing - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // Setup orthogonal projection matrix - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-3.0 * aspect, 3.0 * aspect, -3.0, 3.0, 1.0, 50.0); - - // Upper left view (TOP VIEW) - glViewport(0, height / 2, width / 2, height / 2); - glScissor(0, height / 2, width / 2, height / 2); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - gluLookAt(0.0f, 10.0f, 1e-3f, // Eye-position (above) - 0.0f, 0.0f, 0.0f, // View-point - 0.0f, 1.0f, 0.0f); // Up-vector - drawGrid(0.5, 12); - drawScene(); - - // Lower left view (FRONT VIEW) - glViewport(0, 0, width / 2, height / 2); - glScissor(0, 0, width / 2, height / 2); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - gluLookAt(0.0f, 0.0f, 10.0f, // Eye-position (in front of) - 0.0f, 0.0f, 0.0f, // View-point - 0.0f, 1.0f, 0.0f); // Up-vector - drawGrid(0.5, 12); - drawScene(); - - // Lower right view (SIDE VIEW) - glViewport(width / 2, 0, width / 2, height / 2); - glScissor(width / 2, 0, width / 2, height / 2); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - gluLookAt(10.0f, 0.0f, 0.0f, // Eye-position (to the right) - 0.0f, 0.0f, 0.0f, // View-point - 0.0f, 1.0f, 0.0f); // Up-vector - drawGrid(0.5, 12); - drawScene(); - - // Disable line anti-aliasing - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); - - // ** PERSPECTIVE VIEW ** - - // For perspective view, use solid rendering - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - - // Enable face culling (faster rendering) - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - glFrontFace(GL_CW); - - // Setup perspective projection matrix - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(65.0f, aspect, 1.0f, 50.0f); - - // Upper right view (PERSPECTIVE VIEW) - glViewport(width / 2, height / 2, width / 2, height / 2); - glScissor(width / 2, height / 2, width / 2, height / 2); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - gluLookAt(3.0f, 1.5f, 3.0f, // Eye-position - 0.0f, 0.0f, 0.0f, // View-point - 0.0f, 1.0f, 0.0f); // Up-vector - - // Configure and enable light source 1 - glLightfv(GL_LIGHT1, GL_POSITION, light_position); - glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); - glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); - glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); - glEnable(GL_LIGHT1); - glEnable(GL_LIGHTING); - - // Draw scene - drawScene(); - - // Disable lighting - glDisable(GL_LIGHTING); - - // Disable face culling - glDisable(GL_CULL_FACE); - - // Disable depth test - glDisable(GL_DEPTH_TEST); - - // Disable scissor test - glDisable(GL_SCISSOR_TEST); - - // Draw a border around the active view - if (active_view > 0 && active_view != 2) - { - glViewport(0, 0, width, height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef((GLfloat) ((active_view - 1) & 1), (GLfloat) (1 - (active_view - 1) / 2), 0.0f); - - glColor3f(1.0f, 1.0f, 0.6f); - - glBegin(GL_LINE_STRIP); - glVertex2i(0, 0); - glVertex2i(1, 0); - glVertex2i(1, 1); - glVertex2i(0, 1); - glVertex2i(0, 0); - glEnd(); - } -} - - -//======================================================================== -// Framebuffer size callback function -//======================================================================== - -static void framebufferSizeFun(GLFWwindow* window, int w, int h) -{ - width = w; - height = h > 0 ? h : 1; - do_redraw = 1; -} - - -//======================================================================== -// Window refresh callback function -//======================================================================== - -static void windowRefreshFun(GLFWwindow* window) -{ - do_redraw = 1; -} - - -//======================================================================== -// Mouse position callback function -//======================================================================== - -static void cursorPosFun(GLFWwindow* window, double x, double y) -{ - // Depending on which view was selected, rotate around different axes - switch (active_view) - { - case 1: - rot_x += (int) (y - ypos); - rot_z += (int) (x - xpos); - do_redraw = 1; - break; - case 3: - rot_x += (int) (y - ypos); - rot_y += (int) (x - xpos); - do_redraw = 1; - break; - case 4: - rot_y += (int) (x - xpos); - rot_z += (int) (y - ypos); - do_redraw = 1; - break; - default: - // Do nothing for perspective view, or if no view is selected - break; - } - - // Remember cursor position - xpos = x; - ypos = y; -} - - -//======================================================================== -// Mouse button callback function -//======================================================================== - -static void mouseButtonFun(GLFWwindow* window, int button, int action, int mods) -{ - if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS) - { - // Detect which of the four views was clicked - active_view = 1; - if (xpos >= width / 2) - active_view += 1; - if (ypos >= height / 2) - active_view += 2; - } - else if (button == GLFW_MOUSE_BUTTON_LEFT) - { - // Deselect any previously selected view - active_view = 0; - } - - do_redraw = 1; -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) - glfwSetWindowShouldClose(window, GL_TRUE); -} - - -//======================================================================== -// main -//======================================================================== - -int main(void) -{ - GLFWwindow* window; - - // Initialise GLFW - if (!glfwInit()) - { - fprintf(stderr, "Failed to initialize GLFW\n"); - exit(EXIT_FAILURE); - } - - // Open OpenGL window - window = glfwCreateWindow(500, 500, "Split view demo", NULL, NULL); - if (!window) - { - fprintf(stderr, "Failed to open GLFW window\n"); - - glfwTerminate(); - exit(EXIT_FAILURE); - } - - // Set callback functions - glfwSetFramebufferSizeCallback(window, framebufferSizeFun); - glfwSetWindowRefreshCallback(window, windowRefreshFun); - glfwSetCursorPosCallback(window, cursorPosFun); - glfwSetMouseButtonCallback(window, mouseButtonFun); - glfwSetKeyCallback(window, key_callback); - - // Enable vsync - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwGetFramebufferSize(window, &width, &height); - framebufferSizeFun(window, width, height); - - // Main loop - for (;;) - { - // Only redraw if we need to - if (do_redraw) - { - // Draw all views - drawAllViews(); - - // Swap buffers - glfwSwapBuffers(window); - - do_redraw = 0; - } - - // Wait for new events - glfwWaitEvents(); - - // Check if the window should be closed - if (glfwWindowShouldClose(window)) - break; - } - - // Close OpenGL window and terminate GLFW - glfwTerminate(); - - exit(EXIT_SUCCESS); -} - diff --git a/glfw/examples/wave.c b/glfw/examples/wave.c deleted file mode 100644 index 6890e85..0000000 --- a/glfw/examples/wave.c +++ /dev/null @@ -1,457 +0,0 @@ -/***************************************************************************** - * Wave Simulation in OpenGL - * (C) 2002 Jakob Thomsen - * http://home.in.tum.de/~thomsen - * Modified for GLFW by Sylvain Hellegouarch - sh@programmationworld.com - * Modified for variable frame rate by Marcus Geelnard - * 2003-Jan-31: Minor cleanups and speedups / MG - * 2010-10-24: Formatting and cleanup - Camilla Berglund - *****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#define GLFW_INCLUDE_GLU -#include <GLFW/glfw3.h> - -#ifndef M_PI - #define M_PI 3.1415926535897932384626433832795 -#endif - -// Maximum delta T to allow for differential calculations -#define MAX_DELTA_T 0.01 - -// Animation speed (10.0 looks good) -#define ANIMATION_SPEED 10.0 - -GLfloat alpha = 210.f, beta = -70.f; -GLfloat zoom = 2.f; - -GLboolean locked = GL_FALSE; - -int cursorX; -int cursorY; - -struct Vertex -{ - GLfloat x, y, z; - GLfloat r, g, b; -}; - -#define GRIDW 50 -#define GRIDH 50 -#define VERTEXNUM (GRIDW*GRIDH) - -#define QUADW (GRIDW - 1) -#define QUADH (GRIDH - 1) -#define QUADNUM (QUADW*QUADH) - -GLuint quad[4 * QUADNUM]; -struct Vertex vertex[VERTEXNUM]; - -/* The grid will look like this: - * - * 3 4 5 - * *---*---* - * | | | - * | 0 | 1 | - * | | | - * *---*---* - * 0 1 2 - */ - -//======================================================================== -// Initialize grid geometry -//======================================================================== - -void init_vertices(void) -{ - int x, y, p; - - // Place the vertices in a grid - for (y = 0; y < GRIDH; y++) - { - for (x = 0; x < GRIDW; x++) - { - p = y * GRIDW + x; - - vertex[p].x = (GLfloat) (x - GRIDW / 2) / (GLfloat) (GRIDW / 2); - vertex[p].y = (GLfloat) (y - GRIDH / 2) / (GLfloat) (GRIDH / 2); - vertex[p].z = 0; - - if ((x % 4 < 2) ^ (y % 4 < 2)) - vertex[p].r = 0.0; - else - vertex[p].r = 1.0; - - vertex[p].g = (GLfloat) y / (GLfloat) GRIDH; - vertex[p].b = 1.f - ((GLfloat) x / (GLfloat) GRIDW + (GLfloat) y / (GLfloat) GRIDH) / 2.f; - } - } - - for (y = 0; y < QUADH; y++) - { - for (x = 0; x < QUADW; x++) - { - p = 4 * (y * QUADW + x); - - quad[p + 0] = y * GRIDW + x; // Some point - quad[p + 1] = y * GRIDW + x + 1; // Neighbor at the right side - quad[p + 2] = (y + 1) * GRIDW + x + 1; // Upper right neighbor - quad[p + 3] = (y + 1) * GRIDW + x; // Upper neighbor - } - } -} - -double dt; -double p[GRIDW][GRIDH]; -double vx[GRIDW][GRIDH], vy[GRIDW][GRIDH]; -double ax[GRIDW][GRIDH], ay[GRIDW][GRIDH]; - -//======================================================================== -// Initialize grid -//======================================================================== - -void init_grid(void) -{ - int x, y; - double dx, dy, d; - - for (y = 0; y < GRIDH; y++) - { - for (x = 0; x < GRIDW; x++) - { - dx = (double) (x - GRIDW / 2); - dy = (double) (y - GRIDH / 2); - d = sqrt(dx * dx + dy * dy); - if (d < 0.1 * (double) (GRIDW / 2)) - { - d = d * 10.0; - p[x][y] = -cos(d * (M_PI / (double)(GRIDW * 4))) * 100.0; - } - else - p[x][y] = 0.0; - - vx[x][y] = 0.0; - vy[x][y] = 0.0; - } - } -} - - -//======================================================================== -// Draw scene -//======================================================================== - -void draw_scene(GLFWwindow* window) -{ - // Clear the color and depth buffers - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - // We don't want to modify the projection matrix - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - // Move back - glTranslatef(0.0, 0.0, -zoom); - // Rotate the view - glRotatef(beta, 1.0, 0.0, 0.0); - glRotatef(alpha, 0.0, 0.0, 1.0); - - glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad); - - glfwSwapBuffers(window); -} - - -//======================================================================== -// Initialize Miscellaneous OpenGL state -//======================================================================== - -void init_opengl(void) -{ - // Use Gouraud (smooth) shading - glShadeModel(GL_SMOOTH); - - // Switch on the z-buffer - glEnable(GL_DEPTH_TEST); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, sizeof(struct Vertex), vertex); - glColorPointer(3, GL_FLOAT, sizeof(struct Vertex), &vertex[0].r); // Pointer to the first color - - glPointSize(2.0); - - // Background color is black - glClearColor(0, 0, 0, 0); -} - - -//======================================================================== -// Modify the height of each vertex according to the pressure -//======================================================================== - -void adjust_grid(void) -{ - int pos; - int x, y; - - for (y = 0; y < GRIDH; y++) - { - for (x = 0; x < GRIDW; x++) - { - pos = y * GRIDW + x; - vertex[pos].z = (float) (p[x][y] * (1.0 / 50.0)); - } - } -} - - -//======================================================================== -// Calculate wave propagation -//======================================================================== - -void calc_grid(void) -{ - int x, y, x2, y2; - double time_step = dt * ANIMATION_SPEED; - - // Compute accelerations - for (x = 0; x < GRIDW; x++) - { - x2 = (x + 1) % GRIDW; - for(y = 0; y < GRIDH; y++) - ax[x][y] = p[x][y] - p[x2][y]; - } - - for (y = 0; y < GRIDH; y++) - { - y2 = (y + 1) % GRIDH; - for(x = 0; x < GRIDW; x++) - ay[x][y] = p[x][y] - p[x][y2]; - } - - // Compute speeds - for (x = 0; x < GRIDW; x++) - { - for (y = 0; y < GRIDH; y++) - { - vx[x][y] = vx[x][y] + ax[x][y] * time_step; - vy[x][y] = vy[x][y] + ay[x][y] * time_step; - } - } - - // Compute pressure - for (x = 1; x < GRIDW; x++) - { - x2 = x - 1; - for (y = 1; y < GRIDH; y++) - { - y2 = y - 1; - p[x][y] = p[x][y] + (vx[x2][y] - vx[x][y] + vy[x][y2] - vy[x][y]) * time_step; - } - } -} - - -//======================================================================== -// Print errors -//======================================================================== - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - - -//======================================================================== -// Handle key strokes -//======================================================================== - -void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GL_TRUE); - break; - case GLFW_KEY_SPACE: - init_grid(); - break; - case GLFW_KEY_LEFT: - alpha += 5; - break; - case GLFW_KEY_RIGHT: - alpha -= 5; - break; - case GLFW_KEY_UP: - beta -= 5; - break; - case GLFW_KEY_DOWN: - beta += 5; - break; - case GLFW_KEY_PAGE_UP: - zoom -= 0.25f; - if (zoom < 0.f) - zoom = 0.f; - break; - case GLFW_KEY_PAGE_DOWN: - zoom += 0.25f; - break; - default: - break; - } -} - - -//======================================================================== -// Callback function for mouse button events -//======================================================================== - -void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) -{ - if (button != GLFW_MOUSE_BUTTON_LEFT) - return; - - if (action == GLFW_PRESS) - { - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); - locked = GL_TRUE; - } - else - { - locked = GL_FALSE; - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); - } -} - - -//======================================================================== -// Callback function for cursor motion events -//======================================================================== - -void cursor_position_callback(GLFWwindow* window, double x, double y) -{ - if (locked) - { - alpha += (GLfloat) (x - cursorX) / 10.f; - beta += (GLfloat) (y - cursorY) / 10.f; - } - - cursorX = (int) x; - cursorY = (int) y; -} - - -//======================================================================== -// Callback function for scroll events -//======================================================================== - -void scroll_callback(GLFWwindow* window, double x, double y) -{ - zoom += (float) y / 4.f; - if (zoom < 0) - zoom = 0; -} - - -//======================================================================== -// Callback function for framebuffer resize events -//======================================================================== - -void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - float ratio = 1.f; - - if (height > 0) - ratio = (float) width / (float) height; - - // Setup viewport - glViewport(0, 0, width, height); - - // Change to the projection matrix and set our viewing volume - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, ratio, 1.0, 1024.0); -} - - -//======================================================================== -// main -//======================================================================== - -int main(int argc, char* argv[]) -{ - GLFWwindow* window; - double t, dt_total, t_old; - int width, height; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(640, 480, "Wave Simulation", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetKeyCallback(window, key_callback); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetMouseButtonCallback(window, mouse_button_callback); - glfwSetCursorPosCallback(window, cursor_position_callback); - glfwSetScrollCallback(window, scroll_callback); - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwGetFramebufferSize(window, &width, &height); - framebuffer_size_callback(window, width, height); - - // Initialize OpenGL - init_opengl(); - - // Initialize simulation - init_vertices(); - init_grid(); - adjust_grid(); - - // Initialize timer - t_old = glfwGetTime() - 0.01; - - while (!glfwWindowShouldClose(window)) - { - t = glfwGetTime(); - dt_total = t - t_old; - t_old = t; - - // Safety - iterate if dt_total is too large - while (dt_total > 0.f) - { - // Select iteration time step - dt = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total; - dt_total -= dt; - - // Calculate wave propagation - calc_grid(); - } - - // Compute height of each vertex - adjust_grid(); - - // Draw wave grid to OpenGL display - draw_scene(window); - - glfwPollEvents(); - } - - exit(EXIT_SUCCESS); -} - diff --git a/glfw/include/GLFW/glfw3.h b/glfw/include/GLFW/glfw3.h index 6a20f89..83b2ff0 100644 --- a/glfw/include/GLFW/glfw3.h +++ b/glfw/include/GLFW/glfw3.h @@ -39,20 +39,26 @@ extern "C" { *************************************************************************/ /*! @defgroup context Context handling + * + * This is the reference documentation for context related functions. For more + * information, see the @ref context. */ -/*! @defgroup error Error handling - */ -/*! @defgroup init Initialization and version information +/*! @defgroup init Initialization, version and errors + * + * This is the reference documentation for initialization and termination of + * the library, version management and error handling. For more information, + * see the @ref intro. */ /*! @defgroup input Input handling + * + * This is the reference documentation for input related functions and types. + * For more information, see the @ref input. */ /*! @defgroup monitor Monitor handling * * This is the reference documentation for monitor related functions and types. * For more information, see the @ref monitor. */ -/*! @defgroup time Time input - */ /*! @defgroup window Window handling * * This is the reference documentation for window related functions and types, @@ -140,8 +146,13 @@ extern "C" { #if defined(__APPLE_CC__) #if defined(GLFW_INCLUDE_GLCOREARB) #include <OpenGL/gl3.h> + #if defined(GLFW_INCLUDE_GLEXT) + #include <OpenGL/gl3ext.h> + #endif #elif !defined(GLFW_INCLUDE_NONE) - #define GL_GLEXT_LEGACY + #if !defined(GLFW_INCLUDE_GLEXT) + #define GL_GLEXT_LEGACY + #endif #include <OpenGL/gl.h> #endif #if defined(GLFW_INCLUDE_GLU) @@ -152,14 +163,29 @@ extern "C" { #include <GL/glcorearb.h> #elif defined(GLFW_INCLUDE_ES1) #include <GLES/gl.h> + #if defined(GLFW_INCLUDE_GLEXT) + #include <GLES/glext.h> + #endif #elif defined(GLFW_INCLUDE_ES2) #include <GLES2/gl2.h> + #if defined(GLFW_INCLUDE_GLEXT) + #include <GLES2/gl2ext.h> + #endif #elif defined(GLFW_INCLUDE_ES3) #include <GLES3/gl3.h> + #if defined(GLFW_INCLUDE_GLEXT) + #include <GLES3/gl2ext.h> + #endif #elif defined(GLFW_INCLUDE_ES31) #include <GLES3/gl31.h> + #if defined(GLFW_INCLUDE_GLEXT) + #include <GLES3/gl2ext.h> + #endif #elif !defined(GLFW_INCLUDE_NONE) #include <GL/gl.h> + #if defined(GLFW_INCLUDE_GLEXT) + #include <GL/glext.h> + #endif #endif #if defined(GLFW_INCLUDE_GLU) #include <GL/glu.h> @@ -176,12 +202,12 @@ extern "C" { #if defined(_WIN32) && defined(_GLFW_BUILD_DLL) - /* We are building a Win32 DLL */ + /* We are building GLFW as a Win32 DLL */ #define GLFWAPI __declspec(dllexport) #elif defined(_WIN32) && defined(GLFW_DLL) - /* We are calling a Win32 DLL */ + /* We are calling GLFW as a Win32 DLL */ #if defined(__LCC__) #define GLFWAPI extern #else @@ -190,11 +216,12 @@ extern "C" { #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL) + /* We are building GLFW as a shared / dynamic library */ #define GLFWAPI __attribute__((visibility("default"))) #else - /* We are either building/calling a static lib or we are non-win32 */ + /* We are building or calling GLFW as a static library */ #define GLFWAPI #endif @@ -232,15 +259,24 @@ extern "C" { /*! @name Key and button actions * @{ */ -/*! @brief The key or button was released. +/*! @brief The key or mouse button was released. + * + * The key or mouse button was released. + * * @ingroup input */ #define GLFW_RELEASE 0 -/*! @brief The key or button was pressed. +/*! @brief The key or mouse button was pressed. + * + * The key or mouse button was pressed. + * * @ingroup input */ #define GLFW_PRESS 1 /*! @brief The key was held down until it repeated. + * + * The key was held down until it repeated. + * * @ingroup input */ #define GLFW_REPEAT 2 @@ -248,7 +284,7 @@ extern "C" { /*! @defgroup keys Keyboard keys * - * These key codes are inspired by the *USB HID Usage Tables v1.12* (p. 53-60), + * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60), * but re-arranged to map to 7-bit ASCII for printable keys (function keys are * put in the 256+ range). * @@ -456,36 +492,124 @@ extern "C" { /*! @} */ /*! @defgroup errors Error codes - * @ingroup error + * @ingroup init * @{ */ /*! @brief GLFW has not been initialized. + * + * This occurs if a GLFW function was called that may not be called unless the + * library is [initialized](@ref intro_init). + * + * @par Analysis + * Application programmer error. Initialize GLFW before calling any function + * that requires initialization. */ #define GLFW_NOT_INITIALIZED 0x00010001 /*! @brief No context is current for this thread. + * + * This occurs if a GLFW function was called that needs and operates on the + * current OpenGL or OpenGL ES context but no context is current on the calling + * thread. One such function is @ref glfwSwapInterval. + * + * @par Analysis + * Application programmer error. Ensure a context is current before calling + * functions that require a current context. */ #define GLFW_NO_CURRENT_CONTEXT 0x00010002 -/*! @brief One of the enum parameters for the function was given an invalid - * enum. +/*! @brief One of the arguments to the function was an invalid enum value. + * + * One of the arguments to the function was an invalid enum value, for example + * requesting `GLFW_RED_BITS` with @ref glfwGetWindowAttrib. + * + * @par Analysis + * Application programmer error. Fix the offending call. */ #define GLFW_INVALID_ENUM 0x00010003 -/*! @brief One of the parameters for the function was given an invalid value. +/*! @brief One of the arguments to the function was an invalid value. + * + * One of the arguments to the function was an invalid value, for example + * requesting a non-existent OpenGL or OpenGL ES version like 2.7. + * + * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead + * result in a @ref GLFW_VERSION_UNAVAILABLE error. + * + * @par Analysis + * Application programmer error. Fix the offending call. */ #define GLFW_INVALID_VALUE 0x00010004 /*! @brief A memory allocation failed. + * + * A memory allocation failed. + * + * @par Analysis + * A bug in GLFW or the underlying operating system. Report the bug to our + * [issue tracker](https://github.com/glfw/glfw/issues). */ #define GLFW_OUT_OF_MEMORY 0x00010005 /*! @brief GLFW could not find support for the requested client API on the * system. + * + * GLFW could not find support for the requested client API on the system. + * + * @par Analysis + * The installed graphics driver does not support the requested client API, or + * does not support it via the chosen context creation backend. Below are + * a few examples. + * + * @par + * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only + * supports OpenGL ES via EGL, while nVidia and Intel only supports it via + * a WGL or GLX extension. OS X does not provide OpenGL ES at all. The Mesa + * EGL, OpenGL and OpenGL ES libraries do not interface with the nVidia binary + * driver. */ #define GLFW_API_UNAVAILABLE 0x00010006 -/*! @brief The requested client API version is not available. +/*! @brief The requested OpenGL or OpenGL ES version is not available. + * + * The requested OpenGL or OpenGL ES version (including any requested profile + * or context option) is not available on this machine. + * + * @par Analysis + * The machine does not support your requirements. If your application is + * sufficiently flexible, downgrade your requirements and try again. + * Otherwise, inform the user that their machine does not match your + * requirements. + * + * @par + * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0 + * comes out before the 4.x series gets that far, also fail with this error and + * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions + * will exist. */ #define GLFW_VERSION_UNAVAILABLE 0x00010007 /*! @brief A platform-specific error occurred that does not match any of the * more specific categories. + * + * A platform-specific error occurred that does not match any of the more + * specific categories. + * + * @par Analysis + * A bug in GLFW or the underlying operating system. Report the bug to our + * [issue tracker](https://github.com/glfw/glfw/issues). */ #define GLFW_PLATFORM_ERROR 0x00010008 -/*! @brief The clipboard did not contain data in the requested format. +/*! @brief The requested format is not supported or available. + * + * If emitted during window creation, the requested pixel format is not + * supported. + * + * If emitted when querying the clipboard, the contents of the clipboard could + * not be converted to the requested format. + * + * @par Analysis + * If emitted during window creation, one or more + * [hard constraints](@ref window_hints_hard) did not match any of the + * available pixel formats. If your application is sufficiently flexible, + * downgrade your requirements and try again. Otherwise, inform the user that + * their machine does not match your requirements. + * + * @par + * If emitted when querying the clipboard, ignore the error or report it to + * the user, as appropriate. */ #define GLFW_FORMAT_UNAVAILABLE 0x00010009 /*! @} */ @@ -600,7 +724,7 @@ typedef struct GLFWcursor GLFWcursor; * * @sa glfwSetErrorCallback * - * @ingroup error + * @ingroup init */ typedef void (* GLFWerrorfun)(int,const char*); @@ -768,7 +892,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double); * @param[in] window The window that received the event. * @param[in] key The [keyboard key](@ref keys) that was pressed or released. * @param[in] scancode The system-specific scancode of the key. - * @param[in] action @ref GLFW_PRESS, @ref GLFW_RELEASE or @ref GLFW_REPEAT. + * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were * held down. * @@ -913,54 +1037,66 @@ typedef struct GLFWimage /*! @brief Initializes the GLFW library. * * This function initializes the GLFW library. Before most GLFW functions can - * be used, GLFW must be initialized, and before a program terminates GLFW + * be used, GLFW must be initialized, and before an application terminates GLFW * should be terminated in order to free any resources allocated during or * after initialization. * * If this function fails, it calls @ref glfwTerminate before returning. If it - * succeeds, you should call @ref glfwTerminate before the program exits. + * succeeds, you should call @ref glfwTerminate before the application exits. * * Additional calls to this function after successful initialization but before * termination will return `GL_TRUE` immediately. * - * @return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred. Errors - * are reported to the [error callback](@ref intro_error). - * - * @par New in GLFW 3 - * This function no longer registers @ref glfwTerminate with `atexit`. + * @return `GL_TRUE` if successful, or `GL_FALSE` if an + * [error](@ref error_handling) occurred. * - * @note This function may only be called from the main thread. - * - * @note **OS X:** This function will change the current directory of the + * @remarks __OS X:__ This function will change the current directory of the * application to the `Contents/Resources` subdirectory of the application's - * bundle, if present. + * bundle, if present. This can be disabled with a + * [compile-time option](@ref compile_options_osx). + * + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref intro_init * @sa glfwTerminate * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ This function no longer registers @ref glfwTerminate with `atexit`. + * * @ingroup init */ GLFWAPI int glfwInit(void); /*! @brief Terminates the GLFW library. * - * This function destroys all remaining windows, frees any allocated resources - * and sets the library to an uninitialized state. Once this is called, you - * must again call @ref glfwInit successfully before you will be able to use - * most GLFW functions. + * This function destroys all remaining windows and cursors, restores any + * modified gamma ramps and frees any other allocated resources. Once this + * function is called, you must again call @ref glfwInit successfully before + * you will be able to use most GLFW functions. * * If GLFW has been successfully initialized, this function should be called - * before the program exits. If initialization fails, there is no need to call - * this function, as it is called by @ref glfwInit before it returns failure. + * before the application exits. If initialization fails, there is no need to + * call this function, as it is called by @ref glfwInit before it returns + * failure. * * @remarks This function may be called before @ref glfwInit. * - * @note This function may only be called from the main thread. - * * @warning No window's context may be current on another thread when this * function is called. * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref intro_init * @sa glfwInit * + * @par History + * Added in GLFW 1.0. + * * @ingroup init */ GLFWAPI void glfwTerminate(void); @@ -971,18 +1107,24 @@ GLFWAPI void glfwTerminate(void); * library. It is intended for when you are using GLFW as a shared library and * want to ensure that you are using the minimum required version. * + * Any or all of the version arguments may be `NULL`. This function always + * succeeds. + * * @param[out] major Where to store the major version number, or `NULL`. * @param[out] minor Where to store the minor version number, or `NULL`. * @param[out] rev Where to store the revision number, or `NULL`. * - * @remarks This function always succeeds. - * * @remarks This function may be called before @ref glfwInit. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. * + * @sa @ref intro_version * @sa glfwGetVersionString * + * @par History + * Added in GLFW 1.0. + * * @ingroup init */ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); @@ -994,16 +1136,24 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); * describes the version, platform, compiler and any platform-specific * compile-time options. * - * @return The GLFW version string. + * This function always succeeds. * - * @remarks This function always succeeds. + * @return The GLFW version string. * * @remarks This function may be called before @ref glfwInit. * - * @remarks This function may be called from any thread. + * @par Pointer Lifetime + * The returned string is static and compile-time generated. * + * @par Thread Safety + * This function may be called from any thread. + * + * @sa @ref intro_version * @sa glfwGetVersion * + * @par History + * Added in GLFW 3.0. + * * @ingroup init */ GLFWAPI const char* glfwGetVersionString(void); @@ -1013,26 +1163,29 @@ GLFWAPI const char* glfwGetVersionString(void); * This function sets the error callback, which is called with an error code * and a human-readable description each time a GLFW error occurs. * + * The error callback is called on the thread where the error occurred. If you + * are using GLFW from multiple threads, your error callback needs to be + * written accordingly. + * + * Because the description string may have been generated specifically for that + * error, it is not guaranteed to be valid after the callback has returned. If + * you wish to use it after the callback returns, you need to make a copy. + * * @param[in] cbfun The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set. * - * @remarks This function always succeeds. - * * @remarks This function may be called before @ref glfwInit. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * - * @note The error callback is called by the thread where the error occurred. - * If you are using GLFW from multiple threads, your error callback needs to be - * written accordingly. + * @sa @ref error_handling * - * @note Because the description string provided to the callback may have been - * generated specifically for that error, it is not guaranteed to be valid - * after the callback has returned. If you wish to use it after that, you need - * to make your own copy of it before returning. + * @par History + * Added in GLFW 3.0. * - * @ingroup error + * @ingroup init */ GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun); @@ -1041,22 +1194,26 @@ GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun); * This function returns an array of handles for all currently connected * monitors. * - * @param[out] count Where to store the size of the returned array. This is - * set to zero if an error occurred. - * @return An array of monitor handles, or `NULL` if an error occurred. Errors - * are reported to the [error callback](@ref intro_error). - * - * @note This function may only be called from the main thread. + * @param[out] count Where to store the number of monitors in the returned + * array. This is set to zero if an error occurred. + * @return An array of monitor handles, or `NULL` if an + * [error](@ref error_handling) occurred. * - * @note The returned array is allocated and freed by GLFW. You should not - * free it yourself. + * @par Pointer Lifetime + * The returned array is allocated and freed by GLFW. You should not free it + * yourself. It is guaranteed to be valid only until the monitor configuration + * changes or the library is terminated. * - * @note The returned array is valid only until the monitor configuration - * changes. See @ref glfwSetMonitorCallback to receive notifications of - * configuration changes. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref monitor_monitors + * @sa @ref monitor_event * @sa glfwGetPrimaryMonitor * + * @par History + * Added in GLFW 3.0. + * * @ingroup monitor */ GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); @@ -1066,13 +1223,18 @@ GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); * This function returns the primary monitor. This is usually the monitor * where elements like the Windows task bar or the OS X menu bar is located. * - * @return The primary monitor, or `NULL` if an error occurred. Errors are - * reported to the [error callback](@ref intro_error). + * @return The primary monitor, or `NULL` if an [error](@ref error_handling) + * occurred. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref monitor_monitors * @sa glfwGetMonitors * + * @par History + * Added in GLFW 3.0. + * * @ingroup monitor */ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); @@ -1082,11 +1244,20 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); * This function returns the position, in screen coordinates, of the upper-left * corner of the specified monitor. * + * Any or all of the position arguments may be `NULL`. If an error occurs, all + * non-`NULL` position arguments will be set to zero. + * * @param[in] monitor The monitor to query. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref monitor_properties + * + * @par History + * Added in GLFW 3.0. * * @ingroup monitor */ @@ -1097,17 +1268,26 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); * This function returns the size, in millimetres, of the display area of the * specified monitor. * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * * @param[in] monitor The monitor to query. * @param[out] width Where to store the width, in mm, of the monitor's display * area, or `NULL`. * @param[out] height Where to store the height, in mm, of the monitor's * display area, or `NULL`. * - * @note This function may only be called from the main thread. + * @note Some systems do not provide accurate monitor size information, either + * because the EDID data is incorrect, or because the driver does not report it + * accurately. + * + * @par Thread Safety + * This function may only be called from the main thread. * - * @note Some operating systems do not provide accurate information, either - * because the monitor's EDID data is incorrect, or because the driver does not - * report it accurately. + * @sa @ref monitor_properties + * + * @par History + * Added in GLFW 3.0. * * @ingroup monitor */ @@ -1116,16 +1296,25 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* h /*! @brief Returns the name of the specified monitor. * * This function returns a human-readable name, encoded as UTF-8, of the - * specified monitor. + * specified monitor. The name typically reflects the make and model of the + * monitor and is not guaranteed to be unique among the connected monitors. * * @param[in] monitor The monitor to query. - * @return The UTF-8 encoded name of the monitor, or `NULL` if an error - * occurred. Errors are reported to the [error callback](@ref intro_error). + * @return The UTF-8 encoded name of the monitor, or `NULL` if an + * [error](@ref error_handling) occurred. * - * @note This function may only be called from the main thread. + * @par Pointer Lifetime + * The returned string is allocated and freed by GLFW. You should not free it + * yourself. It is valid until the specified monitor is disconnected or the + * library is terminated. * - * @note The returned string is allocated and freed by GLFW. You should not - * free it yourself. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref monitor_properties + * + * @par History + * Added in GLFW 3.0. * * @ingroup monitor */ @@ -1142,11 +1331,17 @@ GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. - * - * @bug **X11:** This callback is not yet called on monitor configuration + * @bug __X11:__ This callback is not yet called on monitor configuration * changes. * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref monitor_event + * + * @par History + * Added in GLFW 3.0. + * * @ingroup monitor */ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); @@ -1161,19 +1356,27 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); * @param[in] monitor The monitor to query. * @param[out] count Where to store the number of video modes in the returned * array. This is set to zero if an error occurred. - * @return An array of video modes, or `NULL` if an error occurred. Errors are - * reported to the [error callback](@ref intro_error). - * - * @note This function may only be called from the main thread. + * @return An array of video modes, or `NULL` if an + * [error](@ref error_handling) occurred. * - * @note The returned array is allocated and freed by GLFW. You should not - * free it yourself. + * @par Pointer Lifetime + * The returned array is allocated and freed by GLFW. You should not free it + * yourself. It is valid until the specified monitor is disconnected, this + * function is called again for that monitor or the library is terminated. * - * @note The returned array is valid only until this function is called again - * for the specified monitor. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref monitor_modes * @sa glfwGetVideoMode * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Changed to return a dynamic array of video modes for a specific + * monitor. + * * @ingroup monitor */ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); @@ -1181,20 +1384,27 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); /*! @brief Returns the current mode of the specified monitor. * * This function returns the current video mode of the specified monitor. If - * you are using a full screen window, the return value will therefore depend - * on whether it is focused. + * you have created a full screen window for that monitor, the return value + * will depend on whether that window is iconified. * * @param[in] monitor The monitor to query. - * @return The current mode of the monitor, or `NULL` if an error occurred. - * Errors are reported to the [error callback](@ref intro_error). + * @return The current mode of the monitor, or `NULL` if an + * [error](@ref error_handling) occurred. * - * @note This function may only be called from the main thread. + * @par Pointer Lifetime + * The returned array is allocated and freed by GLFW. You should not free it + * yourself. It is valid until the specified monitor is disconnected or the + * library is terminated. * - * @note The returned struct is allocated and freed by GLFW. You should not - * free it yourself. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref monitor_modes * @sa glfwGetVideoModes * + * @par History + * Added in GLFW 3.0. Replaced `glfwGetDesktopMode`. + * * @ingroup monitor */ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); @@ -1207,28 +1417,39 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @param[in] monitor The monitor whose gamma ramp to set. * @param[in] gamma The desired exponent. * - * @remark You cannot generate sRGB gamma using this function, because although - * it is approximately 2.2 it cannot be accurately expressed as a single - * numerical value. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref monitor_gamma * - * @note This function may only be called from the main thread. + * @par History + * Added in GLFW 3.0. * * @ingroup monitor */ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); -/*! @brief Retrieves the current gamma ramp for the specified monitor. +/*! @brief Returns the current gamma ramp for the specified monitor. * - * This function retrieves the current gamma ramp of the specified monitor. + * This function returns the current gamma ramp of the specified monitor. * * @param[in] monitor The monitor to query. - * @return The current gamma ramp, or `NULL` if an error occurred. Errors are - * reported to the [error callback](@ref intro_error). + * @return The current gamma ramp, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @par Pointer Lifetime + * The returned structure and its arrays are allocated and freed by GLFW. You + * should not free them yourself. They are valid until the specified monitor + * is disconnected, this function is called again for that monitor or the + * library is terminated. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * - * @note The value arrays of the returned ramp are allocated and freed by GLFW. - * You should not free them yourself. + * @sa @ref monitor_gamma + * + * @par History + * Added in GLFW 3.0. * * @ingroup monitor */ @@ -1236,15 +1457,26 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); /*! @brief Sets the current gamma ramp for the specified monitor. * - * This function sets the current gamma ramp for the specified monitor. + * This function sets the current gamma ramp for the specified monitor. The + * original gamma ramp for that monitor is saved by GLFW the first time this + * function is called and is restored by @ref glfwTerminate. * * @param[in] monitor The monitor whose gamma ramp to set. * @param[in] ramp The gamma ramp to use. * - * @note This function may only be called from the main thread. - * * @note Gamma ramp sizes other than 256 are not supported by all hardware. * + * @par Pointer Lifetime + * The specified gamma ramp is copied before this function returns. + * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref monitor_gamma + * + * @par History + * Added in GLFW 3.0. + * * @ingroup monitor */ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); @@ -1254,10 +1486,15 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); * This function resets all window hints to their * [default values](@ref window_hints_values). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_hints * @sa glfwWindowHint * + * @par History + * Added in GLFW 3.0. + * * @ingroup window */ GLFWAPI void glfwDefaultWindowHints(void); @@ -1267,54 +1504,74 @@ GLFWAPI void glfwDefaultWindowHints(void); * This function sets hints for the next call to @ref glfwCreateWindow. The * hints, once set, retain their values until changed by a call to @ref * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is - * terminated with @ref glfwTerminate. + * terminated. * * @param[in] target The [window hint](@ref window_hints) to set. * @param[in] hint The new value of the window hint. * - * @par New in GLFW 3 - * Hints are no longer reset to their default values on window creation. To - * set default hint values, use @ref glfwDefaultWindowHints. - * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_hints * @sa glfwDefaultWindowHints * + * @par History + * Added in GLFW 2.2. + * + * @par + * __GLFW 3:__ Renamed from `glfwOpenWindowHint`. Hints are no longer reset to + * default values on window creation. + * * @ingroup window */ GLFWAPI void glfwWindowHint(int target, int hint); /*! @brief Creates a window and its associated context. * - * This function creates a window and its associated context. Most of the - * options controlling how the window and its context should be created are - * specified through @ref glfwWindowHint. + * This function creates a window and its associated OpenGL or OpenGL ES + * context. Most of the options controlling how the window and its context + * should be created are specified with [window hints](@ref window_hints). * * Successful creation does not change which context is current. Before you - * can use the newly created context, you need to make it current using @ref - * glfwMakeContextCurrent. + * can use the newly created context, you need to + * [make it current](@ref context_current). For information about the `share` + * parameter, see @ref context_sharing. * * The created window, framebuffer and context may differ from what you * requested, as not all parameters and hints are * [hard constraints](@ref window_hints_hard). This includes the size of the - * window, especially for full screen windows. To retrieve the actual - * attributes of the created window, framebuffer and context, use queries like - * @ref glfwGetWindowAttrib and @ref glfwGetWindowSize. + * window, especially for full screen windows. To query the actual attributes + * of the created window, framebuffer and context, use queries like @ref + * glfwGetWindowAttrib and @ref glfwGetWindowSize. * * To create a full screen window, you need to specify the monitor the window * will cover. If no monitor is specified, windowed mode will be used. Unless * you have a way for the user to choose a specific monitor, it is recommended - * that you pick the primary monitor. For more information on how to retrieve - * monitors, see @ref monitor_monitors. + * that you pick the primary monitor. For more information on how to query + * connected monitors, see @ref monitor_monitors. + * + * For full screen windows, the specified size becomes the resolution of the + * window's _desired video mode_. As long as a full screen window has input + * focus, the supported video mode most closely matching the desired video mode + * is set for the specified monitor. For more information about full screen + * windows, including the creation of so called _windowed full screen_ or + * _borderless full screen_ windows, see @ref window_full_screen. * * By default, newly created windows use the placement recommended by the * window system. To create the window at a specific position, make it - * initially invisible using the `GLFW_VISIBLE` window hint, set its position - * and then show it. + * initially invisible using the `GLFW_VISIBLE` window hint, set its + * [position](@ref window_pos) and then [show](@ref window_hide) it. * - * If a full screen window is active, the screensaver is prohibited from + * If a full screen window is focused, the screensaver is prohibited from * starting. * + * Window systems put limits on window sizes. Very large or very small window + * dimensions may be overridden by the window system on creation. Check the + * actual [size](@ref window_size) after creation. + * + * The [swap interval](@ref window_swap) is not set during window creation and + * the initial value may vary depending on driver settings and defaults. + * * @param[in] width The desired width, in screen coordinates, of the window. * This must be greater than zero. * @param[in] height The desired height, in screen coordinates, of the window. @@ -1324,38 +1581,47 @@ GLFWAPI void glfwWindowHint(int target, int hint); * windowed mode. * @param[in] share The window whose context to share resources with, or `NULL` * to not share resources. - * @return The handle of the created window, or `NULL` if an error occurred. - * Errors are reported to the [error callback](@ref intro_error). + * @return The handle of the created window, or `NULL` if an + * [error](@ref error_handling) occurred. * - * @remarks The [swap interval](@ref window_swap) is not set during window - * creation and the initial value may vary depending on driver settings and - * defaults. - * - * @remarks **Windows:** Window creation will fail if the Microsoft GDI + * @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 * present, the `IDI_WINLOGO` icon will be used instead. * - * @remarks **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. - * 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 - * information from the application's bundle. For more information on bundles, - * see the + * For more information on bundles, see the * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * in the Mac Developer Library. * - * @remarks **X11:** There is no mechanism for setting the window icon yet. + * @remarks __OS X:__ The first time a window is created the menu bar is + * populated with common commands like Hide, Quit and About. The About entry + * opens a minimal about dialog with information from the application's bundle. + * The menu bar can be disabled with a + * [compile-time option](@ref compile_options_osx). + * + * @remarks __X11:__ There is no mechanism for setting the window icon yet. * - * @remarks **X11:** Some window managers will not respect the placement of + * @remarks __X11:__ Some window managers will not respect the placement of * initially hidden windows. * - * @note This function may only be called from the main thread. + * @note This function may not be called from a callback. + * + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_creation * @sa glfwDestroyWindow * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Renamed from `glfwOpenWindow`. Complete signature overhaul. + * * @ingroup window */ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share); @@ -1365,19 +1631,28 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, G * This function destroys the specified window and its context. On calling * this function, no further callbacks will be called for that window. * - * @param[in] window The window to destroy. + * If the context of the specified window is current on the main thread, it is + * detached before being destroyed. * - * @note This function may only be called from the main thread. + * @param[in] window The window to destroy. * * @note This function may not be called from a callback. * - * @note If the window's context is current on the main thread, it is - * detached before being destroyed. + * @note The context of the specified window must not be current on any other + * thread when this function is called. * - * @warning The window's context must not be current on any other thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_creation * @sa glfwCreateWindow * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Renamed from `glfwCloseWindow`. Added window handle parameter. + * * @ingroup window */ GLFWAPI void glfwDestroyWindow(GLFWwindow* window); @@ -1389,7 +1664,13 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* window); * @param[in] window The window to query. * @return The value of the close flag. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @sa @ref window_close + * + * @par History + * Added in GLFW 3.0. * * @ingroup window */ @@ -1404,7 +1685,13 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); * @param[in] window The window whose flag to change. * @param[in] value The new value. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @sa @ref window_close + * + * @par History + * Added in GLFW 3.0. * * @ingroup window */ @@ -1418,7 +1705,16 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); * @param[in] window The window whose title to change. * @param[in] title The UTF-8 encoded window title. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_title + * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -1429,16 +1725,24 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); * This function retrieves the position, in screen coordinates, of the * upper-left corner of the client area of the specified window. * + * Any or all of the position arguments may be `NULL`. If an error occurs, all + * non-`NULL` position arguments will be set to zero. + * * @param[in] window The window to query. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of * the client area, or `NULL`. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of * the client area, or `NULL`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_pos * @sa glfwSetWindowPos * + * @par History + * Added in GLFW 3.0. + * * @ingroup window */ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); @@ -1446,13 +1750,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); /*! @brief Sets the position of the client area of the specified window. * * This function sets the position, in screen coordinates, of the upper-left - * corner of the client area of the window. - * - * If the specified window is a full screen window, this function does nothing. - * - * If you wish to set an initial window position you should create a hidden - * window (using @ref glfwWindowHint and `GLFW_VISIBLE`), set its position and - * then show it. + * corner of the client area of the specified windowed mode window. If the + * window is a full screen window, this function does nothing. * * @param[in] window The window to query. * @param[in] xpos The x-coordinate of the upper-left corner of the client area. @@ -1461,12 +1760,20 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @note It is very rarely a good idea to move an already visible window, as it * will confuse and annoy the user. * - * @note This function may only be called from the main thread. - * * @note The window manager may put limits on what positions are allowed. * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_pos * @sa glfwGetWindowPos * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. + * * @ingroup window */ GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); @@ -1477,16 +1784,27 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); * of the specified window. If you wish to retrieve the size of the * framebuffer in pixels, see @ref glfwGetFramebufferSize. * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * * @param[in] window The window whose size to retrieve. * @param[out] width Where to store the width, in screen coordinates, of the * client area, or `NULL`. * @param[out] height Where to store the height, in screen coordinates, of the * client area, or `NULL`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_size * @sa glfwSetWindowSize * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. + * * @ingroup window */ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); @@ -1505,12 +1823,20 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); * @param[in] width The desired width of the specified window. * @param[in] height The desired height of the specified window. * - * @note This function may only be called from the main thread. - * * @note The window manager may put limits on what window sizes are allowed. * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_size * @sa glfwGetWindowSize * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. + * * @ingroup window */ GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); @@ -1521,16 +1847,24 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); * specified window. If you wish to retrieve the size of the window in screen * coordinates, see @ref glfwGetWindowSize. * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * * @param[in] window The window whose framebuffer to query. * @param[out] width Where to store the width, in pixels, of the framebuffer, * or `NULL`. * @param[out] height Where to store the height, in pixels, of the framebuffer, * or `NULL`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_fbsize * @sa glfwSetFramebufferSizeCallback * + * @par History + * Added in GLFW 3.0. + * * @ingroup window */ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); @@ -1542,21 +1876,30 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height) * window has one. The size of the frame may vary depending on the * [window-related hints](@ref window_hints_wnd) used to create it. * + * Because this function retrieves the size of each window frame edge and not + * the offset along a particular coordinate axis, the retrieved values will + * always be zero or positive. + * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * * @param[in] window The window whose frame size to query. * @param[out] left Where to store the size, in screen coordinates, of the left - * edge of the window frame. + * edge of the window frame, or `NULL`. * @param[out] top Where to store the size, in screen coordinates, of the top - * edge of the window frame. + * edge of the window frame, or `NULL`. * @param[out] right Where to store the size, in screen coordinates, of the - * right edge of the window frame. + * right edge of the window frame, or `NULL`. * @param[out] bottom Where to store the size, in screen coordinates, of the - * bottom edge of the window frame. + * bottom edge of the window frame, or `NULL`. * - * @remarks This function retrieves the size of each window frame edge, not the - * offset along a screen coordinate axis, so the retrieved values will always - * be zero or positive. + * @par Thread Safety + * This function may only be called from the main thread. * - * @note This function may only be called from the main thread. + * @sa @ref window_size + * + * @par History + * Added in GLFW 3.1. * * @ingroup window */ @@ -1564,66 +1907,95 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int /*! @brief Iconifies the specified window. * - * This function iconifies/minimizes the specified window, if it was previously - * restored. If it is a full screen window, the original monitor resolution is - * restored until the window is restored. If the window is already iconified, - * this function does nothing. + * This function iconifies (minimizes) the specified window if it was + * previously restored. If the window is already iconified, this function does + * nothing. + * + * If the specified window is a full screen window, the original monitor + * resolution is restored until the window is restored. * * @param[in] window The window to iconify. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_iconify * @sa glfwRestoreWindow * + * @par History + * Added in GLFW 2.1. + * + * @par + * __GLFW 3:__ Added window handle parameter. + * * @ingroup window */ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); /*! @brief Restores the specified window. * - * This function restores the specified window, if it was previously - * iconified/minimized. If it is a full screen window, the resolution chosen - * for the window is restored on the selected monitor. If the window is - * already restored, this function does nothing. + * This function restores the specified window if it was previously iconified + * (minimized). If the window is already restored, this function does nothing. + * + * If the specified window is a full screen window, the resolution chosen for + * the window is restored on the selected monitor. * * @param[in] window The window to restore. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_iconify * @sa glfwIconifyWindow * + * @par History + * Added in GLFW 2.1. + * + * @par + * __GLFW 3:__ Added window handle parameter. + * * @ingroup window */ GLFWAPI void glfwRestoreWindow(GLFWwindow* window); /*! @brief Makes the specified window visible. * - * This function makes the specified window visible, if it was previously + * This function makes the specified window visible if it was previously * hidden. If the window is already visible or is in full screen mode, this * function does nothing. * * @param[in] window The window to make visible. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_hide * @sa glfwHideWindow * + * @par History + * Added in GLFW 3.0. + * * @ingroup window */ GLFWAPI void glfwShowWindow(GLFWwindow* window); /*! @brief Hides the specified window. * - * This function hides the specified window, if it was previously visible. If + * This function hides the specified window if it was previously visible. If * the window is already hidden or is in full screen mode, this function does * nothing. * * @param[in] window The window to hide. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref window_hide * @sa glfwShowWindow * + * @par History + * Added in GLFW 3.0. + * * @ingroup window */ GLFWAPI void glfwHideWindow(GLFWwindow* window); @@ -1634,9 +2006,16 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); * in full screen on. * * @param[in] window The window to query. - * @return The monitor, or `NULL` if the window is in windowed mode. + * @return The monitor, or `NULL` if the window is in windowed mode or an error + * occurred. + * + * @par Thread Safety + * This function may only be called from the main thread. * - * @note This function may only be called from the main thread. + * @sa @ref window_monitor + * + * @par History + * Added in GLFW 3.0. * * @ingroup window */ @@ -1644,16 +2023,26 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); /*! @brief Returns an attribute of the specified window. * - * This function returns an attribute of the specified window. There are many - * attributes, some related to the window and others to its context. + * This function returns the value of an attribute of the specified window or + * its OpenGL or OpenGL ES context. * * @param[in] window The window to query. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to * return. - * @return The value of the attribute, or zero if an error occurred. Errors - * are reported to the [error callback](@ref intro_error). + * @return The value of the attribute, or zero if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_attribs + * + * @par History + * Added in GLFW 1.0. * - * @note This function may only be called from the main thread. + * @par + * __GLFW 3:__ Renamed from `glfwGetWindowParam`. Added window handle + * parameter. * * @ingroup window */ @@ -1668,10 +2057,15 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * @param[in] window The window whose pointer to set. * @param[in] pointer The new value. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. * + * @sa @ref window_userptr * @sa glfwGetWindowUserPointer * + * @par History + * Added in GLFW 3.0. + * * @ingroup window */ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); @@ -1683,10 +2077,15 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); * * @param[in] window The window whose pointer to return. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. * + * @sa @ref window_userptr * @sa glfwSetWindowUserPointer * + * @par History + * Added in GLFW 3.0. + * * @ingroup window */ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); @@ -1703,7 +2102,16 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_pos + * + * @par History + * Added in GLFW 3.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. Updated callback signature. * * @ingroup window */ @@ -1721,7 +2129,16 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindow * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_size + * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. Updated callback signature. * * @ingroup window */ @@ -1744,13 +2161,19 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @par New in GLFW 3 - * The close callback no longer returns a value. - * - * @remarks **OS X:** Selecting Quit from the application menu will + * @remarks __OS X:__ Selecting Quit from the application menu will * trigger the close callback for all windows. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_close + * + * @par History + * Added in GLFW 2.5. + * + * @par + * __GLFW 3:__ Added window handle parameter. Updated callback signature. * * @ingroup window */ @@ -1772,11 +2195,16 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwi * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * - * @note On compositing window systems such as Aero, Compiz or Aqua, where the - * window contents are saved off-screen, this callback may be called only very - * infrequently or never at all. + * @sa @ref window_refresh + * + * @par History + * Added in GLFW 2.5. + * + * @par + * __GLFW 3:__ Added window handle parameter. Updated callback signature. * * @ingroup window */ @@ -1798,7 +2226,13 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GL * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_focus + * + * @par History + * Added in GLFW 3.0. * * @ingroup window */ @@ -1815,7 +2249,13 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_iconify + * + * @par History + * Added in GLFW 3.0. * * @ingroup window */ @@ -1832,7 +2272,13 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GL * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_fbsize + * + * @par History + * Added in GLFW 3.0. * * @ingroup window */ @@ -1840,110 +2286,134 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window /*! @brief Processes all pending events. * - * This function processes only those events that have already been received - * and then returns immediately. Processing events will cause the window and - * input callbacks associated with those events to be called. - * - * This function is not required for joystick input to work. + * This function processes only those events that are already in the event + * queue and then returns immediately. Processing events will cause the window + * and input callbacks associated with those events to be called. * - * @par New in GLFW 3 - * This function is no longer called by @ref glfwSwapBuffers. You need to call - * it or @ref glfwWaitEvents yourself. + * On some platforms, a window move, resize or menu operation will cause event + * processing to block. This is due to how event processing is designed on + * those platforms. You can use the + * [window refresh callback](@ref window_refresh) to redraw the contents of + * your window when necessary during such operations. * - * @remarks On some platforms, a window move, resize or menu operation will - * cause event processing to block. This is due to how event processing is - * designed on those platforms. You can use the - * [window refresh callback](@ref GLFWwindowrefreshfun) to redraw the contents - * of your window when necessary during the operation. + * On some platforms, certain events are sent directly to the application + * without going through the event queue, causing callbacks to be called + * outside of a call to one of the event processing functions. * - * @note This function may only be called from the main thread. + * Event processing is not required for joystick input to work. * * @note This function may not be called from a callback. * - * @note On some platforms, certain callbacks may be called outside of a call - * to one of the event processing functions. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref input_event * @sa glfwWaitEvents * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ This function is no longer called by @ref glfwSwapBuffers. + * * @ingroup window */ GLFWAPI void glfwPollEvents(void); -/*! @brief Waits until events are pending and processes them. +/*! @brief Waits until events are queued and processes them. * - * This function puts the calling thread to sleep until at least one event has - * been received. Once one or more events have been received, it behaves as if - * @ref glfwPollEvents was called, i.e. the events are processed and the - * function then returns immediately. Processing events will cause the window - * and input callbacks associated with those events to be called. + * This function puts the calling thread to sleep until at least one event is + * available in the event queue. Once one or more events are available, + * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue + * are processed and the function then returns immediately. Processing events + * will cause the window and input callbacks associated with those events to be + * called. * * Since not all events are associated with callbacks, this function may return * without a callback having been called even if you are monitoring all * callbacks. * - * This function is not required for joystick input to work. - * - * @remarks On some platforms, a window move, resize or menu operation will - * cause event processing to block. This is due to how event processing is - * designed on those platforms. You can use the - * [window refresh callback](@ref GLFWwindowrefreshfun) to redraw the contents - * of your window when necessary during the operation. + * On some platforms, a window move, resize or menu operation will cause event + * processing to block. This is due to how event processing is designed on + * those platforms. You can use the + * [window refresh callback](@ref window_refresh) to redraw the contents of + * your window when necessary during such operations. * - * @remarks If no windows exist, this function returns immediately. For - * synchronization of threads in applications that do not create windows, use - * your threading library of choice. + * If no windows exist, this function returns immediately. For synchronization + * of threads in applications that do not create windows, use your threading + * library of choice. * - * @note This function may only be called from the main thread. + * Event processing is not required for joystick input to work. * * @note This function may not be called from a callback. * * @note On some platforms, certain callbacks may be called outside of a call * to one of the event processing functions. * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_event * @sa glfwPollEvents * + * @par History + * Added in GLFW 2.5. + * * @ingroup window */ GLFWAPI void glfwWaitEvents(void); /*! @brief Posts an empty event to the event queue. * - * This function posts an empty event from the current thread to the main - * thread event queue, causing @ref glfwWaitEvents to return. + * This function posts an empty event from the current thread to the event + * queue, causing @ref glfwWaitEvents to return. * - * @remarks If no windows exist, this function returns immediately. For - * synchronization of threads in applications that do not create windows, use - * your threading library of choice. + * If no windows exist, this function returns immediately. For synchronization + * of threads in applications that do not create windows, use your threading + * library of choice. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. * + * @sa @ref input_event * @sa glfwWaitEvents * + * @par History + * Added in GLFW 3.1. + * * @ingroup window */ GLFWAPI void glfwPostEmptyEvent(void); /*! @brief Returns the value of an input option for the specified window. * + * This function returns the value of an input option for the specified window. + * The mode must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or + * `GLFW_STICKY_MOUSE_BUTTONS`. + * * @param[in] window The window to query. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or * `GLFW_STICKY_MOUSE_BUTTONS`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * * @sa glfwSetInputMode * + * @par History + * Added in GLFW 3.0. + * * @ingroup input */ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); /*! @brief Sets an input option for the specified window. - * @param[in] window The window whose input mode to set. - * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or + * + * This function sets an input mode option for the specified window. The mode + * must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or * `GLFW_STICKY_MOUSE_BUTTONS`. - * @param[in] value The new value of the specified input mode. * - * If `mode` is `GLFW_CURSOR`, the value must be one of the supported input + * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor * modes: * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client @@ -1954,25 +2424,34 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); * and unlimited cursor movement. This is useful for implementing for * example 3D camera controls. * - * If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to + * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are - * enabled, a key press will ensure that @ref glfwGetKey returns @ref - * GLFW_PRESS the next time it is called even if the key had been released - * before the call. This is useful when you are only interested in whether - * keys have been pressed but not when or in which order. + * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS` + * the next time it is called even if the key had been released before the + * call. This is useful when you are only interested in whether keys have been + * pressed but not when or in which order. + * + * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either + * `GL_TRUE` to enable sticky mouse buttons, or `GL_FALSE` to disable it. If + * sticky mouse buttons are enabled, a mouse button press will ensure that @ref + * glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even if + * the mouse button had been released before the call. This is useful when you + * are only interested in whether mouse buttons have been pressed but not when + * or in which order. * - * If `mode` is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either `GL_TRUE` - * to enable sticky mouse buttons, or `GL_FALSE` to disable it. If sticky - * mouse buttons are enabled, a mouse button press will ensure that @ref - * glfwGetMouseButton returns @ref GLFW_PRESS the next time it is called even - * if the mouse button had been released before the call. This is useful when - * you are only interested in whether mouse buttons have been pressed but not - * when or in which order. + * @param[in] window The window whose input mode to set. + * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or + * `GLFW_STICKY_MOUSE_BUTTONS`. + * @param[in] value The new value of the specified input mode. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * * @sa glfwGetInputMode * + * @par History + * Added in GLFW 3.0. Replaced `glfwEnable` and `glfwDisable`. + * * @ingroup input */ GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); @@ -1982,12 +2461,12 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); * * This function returns the last state reported for the specified key to the * specified window. The returned state is one of `GLFW_PRESS` or - * `GLFW_RELEASE`. The higher-level state `GLFW_REPEAT` is only reported to + * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to * the key callback. * * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns - * `GLFW_PRESS` the first time you call this function after a key has been - * pressed, even if the key has already been released. + * `GLFW_PRESS` the first time you call it for a key that was pressed, even if + * that key has already been released. * * The key functions deal with physical keys, with [key tokens](@ref keys) * named after their use on the standard US keyboard layout. If you want to @@ -1997,12 +2476,20 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); * used with this function. * * @param[in] window The desired window. - * @param[in] key The desired [keyboard key](@ref keys). + * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is + * not a valid key for this function. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_key + * + * @par History + * Added in GLFW 1.0. * - * @note `GLFW_KEY_UNKNOWN` is not a valid key for this function. + * @par + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -2012,17 +2499,28 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key); * window. * * This function returns the last state reported for the specified mouse button - * to the specified window. + * to the specified window. The returned state is one of `GLFW_PRESS` or + * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to + * the mouse button callback. * * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function - * returns `GLFW_PRESS` the first time you call this function after a mouse - * button has been pressed, even if the mouse button has already been released. + * `GLFW_PRESS` the first time you call it for a mouse button that was pressed, + * even if that mouse button has already been released. * * @param[in] window The desired window. * @param[in] button The desired [mouse button](@ref buttons). * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_mouse_button + * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -2043,16 +2541,28 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button); * `floor` function. Casting directly to an integer type works for positive * coordinates, but fails for negative ones. * + * Any or all of the position arguments may be `NULL`. If an error occurs, all + * non-`NULL` position arguments will be set to zero. + * * @param[in] window The desired window. * @param[out] xpos Where to store the cursor x-coordinate, relative to the * left edge of the client area, or `NULL`. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to * top edge of the client area, or `NULL`. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref input_cursor_pos * @sa glfwSetCursorPos * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Renamed from `glfwGetMousePos`. Added window handle parameter. + * Moved to floating-point coordinates. + * * @ingroup input */ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); @@ -2075,14 +2585,23 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); * @param[in] ypos The desired y-coordinate, relative to the top edge of the * client area. * - * @remarks **X11:** Due to the asynchronous nature of a modern X desktop, it + * @remarks __X11:__ Due to the asynchronous nature of a modern X desktop, it * may take a moment for the window focus event to arrive. This means you will * not be able to set the cursor position directly after window creation. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref input_cursor_pos * @sa glfwGetCursorPos * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Renamed from `glfwSetMousePos`. Added window handle parameter. + * Moved to floating-point coordinates. + * * @ingroup input */ GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); @@ -2094,16 +2613,29 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); * glfwDestroyCursor. Any remaining cursors are destroyed by @ref * glfwTerminate. * - * The specified image is in 32-bit RGBA format, so eight bits per channel. + * The image data is 32-bit RGBA, i.e. eight bits per channel. The pixels are + * arranged canonically as sequental rows, starting from the top-left corner. * * @param[in] image The desired cursor image. * @param[in] xhot The desired x-coordinate of the cursor hotspot. * @param[in] yhot The desired y-coordinate of the cursor hotspot. * - * @return A new cursor ready to use or `NULL` if an error occurred. Errors - * are reported to the [error callback](@ref intro_error). + * @return A new cursor ready to use or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @note This function may not be called from a callback. + * + * @par Pointer Lifetime + * The specified image data is copied before this function returns. + * + * @par Thread Safety + * This function may only be called from the main thread. * - * @note This function may only be called from the main thread. + * @sa @ref input_cursor + * @sa glfwDestroyCursor + * + * @par History + * Added in GLFW 3.1. * * @ingroup input */ @@ -2117,7 +2649,16 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) * * @param[in] cursor The cursor object to destroy. * - * @note This function may only be called from the main thread. + * @note This function may not be called from a callback. + * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_cursor + * @sa glfwCreateCursor + * + * @par History + * Added in GLFW 3.1. * * @ingroup input */ @@ -2125,11 +2666,19 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor); /*! @brief Sets the system cursor for a given window. * + * This function sets the system cursor for the specified window. + * * @param[in] window The window to set the system cursor for. * @param[in] cursor The cursor to change to, or `NULL` to switch back * to the default system cursor. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_cursor + * + * @par History + * Added in GLFW 3.1. * * @ingroup input */ @@ -2137,7 +2686,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); /*! @brief Sets the key callback. * - * This function sets the key callback of the specific window, which is called + * This function sets the key callback of the specified window, which is called * when a key is pressed, repeated or released. * * The key functions deal with physical keys, with layout independent @@ -2154,7 +2703,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * The scancode of a key is specific to that platform or sometimes even to that * machine. Scancodes are intended to allow users to bind keys that don't have * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their - * state is not saved and so it cannot be retrieved with @ref glfwGetKey. + * state is not saved and so it cannot be queried with @ref glfwGetKey. * * Sometimes GLFW needs to generate synthetic key events, in which case the * scancode may be zero. @@ -2165,7 +2714,16 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_key + * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. Updated callback signature. * * @ingroup input */ @@ -2173,7 +2731,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); /*! @brief Sets the Unicode character callback. * - * This function sets the character callback of the specific window, which is + * This function sets the character callback of the specified window, which is * called when a Unicode character is input. * * The character callback is intended for Unicode text input. As it deals with @@ -2196,7 +2754,16 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_char + * + * @par History + * Added in GLFW 2.4. + * + * @par + * __GLFW 3:__ Added window handle parameter. Updated callback signature. * * @ingroup input */ @@ -2204,7 +2771,7 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); /*! @brief Sets the Unicode character with modifiers callback. * - * This function sets the character with modifiers callback of the specific + * This function sets the character with modifiers callback of the specified * window, which is called when a Unicode character is input regardless of what * modifier keys are used. * @@ -2223,7 +2790,13 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); * @return The previously set callback, or `NULL` if no callback was set or an * error occurred. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_char + * + * @par History + * Added in GLFW 3.1. * * @ingroup input */ @@ -2246,7 +2819,16 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_mouse_button + * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. Updated callback signature. * * @ingroup input */ @@ -2265,7 +2847,17 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmo * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_cursor_pos + * + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Renamed from `glfwSetMousePosCallback`. Added window handle + * parameter. Updated callback signature. * * @ingroup input */ @@ -2283,7 +2875,13 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursor * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_cursor_enter + * + * @par History + * Added in GLFW 3.0. * * @ingroup input */ @@ -2304,7 +2902,17 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcu * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_scroll + * + * @par History + * Added in GLFW 2.1. + * + * @par + * __GLFW 3:__ Renamed from `glfwSetMouseWheelCallback`. Added window handle. + * Updated callback signature. * * @ingroup input */ @@ -2315,6 +2923,10 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cb * This function sets the file drop callback of the specified window, which is * called when one or more dragged files are dropped on the window. * + * Because the path array and its strings may have been generated specifically + * for that event, they are not guaranteed to be valid after the callback has + * returned. If you wish to use them after the callback returns, you need to + * make a deep copy. * * @param[in] window The window whose callback to set. * @param[in] cbfun The new file drop callback, or `NULL` to remove the @@ -2322,7 +2934,13 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cb * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_drop + * + * @par History + * Added in GLFW 3.1. * * @ingroup input */ @@ -2332,10 +2950,16 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun); * * This function returns whether the specified joystick is present. * - * @param[in] joy The joystick to query. + * @param[in] joy The [joystick](@ref joysticks) to query. * @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_joy + * + * @par History + * Added in GLFW 3.0. Replaced `glfwGetJoystickParam`. * * @ingroup input */ @@ -2344,19 +2968,29 @@ GLFWAPI int glfwJoystickPresent(int joy); /*! @brief Returns the values of all axes of the specified joystick. * * This function returns the values of all axes of the specified joystick. + * Each element in the array is a value between -1.0 and 1.0. * - * @param[in] joy The joystick to query. - * @param[out] count Where to store the size of the returned array. This is - * set to zero if an error occurred. + * @param[in] joy The [joystick](@ref joysticks) to query. + * @param[out] count Where to store the number of axis values in the returned + * array. This is set to zero if an error occurred. * @return An array of axis values, or `NULL` if the joystick is not present. * - * @note This function may only be called from the main thread. + * @par Pointer Lifetime + * The returned array is allocated and freed by GLFW. You should not free it + * yourself. It is valid until the specified joystick is disconnected, this + * function is called again for that joystick or the library is terminated. + * + * @par Thread Safety + * This function may only be called from the main thread. * - * @note The returned array is allocated and freed by GLFW. You should not - * free it yourself. + * @sa @ref input_joy_axis * - * @note The returned array is valid only until the next call to @ref - * glfwGetJoystickAxes for that joystick. + * @par History + * Added in GLFW 2.2. + * + * @par + * __GLFW 3:__ Renamed from `glfwGetJoystickPos`. Changed to return a dynamic + * array. * * @ingroup input */ @@ -2365,19 +2999,28 @@ GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count); /*! @brief Returns the state of all buttons of the specified joystick. * * This function returns the state of all buttons of the specified joystick. + * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`. * - * @param[in] joy The joystick to query. - * @param[out] count Where to store the size of the returned array. This is - * set to zero if an error occurred. + * @param[in] joy The [joystick](@ref joysticks) to query. + * @param[out] count Where to store the number of button states in the returned + * array. This is set to zero if an error occurred. * @return An array of button states, or `NULL` if the joystick is not present. * - * @note This function may only be called from the main thread. + * @par Pointer Lifetime + * The returned array is allocated and freed by GLFW. You should not free it + * yourself. It is valid until the specified joystick is disconnected, this + * function is called again for that joystick or the library is terminated. + * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_joy_button * - * @note The returned array is allocated and freed by GLFW. You should not - * free it yourself. + * @par History + * Added in GLFW 2.2. * - * @note The returned array is valid only until the next call to @ref - * glfwGetJoystickButtons for that joystick. + * @par + * __GLFW 3:__ Changed to return a dynamic array. * * @ingroup input */ @@ -2386,18 +3029,25 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count); /*! @brief Returns the name of the specified joystick. * * This function returns the name, encoded as UTF-8, of the specified joystick. + * The returned string is allocated and freed by GLFW. You should not free it + * yourself. * - * @param[in] joy The joystick to query. + * @param[in] joy The [joystick](@ref joysticks) to query. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick * is not present. * - * @note This function may only be called from the main thread. + * @par Pointer Lifetime + * The returned string is allocated and freed by GLFW. You should not free it + * yourself. It is valid until the specified joystick is disconnected, this + * function is called again for that joystick or the library is terminated. * - * @note The returned string is allocated and freed by GLFW. You should not - * free it yourself. + * @par Thread Safety + * This function may only be called from the main thread. * - * @note The returned string is valid only until the next call to @ref - * glfwGetJoystickName for that joystick. + * @sa @ref input_joy_name + * + * @par History + * Added in GLFW 3.0. * * @ingroup input */ @@ -2406,40 +3056,51 @@ GLFWAPI const char* glfwGetJoystickName(int joy); /*! @brief Sets the clipboard to the specified string. * * This function sets the system clipboard to the specified, UTF-8 encoded - * string. The string is copied before returning, so you don't have to retain - * it afterwards. + * string. * * @param[in] window The window that will own the clipboard contents. * @param[in] string A UTF-8 encoded string. * - * @note This function may only be called from the main thread. + * @par Pointer Lifetime + * The specified string is copied before this function returns. + * + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref input_clipboard * @sa glfwGetClipboardString * + * @par History + * Added in GLFW 3.0. + * * @ingroup input */ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); -/*! @brief Retrieves the contents of the clipboard as a string. +/*! @brief Returns the contents of the clipboard as a string. * * This function returns the contents of the system clipboard, if it contains * or is convertible to a UTF-8 encoded string. * * @param[in] window The window that will request the clipboard contents. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL` - * if an error occurred. Errors are reported to the - * [error callback](@ref intro_error). + * if an [error](@ref error_handling) occurred. * - * @note This function may only be called from the main thread. + * @par Pointer Lifetime + * The returned string is allocated and freed by GLFW. You should not free it + * yourself. It is valid until the next call to @ref + * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library + * is terminated. * - * @note The returned string is allocated and freed by GLFW. You should not - * free it yourself. - * - * @note The returned string is valid only until the next call to @ref - * glfwGetClipboardString or @ref glfwSetClipboardString. + * @par Thread Safety + * This function may only be called from the main thread. * + * @sa @ref input_clipboard * @sa glfwSetClipboardString * + * @par History + * Added in GLFW 3.0. + * * @ingroup input */ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); @@ -2450,16 +3111,22 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW * was initialized. * - * @return The current value, in seconds, or zero if an error occurred. Errors - * are reported to the [error callback](@ref intro_error). + * The resolution of the timer is system dependent, but is usually on the order + * of a few micro- or nanoseconds. It uses the highest-resolution monotonic + * time source on each supported platform. * - * @remarks This function may be called from any thread. + * @return The current value, in seconds, or zero if an + * [error](@ref error_handling) occurred. * - * @note The resolution of the timer is system dependent, but is usually on the - * order of a few micro- or nanoseconds. It uses the highest-resolution - * monotonic time source on each supported platform. + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. * - * @ingroup time + * @sa @ref input_time + * + * @par History + * Added in GLFW 1.0. + * + * @ingroup input */ GLFWAPI double glfwGetTime(void); @@ -2470,46 +3137,64 @@ GLFWAPI double glfwGetTime(void); * * @param[in] time The new value, in seconds. * - * @note This function may only be called from the main thread. + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref input_time * - * @note The resolution of the timer is system dependent, but is usually on the - * order of a few micro- or nanoseconds. It uses the highest-resolution - * monotonic time source on each supported platform. + * @par History + * Added in GLFW 2.2. * - * @ingroup time + * @ingroup input */ GLFWAPI void glfwSetTime(double time); /*! @brief Makes the context of the specified window current for the calling * thread. * - * This function makes the context of the specified window current on the - * calling thread. A context can only be made current on a single thread at - * a time and each thread can have only a single current context at a time. + * This function makes the OpenGL or OpenGL ES context of the specified window + * current on the calling thread. A context can only be made current on + * a single thread at a time and each thread can have only a single current + * context at a time. + * + * By default, making a context non-current implicitly forces a pipeline flush. + * On machines that support `GL_KHR_context_flush_control`, you can control + * whether a context performs this flush by setting the + * `GLFW_CONTEXT_RELEASE_BEHAVIOR` [window hint](@ref window_hints_ctx). * * @param[in] window The window whose context to make current, or `NULL` to * detach the current context. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. * + * @sa @ref context_current * @sa glfwGetCurrentContext * + * @par History + * Added in GLFW 3.0. + * * @ingroup context */ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window); /*! @brief Returns the window whose context is current on the calling thread. * - * This function returns the window whose context is current on the calling - * thread. + * This function returns the window whose OpenGL or OpenGL ES context is + * current on the calling thread. * * @return The window whose context is current, or `NULL` if no window's * context is current. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. * + * @sa @ref context_current * @sa glfwMakeContextCurrent * + * @par History + * Added in GLFW 3.0. + * * @ingroup context */ GLFWAPI GLFWwindow* glfwGetCurrentContext(void); @@ -2522,24 +3207,29 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void); * * @param[in] window The window whose buffers to swap. * - * @par New in GLFW 3 - * This function no longer calls @ref glfwPollEvents. You need to call it or - * @ref glfwWaitEvents yourself. - * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. * + * @sa @ref window_swap * @sa glfwSwapInterval * - * @ingroup context + * @par History + * Added in GLFW 1.0. + * + * @par + * __GLFW 3:__ Added window handle parameter. Removed call to @ref + * glfwPollEvents. + * + * @ingroup window */ GLFWAPI void glfwSwapBuffers(GLFWwindow* window); /*! @brief Sets the swap interval for the current context. * * This function sets the swap interval for the current context, i.e. the - * number of screen updates to wait before swapping the buffers of a window and - * returning from @ref glfwSwapBuffers. This is sometimes called 'vertical - * synchronization', 'vertical retrace synchronization' or 'vsync'. + * number of screen updates to wait from the time @ref glfwSwapBuffers was + * called before swapping the buffers and returning. This is sometimes called + * 'vertical synchronization', 'vertical retrace synchronization' or 'vsync'. * * Contexts that support either of the `WGL_EXT_swap_control_tear` and * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals, @@ -2548,11 +3238,12 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window); * glfwExtensionSupported. For more information about swap tearing, see the * extension specifications. * + * A context must be current on the calling thread. Calling this function + * without a current context will cause a `GLFW_NO_CURRENT_CONTEXT` error. + * * @param[in] interval The minimum number of screen updates to wait for * until the buffers are swapped by @ref glfwSwapBuffers. * - * @remarks This function may be called from any thread. - * * @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 @@ -2562,8 +3253,15 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window); * because of user settings that override the request or due to bugs in the * driver. * + * @par Thread Safety + * This function may be called from any thread. + * + * @sa @ref window_swap * @sa glfwSwapBuffers * + * @par History + * Added in GLFW 1.0. + * * @ingroup context */ GLFWAPI void glfwSwapInterval(int interval); @@ -2571,19 +3269,29 @@ GLFWAPI void glfwSwapInterval(int interval); /*! @brief Returns whether the specified extension is available. * * This function returns whether the specified - * [OpenGL or context creation API extension](@ref context_glext) is supported - * by the current context. For example, on Windows both the OpenGL and WGL - * extension strings are checked. + * [API extension](@ref context_glext) is supported by the current OpenGL or + * OpenGL ES context. It searches both for OpenGL and OpenGL ES extension and + * platform-specific context creation API extensions. + * + * A context must be current on the calling thread. Calling this function + * without a current context will cause a `GLFW_NO_CURRENT_CONTEXT` error. + * + * As this functions retrieves and searches one or more extension strings each + * call, it is recommended that you cache its results if it is going to be used + * frequently. The extension strings will not change during the lifetime of + * a context, so there is no danger in doing this. * * @param[in] extension The ASCII encoded name of the extension. * @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise. * - * @remarks This function may be called from any thread. + * @par Thread Safety + * This function may be called from any thread. * - * @note As this functions searches one or more extension strings on each call, - * it is recommended that you cache its results if it's going to be used - * frequently. The extension strings will not change during the lifetime of - * a context, so there is no danger in doing this. + * @sa @ref context_glext + * @sa glfwGetProcAddress + * + * @par History + * Added in GLFW 1.0. * * @ingroup context */ @@ -2596,15 +3304,28 @@ GLFWAPI int glfwExtensionSupported(const char* extension); * [client API or extension function](@ref context_glext), if it is supported * by the current context. * + * A context must be current on the calling thread. Calling this function + * without a current context will cause a `GLFW_NO_CURRENT_CONTEXT` error. + * * @param[in] procname The ASCII encoded name of the function. * @return The address of the function, or `NULL` if the function is - * unavailable. + * unavailable or an [error](@ref error_handling) occurred. + * + * @note The addresses of a given function is not guaranteed to be the same + * between contexts. + * + * @par Pointer Lifetime + * The returned function pointer is valid until the context is destroyed or the + * library is terminated. + * + * @par Thread Safety + * This function may be called from any thread. * - * @remarks This function may be called from any thread. + * @sa @ref context_glext + * @sa glfwExtensionSupported * - * @note The addresses of these functions are not guaranteed to be the same for - * all contexts, especially if they use different client APIs or even different - * context creation hints. + * @par History + * Added in GLFW 1.0. * * @ingroup context */ diff --git a/glfw/include/GLFW/glfw3native.h b/glfw/include/GLFW/glfw3native.h index 0d90406..c00d57c 100644 --- a/glfw/include/GLFW/glfw3native.h +++ b/glfw/include/GLFW/glfw3native.h @@ -45,8 +45,8 @@ extern "C" { * using it.** * * Before the inclusion of @ref glfw3native.h, you must define exactly one - * window API macro and exactly one context API macro. Failure to do this - * will cause a compile-time error. + * window system API macro and exactly one context creation API macro. Failure + * to do this will cause a compile-time error. * * The available window API macros are: * * `GLFW_EXPOSE_NATIVE_WIN32` @@ -109,13 +109,32 @@ extern "C" { #if defined(GLFW_EXPOSE_NATIVE_WIN32) /*! @brief Returns the display device name of the specified monitor. - * @return The display device name of the specified monitor. + * + * @return The UTF-8 encoded display device name (`DISPLAY_DEVICE.DeviceName`) + * of the specified monitor, or `NULL` if an [error](@ref error_handling) + * occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.1. + * * @ingroup native */ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor); /*! @brief Returns the `HWND` of the specified window. - * @return The `HWND` of the specified window. + * + * @return The `HWND` of the specified window, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); @@ -123,7 +142,16 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); #if defined(GLFW_EXPOSE_NATIVE_WGL) /*! @brief Returns the `HGLRC` of the specified window. - * @return The `HGLRC` of the specified window. + * + * @return The `HGLRC` of the specified window, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); @@ -131,13 +159,31 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); #if defined(GLFW_EXPOSE_NATIVE_COCOA) /*! @brief Returns the `CGDirectDisplayID` of the specified monitor. - * @return The `CGDirectDisplayID` of the specified monitor. + * + * @return The `CGDirectDisplayID` of the specified monitor, or + * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.1. + * * @ingroup native */ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); /*! @brief Returns the `NSWindow` of the specified window. - * @return The `NSWindow` of the specified window. + * + * @return The `NSWindow` of the specified window, or `nil` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); @@ -145,7 +191,16 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); #if defined(GLFW_EXPOSE_NATIVE_NSGL) /*! @brief Returns the `NSOpenGLContext` of the specified window. - * @return The `NSOpenGLContext` of the specified window. + * + * @return The `NSOpenGLContext` of the specified window, or `nil` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); @@ -153,19 +208,46 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); #if defined(GLFW_EXPOSE_NATIVE_X11) /*! @brief Returns the `Display` used by GLFW. - * @return The `Display` used by GLFW. + * + * @return The `Display` used by GLFW, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI Display* glfwGetX11Display(void); /*! @brief Returns the `RROutput` of the specified monitor. - * @return The `RROutput` of the specified monitor. + * + * @return The `RROutput` of the specified monitor, or `None` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.1. + * * @ingroup native */ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor); /*! @brief Returns the `Window` of the specified window. - * @return The `Window` of the specified window. + * + * @return The `Window` of the specified window, or `None` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI Window glfwGetX11Window(GLFWwindow* window); @@ -173,7 +255,16 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window); #if defined(GLFW_EXPOSE_NATIVE_GLX) /*! @brief Returns the `GLXContext` of the specified window. - * @return The `GLXContext` of the specified window. + * + * @return The `GLXContext` of the specified window, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); @@ -181,19 +272,46 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); #if defined(GLFW_EXPOSE_NATIVE_EGL) /*! @brief Returns the `EGLDisplay` used by GLFW. - * @return The `EGLDisplay` used by GLFW. + * + * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI EGLDisplay glfwGetEGLDisplay(void); /*! @brief Returns the `EGLContext` of the specified window. - * @return The `EGLContext` of the specified window. + * + * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); /*! @brief Returns the `EGLSurface` of the specified window. - * @return The `EGLSurface` of the specified window. + * + * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.0. + * * @ingroup native */ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); diff --git a/glfw/src/CMakeLists.txt b/glfw/src/CMakeLists.txt index 4a390b1..e006a8f 100644 --- a/glfw/src/CMakeLists.txt +++ b/glfw/src/CMakeLists.txt @@ -8,8 +8,7 @@ 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/glfw3native.h") -set(common_SOURCES context.c init.c input.c joystick.c monitor.c time.c - window.c) +set(common_SOURCES context.c init.c input.c monitor.c window.c) if (_GLFW_COCOA) set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h iokit_joystick.h @@ -53,7 +52,8 @@ if (APPLE) endif() add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) -set_target_properties(glfw PROPERTIES OUTPUT_NAME "${GLFW_LIB_NAME}") +set_target_properties(glfw PROPERTIES OUTPUT_NAME "${GLFW_LIB_NAME}" + POSITION_INDEPENDENT_CODE ON) if (BUILD_SHARED_LIBS) # Include version information in the output diff --git a/glfw/src/cocoa_monitor.m b/glfw/src/cocoa_monitor.m index 5ced387..cfb76a7 100644 --- a/glfw/src/cocoa_monitor.m +++ b/glfw/src/cocoa_monitor.m @@ -326,7 +326,7 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) { CFArrayRef modes; - CFIndex count, i; + CFIndex count, i, j; GLFWvidmode* result; CVDisplayLinkRef link; @@ -340,12 +340,26 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) for (i = 0; i < count; i++) { - CGDisplayModeRef mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); - if (modeIsGood(mode)) + CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); + if (!modeIsGood(dm)) + continue; + + const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link); + + for (j = 0; j < *found; j++) { - result[*found] = vidmodeFromCGDisplayMode(mode, link); - (*found)++; + if (_glfwCompareVideoModes(result + j, &mode) == 0) + break; + } + + if (i < *found) + { + // This is a duplicate, so skip it + continue; } + + result[*found] = mode; + (*found)++; } CFRelease(modes); diff --git a/glfw/src/cocoa_window.m b/glfw/src/cocoa_window.m index ae82d8c..a804d6d 100644 --- a/glfw/src/cocoa_window.m +++ b/glfw/src/cocoa_window.m @@ -1201,6 +1201,7 @@ void _glfwPlatformWaitEvents(void) void _glfwPlatformPostEmptyEvent(void) { + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 @@ -1211,6 +1212,7 @@ void _glfwPlatformPostEmptyEvent(void) data1:0 data2:0]; [NSApp postEvent:event atStart:YES]; + [pool drain]; } void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) diff --git a/glfw/src/context.c b/glfw/src/context.c index fe94af7..8f01846 100644 --- a/glfw/src/context.c +++ b/glfw/src/context.c @@ -35,9 +35,9 @@ // Parses the client API version string and extracts the version number // -static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev) +static GLboolean parseVersionString(int* api, int* major, int* minor, int* rev) { - int i, _api = GLFW_OPENGL_API, _major, _minor = 0, _rev = 0; + int i; const char* version; const char* prefixes[] = { @@ -47,6 +47,8 @@ static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev) NULL }; + *api = GLFW_OPENGL_API; + version = (const char*) glGetString(GL_VERSION); if (!version) { @@ -62,23 +64,18 @@ static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev) if (strncmp(version, prefixes[i], length) == 0) { version += length; - _api = GLFW_OPENGL_ES_API; + *api = GLFW_OPENGL_ES_API; break; } } - if (!sscanf(version, "%d.%d.%d", &_major, &_minor, &_rev)) + if (!sscanf(version, "%d.%d.%d", major, minor, rev)) { _glfwInputError(GLFW_PLATFORM_ERROR, "No version found in context version string"); return GL_FALSE; } - *api = _api; - *major = _major; - *minor = _minor; - *rev = _rev; - return GL_TRUE; } @@ -379,10 +376,10 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig) { _GLFWwindow* window = _glfwPlatformGetCurrentContext(); - if (!parseGLVersion(&window->context.api, - &window->context.major, - &window->context.minor, - &window->context.revision)) + if (!parseVersionString(&window->context.api, + &window->context.major, + &window->context.minor, + &window->context.revision)) { return GL_FALSE; } diff --git a/glfw/src/input.c b/glfw/src/input.c index 7dce923..a2d8ddc 100644 --- a/glfw/src/input.c +++ b/glfw/src/input.c @@ -497,6 +497,62 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun) return cbfun; } +GLFWAPI int glfwJoystickPresent(int joy) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(0); + + if (joy < 0 || joy > GLFW_JOYSTICK_LAST) + { + _glfwInputError(GLFW_INVALID_ENUM, NULL); + return 0; + } + + return _glfwPlatformJoystickPresent(joy); +} + +GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count) +{ + *count = 0; + + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (joy < 0 || joy > GLFW_JOYSTICK_LAST) + { + _glfwInputError(GLFW_INVALID_ENUM, NULL); + return NULL; + } + + return _glfwPlatformGetJoystickAxes(joy, count); +} + +GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count) +{ + *count = 0; + + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (joy < 0 || joy > GLFW_JOYSTICK_LAST) + { + _glfwInputError(GLFW_INVALID_ENUM, NULL); + return NULL; + } + + return _glfwPlatformGetJoystickButtons(joy, count); +} + +GLFWAPI const char* glfwGetJoystickName(int joy) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (joy < 0 || joy > GLFW_JOYSTICK_LAST) + { + _glfwInputError(GLFW_INVALID_ENUM, NULL); + return NULL; + } + + return _glfwPlatformGetJoystickName(joy); +} + GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) { _GLFWwindow* window = (_GLFWwindow*) handle; @@ -511,3 +567,15 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle) return _glfwPlatformGetClipboardString(window); } +GLFWAPI double glfwGetTime(void) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(0.0); + return _glfwPlatformGetTime(); +} + +GLFWAPI void glfwSetTime(double time) +{ + _GLFW_REQUIRE_INIT(); + _glfwPlatformSetTime(time); +} + diff --git a/glfw/src/joystick.c b/glfw/src/joystick.c deleted file mode 100644 index 52aee9b..0000000 --- a/glfw/src/joystick.c +++ /dev/null @@ -1,90 +0,0 @@ -//======================================================================== -// GLFW 3.1 - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2002-2006 Marcus Geelnard -// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#include "internal.h" - - -////////////////////////////////////////////////////////////////////////// -////// GLFW public API ////// -////////////////////////////////////////////////////////////////////////// - -GLFWAPI int glfwJoystickPresent(int joy) -{ - _GLFW_REQUIRE_INIT_OR_RETURN(0); - - if (joy < 0 || joy > GLFW_JOYSTICK_LAST) - { - _glfwInputError(GLFW_INVALID_ENUM, NULL); - return 0; - } - - return _glfwPlatformJoystickPresent(joy); -} - -GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count) -{ - *count = 0; - - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - - if (joy < 0 || joy > GLFW_JOYSTICK_LAST) - { - _glfwInputError(GLFW_INVALID_ENUM, NULL); - return NULL; - } - - return _glfwPlatformGetJoystickAxes(joy, count); -} - -GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count) -{ - *count = 0; - - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - - if (joy < 0 || joy > GLFW_JOYSTICK_LAST) - { - _glfwInputError(GLFW_INVALID_ENUM, NULL); - return NULL; - } - - return _glfwPlatformGetJoystickButtons(joy, count); -} - -GLFWAPI const char* glfwGetJoystickName(int joy) -{ - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - - if (joy < 0 || joy > GLFW_JOYSTICK_LAST) - { - _glfwInputError(GLFW_INVALID_ENUM, NULL); - return NULL; - } - - return _glfwPlatformGetJoystickName(joy); -} - diff --git a/glfw/src/time.c b/glfw/src/time.c deleted file mode 100644 index 1a87125..0000000 --- a/glfw/src/time.c +++ /dev/null @@ -1,46 +0,0 @@ -//======================================================================== -// GLFW 3.1 - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2002-2006 Marcus Geelnard -// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#include "internal.h" - - -////////////////////////////////////////////////////////////////////////// -////// GLFW public API ////// -////////////////////////////////////////////////////////////////////////// - -GLFWAPI double glfwGetTime(void) -{ - _GLFW_REQUIRE_INIT_OR_RETURN(0.0); - return _glfwPlatformGetTime(); -} - -GLFWAPI void glfwSetTime(double time) -{ - _GLFW_REQUIRE_INIT(); - _glfwPlatformSetTime(time); -} - diff --git a/glfw/src/win32_init.c b/glfw/src/win32_init.c index 51fe08e..5b1c18b 100644 --- a/glfw/src/win32_init.c +++ b/glfw/src/win32_init.c @@ -151,9 +151,9 @@ WCHAR* _glfwCreateWideStringFromUTF8(const char* source) if (!length) return NULL; - target = calloc(length + 1, sizeof(WCHAR)); + target = calloc(length, sizeof(WCHAR)); - if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1)) + if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length)) { free(target); return NULL; @@ -173,9 +173,9 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source) if (!length) return NULL; - target = calloc(length + 1, sizeof(char)); + target = calloc(length, sizeof(char)); - if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length + 1, NULL, NULL)) + if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length, NULL, NULL)) { free(target); return NULL; diff --git a/glfw/src/win32_window.c b/glfw/src/win32_window.c index fbdf03a..f7c531d 100644 --- a/glfw/src/win32_window.c +++ b/glfw/src/win32_window.c @@ -728,7 +728,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_MOUSEHWHEEL: { // This message is only sent on Windows Vista and later - _glfwInputScroll(window, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA, 0.0); + // NOTE: The X-axis is inverted for consistency with OS X and X11. + _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0); return 0; } diff --git a/glfw/src/window.c b/glfw/src/window.c index 7d10f38..561671e 100644 --- a/glfw/src/window.c +++ b/glfw/src/window.c @@ -151,7 +151,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, fbconfig.accumBlueBits = _glfw.hints.accumBlueBits; fbconfig.accumAlphaBits = _glfw.hints.accumAlphaBits; fbconfig.auxBuffers = _glfw.hints.auxBuffers; - fbconfig.stereo = _glfw.hints.stereo; + fbconfig.stereo = _glfw.hints.stereo ? GL_TRUE : GL_FALSE; fbconfig.samples = _glfw.hints.samples; fbconfig.sRGB = _glfw.hints.sRGB; fbconfig.doublebuffer = _glfw.hints.doublebuffer ? GL_TRUE : GL_FALSE; @@ -290,6 +290,9 @@ void glfwDefaultWindowHints(void) _glfw.hints.focused = GL_TRUE; _glfw.hints.autoIconify = GL_TRUE; + // The default is to select the highest available refresh rate + _glfw.hints.refreshRate = GLFW_DONT_CARE; + // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // double buffered _glfw.hints.redBits = 8; diff --git a/glfw/src/winmm_joystick.c b/glfw/src/winmm_joystick.c index ad5a67f..fcf6d94 100644 --- a/glfw/src/winmm_joystick.c +++ b/glfw/src/winmm_joystick.c @@ -34,9 +34,9 @@ ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -// Calculate normalized joystick position +// Convert axis value to the [-1,1] range // -static float calcJoystickPos(DWORD pos, DWORD min, DWORD max) +static float normalizeAxis(DWORD pos, DWORD min, DWORD max) { float fpos = (float) pos; float fmin = (float) min; @@ -96,20 +96,20 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count) if (_glfw_joyGetPosEx(joy, &ji) != JOYERR_NOERROR) return NULL; - axes[(*count)++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax); - axes[(*count)++] = calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax); + axes[(*count)++] = normalizeAxis(ji.dwXpos, jc.wXmin, jc.wXmax); + axes[(*count)++] = normalizeAxis(ji.dwYpos, jc.wYmin, jc.wYmax); if (jc.wCaps & JOYCAPS_HASZ) - axes[(*count)++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax); + axes[(*count)++] = normalizeAxis(ji.dwZpos, jc.wZmin, jc.wZmax); if (jc.wCaps & JOYCAPS_HASR) - axes[(*count)++] = calcJoystickPos(ji.dwRpos, jc.wRmin, jc.wRmax); + axes[(*count)++] = normalizeAxis(ji.dwRpos, jc.wRmin, jc.wRmax); if (jc.wCaps & JOYCAPS_HASU) - axes[(*count)++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax); + axes[(*count)++] = normalizeAxis(ji.dwUpos, jc.wUmin, jc.wUmax); if (jc.wCaps & JOYCAPS_HASV) - axes[(*count)++] = calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax); + axes[(*count)++] = normalizeAxis(ji.dwVpos, jc.wVmin, jc.wVmax); return axes; } diff --git a/glfw/src/wl_init.c b/glfw/src/wl_init.c index 46f8179..9105df7 100644 --- a/glfw/src/wl_init.c +++ b/glfw/src/wl_init.c @@ -573,18 +573,25 @@ int _glfwPlatformInit(void) _glfwInitTimer(); _glfwInitJoysticks(); - if (_glfw.wl.pointer && _glfw.wl.shm){ - _glfw.wl.cursorTheme = wl_cursor_theme_load(NULL, 24, _glfw.wl.shm); - if (!_glfw.wl.cursorTheme) { - _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unable to load default cursor theme\n"); + if (_glfw.wl.pointer && _glfw.wl.shm) + { + _glfw.wl.cursorTheme = wl_cursor_theme_load(NULL, 32, _glfw.wl.shm); + if (!_glfw.wl.cursorTheme) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Unable to load default cursor theme\n"); return GL_FALSE; } - _glfw.wl.defaultCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, "left_ptr"); - if (!_glfw.wl.defaultCursor) { - _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unable to load default left pointer\n"); + _glfw.wl.defaultCursor = + wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, "left_ptr"); + if (!_glfw.wl.defaultCursor) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Unable to load default left pointer\n"); return GL_FALSE; } - _glfw.wl.cursorSurface = wl_compositor_create_surface(_glfw.wl.compositor); + _glfw.wl.cursorSurface = + wl_compositor_create_surface(_glfw.wl.compositor); } return GL_TRUE; diff --git a/glfw/src/wl_window.c b/glfw/src/wl_window.c index 0fa16aa..9ace38f 100644 --- a/glfw/src/wl_window.c +++ b/glfw/src/wl_window.c @@ -24,6 +24,8 @@ // //======================================================================== +#define _GNU_SOURCE + #include "internal.h" #include <stdio.h> @@ -101,43 +103,13 @@ static GLboolean createSurface(_GLFWwindow* window, } static int -set_cloexec_or_close(int fd) -{ - long flags; - - if (fd == -1) - return -1; - - flags = fcntl(fd, F_GETFD); - if (flags == -1) - goto err; - - if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) - goto err; - - return fd; - -err: - close(fd); - return -1; -} - -static int -create_tmpfile_cloexec(char *tmpname) +createTmpfileCloexec(char* tmpname) { int fd; -#ifdef HAVE_MKOSTEMP fd = mkostemp(tmpname, O_CLOEXEC); if (fd >= 0) unlink(tmpname); -#else - fd = mkstemp(tmpname); - if (fd >= 0) { - fd = set_cloexec_or_close(fd); - unlink(tmpname); - } -#endif return fd; } @@ -157,42 +129,40 @@ create_tmpfile_cloexec(char *tmpname) * transmitting the file descriptor over Unix sockets using the * SCM_RIGHTS methods. * - * If the C library implements posix_fallocate(), it is used to - * guarantee that disk space is available for the file at the - * given size. If disk space is insufficent, errno is set to ENOSPC. - * If posix_fallocate() is not supported, program may receive - * SIGBUS on accessing mmap()'ed file contents instead. + * posix_fallocate() is used to guarantee that disk space is available + * for the file at the given size. If disk space is insufficent, errno + * is set to ENOSPC. If posix_fallocate() is not supported, program may + * receive SIGBUS on accessing mmap()'ed file contents instead. */ int -os_create_anonymous_file(off_t size) +createAnonymousFile(off_t size) { static const char template[] = "/glfw-shared-XXXXXX"; - const char *path; - char *name; + const char* path; + char* name; int fd; int ret; path = getenv("XDG_RUNTIME_DIR"); - if (!path) { + if (!path) + { errno = ENOENT; return -1; } name = malloc(strlen(path) + sizeof(template)); - if (!name) - return -1; - strcpy(name, path); strcat(name, template); - fd = create_tmpfile_cloexec(name); + fd = createTmpfileCloexec(name); free(name); if (fd < 0) return -1; ret = posix_fallocate(fd, 0, size); - if (ret != 0) { + if (ret != 0) + { close(fd); errno = ret; return -1; @@ -400,24 +370,26 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot) { - struct wl_shm_pool *pool; + struct wl_shm_pool* pool; int stride = image->width * 4; int length = image->width * image->height * 4; - void *data; + void* data; int fd, i; - fd = os_create_anonymous_file(length); - if (fd < 0) { + fd = createAnonymousFile(length); + if (fd < 0) + { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Creating a buffer file for %d B failed: %m\n", - length); + "Wayland: Creating a buffer file for %d B failed: %m\n", + length); return GL_FALSE; } data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (data == MAP_FAILED) { + if (data == MAP_FAILED) + { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Cursor mmap failed: %m\n"); + "Wayland: Cursor mmap failed: %m\n"); close(fd); return GL_FALSE; } @@ -435,10 +407,11 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, *target++ = source[3]; } - cursor->wl.buffer = wl_shm_pool_create_buffer(pool, 0, - image->width, - image->height, - stride, WL_SHM_FORMAT_ARGB8888); + cursor->wl.buffer = + wl_shm_pool_create_buffer(pool, 0, + image->width, + image->height, + stride, WL_SHM_FORMAT_ARGB8888); munmap(data, length); wl_shm_pool_destroy(pool); @@ -456,9 +429,9 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) { - struct wl_buffer *buffer; - struct wl_cursor_image *image; - struct wl_surface *surface = _glfw.wl.cursorSurface; + struct wl_buffer* buffer; + struct wl_cursor_image* image; + struct wl_surface* surface = _glfw.wl.cursorSurface; if (!_glfw.wl.pointer) return; @@ -479,23 +452,23 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) if (!buffer) return; wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerSerial, - surface, - image->hotspot_x, - image->hotspot_y); + surface, + image->hotspot_x, + image->hotspot_y); wl_surface_attach(surface, buffer, 0, 0); wl_surface_damage(surface, 0, 0, - image->width, image->height); + image->width, image->height); wl_surface_commit(surface); } else { wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerSerial, - surface, - cursor->wl.xhot, - cursor->wl.yhot); + surface, + cursor->wl.xhot, + cursor->wl.yhot); wl_surface_attach(surface, cursor->wl.buffer, 0, 0); wl_surface_damage(surface, 0, 0, - cursor->wl.width, cursor->wl.height); + cursor->wl.width, cursor->wl.height); wl_surface_commit(surface); } } diff --git a/glfw/src/x11_init.c b/glfw/src/x11_init.c index 3d07736..ea0b693 100644 --- a/glfw/src/x11_init.c +++ b/glfw/src/x11_init.c @@ -329,6 +329,30 @@ static void updateKeyCodeLUT(void) } } +// Check whether the IM has a usable style +// +static GLboolean hasUsableInputMethodStyle(void) +{ + unsigned int i; + GLboolean found = GL_FALSE; + XIMStyles* styles = NULL; + + if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL) + return GL_FALSE; + + for (i = 0; i < styles->count_styles; i++) + { + if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) + { + found = GL_TRUE; + break; + } + } + + XFree(styles); + return found; +} + // Check whether the specified atom is supported // static Atom getSupportedAtom(Atom* supportedAtoms, @@ -423,6 +447,8 @@ static void detectEWMH(void) getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); _glfw.x11.NET_WM_STATE_FULLSCREEN = getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); + _glfw.x11.NET_WM_FULLSCREEN_MONITORS = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); _glfw.x11.NET_WM_NAME = getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_NAME"); _glfw.x11.NET_WM_ICON_NAME = @@ -509,6 +535,14 @@ static GLboolean initExtensions(void) XRRFreeScreenResources(sr); } + if (XineramaQueryExtension(_glfw.x11.display, + &_glfw.x11.xinerama.versionMajor, + &_glfw.x11.xinerama.versionMinor)) + { + if (XineramaIsActive(_glfw.x11.display)) + _glfw.x11.xinerama.available = GL_TRUE; + } + if (XQueryExtension(_glfw.x11.display, "XInputExtension", &_glfw.x11.xi.majorOpcode, @@ -702,6 +736,21 @@ int _glfwPlatformInit(void) _glfw.x11.cursor = createNULLCursor(); + if (XSupportsLocale()) + { + XSetLocaleModifiers(""); + + _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, 0, 0); + if (_glfw.x11.im) + { + if (!hasUsableInputMethodStyle()) + { + XCloseIM(_glfw.x11.im); + _glfw.x11.im = NULL; + } + } + } + if (!_glfwInitContextAPI()) return GL_FALSE; @@ -721,6 +770,12 @@ void _glfwPlatformTerminate(void) free(_glfw.x11.clipboardString); + if (_glfw.x11.im) + { + XCloseIM(_glfw.x11.im); + _glfw.x11.im = NULL; + } + _glfwTerminateJoysticks(); _glfwTerminateContextAPI(); diff --git a/glfw/src/x11_monitor.c b/glfw/src/x11_monitor.c index 679cafb..36d914d 100644 --- a/glfw/src/x11_monitor.c +++ b/glfw/src/x11_monitor.c @@ -200,18 +200,23 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor) _GLFWmonitor** _glfwPlatformGetMonitors(int* count) { - int i, j, size = 0, found = 0; + int i, j, k, size = 0, found = 0; _GLFWmonitor** monitors = NULL; *count = 0; if (_glfw.x11.randr.available) { + int screenCount = 0; + XineramaScreenInfo* screens = NULL; XRRScreenResources* sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root); RROutput primary = XRRGetOutputPrimary(_glfw.x11.display, _glfw.x11.root); + if (_glfw.x11.xinerama.available) + screens = XineramaQueryScreens(_glfw.x11.display, &screenCount); + for (i = 0; i < sr->ncrtc; i++) { XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, @@ -240,6 +245,18 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) monitors[found]->x11.output = ci->outputs[j]; monitors[found]->x11.crtc = oi->crtc; + for (k = 0; k < screenCount; k++) + { + if (screens[k].x_org == ci->x && + screens[k].y_org == ci->y && + screens[k].width == ci->width && + screens[k].height == ci->height) + { + monitors[found]->x11.index = k; + break; + } + } + XRRFreeOutputInfo(oi); if (ci->outputs[j] == primary) @@ -253,6 +270,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) XRRFreeScreenResources(sr); + if (screens) + XFree(screens); + if (found == 0) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -332,12 +352,8 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) for (j = 0; j < *found; j++) { - if (result[j].width == mode.width && - result[j].height == mode.height && - result[j].refreshRate == mode.refreshRate) - { + if (_glfwCompareVideoModes(result + j, &mode) == 0) break; - } } if (j < *found) diff --git a/glfw/src/x11_platform.h b/glfw/src/x11_platform.h index 8cfa491..a69705b 100644 --- a/glfw/src/x11_platform.h +++ b/glfw/src/x11_platform.h @@ -48,6 +48,9 @@ // The Xkb extension provides improved keyboard support #include <X11/XKBlib.h> +// The Xinerama extension provides legacy monitor indices +#include <X11/extensions/Xinerama.h> + #include "posix_tls.h" #if defined(_GLFW_GLX) @@ -78,6 +81,7 @@ typedef struct _GLFWwindowX11 { Colormap colormap; Window handle; + XIC ic; GLboolean overrideRedirect; @@ -105,6 +109,8 @@ typedef struct _GLFWlibraryX11 Cursor cursor; // Context for mapping window XIDs to _GLFWwindow pointers XContext context; + // XIM input method + XIM im; // True if window manager supports EWMH GLboolean hasEWMH; // Most recent error code received by X error handler @@ -127,6 +133,7 @@ typedef struct _GLFWlibraryX11 Atom NET_WM_STATE_ABOVE; Atom NET_WM_STATE_FULLSCREEN; Atom NET_WM_BYPASS_COMPOSITOR; + Atom NET_WM_FULLSCREEN_MONITORS; Atom NET_ACTIVE_WINDOW; Atom NET_FRAME_EXTENTS; Atom NET_REQUEST_FRAME_EXTENTS; @@ -202,6 +209,12 @@ typedef struct _GLFWlibraryX11 Window source; } xdnd; + struct { + GLboolean available; + int versionMajor; + int versionMinor; + } xinerama; + } _GLFWlibraryX11; @@ -213,6 +226,10 @@ typedef struct _GLFWmonitorX11 RRCrtc crtc; RRMode oldMode; + // Index of corresponding Xinerama screen, + // for EWMH full screen window placement + int index; + } _GLFWmonitorX11; diff --git a/glfw/src/x11_window.c b/glfw/src/x11_window.c index 41f05ce..8fa6c97 100644 --- a/glfw/src/x11_window.c +++ b/glfw/src/x11_window.c @@ -95,19 +95,6 @@ static int translateKey(int keycode) return _glfw.x11.keyCodeLUT[keycode]; } -// Translates an X Window event to Unicode -// -static int translateChar(XKeyEvent* event) -{ - KeySym keysym; - - // Get X11 keysym - XLookupString(event, NULL, 0, &keysym, NULL); - - // Convert to Unicode (see x11_unicode.c) - return (int) _glfwKeySym2Unicode(keysym); -} - // Return the GLFW window corresponding to the specified X11 window // static _GLFWwindow* findWindowByHandle(Window handle) @@ -437,6 +424,18 @@ static GLboolean createWindow(_GLFWwindow* window, XRRSelectInput(_glfw.x11.display, window->x11.handle, RRScreenChangeNotifyMask); + if (_glfw.x11.im) + { + window->x11.ic = XCreateIC(_glfw.x11.im, + XNInputStyle, + XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, + window->x11.handle, + XNFocusWindow, + window->x11.handle, + NULL); + } + _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos); _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height); @@ -716,6 +715,27 @@ static void enterFullscreenMode(_GLFWwindow* window) PropModeReplace, (unsigned char*) &value, 1); } + if (_glfw.x11.xinerama.available && _glfw.x11.NET_WM_FULLSCREEN_MONITORS) + { + XEvent event; + memset(&event, 0, sizeof(event)); + + event.type = ClientMessage; + event.xclient.window = window->x11.handle; + event.xclient.format = 32; // Data is 32-bit longs + event.xclient.message_type = _glfw.x11.NET_WM_FULLSCREEN_MONITORS; + event.xclient.data.l[0] = window->monitor->x11.index; + event.xclient.data.l[1] = window->monitor->x11.index; + event.xclient.data.l[2] = window->monitor->x11.index; + event.xclient.data.l[3] = window->monitor->x11.index; + + XSendEvent(_glfw.x11.display, + _glfw.x11.root, + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &event); + } + if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN) { int x, y; @@ -830,14 +850,43 @@ static void processEvent(XEvent *event) { const int key = translateKey(event->xkey.keycode); const int mods = translateState(event->xkey.state); - const int character = translateChar(&event->xkey); + const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); - _glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods); + if (event->xkey.keycode) + _glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods); - if (character != -1) + if (window->x11.ic) { - const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); - _glfwInputChar(window, character, mods, plain); + // Translate keys to characters with XIM input context + + int i; + Status status; + wchar_t buffer[16]; + + if (XFilterEvent(event, None)) + { + // Discard intermediary (dead key) events for character input + break; + } + + const int count = XwcLookupString(window->x11.ic, + &event->xkey, + buffer, sizeof(buffer), + NULL, &status); + + for (i = 0; i < count; i++) + _glfwInputChar(window, buffer[i], mods, plain); + } + else + { + // Translate keys to characters with fallback lookup table + + KeySym keysym; + XLookupString(&event->xkey, NULL, 0, &keysym, NULL); + + const long character = _glfwKeySym2Unicode(keysym); + if (character != -1) + _glfwInputChar(window, character, mods, plain); } break; @@ -900,9 +949,9 @@ static void processEvent(XEvent *event) else if (event->xbutton.button == Button5) _glfwInputScroll(window, 0.0, -1.0); else if (event->xbutton.button == Button6) - _glfwInputScroll(window, -1.0, 0.0); - else if (event->xbutton.button == Button7) _glfwInputScroll(window, 1.0, 0.0); + else if (event->xbutton.button == Button7) + _glfwInputScroll(window, -1.0, 0.0); else { @@ -1367,6 +1416,12 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) if (window->monitor) leaveFullscreenMode(window); + if (window->x11.ic) + { + XDestroyIC(window->x11.ic); + window->x11.ic = NULL; + } + _glfwDestroyContext(window); if (window->x11.handle) diff --git a/glfw/tests/CMakeLists.txt b/glfw/tests/CMakeLists.txt deleted file mode 100644 index c327eb2..0000000 --- a/glfw/tests/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ - -link_libraries(glfw "${OPENGL_glu_LIBRARY}") - -if (BUILD_SHARED_LIBS) - add_definitions(-DGLFW_DLL) - link_libraries("${OPENGL_gl_LIBRARY}" "${MATH_LIBRARY}") -else() - link_libraries(${glfw_LIBRARIES}) -endif() - -include_directories("${GLFW_SOURCE_DIR}/include" - "${GLFW_SOURCE_DIR}/deps") - -if ("${OPENGL_INCLUDE_DIR}") - include_directories("${OPENGL_INCLUDE_DIR}") -endif() - -set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" - "${GLFW_SOURCE_DIR}/deps/getopt.c") -set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" - "${GLFW_SOURCE_DIR}/deps/tinycthread.c") - -add_executable(clipboard clipboard.c ${GETOPT}) -add_executable(defaults defaults.c) -add_executable(events events.c ${GETOPT}) -add_executable(fsaa fsaa.c ${GETOPT}) -add_executable(gamma gamma.c ${GETOPT}) -add_executable(glfwinfo glfwinfo.c ${GETOPT}) -add_executable(iconify iconify.c ${GETOPT}) -add_executable(joysticks joysticks.c) -add_executable(modes modes.c ${GETOPT}) -add_executable(peter peter.c) -add_executable(reopen reopen.c) -add_executable(cursor cursor.c) - -add_executable(cursoranim WIN32 MACOSX_BUNDLE cursoranim.c) -set_target_properties(cursoranim PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Cursor animation") - -add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c) -set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy") - -add_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD}) -set_target_properties(empty PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Empty Event") - -add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c) -set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") - -add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c) -set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") - -add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD}) -set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") - -add_executable(title WIN32 MACOSX_BUNDLE title.c) -set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") - -add_executable(windows WIN32 MACOSX_BUNDLE windows.c) -set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") - -target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") -target_link_libraries(threads "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") - -set(WINDOWS_BINARIES accuracy empty sharing tearing threads title windows cursoranim) -set(CONSOLE_BINARIES clipboard defaults events fsaa gamma glfwinfo - iconify joysticks modes peter reopen cursor) - -if (MSVC) - # Tell MSVC to use main instead of WinMain for Windows subsystem executables - set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES - LINK_FLAGS "/ENTRY:mainCRTStartup") -endif() - -if (APPLE) - set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES - MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} - MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}) -endif() - diff --git a/glfw/tests/accuracy.c b/glfw/tests/accuracy.c deleted file mode 100644 index 6a63c88..0000000 --- a/glfw/tests/accuracy.c +++ /dev/null @@ -1,128 +0,0 @@ -//======================================================================== -// Mouse cursor accuracy test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test came about as the result of bug #1867804 -// -// No sign of said bug has so far been detected -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -static double cursor_x = 0.0, cursor_y = 0.0; -static int window_width = 640, window_height = 480; -static int swap_interval = 1; - -static void set_swap_interval(GLFWwindow* window, int interval) -{ - char title[256]; - - swap_interval = interval; - glfwSwapInterval(swap_interval); - - sprintf(title, "Cursor Inaccuracy Detector (interval %i)", swap_interval); - - glfwSetWindowTitle(window, title); -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - window_width = width; - window_height = height; - - glViewport(0, 0, window_width, window_height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.f, window_width, 0.f, window_height, 0.f, 1.f); -} - -static void cursor_position_callback(GLFWwindow* window, double x, double y) -{ - cursor_x = x; - cursor_y = y; -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) - set_swap_interval(window, 1 - swap_interval); -} - -int main(void) -{ - GLFWwindow* window; - int width, height; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(window_width, window_height, "", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetCursorPosCallback(window, cursor_position_callback); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetKeyCallback(window, key_callback); - - glfwMakeContextCurrent(window); - - glfwGetFramebufferSize(window, &width, &height); - framebuffer_size_callback(window, width, height); - - set_swap_interval(window, swap_interval); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_LINES); - glVertex2f(0.f, (GLfloat) (window_height - cursor_y)); - glVertex2f((GLfloat) window_width, (GLfloat) (window_height - cursor_y)); - glVertex2f((GLfloat) cursor_x, 0.f); - glVertex2f((GLfloat) cursor_x, (GLfloat) window_height); - glEnd(); - - glfwSwapBuffers(window); - glfwPollEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/clipboard.c b/glfw/tests/clipboard.c deleted file mode 100644 index 4342284..0000000 --- a/glfw/tests/clipboard.c +++ /dev/null @@ -1,149 +0,0 @@ -//======================================================================== -// Clipboard test program -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This program is used to test the clipboard functionality. -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -#include "getopt.h" - -static void usage(void) -{ - printf("Usage: clipboard [-h]\n"); -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GL_TRUE); - break; - - case GLFW_KEY_V: - if (mods == GLFW_MOD_CONTROL) - { - const char* string; - - string = glfwGetClipboardString(window); - if (string) - printf("Clipboard contains \"%s\"\n", string); - else - printf("Clipboard does not contain a string\n"); - } - break; - - case GLFW_KEY_C: - if (mods == GLFW_MOD_CONTROL) - { - const char* string = "Hello GLFW World!"; - glfwSetClipboardString(window, string); - printf("Setting clipboard to \"%s\"\n", string); - } - break; - } -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -int main(int argc, char** argv) -{ - int ch; - GLFWwindow* window; - - while ((ch = getopt(argc, argv, "h")) != -1) - { - switch (ch) - { - case 'h': - usage(); - exit(EXIT_SUCCESS); - - default: - usage(); - exit(EXIT_FAILURE); - } - } - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - { - fprintf(stderr, "Failed to initialize GLFW\n"); - exit(EXIT_FAILURE); - } - - window = glfwCreateWindow(200, 200, "Clipboard Test", NULL, NULL); - if (!window) - { - glfwTerminate(); - - fprintf(stderr, "Failed to open GLFW window\n"); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwSetKeyCallback(window, key_callback); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - - glMatrixMode(GL_PROJECTION); - glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); - glMatrixMode(GL_MODELVIEW); - - glClearColor(0.5f, 0.5f, 0.5f, 0); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - - glColor3f(0.8f, 0.2f, 0.4f); - glRectf(-0.5f, -0.5f, 0.5f, 0.5f); - - glfwSwapBuffers(window); - glfwWaitEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/cursor.c b/glfw/tests/cursor.c deleted file mode 100644 index 9b89926..0000000 --- a/glfw/tests/cursor.c +++ /dev/null @@ -1,289 +0,0 @@ -//======================================================================== -// Cursor & input mode tests -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// System cursors and input modes tests. -// -//======================================================================== - -#define GLFW_INCLUDE_GLU -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -static int W = 640; -static int H = 480; -static int delay = 0; - -static GLFWwindow* windows[2] = { NULL, NULL }; -static GLFWwindow* activeWindow = NULL; -static GLFWcursor* cursor = NULL; - -static struct -{ - int key; - double time; -} commands[] = { - {GLFW_KEY_H, 0}, - {GLFW_KEY_C, 0}, - {GLFW_KEY_D, 0}, - {GLFW_KEY_S, 0}, - {GLFW_KEY_N, 0}, - {GLFW_KEY_1, 0}, - {GLFW_KEY_2, 0}, - {GLFW_KEY_3, 0} -}; - -static int CommandCount = sizeof(commands) / sizeof(commands[0]); - -static struct -{ - int w, h; -} cursorSize[] = { - { 24, 24 }, { 13, 37 }, { 5, 53 }, { 43, 64 }, { 300, 300 } -}; - -static int SizeCount = sizeof(cursorSize) / sizeof(cursorSize[0]); -static int currentSize = 0; - -static void command_callback(int key) -{ - switch (key) - { - case GLFW_KEY_H: - { - printf("H: show this help\n"); - printf("C: call glfwCreateCursor()\n"); - printf("D: call glfwDestroyCursor()\n"); - printf("S: call glfwSetCursor()\n"); - printf("N: call glfwSetCursor() with NULL\n"); - printf("1: set GLFW_CURSOR_NORMAL\n"); - printf("2: set GLFW_CURSOR_HIDDEN\n"); - printf("3: set GLFW_CURSOR_DISABLED\n"); - printf("T: enable 3s delay for all previous commands\n"); - } - break; - - case GLFW_KEY_C: - { - int x, y; - GLFWimage image; - unsigned char* pixels; - - if (cursor) - break; - - image.width = cursorSize[currentSize].w; - image.height = cursorSize[currentSize].h; - - pixels = malloc(4 * image.width * image.height); - image.pixels = pixels; - - for (y = 0; y < image.height; y++) - { - for (x = 0; x < image.width; x++) - { - *pixels++ = 0xff; - *pixels++ = 0; - *pixels++ = 255 * y / image.height; - *pixels++ = 255 * x / image.width; - } - } - - cursor = glfwCreateCursor(&image, image.width / 2, image.height / 2); - currentSize = (currentSize + 1) % SizeCount; - free(image.pixels); - break; - } - - case GLFW_KEY_D: - { - if (cursor != NULL) - { - glfwDestroyCursor(cursor); - cursor = NULL; - } - - break; - } - - case GLFW_KEY_S: - { - if (cursor != NULL) - glfwSetCursor(activeWindow, cursor); - else - printf("The cursor is not created\n"); - - break; - } - - case GLFW_KEY_N: - glfwSetCursor(activeWindow, NULL); - break; - - case GLFW_KEY_1: - glfwSetInputMode(activeWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL); - break; - - case GLFW_KEY_2: - glfwSetInputMode(activeWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); - break; - - case GLFW_KEY_3: - glfwSetInputMode(activeWindow, GLFW_CURSOR, GLFW_CURSOR_DISABLED); - break; - } -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - W = width; - H = height; - - glViewport(0, 0, W, H); -} - -static void refresh_callback(GLFWwindow* window) -{ - glfwMakeContextCurrent(window); - glClearColor(0.0f, window == activeWindow ? 0.8f : 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(window); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GL_TRUE); - break; - - case GLFW_KEY_T: - delay = !delay; - printf("Delay %s.\n", delay ? "enabled" : "disabled"); - break; - - default: - { - if (delay) - { - int i = 0; - - while (i < CommandCount && commands[i].key != key) - i++; - - if (i < CommandCount) - commands[i].time = glfwGetTime(); - } - else - { - command_callback(key); - } - } - break; - } -} - -static void focus_callback(GLFWwindow* window, int focused) -{ - if (focused) - { - activeWindow = window; - refresh_callback(windows[0]); - refresh_callback(windows[1]); - } -} - -int main(void) -{ - int i; - GLboolean running = GL_TRUE; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - for (i = 0; i < 2; i++) - { - windows[i] = glfwCreateWindow(W, H, "Cursor testing", NULL, NULL); - - if (!windows[i]) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetWindowPos(windows[i], 100 + (i & 1) * (W + 50), 100); - - glfwSetWindowRefreshCallback(windows[i], refresh_callback); - glfwSetFramebufferSizeCallback(windows[i], framebuffer_size_callback); - glfwSetKeyCallback(windows[i], key_callback); - glfwSetWindowFocusCallback(windows[i], focus_callback); - - glfwMakeContextCurrent(windows[i]); - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(windows[i]); - } - - activeWindow = windows[0]; - - key_callback(NULL, GLFW_KEY_H, 0, GLFW_PRESS, 0); - - while (running) - { - if (delay) - { - int i; - double t = glfwGetTime(); - - for (i = 0; i < CommandCount; i++) - { - if (commands[i].time != 0 && t - commands[i].time >= 3.0) - { - command_callback(commands[i].key); - commands[i].time = 0; - } - } - } - - running = !(glfwWindowShouldClose(windows[0]) || glfwWindowShouldClose(windows[1])); - - glfwPollEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/cursoranim.c b/glfw/tests/cursoranim.c deleted file mode 100644 index 39a229c..0000000 --- a/glfw/tests/cursoranim.c +++ /dev/null @@ -1,135 +0,0 @@ -//======================================================================== -// Cursor animation -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// Cursor animation test. -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdlib.h> -#include <math.h> - -#ifdef min - #undef min -#endif -#ifdef max - #undef max -#endif - -#define SIZE 64 // cursor size (width & height) -#define N 60 // number of frames - -unsigned char buffer[4 * SIZE * SIZE]; - -static float max(float a, float b) { return a > b ? a : b; } -static float min(float a, float b) { return a < b ? a : b; } - -static float star(int x, int y, float t) -{ - float c = SIZE / 2.0f; - - float i = (0.25f * (float)sin(2.0f * 3.1415926f * t) + 0.75f); - float k = SIZE * 0.046875f * i; - - float dist = (float)sqrt((x - c) * (x - c) + (y - c) * (y - c)); - - float salpha = 1.0f - dist / c; - float xalpha = (float)x == c ? c : k / (float)fabs(x - c); - float yalpha = (float)y == c ? c : k / (float)fabs(y - c); - - return max(0.0f, min(1.0f, i * salpha * 0.2f + salpha * xalpha * yalpha)); -} - -static GLFWcursor* load_frame(float t) -{ - int i = 0, x, y; - const GLFWimage image = { SIZE, SIZE, buffer }; - - for (y = 0; y < image.width; y++) - { - for (x = 0; x < image.height; x++) - { - buffer[i++] = 255; - buffer[i++] = 255; - buffer[i++] = 255; - buffer[i++] = (unsigned char)(255 * star(x, y, t)); - } - } - - return glfwCreateCursor(&image, image.width / 2, image.height / 2); -} - -int main(void) -{ - int i; - double t0, t1, frameTime = 0.0; - - GLFWwindow* window; - GLFWcursor* frames[N]; - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(640, 480, "Cursor animation", NULL, NULL); - - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - for (i = 0; i < N; i++) - frames[i] = load_frame(i / (float)N); - - i = 0; - - t0 = glfwGetTime(); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - glfwSetCursor(window, frames[i]); - glfwSwapBuffers(window); - glfwPollEvents(); - - t1 = glfwGetTime(); - frameTime += t1 - t0; - t0 = t1; - - while (frameTime > 1.0 / (double)N) - { - i = (i + 1) % N; - frameTime -= 1.0 / (double)N; - } - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/defaults.c b/glfw/tests/defaults.c deleted file mode 100644 index 2d48354..0000000 --- a/glfw/tests/defaults.c +++ /dev/null @@ -1,131 +0,0 @@ -//======================================================================== -// Default window/context test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test creates a windowed mode window with all window hints set to -// default values and then reports the actual attributes of the created -// window and context -// -//======================================================================== - -#include <GLFW/glfw3.h> -#include <GL/glext.h> - -#include <stdio.h> -#include <stdlib.h> - -typedef struct -{ - int attrib; - const char* ext; - const char* name; -} AttribGL; - -typedef struct -{ - int attrib; - const char* name; -} AttribGLFW; - -static AttribGL gl_attribs[] = -{ - { GL_RED_BITS, NULL, "red bits" }, - { GL_GREEN_BITS, NULL, "green bits" }, - { GL_BLUE_BITS, NULL, "blue bits" }, - { GL_ALPHA_BITS, NULL, "alpha bits" }, - { GL_DEPTH_BITS, NULL, "depth bits" }, - { GL_STENCIL_BITS, NULL, "stencil bits" }, - { GL_STEREO, NULL, "stereo" }, - { GL_SAMPLES_ARB, "GL_ARB_multisample", "FSAA samples" }, - { 0, NULL, NULL } -}; - -static AttribGLFW glfw_attribs[] = -{ - { GLFW_CONTEXT_VERSION_MAJOR, "Context version major" }, - { GLFW_CONTEXT_VERSION_MINOR, "Context version minor" }, - { GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" }, - { GLFW_OPENGL_DEBUG_CONTEXT, "OpenGL debug context" }, - { GLFW_OPENGL_PROFILE, "OpenGL profile" }, - { 0, NULL } -}; - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -int main(void) -{ - int i, width, height; - GLFWwindow* window; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - - window = glfwCreateWindow(640, 480, "Defaults", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - glfwGetFramebufferSize(window, &width, &height); - - printf("framebuffer size: %ix%i\n", width, height); - - for (i = 0; glfw_attribs[i].name; i++) - { - printf("%s: %i\n", - glfw_attribs[i].name, - glfwGetWindowAttrib(window, glfw_attribs[i].attrib)); - } - - for (i = 0; gl_attribs[i].name; i++) - { - GLint value = 0; - - if (gl_attribs[i].ext) - { - if (!glfwExtensionSupported(gl_attribs[i].ext)) - continue; - } - - glGetIntegerv(gl_attribs[i].attrib, &value); - - printf("%s: %i\n", gl_attribs[i].name, value); - } - - glfwDestroyWindow(window); - window = NULL; - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/empty.c b/glfw/tests/empty.c deleted file mode 100644 index a4534ae..0000000 --- a/glfw/tests/empty.c +++ /dev/null @@ -1,129 +0,0 @@ -//======================================================================== -// Empty event test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test is intended to verify that posting of empty events works -// -//======================================================================== - -#include "tinycthread.h" - -#include <GLFW/glfw3.h> - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> - -static volatile GLboolean running = GL_TRUE; - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static int thread_main(void* data) -{ - struct timespec time; - - while (running) - { - clock_gettime(CLOCK_REALTIME, &time); - time.tv_sec += 1; - thrd_sleep(&time, NULL); - - glfwPostEmptyEvent(); - } - - return 0; -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) - glfwSetWindowShouldClose(window, GL_TRUE); -} - -static float nrand(void) -{ - return (float) rand() / (float) RAND_MAX; -} - -int main(void) -{ - int result; - thrd_t thread; - GLFWwindow* window; - - srand((unsigned int) time(NULL)); - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(640, 480, "Empty Event Test", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - glfwSetKeyCallback(window, key_callback); - - if (thrd_create(&thread, thread_main, NULL) != thrd_success) - { - fprintf(stderr, "Failed to create secondary thread\n"); - - glfwTerminate(); - exit(EXIT_FAILURE); - } - - while (running) - { - int width, height; - float r = nrand(), g = nrand(), b = nrand(); - float l = (float) sqrt(r * r + g * g + b * b); - - glfwGetFramebufferSize(window, &width, &height); - - glViewport(0, 0, width, height); - glClearColor(r / l, g / l, b / l, 1.f); - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(window); - - glfwWaitEvents(); - - if (glfwWindowShouldClose(window)) - running = GL_FALSE; - } - - glfwHideWindow(window); - thrd_join(thread, &result); - glfwDestroyWindow(window); - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/events.c b/glfw/tests/events.c deleted file mode 100644 index 7f30652..0000000 --- a/glfw/tests/events.c +++ /dev/null @@ -1,581 +0,0 @@ -//======================================================================== -// Event linter (event spewer) -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test hooks every available callback and outputs their arguments -// -// Log messages go to stdout, error messages to stderr -// -// Every event also gets a (sequential) number to aid discussion of logs -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> -#include <locale.h> - -#include "getopt.h" - -// Event index -static unsigned int counter = 0; - -typedef struct -{ - GLFWwindow* window; - int number; - int closeable; -} Slot; - -static void usage(void) -{ - printf("Usage: events [-f] [-h] [-n WINDOWS]\n"); - printf("Options:\n"); - printf(" -f use full screen\n"); - printf(" -h show this help\n"); - printf(" -n the number of windows to create\n"); -} - -static const char* get_key_name(int key) -{ - switch (key) - { - // Printable keys - case GLFW_KEY_A: return "A"; - case GLFW_KEY_B: return "B"; - case GLFW_KEY_C: return "C"; - case GLFW_KEY_D: return "D"; - case GLFW_KEY_E: return "E"; - case GLFW_KEY_F: return "F"; - case GLFW_KEY_G: return "G"; - case GLFW_KEY_H: return "H"; - case GLFW_KEY_I: return "I"; - case GLFW_KEY_J: return "J"; - case GLFW_KEY_K: return "K"; - case GLFW_KEY_L: return "L"; - case GLFW_KEY_M: return "M"; - case GLFW_KEY_N: return "N"; - case GLFW_KEY_O: return "O"; - case GLFW_KEY_P: return "P"; - case GLFW_KEY_Q: return "Q"; - case GLFW_KEY_R: return "R"; - case GLFW_KEY_S: return "S"; - case GLFW_KEY_T: return "T"; - case GLFW_KEY_U: return "U"; - case GLFW_KEY_V: return "V"; - case GLFW_KEY_W: return "W"; - case GLFW_KEY_X: return "X"; - case GLFW_KEY_Y: return "Y"; - case GLFW_KEY_Z: return "Z"; - case GLFW_KEY_1: return "1"; - case GLFW_KEY_2: return "2"; - case GLFW_KEY_3: return "3"; - case GLFW_KEY_4: return "4"; - case GLFW_KEY_5: return "5"; - case GLFW_KEY_6: return "6"; - case GLFW_KEY_7: return "7"; - case GLFW_KEY_8: return "8"; - case GLFW_KEY_9: return "9"; - case GLFW_KEY_0: return "0"; - case GLFW_KEY_SPACE: return "SPACE"; - case GLFW_KEY_MINUS: return "MINUS"; - case GLFW_KEY_EQUAL: return "EQUAL"; - case GLFW_KEY_LEFT_BRACKET: return "LEFT BRACKET"; - case GLFW_KEY_RIGHT_BRACKET: return "RIGHT BRACKET"; - case GLFW_KEY_BACKSLASH: return "BACKSLASH"; - case GLFW_KEY_SEMICOLON: return "SEMICOLON"; - case GLFW_KEY_APOSTROPHE: return "APOSTROPHE"; - case GLFW_KEY_GRAVE_ACCENT: return "GRAVE ACCENT"; - case GLFW_KEY_COMMA: return "COMMA"; - case GLFW_KEY_PERIOD: return "PERIOD"; - case GLFW_KEY_SLASH: return "SLASH"; - case GLFW_KEY_WORLD_1: return "WORLD 1"; - case GLFW_KEY_WORLD_2: return "WORLD 2"; - - // Function keys - case GLFW_KEY_ESCAPE: return "ESCAPE"; - case GLFW_KEY_F1: return "F1"; - case GLFW_KEY_F2: return "F2"; - case GLFW_KEY_F3: return "F3"; - case GLFW_KEY_F4: return "F4"; - case GLFW_KEY_F5: return "F5"; - case GLFW_KEY_F6: return "F6"; - case GLFW_KEY_F7: return "F7"; - case GLFW_KEY_F8: return "F8"; - case GLFW_KEY_F9: return "F9"; - case GLFW_KEY_F10: return "F10"; - case GLFW_KEY_F11: return "F11"; - case GLFW_KEY_F12: return "F12"; - case GLFW_KEY_F13: return "F13"; - case GLFW_KEY_F14: return "F14"; - case GLFW_KEY_F15: return "F15"; - case GLFW_KEY_F16: return "F16"; - case GLFW_KEY_F17: return "F17"; - case GLFW_KEY_F18: return "F18"; - case GLFW_KEY_F19: return "F19"; - case GLFW_KEY_F20: return "F20"; - case GLFW_KEY_F21: return "F21"; - case GLFW_KEY_F22: return "F22"; - case GLFW_KEY_F23: return "F23"; - case GLFW_KEY_F24: return "F24"; - case GLFW_KEY_F25: return "F25"; - case GLFW_KEY_UP: return "UP"; - case GLFW_KEY_DOWN: return "DOWN"; - case GLFW_KEY_LEFT: return "LEFT"; - case GLFW_KEY_RIGHT: return "RIGHT"; - case GLFW_KEY_LEFT_SHIFT: return "LEFT SHIFT"; - case GLFW_KEY_RIGHT_SHIFT: return "RIGHT SHIFT"; - case GLFW_KEY_LEFT_CONTROL: return "LEFT CONTROL"; - case GLFW_KEY_RIGHT_CONTROL: return "RIGHT CONTROL"; - case GLFW_KEY_LEFT_ALT: return "LEFT ALT"; - case GLFW_KEY_RIGHT_ALT: return "RIGHT ALT"; - case GLFW_KEY_TAB: return "TAB"; - case GLFW_KEY_ENTER: return "ENTER"; - case GLFW_KEY_BACKSPACE: return "BACKSPACE"; - case GLFW_KEY_INSERT: return "INSERT"; - case GLFW_KEY_DELETE: return "DELETE"; - case GLFW_KEY_PAGE_UP: return "PAGE UP"; - case GLFW_KEY_PAGE_DOWN: return "PAGE DOWN"; - case GLFW_KEY_HOME: return "HOME"; - case GLFW_KEY_END: return "END"; - case GLFW_KEY_KP_0: return "KEYPAD 0"; - case GLFW_KEY_KP_1: return "KEYPAD 1"; - case GLFW_KEY_KP_2: return "KEYPAD 2"; - case GLFW_KEY_KP_3: return "KEYPAD 3"; - case GLFW_KEY_KP_4: return "KEYPAD 4"; - case GLFW_KEY_KP_5: return "KEYPAD 5"; - case GLFW_KEY_KP_6: return "KEYPAD 6"; - case GLFW_KEY_KP_7: return "KEYPAD 7"; - case GLFW_KEY_KP_8: return "KEYPAD 8"; - case GLFW_KEY_KP_9: return "KEYPAD 9"; - case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE"; - case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY"; - case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT"; - case GLFW_KEY_KP_ADD: return "KEYPAD ADD"; - case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL"; - case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL"; - case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER"; - case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN"; - case GLFW_KEY_NUM_LOCK: return "NUM LOCK"; - case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK"; - case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK"; - case GLFW_KEY_PAUSE: return "PAUSE"; - case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER"; - case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER"; - case GLFW_KEY_MENU: return "MENU"; - - default: return "UNKNOWN"; - } -} - -static const char* get_action_name(int action) -{ - switch (action) - { - case GLFW_PRESS: - return "pressed"; - case GLFW_RELEASE: - return "released"; - case GLFW_REPEAT: - return "repeated"; - } - - return "caused unknown action"; -} - -static const char* get_button_name(int button) -{ - switch (button) - { - case GLFW_MOUSE_BUTTON_LEFT: - return "left"; - case GLFW_MOUSE_BUTTON_RIGHT: - return "right"; - case GLFW_MOUSE_BUTTON_MIDDLE: - return "middle"; - default: - { - static char name[16]; - sprintf(name, "%i", button); - return name; - } - } -} - -static const char* get_mods_name(int mods) -{ - static char name[512]; - - if (mods == 0) - return " no mods"; - - name[0] = '\0'; - - if (mods & GLFW_MOD_SHIFT) - strcat(name, " shift"); - if (mods & GLFW_MOD_CONTROL) - strcat(name, " control"); - if (mods & GLFW_MOD_ALT) - strcat(name, " alt"); - if (mods & GLFW_MOD_SUPER) - strcat(name, " super"); - - return name; -} - -static const char* get_character_string(int codepoint) -{ - // This assumes UTF-8, which is stupid - static char result[6 + 1]; - - int length = wctomb(result, codepoint); - if (length == -1) - length = 0; - - result[length] = '\0'; - return result; -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void window_pos_callback(GLFWwindow* window, int x, int y) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Window position: %i %i\n", - counter++, slot->number, glfwGetTime(), x, y); -} - -static void window_size_callback(GLFWwindow* window, int width, int height) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Window size: %i %i\n", - counter++, slot->number, glfwGetTime(), width, height); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Framebuffer size: %i %i\n", - counter++, slot->number, glfwGetTime(), width, height); - - glViewport(0, 0, width, height); -} - -static void window_close_callback(GLFWwindow* window) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Window close\n", - counter++, slot->number, glfwGetTime()); - - glfwSetWindowShouldClose(window, slot->closeable); -} - -static void window_refresh_callback(GLFWwindow* window) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Window refresh\n", - counter++, slot->number, glfwGetTime()); - - glfwMakeContextCurrent(window); - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(window); -} - -static void window_focus_callback(GLFWwindow* window, int focused) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Window %s\n", - counter++, slot->number, glfwGetTime(), - focused ? "focused" : "defocused"); -} - -static void window_iconify_callback(GLFWwindow* window, int iconified) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Window was %s\n", - counter++, slot->number, glfwGetTime(), - iconified ? "iconified" : "restored"); -} - -static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Mouse button %i (%s) (with%s) was %s\n", - counter++, slot->number, glfwGetTime(), button, - get_button_name(button), - get_mods_name(mods), - get_action_name(action)); -} - -static void cursor_position_callback(GLFWwindow* window, double x, double y) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Cursor position: %f %f\n", - counter++, slot->number, glfwGetTime(), x, y); -} - -static void cursor_enter_callback(GLFWwindow* window, int entered) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Cursor %s window\n", - counter++, slot->number, glfwGetTime(), - entered ? "entered" : "left"); -} - -static void scroll_callback(GLFWwindow* window, double x, double y) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Scroll: %0.3f %0.3f\n", - counter++, slot->number, glfwGetTime(), x, y); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - Slot* slot = glfwGetWindowUserPointer(window); - - printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n", - counter++, slot->number, glfwGetTime(), key, scancode, - get_key_name(key), - get_mods_name(mods), - get_action_name(action)); - - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_C: - { - slot->closeable = !slot->closeable; - - printf("(( closing %s ))\n", slot->closeable ? "enabled" : "disabled"); - break; - } - } -} - -static void char_callback(GLFWwindow* window, unsigned int codepoint) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n", - counter++, slot->number, glfwGetTime(), codepoint, - get_character_string(codepoint)); -} - -static void char_mods_callback(GLFWwindow* window, unsigned int codepoint, int mods) -{ - Slot* slot = glfwGetWindowUserPointer(window); - printf("%08x to %i at %0.3f: Character with modifiers 0x%08x (%s) (with%s) input\n", - counter++, slot->number, glfwGetTime(), codepoint, - get_character_string(codepoint), - get_mods_name(mods)); -} - -static void drop_callback(GLFWwindow* window, int count, const char** names) -{ - int i; - Slot* slot = glfwGetWindowUserPointer(window); - - printf("%08x to %i at %0.3f: Drop input\n", - counter++, slot->number, glfwGetTime()); - - for (i = 0; i < count; i++) - printf(" %i: \"%s\"\n", i, names[i]); -} - -static void monitor_callback(GLFWmonitor* monitor, int event) -{ - if (event == GLFW_CONNECTED) - { - int x, y, widthMM, heightMM; - const GLFWvidmode* mode = glfwGetVideoMode(monitor); - - glfwGetMonitorPos(monitor, &x, &y); - glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); - - printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n", - counter++, - glfwGetTime(), - glfwGetMonitorName(monitor), - mode->width, mode->height, - x, y, - widthMM, heightMM); - } - else - { - printf("%08x at %0.3f: Monitor %s was disconnected\n", - counter++, - glfwGetTime(), - glfwGetMonitorName(monitor)); - } -} - -int main(int argc, char** argv) -{ - Slot* slots; - GLFWmonitor* monitor = NULL; - int ch, i, width, height, count = 1; - - setlocale(LC_ALL, ""); - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - printf("Library initialized\n"); - - glfwSetMonitorCallback(monitor_callback); - - while ((ch = getopt(argc, argv, "hfn:")) != -1) - { - switch (ch) - { - case 'h': - usage(); - exit(EXIT_SUCCESS); - - case 'f': - monitor = glfwGetPrimaryMonitor(); - break; - - case 'n': - count = (int) strtol(optarg, NULL, 10); - break; - - default: - usage(); - exit(EXIT_FAILURE); - } - } - - if (monitor) - { - const GLFWvidmode* mode = glfwGetVideoMode(monitor); - - glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); - glfwWindowHint(GLFW_RED_BITS, mode->redBits); - glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); - glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); - - width = mode->width; - height = mode->height; - } - else - { - width = 640; - height = 480; - } - - if (!count) - { - fprintf(stderr, "Invalid user\n"); - exit(EXIT_FAILURE); - } - - slots = calloc(count, sizeof(Slot)); - - for (i = 0; i < count; i++) - { - char title[128]; - - slots[i].closeable = GL_TRUE; - slots[i].number = i + 1; - - sprintf(title, "Event Linter (Window %i)", slots[i].number); - - if (monitor) - { - printf("Creating full screen window %i (%ix%i on %s)\n", - slots[i].number, - width, height, - glfwGetMonitorName(monitor)); - } - else - { - printf("Creating windowed mode window %i (%ix%i)\n", - slots[i].number, - width, height); - } - - slots[i].window = glfwCreateWindow(width, height, title, monitor, NULL); - if (!slots[i].window) - { - free(slots); - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetWindowUserPointer(slots[i].window, slots + i); - - glfwSetWindowPosCallback(slots[i].window, window_pos_callback); - glfwSetWindowSizeCallback(slots[i].window, window_size_callback); - glfwSetFramebufferSizeCallback(slots[i].window, framebuffer_size_callback); - glfwSetWindowCloseCallback(slots[i].window, window_close_callback); - glfwSetWindowRefreshCallback(slots[i].window, window_refresh_callback); - glfwSetWindowFocusCallback(slots[i].window, window_focus_callback); - glfwSetWindowIconifyCallback(slots[i].window, window_iconify_callback); - glfwSetMouseButtonCallback(slots[i].window, mouse_button_callback); - glfwSetCursorPosCallback(slots[i].window, cursor_position_callback); - glfwSetCursorEnterCallback(slots[i].window, cursor_enter_callback); - glfwSetScrollCallback(slots[i].window, scroll_callback); - glfwSetKeyCallback(slots[i].window, key_callback); - glfwSetCharCallback(slots[i].window, char_callback); - glfwSetCharModsCallback(slots[i].window, char_mods_callback); - glfwSetDropCallback(slots[i].window, drop_callback); - - glfwMakeContextCurrent(slots[i].window); - glfwSwapInterval(1); - } - - printf("Main loop starting\n"); - - for (;;) - { - for (i = 0; i < count; i++) - { - if (glfwWindowShouldClose(slots[i].window)) - break; - } - - if (i < count) - break; - - glfwWaitEvents(); - - // Workaround for an issue with msvcrt and mintty - fflush(stdout); - } - - free(slots); - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/fsaa.c b/glfw/tests/fsaa.c deleted file mode 100644 index 459b711..0000000 --- a/glfw/tests/fsaa.c +++ /dev/null @@ -1,157 +0,0 @@ -//======================================================================== -// Fullscreen anti-aliasing test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test renders two high contrast, slowly rotating quads, one aliased -// and one (hopefully) anti-aliased, thus allowing for visual verification -// of whether FSAA is indeed enabled -// -//======================================================================== - -#include <GLFW/glfw3.h> -#include <GL/glext.h> - -#include <stdio.h> -#include <stdlib.h> - -#include "getopt.h" - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_SPACE: - glfwSetTime(0.0); - break; - } -} - -static void usage(void) -{ - printf("Usage: fsaa [-h] [-s SAMPLES]\n"); -} - -int main(int argc, char** argv) -{ - int ch, samples = 4; - GLFWwindow* window; - - while ((ch = getopt(argc, argv, "hs:")) != -1) - { - switch (ch) - { - case 'h': - usage(); - exit(EXIT_SUCCESS); - case 's': - samples = atoi(optarg); - break; - default: - usage(); - exit(EXIT_FAILURE); - } - } - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - if (samples) - printf("Requesting FSAA with %i samples\n", samples); - else - printf("Requesting that FSAA not be available\n"); - - glfwWindowHint(GLFW_SAMPLES, samples); - - window = glfwCreateWindow(800, 400, "Aliasing Detector", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetKeyCallback(window, key_callback); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - if (!glfwExtensionSupported("GL_ARB_multisample")) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glGetIntegerv(GL_SAMPLES_ARB, &samples); - if (samples) - printf("Context reports FSAA is available with %i samples\n", samples); - else - printf("Context reports FSAA is unavailable\n"); - - glMatrixMode(GL_PROJECTION); - glOrtho(0.f, 1.f, 0.f, 0.5f, 0.f, 1.f); - glMatrixMode(GL_MODELVIEW); - - while (!glfwWindowShouldClose(window)) - { - GLfloat time = (GLfloat) glfwGetTime(); - - glClear(GL_COLOR_BUFFER_BIT); - - glLoadIdentity(); - glTranslatef(0.25f, 0.25f, 0.f); - glRotatef(time, 0.f, 0.f, 1.f); - - glDisable(GL_MULTISAMPLE_ARB); - glRectf(-0.15f, -0.15f, 0.15f, 0.15f); - - glLoadIdentity(); - glTranslatef(0.75f, 0.25f, 0.f); - glRotatef(time, 0.f, 0.f, 1.f); - - glEnable(GL_MULTISAMPLE_ARB); - glRectf(-0.15f, -0.15f, 0.15f, 0.15f); - - glfwSwapBuffers(window); - glfwPollEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/gamma.c b/glfw/tests/gamma.c deleted file mode 100644 index c67e128..0000000 --- a/glfw/tests/gamma.c +++ /dev/null @@ -1,181 +0,0 @@ -//======================================================================== -// Gamma correction test program -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This program is used to test the gamma correction functionality for -// both fullscreen and windowed mode windows -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -#include "getopt.h" - -#define STEP_SIZE 0.1f - -static GLfloat gamma_value = 1.0f; - -static void usage(void) -{ - printf("Usage: gamma [-h] [-f]\n"); -} - -static void set_gamma(GLFWwindow* window, float value) -{ - GLFWmonitor* monitor = glfwGetWindowMonitor(window); - if (!monitor) - monitor = glfwGetPrimaryMonitor(); - - gamma_value = value; - printf("Gamma: %f\n", gamma_value); - glfwSetGamma(monitor, gamma_value); -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_ESCAPE: - { - glfwSetWindowShouldClose(window, GL_TRUE); - break; - } - - case GLFW_KEY_KP_ADD: - case GLFW_KEY_Q: - { - set_gamma(window, gamma_value + STEP_SIZE); - break; - } - - case GLFW_KEY_KP_SUBTRACT: - case GLFW_KEY_W: - { - if (gamma_value - STEP_SIZE > 0.f) - set_gamma(window, gamma_value - STEP_SIZE); - - break; - } - } -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -int main(int argc, char** argv) -{ - int width, height, ch; - GLFWmonitor* monitor = NULL; - GLFWwindow* window; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - while ((ch = getopt(argc, argv, "fh")) != -1) - { - switch (ch) - { - case 'h': - usage(); - exit(EXIT_SUCCESS); - - case 'f': - monitor = glfwGetPrimaryMonitor(); - break; - - default: - usage(); - exit(EXIT_FAILURE); - } - } - - if (monitor) - { - const GLFWvidmode* mode = glfwGetVideoMode(monitor); - - glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); - glfwWindowHint(GLFW_RED_BITS, mode->redBits); - glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); - glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); - - width = mode->width; - height = mode->height; - } - else - { - width = 200; - height = 200; - } - - window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - set_gamma(window, 1.f); - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwSetKeyCallback(window, key_callback); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - - glMatrixMode(GL_PROJECTION); - glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); - glMatrixMode(GL_MODELVIEW); - - glClearColor(0.5f, 0.5f, 0.5f, 0); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - - glColor3f(0.8f, 0.2f, 0.4f); - glRectf(-0.5f, -0.5f, 0.5f, 0.5f); - - glfwSwapBuffers(window); - glfwWaitEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/glfwinfo.c b/glfw/tests/glfwinfo.c deleted file mode 100644 index dcf5353..0000000 --- a/glfw/tests/glfwinfo.c +++ /dev/null @@ -1,429 +0,0 @@ -//======================================================================== -// Version information dumper -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test is a pale imitation of glxinfo(1), except not really -// -// It dumps GLFW and OpenGL version information -// -//======================================================================== - -#include <GLFW/glfw3.h> -#include <GL/glext.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "getopt.h" - -#ifdef _MSC_VER -#define strcasecmp(x, y) _stricmp(x, y) -#endif - -#define API_OPENGL "gl" -#define API_OPENGL_ES "es" - -#define PROFILE_NAME_CORE "core" -#define PROFILE_NAME_COMPAT "compat" - -#define STRATEGY_NAME_NONE "none" -#define STRATEGY_NAME_LOSE "lose" - -#define BEHAVIOR_NAME_NONE "none" -#define BEHAVIOR_NAME_FLUSH "flush" - -static void usage(void) -{ - printf("Usage: glfwinfo [-h] [-a API] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-s STRATEGY] [-b BEHAVIOR]\n"); - printf("Options:\n"); - printf(" -a the client API to use (" API_OPENGL " or " API_OPENGL_ES ")\n"); - printf(" -b the release behavior to use (" BEHAVIOR_NAME_NONE " or " BEHAVIOR_NAME_FLUSH ")\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(" -s the robustness strategy to use (" STRATEGY_NAME_NONE " or " STRATEGY_NAME_LOSE ")\n"); -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static const char* get_client_api_name(int api) -{ - if (api == GLFW_OPENGL_API) - return "OpenGL"; - else if (api == GLFW_OPENGL_ES_API) - return "OpenGL ES"; - - return "Unknown API"; -} - -static const char* get_profile_name_gl(GLint mask) -{ - if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) - return PROFILE_NAME_COMPAT; - if (mask & GL_CONTEXT_CORE_PROFILE_BIT) - return PROFILE_NAME_CORE; - - return "unknown"; -} - -static const char* get_profile_name_glfw(int profile) -{ - if (profile == GLFW_OPENGL_COMPAT_PROFILE) - return PROFILE_NAME_COMPAT; - if (profile == GLFW_OPENGL_CORE_PROFILE) - return PROFILE_NAME_CORE; - - return "unknown"; -} - -static const char* get_strategy_name_gl(GLint strategy) -{ - if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB) - return STRATEGY_NAME_LOSE; - if (strategy == GL_NO_RESET_NOTIFICATION_ARB) - return STRATEGY_NAME_NONE; - - return "unknown"; -} - -static const char* get_strategy_name_glfw(int strategy) -{ - if (strategy == GLFW_LOSE_CONTEXT_ON_RESET) - return STRATEGY_NAME_LOSE; - if (strategy == GLFW_NO_RESET_NOTIFICATION) - return STRATEGY_NAME_NONE; - - return "unknown"; -} - -static void list_extensions(int api, int major, int minor) -{ - int i; - GLint count; - const GLubyte* extensions; - - printf("%s context supported extensions:\n", get_client_api_name(api)); - - if (api == GLFW_OPENGL_API && major > 2) - { - PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi"); - if (!glGetStringi) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glGetIntegerv(GL_NUM_EXTENSIONS, &count); - - for (i = 0; i < count; i++) - puts((const char*) glGetStringi(GL_EXTENSIONS, i)); - } - else - { - extensions = glGetString(GL_EXTENSIONS); - while (*extensions != '\0') - { - if (*extensions == ' ') - putchar('\n'); - else - putchar(*extensions); - - extensions++; - } - } - - putchar('\n'); -} - -static GLboolean valid_version(void) -{ - int major, minor, revision; - - glfwGetVersion(&major, &minor, &revision); - - printf("GLFW header version: %u.%u.%u\n", - GLFW_VERSION_MAJOR, - GLFW_VERSION_MINOR, - GLFW_VERSION_REVISION); - - printf("GLFW library version: %u.%u.%u\n", major, minor, revision); - - if (major != GLFW_VERSION_MAJOR) - { - printf("*** ERROR: GLFW major version mismatch! ***\n"); - return GL_FALSE; - } - - if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION) - printf("*** WARNING: GLFW version mismatch! ***\n"); - - printf("GLFW library version string: \"%s\"\n", glfwGetVersionString()); - return GL_TRUE; -} - -int main(int argc, char** argv) -{ - int ch, api = 0, profile = 0, strategy = 0, behavior = 0, major = 1, minor = 0, revision; - GLboolean debug = GL_FALSE, forward = GL_FALSE, list = GL_FALSE; - GLint flags, mask; - GLFWwindow* window; - - while ((ch = getopt(argc, argv, "a:b:dfhlm:n:p:s:")) != -1) - { - switch (ch) - { - case 'a': - if (strcasecmp(optarg, API_OPENGL) == 0) - api = GLFW_OPENGL_API; - else if (strcasecmp(optarg, API_OPENGL_ES) == 0) - api = GLFW_OPENGL_ES_API; - else - { - usage(); - exit(EXIT_FAILURE); - } - break; - case 'b': - if (strcasecmp(optarg, BEHAVIOR_NAME_NONE) == 0) - behavior = GLFW_RELEASE_BEHAVIOR_NONE; - else if (strcasecmp(optarg, BEHAVIOR_NAME_FLUSH) == 0) - behavior = GLFW_RELEASE_BEHAVIOR_FLUSH; - else - { - usage(); - exit(EXIT_FAILURE); - } - break; - case 'd': - debug = GL_TRUE; - break; - case 'f': - forward = GL_TRUE; - break; - case 'h': - usage(); - exit(EXIT_SUCCESS); - case 'l': - list = GL_TRUE; - break; - case 'm': - major = atoi(optarg); - break; - case 'n': - minor = atoi(optarg); - break; - case 'p': - if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0) - profile = GLFW_OPENGL_CORE_PROFILE; - else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0) - profile = GLFW_OPENGL_COMPAT_PROFILE; - else - { - usage(); - exit(EXIT_FAILURE); - } - break; - case 's': - if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0) - strategy = GLFW_NO_RESET_NOTIFICATION; - else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0) - strategy = GLFW_LOSE_CONTEXT_ON_RESET; - else - { - usage(); - exit(EXIT_FAILURE); - } - break; - default: - usage(); - exit(EXIT_FAILURE); - } - } - - // Initialize GLFW and create window - - if (!valid_version()) - exit(EXIT_FAILURE); - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - if (major != 1 || minor != 0) - { - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor); - } - - if (api != 0) - glfwWindowHint(GLFW_CLIENT_API, api); - - if (debug) - glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); - - if (forward) - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - - if (profile != 0) - glfwWindowHint(GLFW_OPENGL_PROFILE, profile); - - if (strategy) - glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS, strategy); - - if (behavior) - glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR, behavior); - - glfwWindowHint(GLFW_RED_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_GREEN_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_BLUE_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_ALPHA_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_DEPTH_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_STENCIL_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_ACCUM_RED_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_ACCUM_GREEN_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_ACCUM_BLUE_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_AUX_BUFFERS, GLFW_DONT_CARE); - glfwWindowHint(GLFW_SAMPLES, GLFW_DONT_CARE); - glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_DONT_CARE); - - glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - - window = glfwCreateWindow(200, 200, "Version", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - - // Report client API version - - api = glfwGetWindowAttrib(window, GLFW_CLIENT_API); - major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); - minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); - revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION); - - printf("%s context version string: \"%s\"\n", - get_client_api_name(api), - glGetString(GL_VERSION)); - - printf("%s context version parsed by GLFW: %u.%u.%u\n", - get_client_api_name(api), - major, minor, revision); - - // Report client API context properties - - if (api == GLFW_OPENGL_API) - { - if (major >= 3) - { - glGetIntegerv(GL_CONTEXT_FLAGS, &flags); - printf("%s context flags (0x%08x):", get_client_api_name(api), flags); - - if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) - printf(" forward-compatible"); - if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) - printf(" debug"); - if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) - printf(" robustness"); - putchar('\n'); - - printf("%s context flags parsed by GLFW:", get_client_api_name(api)); - - if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT)) - printf(" forward-compatible"); - if (glfwGetWindowAttrib(window, GLFW_OPENGL_DEBUG_CONTEXT)) - printf(" debug"); - if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) != GLFW_NO_ROBUSTNESS) - printf(" robustness"); - putchar('\n'); - } - - if (major > 3 || (major == 3 && minor >= 2)) - { - int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE); - - glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); - printf("%s profile mask (0x%08x): %s\n", - get_client_api_name(api), - mask, - get_profile_name_gl(mask)); - - printf("%s profile mask parsed by GLFW: %s\n", - get_client_api_name(api), - get_profile_name_glfw(profile)); - } - - if (glfwExtensionSupported("GL_ARB_robustness")) - { - int robustness; - GLint strategy; - glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy); - - printf("%s robustness strategy (0x%08x): %s\n", - get_client_api_name(api), - strategy, - get_strategy_name_gl(strategy)); - - robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS); - - printf("%s robustness strategy parsed by GLFW: %s\n", - get_client_api_name(api), - get_strategy_name_glfw(robustness)); - } - } - - printf("%s context renderer string: \"%s\"\n", - get_client_api_name(api), - glGetString(GL_RENDERER)); - printf("%s context vendor string: \"%s\"\n", - get_client_api_name(api), - glGetString(GL_VENDOR)); - - if (major > 1) - { - printf("%s context shading language version: \"%s\"\n", - get_client_api_name(api), - glGetString(GL_SHADING_LANGUAGE_VERSION)); - } - - // Report client API extensions - if (list) - list_extensions(api, major, minor); - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/iconify.c b/glfw/tests/iconify.c deleted file mode 100644 index 3cdfd07..0000000 --- a/glfw/tests/iconify.c +++ /dev/null @@ -1,182 +0,0 @@ -//======================================================================== -// Iconify/restore test program -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This program is used to test the iconify/restore functionality for -// both fullscreen and windowed mode windows -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -#include "getopt.h" - -static void usage(void) -{ - printf("Usage: iconify [-h] [-f]\n"); -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - printf("%0.2f Key %s\n", - glfwGetTime(), - action == GLFW_PRESS ? "pressed" : "released"); - - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_SPACE: - glfwIconifyWindow(window); - break; - case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GL_TRUE); - break; - } -} - -static void window_size_callback(GLFWwindow* window, int width, int height) -{ - printf("%0.2f Window resized to %ix%i\n", glfwGetTime(), width, height); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - printf("%0.2f Framebuffer resized to %ix%i\n", glfwGetTime(), width, height); - - glViewport(0, 0, width, height); -} - -static void window_focus_callback(GLFWwindow* window, int focused) -{ - printf("%0.2f Window %s\n", - glfwGetTime(), - focused ? "focused" : "defocused"); -} - -static void window_iconify_callback(GLFWwindow* window, int iconified) -{ - printf("%0.2f Window %s\n", - glfwGetTime(), - iconified ? "iconified" : "restored"); -} - -int main(int argc, char** argv) -{ - int width, height, ch; - GLFWmonitor* monitor = NULL; - GLFWwindow* window; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - while ((ch = getopt(argc, argv, "fh")) != -1) - { - switch (ch) - { - case 'h': - usage(); - exit(EXIT_SUCCESS); - - case 'f': - monitor = glfwGetPrimaryMonitor(); - break; - - default: - usage(); - exit(EXIT_FAILURE); - } - } - - if (monitor) - { - const GLFWvidmode* mode = glfwGetVideoMode(monitor); - - glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); - glfwWindowHint(GLFW_RED_BITS, mode->redBits); - glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); - glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); - - width = mode->width; - height = mode->height; - } - else - { - width = 640; - height = 480; - } - - window = glfwCreateWindow(width, height, "Iconify", monitor, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwSetKeyCallback(window, key_callback); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetWindowSizeCallback(window, window_size_callback); - glfwSetWindowFocusCallback(window, window_focus_callback); - glfwSetWindowIconifyCallback(window, window_iconify_callback); - - printf("Window is %s and %s\n", - glfwGetWindowAttrib(window, GLFW_ICONIFIED) ? "iconified" : "restored", - glfwGetWindowAttrib(window, GLFW_FOCUSED) ? "focused" : "defocused"); - - glEnable(GL_SCISSOR_TEST); - - while (!glfwWindowShouldClose(window)) - { - glfwGetFramebufferSize(window, &width, &height); - - glScissor(0, 0, width, height); - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); - - glScissor(0, 0, 640, 480); - glClearColor(1, 1, 1, 0); - glClear(GL_COLOR_BUFFER_BIT); - - glfwSwapBuffers(window); - glfwPollEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/joysticks.c b/glfw/tests/joysticks.c deleted file mode 100644 index a3a5cd7..0000000 --- a/glfw/tests/joysticks.c +++ /dev/null @@ -1,234 +0,0 @@ -//======================================================================== -// Joystick input test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test displays the state of every button and axis of every connected -// joystick and/or gamepad -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#ifdef _MSC_VER -#define strdup(x) _strdup(x) -#endif - -typedef struct Joystick -{ - GLboolean present; - char* name; - float* axes; - unsigned char* buttons; - int axis_count; - int button_count; -} Joystick; - -static Joystick joysticks[GLFW_JOYSTICK_LAST - GLFW_JOYSTICK_1 + 1]; -static int joystick_count = 0; - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -static void draw_joystick(Joystick* j, int x, int y, int width, int height) -{ - int i; - const int axis_height = 3 * height / 4; - const int button_height = height / 4; - - if (j->axis_count) - { - const int axis_width = width / j->axis_count; - - for (i = 0; i < j->axis_count; i++) - { - float value = j->axes[i] / 2.f + 0.5f; - - glColor3f(0.3f, 0.3f, 0.3f); - glRecti(x + i * axis_width, - y, - x + (i + 1) * axis_width, - y + axis_height); - - glColor3f(1.f, 1.f, 1.f); - glRecti(x + i * axis_width, - y + (int) (value * (axis_height - 5)), - x + (i + 1) * axis_width, - 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++) - { - if (j->buttons[i]) - glColor3f(1.f, 1.f, 1.f); - else - glColor3f(0.3f, 0.3f, 0.3f); - - glRecti(x + i * button_width, - y + axis_height, - x + (i + 1) * button_width, - y + axis_height + button_height); - } - } -} - -static void draw_joysticks(GLFWwindow* window) -{ - int i, width, height; - - glfwGetFramebufferSize(window, &width, &height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.f, width, height, 0.f, 1.f, -1.f); - glMatrixMode(GL_MODELVIEW); - - for (i = 0; i < sizeof(joysticks) / sizeof(Joystick); i++) - { - Joystick* j = joysticks + i; - - if (j->present) - { - draw_joystick(j, - 0, i * height / joystick_count, - width, height / joystick_count); - } - } -} - -static void refresh_joysticks(void) -{ - int i; - - for (i = 0; i < sizeof(joysticks) / sizeof(Joystick); i++) - { - Joystick* j = joysticks + i; - - if (glfwJoystickPresent(GLFW_JOYSTICK_1 + i)) - { - const float* axes; - const unsigned char* buttons; - int axis_count, button_count; - - free(j->name); - j->name = strdup(glfwGetJoystickName(GLFW_JOYSTICK_1 + i)); - - axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1 + i, &axis_count); - if (axis_count != j->axis_count) - { - j->axis_count = axis_count; - j->axes = realloc(j->axes, j->axis_count * sizeof(float)); - } - - memcpy(j->axes, axes, axis_count * sizeof(float)); - - buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1 + i, &button_count); - if (button_count != j->button_count) - { - j->button_count = button_count; - j->buttons = realloc(j->buttons, j->button_count); - } - - memcpy(j->buttons, buttons, button_count * sizeof(unsigned char)); - - if (!j->present) - { - printf("Found joystick %i named \'%s\' with %i axes, %i buttons\n", - i + 1, j->name, j->axis_count, j->button_count); - - joystick_count++; - } - - j->present = GL_TRUE; - } - else - { - if (j->present) - { - printf("Lost joystick %i named \'%s\'\n", i + 1, j->name); - - free(j->name); - free(j->axes); - free(j->buttons); - memset(j, 0, sizeof(Joystick)); - - joystick_count--; - } - } - } -} - -int main(void) -{ - GLFWwindow* window; - - memset(joysticks, 0, sizeof(joysticks)); - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(640, 480, "Joystick Test", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - - refresh_joysticks(); - draw_joysticks(window); - - glfwSwapBuffers(window); - glfwPollEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/modes.c b/glfw/tests/modes.c deleted file mode 100644 index 58067e3..0000000 --- a/glfw/tests/modes.c +++ /dev/null @@ -1,240 +0,0 @@ -//======================================================================== -// Video mode test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test enumerates or verifies video modes -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include "getopt.h" - -enum Mode -{ - LIST_MODE, - TEST_MODE -}; - -static void usage(void) -{ - printf("Usage: modes [-t]\n"); - printf(" modes -h\n"); -} - -static const char* format_mode(const GLFWvidmode* mode) -{ - static char buffer[512]; - - sprintf(buffer, - "%i x %i x %i (%i %i %i) %i Hz", - mode->width, mode->height, - mode->redBits + mode->greenBits + mode->blueBits, - mode->redBits, mode->greenBits, mode->blueBits, - mode->refreshRate); - - buffer[sizeof(buffer) - 1] = '\0'; - return buffer; -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - printf("Framebuffer resized to %ix%i\n", width, height); - - glViewport(0, 0, width, height); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_ESCAPE) - glfwSetWindowShouldClose(window, GL_TRUE); -} - -static void list_modes(GLFWmonitor* monitor) -{ - int count, x, y, widthMM, heightMM, dpi, i; - const GLFWvidmode* mode = glfwGetVideoMode(monitor); - const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); - - glfwGetMonitorPos(monitor, &x, &y); - glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); - - printf("Name: %s (%s)\n", - glfwGetMonitorName(monitor), - glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary"); - printf("Current mode: %s\n", format_mode(mode)); - printf("Virtual position: %i %i\n", x, y); - - dpi = (int) ((float) mode->width * 25.4f / (float) widthMM); - printf("Physical size: %i x %i mm (%i dpi)\n", widthMM, heightMM, dpi); - - printf("Modes:\n"); - - for (i = 0; i < count; i++) - { - printf("%3u: %s", (unsigned int) i, format_mode(modes + i)); - - if (memcmp(mode, modes + i, sizeof(GLFWvidmode)) == 0) - printf(" (current mode)"); - - putchar('\n'); - } -} - -static void test_modes(GLFWmonitor* monitor) -{ - int i, count; - GLFWwindow* window; - const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); - - for (i = 0; i < count; i++) - { - const GLFWvidmode* mode = modes + i; - GLFWvidmode current; - - glfwWindowHint(GLFW_RED_BITS, mode->redBits); - glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); - glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); - glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); - - printf("Testing mode %u on monitor %s: %s\n", - (unsigned int) i, - glfwGetMonitorName(monitor), - format_mode(mode)); - - window = glfwCreateWindow(mode->width, mode->height, - "Video Mode Test", - glfwGetPrimaryMonitor(), - NULL); - if (!window) - { - printf("Failed to enter mode %u: %s\n", - (unsigned int) i, - format_mode(mode)); - continue; - } - - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetKeyCallback(window, key_callback); - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwSetTime(0.0); - - while (glfwGetTime() < 5.0) - { - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(window); - glfwPollEvents(); - - if (glfwWindowShouldClose(window)) - { - printf("User terminated program\n"); - - glfwTerminate(); - exit(EXIT_SUCCESS); - } - } - - glGetIntegerv(GL_RED_BITS, ¤t.redBits); - glGetIntegerv(GL_GREEN_BITS, ¤t.greenBits); - glGetIntegerv(GL_BLUE_BITS, ¤t.blueBits); - - glfwGetWindowSize(window, ¤t.width, ¤t.height); - - if (current.redBits != mode->redBits || - current.greenBits != mode->greenBits || - current.blueBits != mode->blueBits) - { - printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n", - current.redBits, current.greenBits, current.blueBits, - mode->redBits, mode->greenBits, mode->blueBits); - } - - if (current.width != mode->width || current.height != mode->height) - { - printf("*** Size mismatch: %ix%i instead of %ix%i\n", - current.width, current.height, - mode->width, mode->height); - } - - printf("Closing window\n"); - - glfwDestroyWindow(window); - window = NULL; - - glfwPollEvents(); - } -} - -int main(int argc, char** argv) -{ - int ch, i, count, mode = LIST_MODE; - GLFWmonitor** monitors; - - while ((ch = getopt(argc, argv, "th")) != -1) - { - switch (ch) - { - case 'h': - usage(); - exit(EXIT_SUCCESS); - case 't': - mode = TEST_MODE; - break; - default: - usage(); - exit(EXIT_FAILURE); - } - } - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - monitors = glfwGetMonitors(&count); - - for (i = 0; i < count; i++) - { - if (mode == LIST_MODE) - list_modes(monitors[i]); - else if (mode == TEST_MODE) - test_modes(monitors[i]); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/peter.c b/glfw/tests/peter.c deleted file mode 100644 index 4eab10f..0000000 --- a/glfw/tests/peter.c +++ /dev/null @@ -1,145 +0,0 @@ -//======================================================================== -// Cursor mode test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test allows you to switch between the various cursor modes -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -static GLboolean reopen = GL_FALSE; -static double cursor_x; -static double cursor_y; - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void cursor_position_callback(GLFWwindow* window, double x, double y) -{ - printf("%0.3f: Cursor position: %f %f (%f %f)\n", - glfwGetTime(), - x, y, x - cursor_x, y - cursor_y); - - cursor_x = x; - cursor_y = y; -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_D: - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); - break; - - case GLFW_KEY_H: - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); - break; - - case GLFW_KEY_N: - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); - break; - - case GLFW_KEY_R: - reopen = GL_TRUE; - break; - } -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -static GLFWwindow* open_window(void) -{ - GLFWwindow* window = glfwCreateWindow(640, 480, "Peter Detector", NULL, NULL); - if (!window) - return NULL; - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwGetCursorPos(window, &cursor_x, &cursor_y); - printf("Cursor position: %f %f\n", cursor_x, cursor_y); - - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetCursorPosCallback(window, cursor_position_callback); - glfwSetKeyCallback(window, key_callback); - - return window; -} - -int main(void) -{ - GLFWwindow* window; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = open_window(); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glClearColor(0.f, 0.f, 0.f, 0.f); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - - glfwSwapBuffers(window); - glfwWaitEvents(); - - if (reopen) - { - glfwDestroyWindow(window); - window = open_window(); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - reopen = GL_FALSE; - } - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/reopen.c b/glfw/tests/reopen.c deleted file mode 100644 index ca79eed..0000000 --- a/glfw/tests/reopen.c +++ /dev/null @@ -1,177 +0,0 @@ -//======================================================================== -// Window re-opener (open/close stress test) -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test came about as the result of bug #1262773 -// -// It closes and re-opens the GLFW window every five seconds, alternating -// between windowed and fullscreen mode -// -// It also times and logs opening and closing actions and attempts to separate -// user initiated window closing from its own -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <time.h> -#include <stdio.h> -#include <stdlib.h> - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -static void window_close_callback(GLFWwindow* window) -{ - printf("Close callback triggered\n"); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action != GLFW_PRESS) - return; - - switch (key) - { - case GLFW_KEY_Q: - case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GL_TRUE); - break; - } -} - -static GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor) -{ - double base; - GLFWwindow* window; - - base = glfwGetTime(); - - window = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL); - if (!window) - return NULL; - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetWindowCloseCallback(window, window_close_callback); - glfwSetKeyCallback(window, key_callback); - - if (monitor) - { - printf("Opening full screen window on monitor %s took %0.3f seconds\n", - glfwGetMonitorName(monitor), - glfwGetTime() - base); - } - else - { - printf("Opening regular window took %0.3f seconds\n", - glfwGetTime() - base); - } - - return window; -} - -static void close_window(GLFWwindow* window) -{ - double base = glfwGetTime(); - glfwDestroyWindow(window); - printf("Closing window took %0.3f seconds\n", glfwGetTime() - base); -} - -int main(int argc, char** argv) -{ - int count = 0; - GLFWwindow* window; - - srand((unsigned int) time(NULL)); - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - for (;;) - { - GLFWmonitor* monitor = NULL; - - if (count % 2 == 0) - { - int monitorCount; - GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); - monitor = monitors[rand() % monitorCount]; - } - - window = open_window(640, 480, monitor); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glMatrixMode(GL_PROJECTION); - glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); - glMatrixMode(GL_MODELVIEW); - - glfwSetTime(0.0); - - while (glfwGetTime() < 5.0) - { - glClear(GL_COLOR_BUFFER_BIT); - - glPushMatrix(); - glRotatef((GLfloat) glfwGetTime() * 100.f, 0.f, 0.f, 1.f); - glRectf(-0.5f, -0.5f, 1.f, 1.f); - glPopMatrix(); - - glfwSwapBuffers(window); - glfwPollEvents(); - - if (glfwWindowShouldClose(window)) - { - close_window(window); - printf("User closed window\n"); - - glfwTerminate(); - exit(EXIT_SUCCESS); - } - } - - printf("Closing window\n"); - close_window(window); - - count++; - } - - glfwTerminate(); -} - diff --git a/glfw/tests/sharing.c b/glfw/tests/sharing.c deleted file mode 100644 index 54b15c8..0000000 --- a/glfw/tests/sharing.c +++ /dev/null @@ -1,184 +0,0 @@ -//======================================================================== -// Context sharing test program -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This program is used to test sharing of objects between contexts -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -#define WIDTH 400 -#define HEIGHT 400 -#define OFFSET 50 - -static GLFWwindow* windows[2]; - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) - glfwSetWindowShouldClose(window, GL_TRUE); -} - -static GLFWwindow* open_window(const char* title, GLFWwindow* share, int posX, int posY) -{ - GLFWwindow* window; - - glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share); - if (!window) - return NULL; - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - glfwSetWindowPos(window, posX, posY); - glfwShowWindow(window); - - glfwSetKeyCallback(window, key_callback); - - return window; -} - -static GLuint create_texture(void) -{ - int x, y; - char pixels[256 * 256]; - GLuint texture; - - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - - for (y = 0; y < 256; y++) - { - for (x = 0; x < 256; x++) - pixels[y * 256 + x] = rand() % 256; - } - - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - return texture; -} - -static void draw_quad(GLuint texture) -{ - int width, height; - glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height); - - glViewport(0, 0, width, height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.f, 1.f, 0.f, 1.f, 0.f, 1.f); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - glBegin(GL_QUADS); - - glTexCoord2f(0.f, 0.f); - glVertex2f(0.f, 0.f); - - glTexCoord2f(1.f, 0.f); - glVertex2f(1.f, 0.f); - - glTexCoord2f(1.f, 1.f); - glVertex2f(1.f, 1.f); - - glTexCoord2f(0.f, 1.f); - glVertex2f(0.f, 1.f); - - glEnd(); -} - -int main(int argc, char** argv) -{ - int x, y, width; - GLuint texture; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - windows[0] = open_window("First", NULL, OFFSET, OFFSET); - if (!windows[0]) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - // This is the one and only time we create a texture - // It is created inside the first context, created above - // It will then be shared with the second context, created below - texture = create_texture(); - - glfwGetWindowPos(windows[0], &x, &y); - glfwGetWindowSize(windows[0], &width, NULL); - - // Put the second window to the right of the first one - windows[1] = open_window("Second", windows[0], x + width + OFFSET, y); - if (!windows[1]) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - // Set drawing color for both contexts - glfwMakeContextCurrent(windows[0]); - glColor3f(0.6f, 0.f, 0.6f); - glfwMakeContextCurrent(windows[1]); - glColor3f(0.6f, 0.6f, 0.f); - - glfwMakeContextCurrent(windows[0]); - - while (!glfwWindowShouldClose(windows[0]) && - !glfwWindowShouldClose(windows[1])) - { - glfwMakeContextCurrent(windows[0]); - draw_quad(texture); - - glfwMakeContextCurrent(windows[1]); - draw_quad(texture); - - glfwSwapBuffers(windows[0]); - glfwSwapBuffers(windows[1]); - - glfwWaitEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/tearing.c b/glfw/tests/tearing.c deleted file mode 100644 index 94865fa..0000000 --- a/glfw/tests/tearing.c +++ /dev/null @@ -1,130 +0,0 @@ -//======================================================================== -// Vsync enabling test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test renders a high contrast, horizontally moving bar, allowing for -// visual verification of whether the set swap interval is indeed obeyed -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -static int swap_interval; -static double frame_rate; - -static void update_window_title(GLFWwindow* window) -{ - char title[256]; - - sprintf(title, "Tearing detector (interval %i, %0.1f Hz)", - swap_interval, frame_rate); - - glfwSetWindowTitle(window, title); -} - -static void set_swap_interval(GLFWwindow* window, int interval) -{ - swap_interval = interval; - glfwSwapInterval(swap_interval); - update_window_title(window); -} - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) - set_swap_interval(window, 1 - swap_interval); -} - -int main(void) -{ - float position; - unsigned long frame_count = 0; - double last_time, current_time; - GLFWwindow* window; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(640, 480, "", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - set_swap_interval(window, 0); - - last_time = glfwGetTime(); - frame_rate = 0.0; - - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetKeyCallback(window, key_callback); - - glMatrixMode(GL_PROJECTION); - glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); - glMatrixMode(GL_MODELVIEW); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - - position = cosf((float) glfwGetTime() * 4.f) * 0.75f; - glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f); - - glfwSwapBuffers(window); - glfwPollEvents(); - - frame_count++; - - current_time = glfwGetTime(); - if (current_time - last_time > 1.0) - { - frame_rate = frame_count / (current_time - last_time); - frame_count = 0; - last_time = current_time; - update_window_title(window); - } - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/threads.c b/glfw/tests/threads.c deleted file mode 100644 index 78519c7..0000000 --- a/glfw/tests/threads.c +++ /dev/null @@ -1,135 +0,0 @@ -//======================================================================== -// Multithreading test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test is intended to verify whether the OpenGL context part of -// the GLFW API is able to be used from multiple threads -// -//======================================================================== - -#include "tinycthread.h" - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -typedef struct -{ - GLFWwindow* window; - const char* title; - float r, g, b; - thrd_t id; -} Thread; - -static volatile GLboolean running = GL_TRUE; - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static int thread_main(void* data) -{ - const Thread* thread = data; - - glfwMakeContextCurrent(thread->window); - glfwSwapInterval(1); - - while (running) - { - const float v = (float) fabs(sin(glfwGetTime() * 2.f)); - glClearColor(thread->r * v, thread->g * v, thread->b * v, 0.f); - - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(thread->window); - } - - glfwMakeContextCurrent(NULL); - return 0; -} - -int main(void) -{ - int i, result; - Thread threads[] = - { - { NULL, "Red", 1.f, 0.f, 0.f, 0 }, - { NULL, "Green", 0.f, 1.f, 0.f, 0 }, - { NULL, "Blue", 0.f, 0.f, 1.f, 0 } - }; - const int count = sizeof(threads) / sizeof(Thread); - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - - for (i = 0; i < count; i++) - { - threads[i].window = glfwCreateWindow(200, 200, - threads[i].title, - NULL, NULL); - if (!threads[i].window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); - glfwShowWindow(threads[i].window); - - if (thrd_create(&threads[i].id, thread_main, threads + i) != - thrd_success) - { - fprintf(stderr, "Failed to create secondary thread\n"); - - glfwTerminate(); - exit(EXIT_FAILURE); - } - } - - while (running) - { - glfwWaitEvents(); - - for (i = 0; i < count; i++) - { - if (glfwWindowShouldClose(threads[i].window)) - running = GL_FALSE; - } - } - - for (i = 0; i < count; i++) - glfwHideWindow(threads[i].window); - - for (i = 0; i < count; i++) - thrd_join(threads[i].id, &result); - - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/title.c b/glfw/tests/title.c deleted file mode 100644 index 15ddb83..0000000 --- a/glfw/tests/title.c +++ /dev/null @@ -1,76 +0,0 @@ -//======================================================================== -// UTF-8 window title test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test sets a UTF-8 window title -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -int main(void) -{ - GLFWwindow* window; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - window = glfwCreateWindow(400, 400, "English 日本語 русский язык 官話", NULL, NULL); - if (!window) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - glfwSwapInterval(1); - - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - - while (!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(window); - glfwWaitEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw/tests/windows.c b/glfw/tests/windows.c deleted file mode 100644 index 164a298..0000000 --- a/glfw/tests/windows.c +++ /dev/null @@ -1,117 +0,0 @@ -//======================================================================== -// Simple multi-window test -// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test creates four windows and clears each in a different color -// -//======================================================================== - -#include <GLFW/glfw3.h> - -#include <stdio.h> -#include <stdlib.h> - -static const char* titles[4] = -{ - "Foo", - "Bar", - "Baz", - "Quux" -}; - -static void error_callback(int error, const char* description) -{ - fprintf(stderr, "Error: %s\n", description); -} - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) - { - int xpos, ypos; - glfwGetWindowPos(window, &xpos, &ypos); - glfwSetWindowPos(window, xpos, ypos); - } -} - -int main(void) -{ - int i; - GLboolean running = GL_TRUE; - GLFWwindow* windows[4]; - - glfwSetErrorCallback(error_callback); - - if (!glfwInit()) - exit(EXIT_FAILURE); - - glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - - for (i = 0; i < 4; i++) - { - int left, top, right, bottom; - - windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL); - if (!windows[i]) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } - - glfwSetKeyCallback(windows[i], key_callback); - - glfwMakeContextCurrent(windows[i]); - glClearColor((GLclampf) (i & 1), - (GLclampf) (i >> 1), - i ? 0.f : 1.f, - 0.f); - - glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom); - glfwSetWindowPos(windows[i], - 100 + (i & 1) * (200 + left + right), - 100 + (i >> 1) * (200 + top + bottom)); - } - - for (i = 0; i < 4; i++) - glfwShowWindow(windows[i]); - - while (running) - { - for (i = 0; i < 4; i++) - { - glfwMakeContextCurrent(windows[i]); - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(windows[i]); - - if (glfwWindowShouldClose(windows[i])) - running = GL_FALSE; - } - - glfwPollEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - diff --git a/glfw_joystick.c b/glfw_joystick.c deleted file mode 100644 index c3f65bf..0000000 --- a/glfw_joystick.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "glfw/src/joystick.c" - diff --git a/glfw_time.c b/glfw_time.c deleted file mode 100644 index a7ec724..0000000 --- a/glfw_time.c +++ /dev/null @@ -1 +0,0 @@ -#include "glfw/src/time.c" |