Updated GLFW to version 3.1.
This commit is contained in:
parent
79e75b70ec
commit
09fc128136
@ -86,6 +86,10 @@ INCLUDE(${CMAKE_SOURCE_DIR}/extern/acgl/CMakeListsStaticInclude.txt)
|
||||
# GLFW (and some other linker flags)
|
||||
#
|
||||
|
||||
OPTION(GLFW_BUILD_DOCS OFF)
|
||||
OPTION(GLFW_BUILD_TESTS OFF)
|
||||
OPTION(GLFW_BUILD_EXAMPLES OFF)
|
||||
|
||||
FILE(GLOB_RECURSE HEADER_FILES_GLFW "${CMAKE_SOURCE_DIR}/extern/glfw/include/*.h")
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extern/glfw/include)
|
||||
SET(HEADER_FILES ${HEADER_FILES} ${HEADER_FILES_GLFW})
|
||||
|
4
extern/glfw/CMake/modules/FindEGL.cmake
vendored
4
extern/glfw/CMake/modules/FindEGL.cmake
vendored
@ -4,10 +4,10 @@
|
||||
# EGL_LIBRARY
|
||||
# EGL_FOUND
|
||||
|
||||
find_path(EGL_INCLUDE_DIR NAMES EGL/egl.h)
|
||||
find_path(EGL_INCLUDE_DIR NAMES EGL/egl.h PATHS /opt/vc/include)
|
||||
|
||||
set(EGL_NAMES ${EGL_NAMES} egl EGL)
|
||||
find_library(EGL_LIBRARY NAMES ${EGL_NAMES})
|
||||
find_library(EGL_LIBRARY NAMES ${EGL_NAMES} PATHS /opt/vc/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
|
||||
|
4
extern/glfw/CMake/modules/FindGLESv1.cmake
vendored
4
extern/glfw/CMake/modules/FindGLESv1.cmake
vendored
@ -4,10 +4,10 @@
|
||||
# GLESv1_LIBRARY
|
||||
# GLESv1_FOUND
|
||||
|
||||
find_path(GLESv1_INCLUDE_DIR NAMES GLES/gl.h)
|
||||
find_path(GLESv1_INCLUDE_DIR NAMES GLES/gl.h PATHS /opt/vc/include)
|
||||
|
||||
set(GLESv1_NAMES ${GLESv1_NAMES} GLESv1_CM)
|
||||
find_library(GLESv1_LIBRARY NAMES ${GLESv1_NAMES})
|
||||
find_library(GLESv1_LIBRARY NAMES ${GLESv1_NAMES} PATHS /opt/vc/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLESv1 DEFAULT_MSG GLESv1_LIBRARY GLESv1_INCLUDE_DIR)
|
||||
|
4
extern/glfw/CMake/modules/FindGLESv2.cmake
vendored
4
extern/glfw/CMake/modules/FindGLESv2.cmake
vendored
@ -4,10 +4,10 @@
|
||||
# GLESv2_LIBRARY
|
||||
# GLESv2_FOUND
|
||||
|
||||
find_path(GLESv2_INCLUDE_DIR NAMES GLES2/gl2.h)
|
||||
find_path(GLESv2_INCLUDE_DIR NAMES GLES2/gl2.h PATHS /opt/vc/include)
|
||||
|
||||
set(GLESv2_NAMES ${GLESv2_NAMES} GLESv2)
|
||||
find_library(GLESv2_LIBRARY NAMES ${GLESv2_NAMES})
|
||||
find_library(GLESv2_LIBRARY NAMES ${GLESv2_NAMES} PATHS /opt/vc/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLESv2 DEFAULT_MSG GLESv2_LIBRARY GLESv2_INCLUDE_DIR)
|
||||
|
18
extern/glfw/CMake/modules/FindMir.cmake
vendored
Normal file
18
extern/glfw/CMake/modules/FindMir.cmake
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
# Try to find Mir on a Unix system
|
||||
#
|
||||
# This will define:
|
||||
#
|
||||
# MIR_LIBRARIES - Link these to use Wayland
|
||||
# MIR_INCLUDE_DIR - Include directory for Wayland
|
||||
#
|
||||
# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
|
||||
|
||||
if (NOT WIN32)
|
||||
|
||||
find_package (PkgConfig)
|
||||
pkg_check_modules (PKG_MIR QUIET mirclient)
|
||||
|
||||
set (MIR_INCLUDE_DIR ${PKG_MIR_INCLUDE_DIRS})
|
||||
set (MIR_LIBRARIES ${PKG_MIR_LIBRARIES})
|
||||
|
||||
endif ()
|
66
extern/glfw/CMake/modules/FindWayland.cmake
vendored
Normal file
66
extern/glfw/CMake/modules/FindWayland.cmake
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
# 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_CURSOR 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 ()
|
34
extern/glfw/CMake/modules/FindXKBCommon.cmake
vendored
Normal file
34
extern/glfw/CMake/modules/FindXKBCommon.cmake
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# - 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)
|
||||
|
19
extern/glfw/CMakeFiles/Export/lib/cmake/glfw/glfwTargets-release.cmake
vendored
Normal file
19
extern/glfw/CMakeFiles/Export/lib/cmake/glfw/glfwTargets-release.cmake
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file for configuration "Release".
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Import target "glfw" for configuration "Release"
|
||||
set_property(TARGET glfw APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(glfw PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libglfw3.a"
|
||||
)
|
||||
|
||||
list(APPEND _IMPORT_CHECK_TARGETS glfw )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_glfw "${_IMPORT_PREFIX}/lib/libglfw3.a" )
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
84
extern/glfw/CMakeFiles/Export/lib/cmake/glfw/glfwTargets.cmake
vendored
Normal file
84
extern/glfw/CMakeFiles/Export/lib/cmake/glfw/glfwTargets.cmake
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
# Generated by CMake 3.1.3
|
||||
|
||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
|
||||
message(FATAL_ERROR "CMake >= 2.6.0 required")
|
||||
endif()
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(VERSION 2.6)
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file.
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
||||
set(_targetsDefined)
|
||||
set(_targetsNotDefined)
|
||||
set(_expectedTargets)
|
||||
foreach(_expectedTarget glfw)
|
||||
list(APPEND _expectedTargets ${_expectedTarget})
|
||||
if(NOT TARGET ${_expectedTarget})
|
||||
list(APPEND _targetsNotDefined ${_expectedTarget})
|
||||
endif()
|
||||
if(TARGET ${_expectedTarget})
|
||||
list(APPEND _targetsDefined ${_expectedTarget})
|
||||
endif()
|
||||
endforeach()
|
||||
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
||||
return()
|
||||
endif()
|
||||
if(NOT "${_targetsDefined}" STREQUAL "")
|
||||
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
|
||||
endif()
|
||||
unset(_targetsDefined)
|
||||
unset(_targetsNotDefined)
|
||||
unset(_expectedTargets)
|
||||
|
||||
|
||||
# Compute the installation prefix relative to this file.
|
||||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
|
||||
# Create imported target glfw
|
||||
add_library(glfw STATIC IMPORTED)
|
||||
|
||||
# Load information for each installed configuration.
|
||||
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
file(GLOB CONFIG_FILES "${_DIR}/glfwTargets-*.cmake")
|
||||
foreach(f ${CONFIG_FILES})
|
||||
include(${f})
|
||||
endforeach()
|
||||
|
||||
# Cleanup temporary variables.
|
||||
set(_IMPORT_PREFIX)
|
||||
|
||||
# Loop over all imported files and verify that they actually exist
|
||||
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
||||
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
||||
if(NOT EXISTS "${file}" )
|
||||
message(FATAL_ERROR "The imported target \"${target}\" references the file
|
||||
\"${file}\"
|
||||
but this file does not exist. Possible reasons include:
|
||||
* The file was deleted, renamed, or moved to another location.
|
||||
* An install or uninstall procedure did not complete successfully.
|
||||
* The installation package was faulty and contained
|
||||
\"${CMAKE_CURRENT_LIST_FILE}\"
|
||||
but not all the files it references.
|
||||
")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_IMPORT_CHECK_FILES_FOR_${target})
|
||||
endforeach()
|
||||
unset(_IMPORT_CHECK_TARGETS)
|
||||
|
||||
# This file does not depend on other imported targets which have
|
||||
# been exported from the same project but in a separate export set.
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
323
extern/glfw/CMakeLists.txt
vendored
323
extern/glfw/CMakeLists.txt
vendored
@ -1,15 +1,23 @@
|
||||
project(GLFW C)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 2.8.9)
|
||||
|
||||
if (CMAKE_VERSION VERSION_EQUAL "3.0" OR CMAKE_VERSION VERSION_GREATER "3.0")
|
||||
# Until all major package systems have moved to CMake 3,
|
||||
# we stick with the older INSTALL_NAME_DIR mechanism
|
||||
cmake_policy(SET CMP0042 OLD)
|
||||
endif()
|
||||
|
||||
set(GLFW_VERSION_MAJOR "3")
|
||||
set(GLFW_VERSION_MINOR "0")
|
||||
set(GLFW_VERSION_PATCH "4")
|
||||
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")
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
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)
|
||||
@ -26,10 +34,16 @@ 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)
|
||||
option(GLFW_USE_MIR "Use Mir for context creation (implies EGL as well)" OFF)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON)
|
||||
endif()
|
||||
@ -38,6 +52,12 @@ if (BUILD_SHARED_LIBS)
|
||||
set(_GLFW_BUILD_DLL 1)
|
||||
endif()
|
||||
|
||||
if (GLFW_USE_WAYLAND)
|
||||
set(GLFW_USE_EGL ON)
|
||||
elseif (GLFW_USE_MIR)
|
||||
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")
|
||||
@ -52,7 +72,7 @@ if (GLFW_USE_EGL)
|
||||
message(FATAL_ERROR "Unsupported client library")
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake/modules)
|
||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake/modules")
|
||||
find_package(EGL REQUIRED)
|
||||
|
||||
if (NOT _GLFW_USE_OPENGL)
|
||||
@ -115,12 +135,39 @@ if (MSVC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
# Enable link-time exploit mitigation features enabled by default on MSVC
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
# Compatibility with data execution prevention (DEP)
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
|
||||
check_c_compiler_flag("" _GLFW_HAS_DEP)
|
||||
if (_GLFW_HAS_DEP)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Compatibility with address space layout randomization (ASLR)
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
|
||||
check_c_compiler_flag("" _GLFW_HAS_ASLR)
|
||||
if (_GLFW_HAS_ASLR)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Compatibility with 64-bit address space layout randomization (ASLR)
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
|
||||
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
|
||||
if (_GLFW_HAS_64ASLR)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Detect and select backend APIs
|
||||
#--------------------------------------------------------------------
|
||||
if (WIN32)
|
||||
set(_GLFW_WIN32 1)
|
||||
message(STATUS "Using Win32 for window creation")
|
||||
message(STATUS "Using Win32 for window creation")
|
||||
|
||||
if (GLFW_USE_EGL)
|
||||
set(_GLFW_EGL 1)
|
||||
@ -135,8 +182,16 @@ elseif (APPLE)
|
||||
set(_GLFW_NSGL 1)
|
||||
message(STATUS "Using NSGL for context creation")
|
||||
elseif (UNIX)
|
||||
set(_GLFW_X11 1)
|
||||
message(STATUS "Using X11 for window creation")
|
||||
if (GLFW_USE_WAYLAND)
|
||||
set(_GLFW_WAYLAND 1)
|
||||
message(STATUS "Using Wayland for window creation")
|
||||
elseif (GLFW_USE_MIR)
|
||||
set(_GLFW_MIR 1)
|
||||
message(STATUS "Using Mir for window creation")
|
||||
else()
|
||||
set(_GLFW_X11 1)
|
||||
message(STATUS "Using X11 for window creation")
|
||||
endif()
|
||||
|
||||
if (GLFW_USE_EGL)
|
||||
set(_GLFW_EGL 1)
|
||||
@ -153,12 +208,8 @@ endif()
|
||||
# Use Win32 for window creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_WIN32)
|
||||
# The DLL links against winmm; the static library loads it
|
||||
# That way, both code paths receive testing
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set(_GLFW_NO_DLOAD_WINMM 1)
|
||||
list(APPEND glfw_LIBRARIES winmm)
|
||||
endif()
|
||||
|
||||
list(APPEND glfw_PKG_LIBS "-lgdi32")
|
||||
|
||||
if (GLFW_USE_DWM_SWAP_INTERVAL)
|
||||
set(_GLFW_USE_DWM_SWAP_INTERVAL 1)
|
||||
@ -171,16 +222,20 @@ if (_GLFW_WIN32)
|
||||
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
||||
# win32_platform.h. We define them here until a saner solution can be found
|
||||
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
||||
add_definitions(-DUNICODE)
|
||||
add_definitions(-DWINVER=0x0501)
|
||||
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
||||
add_definitions(-DUNICODE -DWINVER=0x0501)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Use WGL for context creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_WGL)
|
||||
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
|
||||
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
|
||||
|
||||
list(APPEND glfw_PKG_LIBS "-lopengl32")
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIRS "${OPENGL_INCLUDE_DIR}")
|
||||
list(APPEND glfw_LIBRARIES "${OPENGL_gl_LIBRARY}")
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
@ -190,13 +245,13 @@ if (_GLFW_X11)
|
||||
|
||||
find_package(X11 REQUIRED)
|
||||
|
||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} x11")
|
||||
list(APPEND 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})
|
||||
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})
|
||||
list(APPEND glfw_LIBRARIES "${RT_LIBRARY}")
|
||||
endif()
|
||||
|
||||
# Check for XRandR (modern resolution switching and gamma control)
|
||||
@ -204,35 +259,44 @@ if (_GLFW_X11)
|
||||
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")
|
||||
list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}")
|
||||
list(APPEND glfw_LIBRARIES "${X11_Xrandr_LIB}")
|
||||
list(APPEND glfw_PKG_DEPS "xrandr")
|
||||
|
||||
# Check for Xinerama (legacy multi-monitor support)
|
||||
if (NOT X11_Xinerama_FOUND)
|
||||
message(FATAL_ERROR "The Xinerama library and headers were not found")
|
||||
endif()
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIRS "${X11_Xinerama_INCLUDE_PATH}")
|
||||
list(APPEND glfw_LIBRARIES "${X11_Xinerama_LIB}")
|
||||
list(APPEND glfw_PKG_DEPS "xinerama")
|
||||
|
||||
# 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})
|
||||
list(APPEND glfw_INCLUDE_DIRS "${X11_Xinput_INCLUDE_PATH}")
|
||||
|
||||
if (X11_Xinput_LIB)
|
||||
list(APPEND glfw_LIBRARIES ${X11_Xinput_LIB})
|
||||
list(APPEND glfw_LIBRARIES "${X11_Xinput_LIB}")
|
||||
else()
|
||||
# Backwards compatibility (bug in CMake 2.8.7)
|
||||
list(APPEND glfw_LIBRARIES Xi)
|
||||
endif()
|
||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xi")
|
||||
list(APPEND 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")
|
||||
list(APPEND glfw_INCLUDE_DIRS "${X11_xf86vmode_INCLUDE_PATH}")
|
||||
list(APPEND glfw_PKG_DEPS "xxf86vm")
|
||||
|
||||
if (X11_Xxf86vm_LIB)
|
||||
list(APPEND glfw_LIBRARIES ${X11_Xxf86vm_LIB})
|
||||
list(APPEND glfw_LIBRARIES "${X11_Xxf86vm_LIB}")
|
||||
else()
|
||||
# Backwards compatibility (see CMake bug 0006976)
|
||||
list(APPEND glfw_LIBRARIES Xxf86vm)
|
||||
@ -241,24 +305,79 @@ if (_GLFW_X11)
|
||||
# Check for Xkb (X keyboard extension)
|
||||
if (NOT X11_Xkb_FOUND)
|
||||
message(FATAL_ERROR "The X keyboard extension headers were not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
|
||||
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")
|
||||
list(APPEND glfw_LIBRARIES "${RT_LIBRARY}")
|
||||
list(APPEND 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")
|
||||
list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}")
|
||||
list(APPEND 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}")
|
||||
list(APPEND glfw_PKG_DEPS "xcursor")
|
||||
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Use Wayland for window creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_WAYLAND)
|
||||
find_package(Wayland REQUIRED)
|
||||
list(APPEND 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)
|
||||
list(APPEND 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}")
|
||||
list(APPEND glfw_PKG_LIBS "-lm")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Use Mir for window creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_MIR)
|
||||
find_package(Mir REQUIRED)
|
||||
list(APPEND glfw_PKG_DEPS "mirclient")
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIRS "${MIR_INCLUDE_DIR}")
|
||||
list(APPEND glfw_LIBRARIES "${MIR_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
|
||||
|
||||
find_package(XKBCommon REQUIRED)
|
||||
list(APPEND 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}")
|
||||
list(APPEND glfw_PKG_LIBS "-lm")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
@ -266,14 +385,14 @@ endif()
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_GLX)
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
|
||||
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
|
||||
list(APPEND glfw_INCLUDE_DIRS "${OPENGL_INCLUDE_DIR}")
|
||||
list(APPEND glfw_LIBRARIES "${OPENGL_gl_LIBRARY}")
|
||||
|
||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} gl")
|
||||
list(APPEND glfw_PKG_DEPS "gl")
|
||||
|
||||
include(CheckFunctionExists)
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
|
||||
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)
|
||||
@ -285,15 +404,15 @@ if (_GLFW_GLX)
|
||||
|
||||
# Check for dlopen support as a fallback
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
|
||||
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}")
|
||||
list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
|
||||
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -304,25 +423,23 @@ endif()
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_EGL)
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
|
||||
list(APPEND glfw_LIBRARIES ${EGL_LIBRARY})
|
||||
list(APPEND glfw_INCLUDE_DIRS "${EGL_INCLUDE_DIR}")
|
||||
list(APPEND glfw_LIBRARIES "${EGL_LIBRARY}")
|
||||
|
||||
if (UNIX)
|
||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl")
|
||||
endif()
|
||||
list(APPEND 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")
|
||||
list(APPEND glfw_LIBRARIES "${OPENGL_gl_LIBRARY}")
|
||||
list(APPEND glfw_INCLUDE_DIRS "${OPENGL_INCLUDE_DIR}")
|
||||
list(APPEND 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")
|
||||
list(APPEND glfw_LIBRARIES "${GLESv1_LIBRARY}")
|
||||
list(APPEND glfw_INCLUDE_DIRS "${GLESv1_INCLUDE_DIR}")
|
||||
list(APPEND 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")
|
||||
list(APPEND glfw_LIBRARIES "${GLESv2_LIBRARY}")
|
||||
list(APPEND glfw_INCLUDE_DIRS "${GLESv2_INCLUDE_DIR}")
|
||||
list(APPEND glfw_PKG_DEPS "glesv2")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
@ -331,7 +448,7 @@ 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()
|
||||
@ -340,32 +457,46 @@ if (_GLFW_COCOA AND _GLFW_NSGL)
|
||||
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})
|
||||
mark_as_advanced(COCOA_FRAMEWORK
|
||||
IOKIT_FRAMEWORK
|
||||
CORE_FOUNDATION_FRAMEWORK
|
||||
CORE_VIDEO_FRAMEWORK)
|
||||
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")
|
||||
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")
|
||||
foreach(arg ${glfw_PKG_DEPS})
|
||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
|
||||
endforeach()
|
||||
foreach(arg ${glfw_PKG_LIBS})
|
||||
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}")
|
||||
endforeach()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Choose library output name
|
||||
@ -380,23 +511,35 @@ endif()
|
||||
#--------------------------------------------------------------------
|
||||
# Create generated files
|
||||
#--------------------------------------------------------------------
|
||||
configure_file(${GLFW_SOURCE_DIR}/docs/Doxyfile.in
|
||||
${GLFW_BINARY_DIR}/docs/Doxyfile @ONLY)
|
||||
|
||||
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)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
if (UNIX)
|
||||
configure_file(${GLFW_SOURCE_DIR}/src/glfw3.pc.in
|
||||
${GLFW_BINARY_DIR}/src/glfw3.pc @ONLY)
|
||||
set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw3/")
|
||||
else()
|
||||
set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/")
|
||||
endif()
|
||||
|
||||
configure_package_config_file("${GLFW_SOURCE_DIR}/src/glfw3Config.cmake.in"
|
||||
"${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
|
||||
INSTALL_DESTINATION "${GLFW_CONFIG_PATH}"
|
||||
PATH_VARS CMAKE_INSTALL_PREFIX
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||
|
||||
write_basic_package_version_file("${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
|
||||
VERSION ${GLFW_VERSION_FULL}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
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/glfw3.pc.in"
|
||||
"${GLFW_BINARY_DIR}/src/glfw3.pc" @ONLY)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Add subdirectories
|
||||
#--------------------------------------------------------------------
|
||||
@ -419,27 +562,25 @@ endif()
|
||||
# The library is installed by src/CMakeLists.txt
|
||||
#--------------------------------------------------------------------
|
||||
if (GLFW_INSTALL)
|
||||
install(DIRECTORY include/GLFW DESTINATION include
|
||||
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
|
||||
install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
|
||||
"${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
|
||||
DESTINATION lib${LIB_SUFFIX}/cmake/glfw)
|
||||
|
||||
if (UNIX)
|
||||
install(EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}/cmake/glfw)
|
||||
install(FILES ${GLFW_BINARY_DIR}/src/glfw3.pc
|
||||
DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
||||
endif()
|
||||
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)
|
||||
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)
|
||||
"${CMAKE_COMMAND}" -P
|
||||
"${GLFW_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
206
extern/glfw/README.md
vendored
206
extern/glfw/README.md
vendored
@ -2,13 +2,14 @@
|
||||
|
||||
## Introduction
|
||||
|
||||
GLFW is a free, Open Source, portable library for OpenGL and OpenGL ES
|
||||
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.0.4 adds better support for custom build environments and fixes for
|
||||
a large number of bugs that together affect all supported platforms. As this is
|
||||
a patch release, there are no API changes.
|
||||
Version 3.1 adds improved documentation, support for custom system cursors, file
|
||||
drop events, main thread wake-up, window frame size retrieval, floating windows,
|
||||
character input with modifier keys, single buffered windows, build improvements
|
||||
and fixes for a large number of bugs.
|
||||
|
||||
If you are new to GLFW, you may find the
|
||||
[introductory tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW
|
||||
@ -16,6 +17,9 @@ If you are new to GLFW, you may find the
|
||||
[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
|
||||
|
||||
@ -30,58 +34,141 @@ See the
|
||||
guide in the GLFW documentation.
|
||||
|
||||
|
||||
## Reporting bugs
|
||||
|
||||
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
|
||||
Please always include the name and version of the OS where the bug occurs and
|
||||
the version of GLFW used. If you have cloned it, include the commit ID used.
|
||||
|
||||
If it's a build issue, please also include the build log and the name and
|
||||
version of your development environment.
|
||||
|
||||
If it's a context creation issue, please also include the make and model of your
|
||||
graphics card and the version of your driver.
|
||||
|
||||
This will help both us and other people experiencing the same bug.
|
||||
|
||||
|
||||
## 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://github.com/tinycthread/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 the `GLFW_BUILD_DOCS` CMake option for controlling whether the
|
||||
documentation is built
|
||||
- Added the `_GLFW_USE_CONFIG_H` configuration macro for controlling whether to
|
||||
include the configuration header
|
||||
- Moved version number macro to `internal.h` for easier manual compilation
|
||||
- Renamed configuration header to `glfw_config.h` to avoid conflicts
|
||||
- Bugfix: The `glfw3.pc` file did not respect the `LIB_SUFFIX` CMake option
|
||||
- Bugfix: The `joysticks` test would segfault if a controller had no axes
|
||||
- [Win32] Allowed swap interval to be explicitly set to zero on DWM systems
|
||||
- [Win32] Bugfix: Removed joystick axis value negation left over from GLFW 2
|
||||
- [Win32] Bugfix: Restoring windows using the Win+D hot key did not trigger the
|
||||
focus callback
|
||||
- [Win32] Bugfix: The disabled cursor mode clip rectangle was updated for
|
||||
unfocused windows
|
||||
- [Win32] Bugfix: Cursor was not properly re-centered over odd-sized windows
|
||||
- [Win32] Bugfix: Negative window positions were reported incorrectly
|
||||
- [Win32] Bugfix: The iconify callback was not triggered when switching away
|
||||
from a full screen window using Alt+Tab
|
||||
- [Win32] Bugfix: Resizing a window with `glfwSetWindowSize` gave it focus
|
||||
- [Cocoa] Added dependency on CoreVideo framework for refresh rate retrieval
|
||||
- [Cocoa] Enabled Lion full screen for resizable windowed mode windows
|
||||
- [Cocoa] Moved to Cocoa API for application transformation and activation
|
||||
- [Cocoa] Bugfix: The `GLFW_KEY_GRAVE_ACCENT` key was reported as
|
||||
`GLFW_KEY_WORLD_1` and vice versa
|
||||
- [Cocoa] Bugfix: The `GLFW_KEY_F13` key was reported as
|
||||
`GLFW_KEY_PRINT_SCREEN`
|
||||
- [Cocoa] Bugfix: Implicit conversion from `NSUInteger` to int caused warnings
|
||||
with Xcode 5
|
||||
- [Cocoa] Bugfix: Use of undeclared selectors with `@selector` caused warnings
|
||||
with Xcode 5
|
||||
- [Cocoa] Bugfix: The cursor remained visible if moved onto client area after
|
||||
having been set to hidden outside it
|
||||
- [Cocoa] Bugfix: The refresh rate was zero for all modes of certain monitors
|
||||
- [Cocoa] Bugfix: The `install_name` field of the dynamic library was not set
|
||||
- [Cocoa] Bugfix: Full screen windows were never reported as having focus
|
||||
- [Cocoa] Bugfix: A superfluous I/O flag test prevented video modes from being
|
||||
listed for Thunderbolt monitor
|
||||
- [Cocoa] Bugfix: Retrieving the name of some external displays caused segfault
|
||||
- [Cocoa] Bugfix: The 10.9 SDK defines `GLintptrARB` and `GLsizeiptrARB`
|
||||
differently from the Khronos `glext.h`
|
||||
- [Cocoa] Bugfix: Creating hidden windows would steal application focus
|
||||
- [Cocoa] Bugfix: Controllers were reported as having zero buttons and axes
|
||||
- [Cocoa] Bugfix: Removed joystick axis value negation left over from GLFW 2
|
||||
- [X11] Added setting of the `WM_CLASS` property to the initial window title
|
||||
- [X11] Added support for `_NET_WM_BYPASS_COMPOSITOR`
|
||||
- [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2
|
||||
- [X11] Bugfix: The position of hidden windows was ignored by Metacity
|
||||
and Compiz
|
||||
- [X11] Bugfix: The `pthread.h` header was not included by the GLX platform
|
||||
header.
|
||||
- Added `GLFWcursor` custom system cursor handle
|
||||
- Added `glfwCreateCursor`, `glfwCreateStandardCursor`, `glfwDestroyCursor` and
|
||||
`glfwSetCursor` for managing system cursor images
|
||||
- Added `GLFWimage` struct for passing 32-bit RGBA images
|
||||
- Added monitor and adapter identifier access to native API
|
||||
- Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files
|
||||
- Added `glfwPostEmptyEvent` for allowing secondary threads to cause
|
||||
`glfwWaitEvents` to return
|
||||
- Added `empty` test program for verifying posting of empty events
|
||||
- Added `glfwSetCharModsCallback` for receiving character events with modifiers
|
||||
- Added `glfwGetWindowFrameSize` for retrieving the size of the frame around
|
||||
the client area of a window
|
||||
- Added `GLFW_AUTO_ICONIFY` for controlling whether full screen windows
|
||||
automatically iconify (and restore the previous video mode) on focus loss
|
||||
- Added `GLFW_DONT_CARE` for indicating that any value is acceptable
|
||||
- Added `GLFW_DOUBLEBUFFER` for controlling whether to use double buffering
|
||||
- Added `GLFW_CONTEXT_RELEASE_BEHAVIOR` and values
|
||||
`GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` and
|
||||
`GLFW_RELEASE_BEHAVIOR_NONE` for `GL_KHR_context_flush_control` support
|
||||
- Added `GLFW_INCLUDE_ES31` for including the OpenGL ES 3.1 header
|
||||
- Added `GLFW_FLOATING` for creating always-on-top windowed mode windows
|
||||
- Added `GLFW_FOCUSED` window hint for controlling initial input focus
|
||||
- Added *partial and experimental* support for Wayland
|
||||
- Added *partial and experimental* support for Mir
|
||||
- Changed the window state attributes (focused, iconified and visible) to query
|
||||
the system directly
|
||||
- Changed the default of `GLFW_REFRESH_RATE` to `GLFW_DONT_CARE` to maintain
|
||||
the default behavior
|
||||
- Changed static library to build as position independent code for easier use
|
||||
from the Rust language
|
||||
- Changed `glfwGetCursorPos` to query the system directly for all cursor modes
|
||||
except captured mode
|
||||
- Bugfix: The debug context attribute was set from `GL_ARB_debug_output` even
|
||||
when a debug context had not been requested
|
||||
- Bugfix: The particles example was not linked against the threading library
|
||||
- Bugfix: The cursor was not positioned over newly created full screen windows
|
||||
- Bugfix: The queried cursor position was not always up-to-date
|
||||
- Bugfix: `glfwExtensionSupported` always failed for OpenGL ES 3.0 and later if
|
||||
the library was compiled for OpenGL ES
|
||||
- [Cocoa] Added `_GLFW_USE_RETINA` to control whether windows will use the full
|
||||
resolution on Retina displays
|
||||
- [Cocoa] Made content view subclass of `NSOpenGLView`
|
||||
- [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen
|
||||
recorders to fail
|
||||
- [Cocoa] Bugfix: Some Core Foundation objects were leaked during joystick
|
||||
enumeration and termination
|
||||
- [Cocoa] Bugfix: One copy of each display name string was leaked
|
||||
- [Cocoa] Bugfix: Monitor enumeration caused a segfault if no `NSScreen` was
|
||||
found for a given `CGDisplay`
|
||||
- [Cocoa] Bugfix: Modifier key events were lost if the corresponding modifier
|
||||
bit field was unchanged
|
||||
- [Cocoa] Bugfix: Joystick enumeration took hundreds of ms on some systems
|
||||
- [Cocoa] Bugfix: The cursor was hidden when the user resized a GLFW window
|
||||
- [Cocoa] Bugfix: The 10.10 Yosemite OpenGL 4.1 profile token was not used
|
||||
- [Cocoa] Bugfix: The generic software OpenGL renderer could be selected under
|
||||
certain conditions
|
||||
- [Cocoa] Bugfix: The virtual cursor jumped unpredictably when entering
|
||||
disabled cursor mode
|
||||
- [Win32] Enabled generation of pkg-config file for MinGW
|
||||
- [Win32] Removed option to require explicitly linking against `winmm.dll`
|
||||
- [Win32] Bugfix: Failure to load winmm or its functions was not reported to
|
||||
the error callback
|
||||
- [Win32] Bugfix: Some keys were reported based on the current layout instead
|
||||
of their physical location
|
||||
- [Win32] Bugfix: Maximized hidden windows were restored by `glfwShowWindow`
|
||||
- [Win32] Bugfix: Context re-creation was not triggered by sRGB hint
|
||||
- [Win32] Bugfix: Full screen windows were incorrectly sized and placed on some
|
||||
systems
|
||||
- [Win32] Bugfix: Gamma ramp functions acted on entire desktop instead of the
|
||||
specified monitor
|
||||
- [Win32] Bugfix: The wrong incorrect physical size was returned for
|
||||
non-primary monitors
|
||||
- [Win32] Bugfix: X-axis scroll offsets were inverted
|
||||
- [Win32] Bugfix: The Optimus HPG forcing variable was not correctly exported
|
||||
- [Win32] Bugfix: The iconified window state attribute was not always updated
|
||||
- [Win32] Bugfix: Previously focused windows with disabled cursor mode and that
|
||||
had been iconified by Win+D were not visible when restored
|
||||
- [Win32] Bugfix: The virtual cursor jumped unpredictably when entering
|
||||
disabled cursor mode
|
||||
- [X11] Added run-time support for systems lacking the XKB extension
|
||||
- [X11] Made GLX 1.3 the minimum supported version
|
||||
- [X11] Replaced `XRRGetScreenResources` with `XRRGetScreenResourcesCurrent`
|
||||
for monitor property retrieval
|
||||
- [X11] Bugfix: The case of finding no usable CRTCs was not detected
|
||||
- [X11] Bugfix: Detection of broken Nvidia RandR gamma support did not verify
|
||||
that at least one CRTC was present
|
||||
- [X11] Bugfix: A stale `_NET_SUPPORTING_WM_CHECK` root window property would
|
||||
cause an uncaught `BadWindow` error
|
||||
- [X11] Bugfix: No check was made for the presence of GLX 1.3 when
|
||||
`GLX_SGIX_fbconfig` was unavailable
|
||||
- [X11] Bugfix: The message type of ICCCM protocol events was not checked
|
||||
- [X11] Bugfix: `glfwDestroyWindow` did not flush the output buffer
|
||||
- [X11] Bugfix: Window frame interactions were reported as focus events
|
||||
- [X11] Bugfix: Workaround for legacy Compiz caused flickering during resize
|
||||
- [X11] Bugfix: The name pointer of joysticks were not cleared on disconnection
|
||||
- [X11] Bugfix: Video mode resolutions and monitor physical sizes were not
|
||||
corrected for rotated CRTCs
|
||||
- [X11] Bugfix: Unicode character input ignored dead keys
|
||||
- [X11] Bugfix: X-axis scroll offsets were inverted
|
||||
- [X11] Bugfix: Full screen override redirect windows were not always
|
||||
positioned over the specified monitor
|
||||
- [X11] Bugfix: Character input did not work for the default `"C"` locale
|
||||
- [X11] Bugfix: Joysticks connected after `glfwInit` were not detected
|
||||
(temporary inotify solution until proper libudev solution)
|
||||
|
||||
|
||||
## Contact
|
||||
@ -119,23 +206,29 @@ skills.
|
||||
- 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
|
||||
- Lucas Hinderberger
|
||||
- Paul Holden
|
||||
- Toni Jovanoski
|
||||
- Arseny Kapoulkine
|
||||
- Osman Keskin
|
||||
- Cameron King
|
||||
- Peter Knut
|
||||
@ -163,10 +256,12 @@ skills.
|
||||
- Peoro
|
||||
- Braden Pellett
|
||||
- Arturo J. Pérez
|
||||
- Cyril Pichard
|
||||
- Pieroman
|
||||
- Jorge Rodriguez
|
||||
- Ed Ropple
|
||||
- Riku Salminen
|
||||
- Brandon Schaefer
|
||||
- Sebastian Schuberth
|
||||
- Matt Sealey
|
||||
- SephiRok
|
||||
@ -184,12 +279,15 @@ skills.
|
||||
- Samuli Tuomola
|
||||
- urraka
|
||||
- Jari Vetoniemi
|
||||
- Ricardo Vieira
|
||||
- Simon Voordouw
|
||||
- Torsten Walluhn
|
||||
- Patrick Walton
|
||||
- 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
|
||||
|
74
extern/glfw/cmake_install.cmake
vendored
Normal file
74
extern/glfw/cmake_install.cmake
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# Install script for directory: /home/fab/swp/swp/extern/glfw
|
||||
|
||||
# Set the install prefix
|
||||
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
|
||||
set(CMAKE_INSTALL_PREFIX "/usr/local")
|
||||
endif()
|
||||
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# Set the install configuration name.
|
||||
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
|
||||
if(BUILD_TYPE)
|
||||
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
|
||||
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_CONFIG_NAME "Release")
|
||||
endif()
|
||||
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
|
||||
endif()
|
||||
|
||||
# Set the component getting installed.
|
||||
if(NOT CMAKE_INSTALL_COMPONENT)
|
||||
if(COMPONENT)
|
||||
message(STATUS "Install component: \"${COMPONENT}\"")
|
||||
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_COMPONENT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Install shared libraries without execute permission?
|
||||
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
|
||||
set(CMAKE_INSTALL_SO_NO_EXE "0")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
|
||||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include" TYPE DIRECTORY FILES "/home/fab/swp/swp/extern/glfw/include/GLFW" FILES_MATCHING REGEX "/glfw3\\.h$" REGEX "/glfw3native\\.h$")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
|
||||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw" TYPE FILE FILES
|
||||
"/home/fab/swp/swp/extern/glfw/src/glfw3Config.cmake"
|
||||
"/home/fab/swp/swp/extern/glfw/src/glfw3ConfigVersion.cmake"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
|
||||
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw/glfwTargets.cmake")
|
||||
file(DIFFERENT EXPORT_FILE_CHANGED FILES
|
||||
"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw/glfwTargets.cmake"
|
||||
"/home/fab/swp/swp/extern/glfw/CMakeFiles/Export/lib/cmake/glfw/glfwTargets.cmake")
|
||||
if(EXPORT_FILE_CHANGED)
|
||||
file(GLOB OLD_CONFIG_FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw/glfwTargets-*.cmake")
|
||||
if(OLD_CONFIG_FILES)
|
||||
message(STATUS "Old export file \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw/glfwTargets.cmake\" will be replaced. Removing files [${OLD_CONFIG_FILES}].")
|
||||
file(REMOVE ${OLD_CONFIG_FILES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw" TYPE FILE FILES "/home/fab/swp/swp/extern/glfw/CMakeFiles/Export/lib/cmake/glfw/glfwTargets.cmake")
|
||||
if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
|
||||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw" TYPE FILE FILES "/home/fab/swp/swp/extern/glfw/CMakeFiles/Export/lib/cmake/glfw/glfwTargets-release.cmake")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
|
||||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" TYPE FILE FILES "/home/fab/swp/swp/extern/glfw/src/glfw3.pc")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_LOCAL_ONLY)
|
||||
# Include the install script for each subdirectory.
|
||||
include("/home/fab/swp/swp/extern/glfw/src/cmake_install.cmake")
|
||||
|
||||
endif()
|
||||
|
29
extern/glfw/cmake_uninstall.cmake
vendored
Normal file
29
extern/glfw/cmake_uninstall.cmake
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
if (NOT EXISTS "/home/fab/swp/swp/extern/glfw/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: \"/home/fab/swp/swp/extern/glfw/install_manifest.txt\"")
|
||||
endif()
|
||||
|
||||
file(READ "/home/fab/swp/swp/extern/glfw/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("/usr/bin/cmake" 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("/usr/bin/cmake" 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()
|
||||
|
842
extern/glfw/deps/GL/glext.h
vendored
842
extern/glfw/deps/GL/glext.h
vendored
File diff suppressed because it is too large
Load Diff
82
extern/glfw/deps/GL/glxext.h
vendored
82
extern/glfw/deps/GL/glxext.h
vendored
@ -6,7 +6,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2013 The Khronos Group Inc.
|
||||
** Copyright (c) 2013-2014 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@ -33,10 +33,10 @@ extern "C" {
|
||||
** used to make the header, and the header can be found at
|
||||
** http://www.opengl.org/registry/
|
||||
**
|
||||
** Khronos $Revision: 23649 $ on $Date: 2013-10-23 00:21:49 -0700 (Wed, 23 Oct 2013) $
|
||||
** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $
|
||||
*/
|
||||
|
||||
#define GLX_GLXEXT_VERSION 20131008
|
||||
#define GLX_GLXEXT_VERSION 20140810
|
||||
|
||||
/* Generated C header for:
|
||||
* API: glx
|
||||
@ -49,6 +49,7 @@ extern "C" {
|
||||
|
||||
#ifndef GLX_VERSION_1_3
|
||||
#define GLX_VERSION_1_3 1
|
||||
typedef XID GLXContextID;
|
||||
typedef struct __GLXFBConfigRec *GLXFBConfig;
|
||||
typedef XID GLXWindow;
|
||||
typedef XID GLXPbuffer;
|
||||
@ -157,6 +158,13 @@ __GLXextFuncPtr glXGetProcAddress (const GLubyte *procName);
|
||||
#endif
|
||||
#endif /* GLX_VERSION_1_4 */
|
||||
|
||||
#ifndef GLX_ARB_context_flush_control
|
||||
#define GLX_ARB_context_flush_control 1
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#endif /* GLX_ARB_context_flush_control */
|
||||
|
||||
#ifndef GLX_ARB_create_context
|
||||
#define GLX_ARB_create_context 1
|
||||
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
@ -272,7 +280,6 @@ __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName);
|
||||
|
||||
#ifndef GLX_EXT_import_context
|
||||
#define GLX_EXT_import_context 1
|
||||
typedef XID GLXContextID;
|
||||
#define GLX_SHARE_CONTEXT_EXT 0x800A
|
||||
#define GLX_VISUAL_ID_EXT 0x800B
|
||||
#define GLX_SCREEN_EXT 0x800C
|
||||
@ -290,6 +297,23 @@ void glXFreeContextEXT (Display *dpy, GLXContext context);
|
||||
#endif
|
||||
#endif /* GLX_EXT_import_context */
|
||||
|
||||
#ifndef GLX_EXT_stereo_tree
|
||||
#define GLX_EXT_stereo_tree 1
|
||||
typedef struct {
|
||||
int type;
|
||||
unsigned long serial;
|
||||
Bool send_event;
|
||||
Display *display;
|
||||
int extension;
|
||||
int evtype;
|
||||
GLXDrawable window;
|
||||
Bool stereo_tree;
|
||||
} GLXStereoNotifyEventEXT;
|
||||
#define GLX_STEREO_TREE_EXT 0x20F5
|
||||
#define GLX_STEREO_NOTIFY_MASK_EXT 0x00000001
|
||||
#define GLX_STEREO_NOTIFY_EXT 0x00000000
|
||||
#endif /* GLX_EXT_stereo_tree */
|
||||
|
||||
#ifndef GLX_EXT_swap_control
|
||||
#define GLX_EXT_swap_control 1
|
||||
#define GLX_SWAP_INTERVAL_EXT 0x20F1
|
||||
@ -407,6 +431,32 @@ GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixm
|
||||
#endif
|
||||
#endif /* GLX_MESA_pixmap_colormap */
|
||||
|
||||
#ifndef GLX_MESA_query_renderer
|
||||
#define GLX_MESA_query_renderer 1
|
||||
#define GLX_RENDERER_VENDOR_ID_MESA 0x8183
|
||||
#define GLX_RENDERER_DEVICE_ID_MESA 0x8184
|
||||
#define GLX_RENDERER_VERSION_MESA 0x8185
|
||||
#define GLX_RENDERER_ACCELERATED_MESA 0x8186
|
||||
#define GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187
|
||||
#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188
|
||||
#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189
|
||||
#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A
|
||||
#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B
|
||||
#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C
|
||||
#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D
|
||||
#define GLX_RENDERER_ID_MESA 0x818E
|
||||
typedef Bool ( *PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
|
||||
typedef const char *( *PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute);
|
||||
typedef Bool ( *PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value);
|
||||
typedef const char *( *PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute);
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
Bool glXQueryCurrentRendererIntegerMESA (int attribute, unsigned int *value);
|
||||
const char *glXQueryCurrentRendererStringMESA (int attribute);
|
||||
Bool glXQueryRendererIntegerMESA (Display *dpy, int screen, int renderer, int attribute, unsigned int *value);
|
||||
const char *glXQueryRendererStringMESA (Display *dpy, int screen, int renderer, int attribute);
|
||||
#endif
|
||||
#endif /* GLX_MESA_query_renderer */
|
||||
|
||||
#ifndef GLX_MESA_release_buffers
|
||||
#define GLX_MESA_release_buffers 1
|
||||
typedef Bool ( *PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable);
|
||||
@ -425,6 +475,16 @@ Bool glXSet3DfxModeMESA (int mode);
|
||||
#endif
|
||||
#endif /* GLX_MESA_set_3dfx_mode */
|
||||
|
||||
#ifndef GLX_NV_copy_buffer
|
||||
#define GLX_NV_copy_buffer 1
|
||||
typedef void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
|
||||
typedef void ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
void glXCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
|
||||
void glXNamedCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
|
||||
#endif
|
||||
#endif /* GLX_NV_copy_buffer */
|
||||
|
||||
#ifndef GLX_NV_copy_image
|
||||
#define GLX_NV_copy_image 1
|
||||
typedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
@ -433,6 +493,14 @@ void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLe
|
||||
#endif
|
||||
#endif /* GLX_NV_copy_image */
|
||||
|
||||
#ifndef GLX_NV_delay_before_swap
|
||||
#define GLX_NV_delay_before_swap 1
|
||||
typedef Bool ( *PFNGLXDELAYBEFORESWAPNVPROC) (Display *dpy, GLXDrawable drawable, GLfloat seconds);
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
Bool glXDelayBeforeSwapNV (Display *dpy, GLXDrawable drawable, GLfloat seconds);
|
||||
#endif
|
||||
#endif /* GLX_NV_delay_before_swap */
|
||||
|
||||
#ifndef GLX_NV_float_buffer
|
||||
#define GLX_NV_float_buffer 1
|
||||
#define GLX_FLOAT_COMPONENTS_NV 0x20B0
|
||||
@ -493,8 +561,8 @@ void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV devic
|
||||
#endif
|
||||
#endif /* GLX_NV_video_capture */
|
||||
|
||||
#ifndef GLX_NV_video_output
|
||||
#define GLX_NV_video_output 1
|
||||
#ifndef GLX_NV_video_out
|
||||
#define GLX_NV_video_out 1
|
||||
typedef unsigned int GLXVideoDeviceNV;
|
||||
#define GLX_VIDEO_OUT_COLOR_NV 0x20C3
|
||||
#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4
|
||||
@ -520,7 +588,7 @@ int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf);
|
||||
int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
|
||||
int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#endif
|
||||
#endif /* GLX_NV_video_output */
|
||||
#endif /* GLX_NV_video_out */
|
||||
|
||||
#ifndef GLX_OML_swap_method
|
||||
#define GLX_OML_swap_method 1
|
||||
|
13
extern/glfw/deps/GL/wglext.h
vendored
13
extern/glfw/deps/GL/wglext.h
vendored
@ -6,7 +6,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2013 The Khronos Group Inc.
|
||||
** Copyright (c) 2013-2014 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@ -33,7 +33,7 @@ extern "C" {
|
||||
** used to make the header, and the header can be found at
|
||||
** http://www.opengl.org/registry/
|
||||
**
|
||||
** Khronos $Revision: 23649 $ on $Date: 2013-10-23 00:21:49 -0700 (Wed, 23 Oct 2013) $
|
||||
** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||
@ -41,7 +41,7 @@ extern "C" {
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define WGL_WGLEXT_VERSION 20130916
|
||||
#define WGL_WGLEXT_VERSION 20140810
|
||||
|
||||
/* Generated C header for:
|
||||
* API: wgl
|
||||
@ -70,6 +70,13 @@ BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width,
|
||||
#endif
|
||||
#endif /* WGL_ARB_buffer_region */
|
||||
|
||||
#ifndef WGL_ARB_context_flush_control
|
||||
#define WGL_ARB_context_flush_control 1
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#endif /* WGL_ARB_context_flush_control */
|
||||
|
||||
#ifndef WGL_ARB_create_context
|
||||
#define WGL_ARB_create_context 1
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
|
282
extern/glfw/deps/KHR/khrplatform.h
vendored
Normal file
282
extern/glfw/deps/KHR/khrplatform.h
vendored
Normal file
@ -0,0 +1,282 @@
|
||||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2009 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by sending them to the public Khronos Bugzilla
|
||||
* (http://khronos.org/bugzilla) by filing a bug against product
|
||||
* "Khronos (general)" component "Registry".
|
||||
*
|
||||
* A predefined template which fills in some of the bug fields can be
|
||||
* reached using http://tinyurl.com/khrplatform-h-bugreport, but you
|
||||
* must create a Bugzilla login first.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef _WIN64
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
467
extern/glfw/deps/getopt.c
vendored
467
extern/glfw/deps/getopt.c
vendored
@ -1,267 +1,230 @@
|
||||
/*****************************************************************************
|
||||
* getopt.c - competent and free getopt library.
|
||||
* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $
|
||||
*
|
||||
* Copyright (c)2002-2003 Mark K. Kim
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the original author of this software nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
/* Copyright (c) 2012, Kim Gräsman
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Kim Gräsman nor the names of contributors may be used
|
||||
* to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "getopt.h"
|
||||
|
||||
/* 2013-01-06 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
*
|
||||
* Only define _CRT_SECURE_NO_WARNINGS if not already defined.
|
||||
*/
|
||||
/* 2012-08-12 Lambert Clara <lambert.clara@yahoo.fr>
|
||||
*
|
||||
* Constify third argument of getopt.
|
||||
*/
|
||||
/* 2011-07-27 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
*
|
||||
* Added _CRT_SECURE_NO_WARNINGS macro.
|
||||
*/
|
||||
/* 2009-10-12 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
*
|
||||
* Removed unused global static variable 'ID'.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
char* optarg = NULL;
|
||||
int optind = 0;
|
||||
int opterr = 1;
|
||||
int optopt = '?';
|
||||
const int no_argument = 0;
|
||||
const int required_argument = 1;
|
||||
const int optional_argument = 2;
|
||||
|
||||
char* optarg;
|
||||
int optopt;
|
||||
/* The variable optind [...] shall be initialized to 1 by the system. */
|
||||
int optind = 1;
|
||||
int opterr;
|
||||
|
||||
static char** prev_argv = NULL; /* Keep a copy of argv and argc to */
|
||||
static int prev_argc = 0; /* tell if getopt params change */
|
||||
static int argv_index = 0; /* Option we're checking */
|
||||
static int argv_index2 = 0; /* Option argument we're checking */
|
||||
static int opt_offset = 0; /* Index into compounded "-option" */
|
||||
static int dashdash = 0; /* True if "--" option reached */
|
||||
static int nonopt = 0; /* How many nonopts we've found */
|
||||
static char* optcursor = NULL;
|
||||
|
||||
static void increment_index()
|
||||
{
|
||||
/* Move onto the next option */
|
||||
if(argv_index < argv_index2)
|
||||
{
|
||||
while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-'
|
||||
&& argv_index < argv_index2+1);
|
||||
}
|
||||
else argv_index++;
|
||||
opt_offset = 1;
|
||||
}
|
||||
/* Implemented based on [1] and [2] for optional arguments.
|
||||
optopt is handled FreeBSD-style, per [3].
|
||||
Other GNU and FreeBSD extensions are purely accidental.
|
||||
|
||||
|
||||
/*
|
||||
* Permutes argv[] so that the argument currently being processed is moved
|
||||
* to the end.
|
||||
[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html
|
||||
[2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
|
||||
[3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE
|
||||
*/
|
||||
static int permute_argv_once()
|
||||
{
|
||||
/* Movability check */
|
||||
if(argv_index + nonopt >= prev_argc) return 1;
|
||||
/* Move the current option to the end, bring the others to front */
|
||||
else
|
||||
{
|
||||
char* tmp = prev_argv[argv_index];
|
||||
int getopt(int argc, char* const argv[], const char* optstring) {
|
||||
int optchar = -1;
|
||||
const char* optdecl = NULL;
|
||||
|
||||
/* Move the data */
|
||||
memmove(&prev_argv[argv_index], &prev_argv[argv_index+1],
|
||||
sizeof(char**) * (prev_argc - argv_index - 1));
|
||||
prev_argv[prev_argc - 1] = tmp;
|
||||
optarg = NULL;
|
||||
opterr = 0;
|
||||
optopt = 0;
|
||||
|
||||
nonopt++;
|
||||
return 0;
|
||||
}
|
||||
/* Unspecified, but we need it to avoid overrunning the argv bounds. */
|
||||
if (optind >= argc)
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called argv[optind] is a null pointer, getopt()
|
||||
shall return -1 without changing optind. */
|
||||
if (argv[optind] == NULL)
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called *argv[optind] is not the character '-',
|
||||
getopt() shall return -1 without changing optind. */
|
||||
if (*argv[optind] != '-')
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called argv[optind] points to the string "-",
|
||||
getopt() shall return -1 without changing optind. */
|
||||
if (strcmp(argv[optind], "-") == 0)
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called argv[optind] points to the string "--",
|
||||
getopt() shall return -1 after incrementing optind. */
|
||||
if (strcmp(argv[optind], "--") == 0) {
|
||||
++optind;
|
||||
goto no_more_optchars;
|
||||
}
|
||||
|
||||
if (optcursor == NULL || *optcursor == '\0')
|
||||
optcursor = argv[optind] + 1;
|
||||
|
||||
optchar = *optcursor;
|
||||
|
||||
/* FreeBSD: The variable optopt saves the last known option character
|
||||
returned by getopt(). */
|
||||
optopt = optchar;
|
||||
|
||||
/* The getopt() function shall return the next option character (if one is
|
||||
found) from argv that matches a character in optstring, if there is
|
||||
one that matches. */
|
||||
optdecl = strchr(optstring, optchar);
|
||||
if (optdecl) {
|
||||
/* [I]f a character is followed by a colon, the option takes an
|
||||
argument. */
|
||||
if (optdecl[1] == ':') {
|
||||
optarg = ++optcursor;
|
||||
if (*optarg == '\0') {
|
||||
/* GNU extension: Two colons mean an option takes an
|
||||
optional arg; if there is text in the current argv-element
|
||||
(i.e., in the same word as the option name itself, for example,
|
||||
"-oarg"), then it is returned in optarg, otherwise optarg is set
|
||||
to zero. */
|
||||
if (optdecl[2] != ':') {
|
||||
/* If the option was the last character in the string pointed to by
|
||||
an element of argv, then optarg shall contain the next element
|
||||
of argv, and optind shall be incremented by 2. If the resulting
|
||||
value of optind is greater than argc, this indicates a missing
|
||||
option-argument, and getopt() shall return an error indication.
|
||||
|
||||
Otherwise, optarg shall point to the string following the
|
||||
option character in that element of argv, and optind shall be
|
||||
incremented by 1.
|
||||
*/
|
||||
if (++optind < argc) {
|
||||
optarg = argv[optind];
|
||||
} else {
|
||||
/* If it detects a missing option-argument, it shall return the
|
||||
colon character ( ':' ) if the first character of optstring
|
||||
was a colon, or a question-mark character ( '?' ) otherwise.
|
||||
*/
|
||||
optarg = NULL;
|
||||
optchar = (optstring[0] == ':') ? ':' : '?';
|
||||
}
|
||||
} else {
|
||||
optarg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
optcursor = NULL;
|
||||
}
|
||||
} else {
|
||||
/* If getopt() encounters an option character that is not contained in
|
||||
optstring, it shall return the question-mark ( '?' ) character. */
|
||||
optchar = '?';
|
||||
}
|
||||
|
||||
if (optcursor == NULL || *++optcursor == '\0')
|
||||
++optind;
|
||||
|
||||
return optchar;
|
||||
|
||||
no_more_optchars:
|
||||
optcursor = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Implementation based on [1].
|
||||
|
||||
int getopt(int argc, char** argv, const char* optstr)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
/* If we have new argv, reinitialize */
|
||||
if(prev_argv != argv || prev_argc != argc)
|
||||
{
|
||||
/* Initialize variables */
|
||||
prev_argv = argv;
|
||||
prev_argc = argc;
|
||||
argv_index = 1;
|
||||
argv_index2 = 1;
|
||||
opt_offset = 1;
|
||||
dashdash = 0;
|
||||
nonopt = 0;
|
||||
}
|
||||
|
||||
/* Jump point in case we want to ignore the current argv_index */
|
||||
getopt_top:
|
||||
|
||||
/* Misc. initializations */
|
||||
optarg = NULL;
|
||||
|
||||
/* Dash-dash check */
|
||||
if(argv[argv_index] && !strcmp(argv[argv_index], "--"))
|
||||
{
|
||||
dashdash = 1;
|
||||
increment_index();
|
||||
}
|
||||
|
||||
/* If we're at the end of argv, that's it. */
|
||||
if(argv[argv_index] == NULL)
|
||||
{
|
||||
c = -1;
|
||||
}
|
||||
/* Are we looking at a string? Single dash is also a string */
|
||||
else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-"))
|
||||
{
|
||||
/* If we want a string... */
|
||||
if(optstr[0] == '-')
|
||||
{
|
||||
c = 1;
|
||||
optarg = argv[argv_index];
|
||||
increment_index();
|
||||
}
|
||||
/* If we really don't want it (we're in POSIX mode), we're done */
|
||||
else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT"))
|
||||
{
|
||||
c = -1;
|
||||
|
||||
/* Everything else is a non-opt argument */
|
||||
nonopt = argc - argv_index;
|
||||
}
|
||||
/* If we mildly don't want it, then move it back */
|
||||
else
|
||||
{
|
||||
if(!permute_argv_once()) goto getopt_top;
|
||||
else c = -1;
|
||||
}
|
||||
}
|
||||
/* Otherwise we're looking at an option */
|
||||
else
|
||||
{
|
||||
char* opt_ptr = NULL;
|
||||
|
||||
/* Grab the option */
|
||||
c = argv[argv_index][opt_offset++];
|
||||
|
||||
/* Is the option in the optstr? */
|
||||
if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c);
|
||||
else opt_ptr = strchr(optstr, c);
|
||||
/* Invalid argument */
|
||||
if(!opt_ptr)
|
||||
{
|
||||
if(opterr)
|
||||
{
|
||||
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
|
||||
}
|
||||
|
||||
optopt = c;
|
||||
c = '?';
|
||||
|
||||
/* Move onto the next option */
|
||||
increment_index();
|
||||
}
|
||||
/* Option takes argument */
|
||||
else if(opt_ptr[1] == ':')
|
||||
{
|
||||
/* ie, -oARGUMENT, -xxxoARGUMENT, etc. */
|
||||
if(argv[argv_index][opt_offset] != '\0')
|
||||
{
|
||||
optarg = &argv[argv_index][opt_offset];
|
||||
increment_index();
|
||||
}
|
||||
/* ie, -o ARGUMENT (only if it's a required argument) */
|
||||
else if(opt_ptr[2] != ':')
|
||||
{
|
||||
/* One of those "you're not expected to understand this" moment */
|
||||
if(argv_index2 < argv_index) argv_index2 = argv_index;
|
||||
while(argv[++argv_index2] && argv[argv_index2][0] == '-');
|
||||
optarg = argv[argv_index2];
|
||||
|
||||
/* Don't cross into the non-option argument list */
|
||||
if(argv_index2 + nonopt >= prev_argc) optarg = NULL;
|
||||
|
||||
/* Move onto the next option */
|
||||
increment_index();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Move onto the next option */
|
||||
increment_index();
|
||||
}
|
||||
|
||||
/* In case we got no argument for an option with required argument */
|
||||
if(optarg == NULL && opt_ptr[2] != ':')
|
||||
{
|
||||
optopt = c;
|
||||
c = '?';
|
||||
|
||||
if(opterr)
|
||||
{
|
||||
fprintf(stderr,"%s: option requires an argument -- %c\n",
|
||||
argv[0], optopt);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Option does not take argument */
|
||||
else
|
||||
{
|
||||
/* Next argv_index */
|
||||
if(argv[argv_index][opt_offset] == '\0')
|
||||
{
|
||||
increment_index();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate optind */
|
||||
if(c == -1)
|
||||
{
|
||||
optind = argc - nonopt;
|
||||
}
|
||||
else
|
||||
{
|
||||
optind = argv_index;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/* vim:ts=3
|
||||
[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
|
||||
*/
|
||||
int getopt_long(int argc, char* const argv[], const char* optstring,
|
||||
const struct option* longopts, int* longindex) {
|
||||
const struct option* o = longopts;
|
||||
const struct option* match = NULL;
|
||||
int num_matches = 0;
|
||||
size_t argument_name_length = 0;
|
||||
const char* current_argument = NULL;
|
||||
int retval = -1;
|
||||
|
||||
optarg = NULL;
|
||||
optopt = 0;
|
||||
|
||||
if (optind >= argc)
|
||||
return -1;
|
||||
|
||||
if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0)
|
||||
return getopt(argc, argv, optstring);
|
||||
|
||||
/* It's an option; starts with -- and is longer than two chars. */
|
||||
current_argument = argv[optind] + 2;
|
||||
argument_name_length = strcspn(current_argument, "=");
|
||||
for (; o->name; ++o) {
|
||||
if (strncmp(o->name, current_argument, argument_name_length) == 0) {
|
||||
match = o;
|
||||
++num_matches;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_matches == 1) {
|
||||
/* If longindex is not NULL, it points to a variable which is set to the
|
||||
index of the long option relative to longopts. */
|
||||
if (longindex)
|
||||
*longindex = (int) (match - longopts);
|
||||
|
||||
/* If flag is NULL, then getopt_long() shall return val.
|
||||
Otherwise, getopt_long() returns 0, and flag shall point to a variable
|
||||
which shall be set to val if the option is found, but left unchanged if
|
||||
the option is not found. */
|
||||
if (match->flag)
|
||||
*(match->flag) = match->val;
|
||||
|
||||
retval = match->flag ? 0 : match->val;
|
||||
|
||||
if (match->has_arg != no_argument) {
|
||||
optarg = strchr(argv[optind], '=');
|
||||
if (optarg != NULL)
|
||||
++optarg;
|
||||
|
||||
if (match->has_arg == required_argument) {
|
||||
/* Only scan the next argv for required arguments. Behavior is not
|
||||
specified, but has been observed with Ubuntu and Mac OSX. */
|
||||
if (optarg == NULL && ++optind < argc) {
|
||||
optarg = argv[optind];
|
||||
}
|
||||
|
||||
if (optarg == NULL)
|
||||
retval = ':';
|
||||
}
|
||||
} else if (strchr(argv[optind], '=')) {
|
||||
/* An argument was provided to a non-argument option.
|
||||
I haven't seen this specified explicitly, but both GNU and BSD-based
|
||||
implementations show this behavior.
|
||||
*/
|
||||
retval = '?';
|
||||
}
|
||||
} else {
|
||||
/* Unknown option or ambiguous match. */
|
||||
retval = '?';
|
||||
}
|
||||
|
||||
++optind;
|
||||
return retval;
|
||||
}
|
||||
|
94
extern/glfw/deps/getopt.h
vendored
94
extern/glfw/deps/getopt.h
vendored
@ -1,63 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* getopt.h - competent and free getopt library.
|
||||
* $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $
|
||||
*
|
||||
* Copyright (c)2002-2003 Mark K. Kim
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the original author of this software nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
#ifndef GETOPT_H_
|
||||
#define GETOPT_H_
|
||||
/* Copyright (c) 2012, Kim Gräsman
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Kim Gräsman nor the names of contributors may be used
|
||||
* to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_GETOPT_PORT_H
|
||||
#define INCLUDED_GETOPT_PORT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const int no_argument;
|
||||
extern const int required_argument;
|
||||
extern const int optional_argument;
|
||||
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
extern int opterr;
|
||||
extern int optopt;
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
int getopt(int argc, char** argv, const char* optstr);
|
||||
struct option {
|
||||
const char* name;
|
||||
int has_arg;
|
||||
int* flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
int getopt(int argc, char* const argv[], const char* optstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
int getopt_long(int argc, char* const argv[],
|
||||
const char* optstring, const struct option* longopts, int* longindex);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* GETOPT_H_ */
|
||||
|
||||
|
||||
/* vim:ts=3
|
||||
*/
|
||||
#endif // INCLUDED_GETOPT_PORT_H
|
||||
|
728
extern/glfw/deps/glad.c
vendored
Normal file
728
extern/glfw/deps/glad.c
vendored
Normal file
@ -0,0 +1,728 @@
|
||||
#include <string.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
struct gladGLversionStruct GLVersion;
|
||||
|
||||
#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
|
||||
#define _GLAD_IS_SOME_NEW_VERSION 1
|
||||
#endif
|
||||
|
||||
int GLAD_GL_VERSION_1_0;
|
||||
int GLAD_GL_VERSION_1_1;
|
||||
int GLAD_GL_VERSION_1_2;
|
||||
int GLAD_GL_VERSION_1_3;
|
||||
int GLAD_GL_VERSION_1_4;
|
||||
int GLAD_GL_VERSION_1_5;
|
||||
int GLAD_GL_VERSION_2_0;
|
||||
int GLAD_GL_VERSION_2_1;
|
||||
int GLAD_GL_VERSION_3_0;
|
||||
int GLAD_GL_VERSION_3_1;
|
||||
int GLAD_GL_VERSION_3_2;
|
||||
PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
|
||||
PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
|
||||
PFNGLFLUSHPROC glad_glFlush;
|
||||
PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
|
||||
PFNGLCLEARCOLORPROC glad_glClearColor;
|
||||
PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
|
||||
PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
|
||||
PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
|
||||
PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
|
||||
PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
|
||||
PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
|
||||
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
|
||||
PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
|
||||
PFNGLLINKPROGRAMPROC glad_glLinkProgram;
|
||||
PFNGLBINDTEXTUREPROC glad_glBindTexture;
|
||||
PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
|
||||
PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
|
||||
PFNGLFENCESYNCPROC glad_glFenceSync;
|
||||
PFNGLUNIFORM3UIPROC glad_glUniform3ui;
|
||||
PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
|
||||
PFNGLGETSTRINGPROC glad_glGetString;
|
||||
PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
|
||||
PFNGLDETACHSHADERPROC glad_glDetachShader;
|
||||
PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
|
||||
PFNGLGENBUFFERSPROC glad_glGenBuffers;
|
||||
PFNGLENDQUERYPROC glad_glEndQuery;
|
||||
PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
|
||||
PFNGLLINEWIDTHPROC glad_glLineWidth;
|
||||
PFNGLUNIFORM2FVPROC glad_glUniform2fv;
|
||||
PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
|
||||
PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
|
||||
PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
|
||||
PFNGLCOMPILESHADERPROC glad_glCompileShader;
|
||||
PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
|
||||
PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
|
||||
PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
|
||||
PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
|
||||
PFNGLPOLYGONMODEPROC glad_glPolygonMode;
|
||||
PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
|
||||
PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
|
||||
PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
|
||||
PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
|
||||
PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
|
||||
PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
|
||||
PFNGLISSYNCPROC glad_glIsSync;
|
||||
PFNGLCLAMPCOLORPROC glad_glClampColor;
|
||||
PFNGLUNIFORM4IVPROC glad_glUniform4iv;
|
||||
PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
|
||||
PFNGLCLEARSTENCILPROC glad_glClearStencil;
|
||||
PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
|
||||
PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
|
||||
PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
|
||||
PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
|
||||
PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
|
||||
PFNGLENABLEIPROC glad_glEnablei;
|
||||
PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
|
||||
PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
|
||||
PFNGLGENTEXTURESPROC glad_glGenTextures;
|
||||
PFNGLDEPTHFUNCPROC glad_glDepthFunc;
|
||||
PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
|
||||
PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
|
||||
PFNGLUNIFORM1FPROC glad_glUniform1f;
|
||||
PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
|
||||
PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
|
||||
PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
|
||||
PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
|
||||
PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
|
||||
PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
|
||||
PFNGLCREATESHADERPROC glad_glCreateShader;
|
||||
PFNGLISBUFFERPROC glad_glIsBuffer;
|
||||
PFNGLUNIFORM1IPROC glad_glUniform1i;
|
||||
PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
|
||||
PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
|
||||
PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
|
||||
PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
|
||||
PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
|
||||
PFNGLDISABLEPROC glad_glDisable;
|
||||
PFNGLUNIFORM2IPROC glad_glUniform2i;
|
||||
PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
|
||||
PFNGLLOGICOPPROC glad_glLogicOp;
|
||||
PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
|
||||
PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
|
||||
PFNGLCOLORMASKPROC glad_glColorMask;
|
||||
PFNGLHINTPROC glad_glHint;
|
||||
PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
|
||||
PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
|
||||
PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
|
||||
PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
|
||||
PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
|
||||
PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
|
||||
PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
|
||||
PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
|
||||
PFNGLCULLFACEPROC glad_glCullFace;
|
||||
PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
|
||||
PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
|
||||
PFNGLUNIFORM4FVPROC glad_glUniform4fv;
|
||||
PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
|
||||
PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
|
||||
PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
|
||||
PFNGLPOINTSIZEPROC glad_glPointSize;
|
||||
PFNGLGETSTRINGIPROC glad_glGetStringi;
|
||||
PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
|
||||
PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
|
||||
PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
|
||||
PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
|
||||
PFNGLGENQUERIESPROC glad_glGenQueries;
|
||||
PFNGLWAITSYNCPROC glad_glWaitSync;
|
||||
PFNGLATTACHSHADERPROC glad_glAttachShader;
|
||||
PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
|
||||
PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
|
||||
PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
|
||||
PFNGLUNIFORM3IPROC glad_glUniform3i;
|
||||
PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
|
||||
PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
|
||||
PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
|
||||
PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
|
||||
PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
|
||||
PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
|
||||
PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
|
||||
PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
|
||||
PFNGLUNIFORM3FPROC glad_glUniform3f;
|
||||
PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
|
||||
PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
|
||||
PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
|
||||
PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
|
||||
PFNGLDRAWELEMENTSPROC glad_glDrawElements;
|
||||
PFNGLCOLORMASKIPROC glad_glColorMaski;
|
||||
PFNGLISENABLEDIPROC glad_glIsEnabledi;
|
||||
PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
|
||||
PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
|
||||
PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
|
||||
PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
|
||||
PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
|
||||
PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
|
||||
PFNGLUNIFORM1IVPROC glad_glUniform1iv;
|
||||
PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
|
||||
PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
|
||||
PFNGLREADBUFFERPROC glad_glReadBuffer;
|
||||
PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
|
||||
PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
|
||||
PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
|
||||
PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
|
||||
PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
|
||||
PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
|
||||
PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
|
||||
PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
|
||||
PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
|
||||
PFNGLGETSHADERIVPROC glad_glGetShaderiv;
|
||||
PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
|
||||
PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
|
||||
PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
|
||||
PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
|
||||
PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
|
||||
PFNGLBLENDCOLORPROC glad_glBlendColor;
|
||||
PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
|
||||
PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
|
||||
PFNGLDEPTHMASKPROC glad_glDepthMask;
|
||||
PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
|
||||
PFNGLDISABLEIPROC glad_glDisablei;
|
||||
PFNGLGETDOUBLEVPROC glad_glGetDoublev;
|
||||
PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
|
||||
PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
|
||||
PFNGLSHADERSOURCEPROC glad_glShaderSource;
|
||||
PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
|
||||
PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
|
||||
PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
|
||||
PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
|
||||
PFNGLDRAWARRAYSPROC glad_glDrawArrays;
|
||||
PFNGLUNIFORM1UIPROC glad_glUniform1ui;
|
||||
PFNGLISPROGRAMPROC glad_glIsProgram;
|
||||
PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
|
||||
PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
|
||||
PFNGLGETSYNCIVPROC glad_glGetSynciv;
|
||||
PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
|
||||
PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
|
||||
PFNGLUNIFORM4IPROC glad_glUniform4i;
|
||||
PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
|
||||
PFNGLCLEARPROC glad_glClear;
|
||||
PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
|
||||
PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
|
||||
PFNGLUNIFORM2FPROC glad_glUniform2f;
|
||||
PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
|
||||
PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
|
||||
PFNGLBEGINQUERYPROC glad_glBeginQuery;
|
||||
PFNGLUNIFORM2IVPROC glad_glUniform2iv;
|
||||
PFNGLBINDBUFFERPROC glad_glBindBuffer;
|
||||
PFNGLISENABLEDPROC glad_glIsEnabled;
|
||||
PFNGLSTENCILOPPROC glad_glStencilOp;
|
||||
PFNGLREADPIXELSPROC glad_glReadPixels;
|
||||
PFNGLCLEARDEPTHPROC glad_glClearDepth;
|
||||
PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
|
||||
PFNGLUNIFORM4FPROC glad_glUniform4f;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
|
||||
PFNGLMAPBUFFERPROC glad_glMapBuffer;
|
||||
PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
|
||||
PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
|
||||
PFNGLUNIFORM3FVPROC glad_glUniform3fv;
|
||||
PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
|
||||
PFNGLBUFFERDATAPROC glad_glBufferData;
|
||||
PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
|
||||
PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
|
||||
PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
|
||||
PFNGLDELETESYNCPROC glad_glDeleteSync;
|
||||
PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
|
||||
PFNGLGETERRORPROC glad_glGetError;
|
||||
PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
|
||||
PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
|
||||
PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
|
||||
PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
|
||||
PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
|
||||
PFNGLGETFLOATVPROC glad_glGetFloatv;
|
||||
PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
|
||||
PFNGLUNIFORM3IVPROC glad_glUniform3iv;
|
||||
PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
|
||||
PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
|
||||
PFNGLUSEPROGRAMPROC glad_glUseProgram;
|
||||
PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
|
||||
PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
|
||||
PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
|
||||
PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
|
||||
PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
|
||||
PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
|
||||
PFNGLSTENCILFUNCPROC glad_glStencilFunc;
|
||||
PFNGLGETINTEGERVPROC glad_glGetIntegerv;
|
||||
PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
|
||||
PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
|
||||
PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
|
||||
PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
|
||||
PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
|
||||
PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
|
||||
PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
|
||||
PFNGLUNIFORM1FVPROC glad_glUniform1fv;
|
||||
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
|
||||
PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
|
||||
PFNGLISQUERYPROC glad_glIsQuery;
|
||||
PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
|
||||
PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
|
||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
|
||||
PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
|
||||
PFNGLGETQUERYIVPROC glad_glGetQueryiv;
|
||||
PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
|
||||
PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
|
||||
PFNGLSTENCILMASKPROC glad_glStencilMask;
|
||||
PFNGLUNIFORM4UIPROC glad_glUniform4ui;
|
||||
PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
|
||||
PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
|
||||
PFNGLISTEXTUREPROC glad_glIsTexture;
|
||||
PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
|
||||
PFNGLISSHADERPROC glad_glIsShader;
|
||||
PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
|
||||
PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
|
||||
PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
|
||||
PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
|
||||
PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
|
||||
PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
|
||||
PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
|
||||
PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
|
||||
PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
|
||||
PFNGLENABLEPROC glad_glEnable;
|
||||
PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
|
||||
PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
|
||||
PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
|
||||
PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
|
||||
PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
|
||||
PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
|
||||
PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
|
||||
PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
|
||||
PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
|
||||
PFNGLFINISHPROC glad_glFinish;
|
||||
PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
|
||||
PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
|
||||
PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
|
||||
PFNGLDELETESHADERPROC glad_glDeleteShader;
|
||||
PFNGLBLENDFUNCPROC glad_glBlendFunc;
|
||||
PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
|
||||
PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
|
||||
PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
|
||||
PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
|
||||
PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
|
||||
PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
|
||||
PFNGLVIEWPORTPROC glad_glViewport;
|
||||
PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
|
||||
PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
|
||||
PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
|
||||
PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
|
||||
PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
|
||||
PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
|
||||
PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
|
||||
PFNGLUNIFORM2UIPROC glad_glUniform2ui;
|
||||
PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
|
||||
PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
|
||||
PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
|
||||
PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
|
||||
PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
|
||||
PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
|
||||
PFNGLDEPTHRANGEPROC glad_glDepthRange;
|
||||
PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
|
||||
PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
|
||||
PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
|
||||
PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
|
||||
PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
|
||||
PFNGLFRONTFACEPROC glad_glFrontFace;
|
||||
PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
|
||||
PFNGLSCISSORPROC glad_glScissor;
|
||||
PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
|
||||
PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
|
||||
PFNGLTEXBUFFERPROC glad_glTexBuffer;
|
||||
PFNGLPIXELSTOREIPROC glad_glPixelStorei;
|
||||
PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
|
||||
PFNGLPIXELSTOREFPROC glad_glPixelStoref;
|
||||
PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
|
||||
PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
|
||||
PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
|
||||
PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
|
||||
static void load_GL_VERSION_1_0(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_1_0) return;
|
||||
glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace");
|
||||
glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace");
|
||||
glad_glHint = (PFNGLHINTPROC)load("glHint");
|
||||
glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth");
|
||||
glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize");
|
||||
glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode");
|
||||
glad_glScissor = (PFNGLSCISSORPROC)load("glScissor");
|
||||
glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf");
|
||||
glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv");
|
||||
glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri");
|
||||
glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv");
|
||||
glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D");
|
||||
glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D");
|
||||
glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer");
|
||||
glad_glClear = (PFNGLCLEARPROC)load("glClear");
|
||||
glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor");
|
||||
glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil");
|
||||
glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth");
|
||||
glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask");
|
||||
glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask");
|
||||
glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask");
|
||||
glad_glDisable = (PFNGLDISABLEPROC)load("glDisable");
|
||||
glad_glEnable = (PFNGLENABLEPROC)load("glEnable");
|
||||
glad_glFinish = (PFNGLFINISHPROC)load("glFinish");
|
||||
glad_glFlush = (PFNGLFLUSHPROC)load("glFlush");
|
||||
glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc");
|
||||
glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp");
|
||||
glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc");
|
||||
glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp");
|
||||
glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc");
|
||||
glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref");
|
||||
glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei");
|
||||
glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer");
|
||||
glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels");
|
||||
glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv");
|
||||
glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev");
|
||||
glad_glGetError = (PFNGLGETERRORPROC)load("glGetError");
|
||||
glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv");
|
||||
glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv");
|
||||
glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
|
||||
glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage");
|
||||
glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv");
|
||||
glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv");
|
||||
glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv");
|
||||
glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv");
|
||||
glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled");
|
||||
glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange");
|
||||
glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport");
|
||||
}
|
||||
static void load_GL_VERSION_1_1(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_1_1) return;
|
||||
glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays");
|
||||
glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements");
|
||||
glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset");
|
||||
glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D");
|
||||
glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D");
|
||||
glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D");
|
||||
glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D");
|
||||
glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D");
|
||||
glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D");
|
||||
glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture");
|
||||
glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures");
|
||||
glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures");
|
||||
glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture");
|
||||
}
|
||||
static void load_GL_VERSION_1_2(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_1_2) return;
|
||||
glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements");
|
||||
glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D");
|
||||
glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D");
|
||||
glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D");
|
||||
}
|
||||
static void load_GL_VERSION_1_3(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_1_3) return;
|
||||
glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture");
|
||||
glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage");
|
||||
glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D");
|
||||
glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D");
|
||||
glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D");
|
||||
glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D");
|
||||
glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D");
|
||||
glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D");
|
||||
glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage");
|
||||
}
|
||||
static void load_GL_VERSION_1_4(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_1_4) return;
|
||||
glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate");
|
||||
glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays");
|
||||
glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements");
|
||||
glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf");
|
||||
glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv");
|
||||
glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri");
|
||||
glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv");
|
||||
glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor");
|
||||
glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation");
|
||||
}
|
||||
static void load_GL_VERSION_1_5(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_1_5) return;
|
||||
glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries");
|
||||
glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries");
|
||||
glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery");
|
||||
glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery");
|
||||
glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery");
|
||||
glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv");
|
||||
glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv");
|
||||
glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv");
|
||||
glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer");
|
||||
glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers");
|
||||
glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers");
|
||||
glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer");
|
||||
glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData");
|
||||
glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData");
|
||||
glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData");
|
||||
glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer");
|
||||
glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer");
|
||||
glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv");
|
||||
glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv");
|
||||
}
|
||||
static void load_GL_VERSION_2_0(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_2_0) return;
|
||||
glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate");
|
||||
glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers");
|
||||
glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate");
|
||||
glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate");
|
||||
glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate");
|
||||
glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader");
|
||||
glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation");
|
||||
glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader");
|
||||
glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram");
|
||||
glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader");
|
||||
glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram");
|
||||
glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader");
|
||||
glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader");
|
||||
glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray");
|
||||
glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray");
|
||||
glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib");
|
||||
glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform");
|
||||
glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders");
|
||||
glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation");
|
||||
glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv");
|
||||
glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog");
|
||||
glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv");
|
||||
glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog");
|
||||
glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource");
|
||||
glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation");
|
||||
glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv");
|
||||
glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv");
|
||||
glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv");
|
||||
glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv");
|
||||
glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv");
|
||||
glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv");
|
||||
glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram");
|
||||
glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader");
|
||||
glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram");
|
||||
glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource");
|
||||
glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram");
|
||||
glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f");
|
||||
glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f");
|
||||
glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f");
|
||||
glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f");
|
||||
glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i");
|
||||
glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i");
|
||||
glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i");
|
||||
glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i");
|
||||
glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv");
|
||||
glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv");
|
||||
glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv");
|
||||
glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv");
|
||||
glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv");
|
||||
glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv");
|
||||
glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv");
|
||||
glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv");
|
||||
glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv");
|
||||
glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv");
|
||||
glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv");
|
||||
glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram");
|
||||
glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d");
|
||||
glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv");
|
||||
glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f");
|
||||
glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv");
|
||||
glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s");
|
||||
glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv");
|
||||
glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d");
|
||||
glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv");
|
||||
glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f");
|
||||
glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv");
|
||||
glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s");
|
||||
glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv");
|
||||
glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d");
|
||||
glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv");
|
||||
glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f");
|
||||
glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv");
|
||||
glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s");
|
||||
glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv");
|
||||
glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv");
|
||||
glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv");
|
||||
glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv");
|
||||
glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub");
|
||||
glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv");
|
||||
glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv");
|
||||
glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv");
|
||||
glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv");
|
||||
glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d");
|
||||
glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv");
|
||||
glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f");
|
||||
glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv");
|
||||
glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv");
|
||||
glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s");
|
||||
glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv");
|
||||
glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv");
|
||||
glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv");
|
||||
glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv");
|
||||
glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer");
|
||||
}
|
||||
static void load_GL_VERSION_2_1(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_2_1) return;
|
||||
glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv");
|
||||
glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv");
|
||||
glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv");
|
||||
glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv");
|
||||
glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv");
|
||||
glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv");
|
||||
}
|
||||
static void load_GL_VERSION_3_0(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_3_0) return;
|
||||
glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski");
|
||||
glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v");
|
||||
glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
|
||||
glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei");
|
||||
glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei");
|
||||
glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi");
|
||||
glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback");
|
||||
glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback");
|
||||
glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
|
||||
glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
|
||||
glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings");
|
||||
glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying");
|
||||
glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor");
|
||||
glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender");
|
||||
glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender");
|
||||
glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer");
|
||||
glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv");
|
||||
glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv");
|
||||
glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i");
|
||||
glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i");
|
||||
glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i");
|
||||
glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i");
|
||||
glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui");
|
||||
glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui");
|
||||
glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui");
|
||||
glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui");
|
||||
glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv");
|
||||
glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv");
|
||||
glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv");
|
||||
glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv");
|
||||
glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv");
|
||||
glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv");
|
||||
glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv");
|
||||
glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv");
|
||||
glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv");
|
||||
glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv");
|
||||
glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv");
|
||||
glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv");
|
||||
glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv");
|
||||
glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation");
|
||||
glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation");
|
||||
glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui");
|
||||
glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui");
|
||||
glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui");
|
||||
glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui");
|
||||
glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv");
|
||||
glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv");
|
||||
glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv");
|
||||
glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv");
|
||||
glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv");
|
||||
glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv");
|
||||
glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv");
|
||||
glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv");
|
||||
glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv");
|
||||
glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv");
|
||||
glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv");
|
||||
glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi");
|
||||
glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi");
|
||||
glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer");
|
||||
glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer");
|
||||
glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers");
|
||||
glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers");
|
||||
glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage");
|
||||
glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv");
|
||||
glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer");
|
||||
glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer");
|
||||
glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");
|
||||
glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
|
||||
glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus");
|
||||
glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D");
|
||||
glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D");
|
||||
glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
|
||||
glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
|
||||
glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
|
||||
glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap");
|
||||
glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
|
||||
glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
|
||||
glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
|
||||
glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange");
|
||||
glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange");
|
||||
glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray");
|
||||
glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays");
|
||||
glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays");
|
||||
glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray");
|
||||
}
|
||||
static void load_GL_VERSION_3_1(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_3_1) return;
|
||||
glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load("glDrawArraysInstanced");
|
||||
glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load("glDrawElementsInstanced");
|
||||
glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load("glTexBuffer");
|
||||
glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load("glPrimitiveRestartIndex");
|
||||
glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load("glCopyBufferSubData");
|
||||
glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices");
|
||||
glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv");
|
||||
glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName");
|
||||
glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex");
|
||||
glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv");
|
||||
glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName");
|
||||
glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding");
|
||||
}
|
||||
static void load_GL_VERSION_3_2(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_3_2) return;
|
||||
glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex");
|
||||
glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex");
|
||||
glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex");
|
||||
glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex");
|
||||
glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load("glProvokingVertex");
|
||||
glad_glFenceSync = (PFNGLFENCESYNCPROC)load("glFenceSync");
|
||||
glad_glIsSync = (PFNGLISSYNCPROC)load("glIsSync");
|
||||
glad_glDeleteSync = (PFNGLDELETESYNCPROC)load("glDeleteSync");
|
||||
glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load("glClientWaitSync");
|
||||
glad_glWaitSync = (PFNGLWAITSYNCPROC)load("glWaitSync");
|
||||
glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load("glGetInteger64v");
|
||||
glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load("glGetSynciv");
|
||||
glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load("glGetInteger64i_v");
|
||||
glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load("glGetBufferParameteri64v");
|
||||
glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load("glFramebufferTexture");
|
||||
glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample");
|
||||
glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample");
|
||||
glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv");
|
||||
glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
|
||||
}
|
||||
static void find_extensionsGL(void) {
|
||||
}
|
||||
|
||||
static void find_coreGL(void) {
|
||||
const char *v = (const char *)glGetString(GL_VERSION);
|
||||
int major = v[0] - '0';
|
||||
int minor = v[2] - '0';
|
||||
GLVersion.major = major; GLVersion.minor = minor;
|
||||
GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
|
||||
GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
|
||||
GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
|
||||
GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
|
||||
GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
|
||||
GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
|
||||
GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
|
||||
GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
|
||||
GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
|
||||
GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
|
||||
GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
|
||||
}
|
||||
|
||||
void gladLoadGLLoader(GLADloadproc load) {
|
||||
GLVersion.major = 0; GLVersion.minor = 0;
|
||||
glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
|
||||
if(glGetString == NULL) return;
|
||||
find_coreGL();
|
||||
load_GL_VERSION_1_0(load);
|
||||
load_GL_VERSION_1_1(load);
|
||||
load_GL_VERSION_1_2(load);
|
||||
load_GL_VERSION_1_3(load);
|
||||
load_GL_VERSION_1_4(load);
|
||||
load_GL_VERSION_1_5(load);
|
||||
load_GL_VERSION_2_0(load);
|
||||
load_GL_VERSION_2_1(load);
|
||||
load_GL_VERSION_3_0(load);
|
||||
load_GL_VERSION_3_1(load);
|
||||
load_GL_VERSION_3_2(load);
|
||||
|
||||
find_extensionsGL();
|
||||
|
||||
return;
|
||||
}
|
||||
|
1925
extern/glfw/deps/glad/glad.h
vendored
Normal file
1925
extern/glfw/deps/glad/glad.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
extern/glfw/deps/tinycthread.h
vendored
1
extern/glfw/deps/tinycthread.h
vendored
@ -122,6 +122,7 @@ typedef int _tthread_clockid_t;
|
||||
/* Emulate clock_gettime */
|
||||
int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts);
|
||||
#define clock_gettime _tthread_clock_gettime
|
||||
#define CLOCK_REALTIME 0
|
||||
#endif
|
||||
|
||||
|
||||
|
5
extern/glfw/docs/CMakeLists.txt
vendored
5
extern/glfw/docs/CMakeLists.txt
vendored
@ -1,5 +0,0 @@
|
||||
|
||||
add_custom_target(docs ALL ${DOXYGEN_EXECUTABLE}
|
||||
WORKING_DIRECTORY ${GLFW_BINARY_DIR}/docs
|
||||
COMMENT "Generating HTML documentation" VERBATIM)
|
||||
|
1872
extern/glfw/docs/Doxyfile.in
vendored
1872
extern/glfw/docs/Doxyfile.in
vendored
File diff suppressed because it is too large
Load Diff
217
extern/glfw/docs/build.dox
vendored
217
extern/glfw/docs/build.dox
vendored
@ -1,217 +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.
|
||||
|
||||
|
||||
@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 3 header file, i.e.:
|
||||
|
||||
@code
|
||||
#include <GLFW/glfw3.h>
|
||||
@endcode
|
||||
|
||||
This defines all the constants, types and function prototypes of the GLFW API.
|
||||
It also includes the chosen client API header files (by default OpenGL), and
|
||||
defines all the constants and types necessary for those headers to work on that
|
||||
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
|
||||
|
||||
If you are using an OpenGL extension loading library such as
|
||||
[GLEW](http://glew.sourceforge.net/), the GLEW header should also be included
|
||||
*before* the GLFW one. The GLEW header defines macros that disable any OpenGL
|
||||
header that the GLFW header includes and GLEW will work as expected.
|
||||
|
||||
|
||||
@subsection build_macros GLFW header option macros
|
||||
|
||||
These macros may be defined before the inclusion of the GLFW header and affect
|
||||
the behavior of the header. Note that GLFW does not provide any of the OpenGL
|
||||
or OpenGL ES headers mentioned below. These are provided by your development
|
||||
environment or your OpenGL or OpenGL ES SDK.
|
||||
|
||||
`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_NONE` makes the header not include any client API header.
|
||||
|
||||
`GLFW_INCLUDE_GLU` makes the header include the GLU header *in addition to* the
|
||||
OpenGL header. This should only be used with the default `GL/gl.h` header
|
||||
(`OpenGL/gl.h` on OS X), i.e. if you are not using any of the above macros.
|
||||
|
||||
`GLFW_DLL` is necessary when using the GLFW DLL on Windows, in order to explain
|
||||
to the compiler that the GLFW functions will be coming from another executable.
|
||||
It has no function on other platforms.
|
||||
|
||||
|
||||
@section build_link Link with the right libraries
|
||||
|
||||
@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
|
||||
|
||||
You can use the GLFW source tree directly from a project that uses CMake. This
|
||||
way, GLFW will be built along with your application as needed.
|
||||
|
||||
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.
|
||||
|
||||
add_subdirectory(path/to/glfw)
|
||||
|
||||
To be able to include the GLFW header from your code, you need to tell the
|
||||
compiler where to find it.
|
||||
|
||||
include_directories(path/to/glfw/include)
|
||||
|
||||
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.
|
||||
|
||||
target_link_libraries(myapp glfw ${GLFW_LIBRARIES})
|
||||
|
||||
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.
|
||||
|
||||
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES})
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
This creates the CMake commands to find pkg-config packages. Then you need to
|
||||
find the GLFW package.
|
||||
|
||||
pkg_search_module(GLFW REQUIRED glfw3)
|
||||
|
||||
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.
|
||||
|
||||
include_directories(${GLFW_INCLUDE_DIRS})
|
||||
|
||||
You also need to link against the correct libraries. If you are using the
|
||||
shared library version of GLFW, use the `GLFW_LIBRARIES` variable.
|
||||
|
||||
target_link_libraries(simple ${GLFW_LIBRARIES})
|
||||
|
||||
|
||||
If you are using the static library version of GLFW, use the
|
||||
`GLFW_STATIC_LIBRARIES` variable instead.
|
||||
|
||||
target_link_libraries(simple ${GLFW_STATIC_LIBRARIES})
|
||||
|
||||
|
||||
@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` file is generated when the GLFW library is built and installed
|
||||
along with it.
|
||||
|
||||
A typical compile and link command-line when using the static may look like this:
|
||||
|
||||
cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --static --libs glfw3`
|
||||
|
||||
If you are using the shared library, simply omit the `--static` flag.
|
||||
|
||||
cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3`
|
||||
|
||||
You can also use the `glfw3.pc` file without installing it first, by using the
|
||||
`PKG_CONFIG_PATH` environment variable.
|
||||
|
||||
env PKG_CONFIG_PATH=path/to/glfw/src cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --static --libs glfw3`
|
||||
|
||||
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
|
||||
`-lGLU` to your link flags.
|
||||
|
||||
See the manpage and other documentation for pkg-config and your compiler and
|
||||
linker for more information on how to link programs.
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
|
||||
@subsection build_link_osx With command-line on OS X
|
||||
|
||||
If you do not wish to use pkg-config, you need to add the required frameworks
|
||||
and libraries to your command-line using the `-l` and `-framework` switches,
|
||||
i.e.:
|
||||
|
||||
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
|
||||
|
||||
Note that you do not add the `.framework` extension to a framework when adding
|
||||
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.
|
||||
|
||||
*/
|
137
extern/glfw/docs/compat.dox
vendored
137
extern/glfw/docs/compat.dox
vendored
@ -1,137 +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_wm ICCCM and EWMH conformance
|
||||
|
||||
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 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` protocol to tell the window manager to make
|
||||
the GLFW window full screen. If the running window manager does not support this
|
||||
protocol, full screen windows may not work properly. GLFW has a fallback code
|
||||
path in case this protocol is unavailable, but every window manager behaves
|
||||
slightly differently in this regard.
|
||||
|
||||
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.
|
||||
|
||||
@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 either GLX 1.3 or greater, or the `GLX_SGIX_fbconfig`
|
||||
extension. Where both are available, the SGIX extension is preferred. If
|
||||
neither is available, GLFW will be unable to create windows.
|
||||
|
||||
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.
|
||||
|
||||
@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.
|
||||
|
||||
@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.
|
||||
|
||||
*/
|
261
extern/glfw/docs/compile.dox
vendored
261
extern/glfw/docs/compile.dox
vendored
@ -1,261 +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 CMake users and so have no `GLFW_` prefix.
|
||||
|
||||
If you are using the GUI version of CMake, these are listed and can be changed
|
||||
from there. If you are using the command-line version, use the `ccmake` tool.
|
||||
Some package systems like Ubuntu and other distributions based on Debian
|
||||
GNU/Linux have this tool in a separate `cmake-curses-gui` package.
|
||||
|
||||
|
||||
@subsection compile_options_shared Shared CMake options
|
||||
|
||||
`BUILD_SHARED_LIBS` determines whether GLFW is built as a static
|
||||
library or as a DLL / shared library / dynamic library.
|
||||
|
||||
`LIB_SUFFIX` affects where the GLFW shared /dynamic library is installed. If it
|
||||
is empty, it is installed to `${CMAKE_INSTALL_PREFIX}/lib`. If it is set to
|
||||
`64`, it is installed to `${CMAKE_INSTALL_PREFIX}/lib64`.
|
||||
|
||||
`GLFW_CLIENT_LIBRARY` determines which client API library to use. If set to
|
||||
`opengl` the OpenGL library is used, if set to `glesv1` for the OpenGL ES 1.x
|
||||
library is used, or if set to `glesv2` the OpenGL ES 2.0 library is used. The
|
||||
selected library and its header files must be present on the system for this to
|
||||
work.
|
||||
|
||||
`GLFW_BUILD_EXAMPLES` determines whether the GLFW examples are built
|
||||
along with the library.
|
||||
|
||||
`GLFW_BUILD_TESTS` determines whether the GLFW test programs are
|
||||
built along with the library.
|
||||
|
||||
`GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with
|
||||
the library.
|
||||
|
||||
|
||||
@subsection compile_options_osx OS X specific CMake options
|
||||
|
||||
`GLFW_USE_CHDIR` determines whether `glfwInit` changes the current
|
||||
directory of bundled applications to the `Contents/Resources` directory.
|
||||
|
||||
`GLFW_USE_MENUBAR` determines whether the first call to
|
||||
`glfwCreateWindow` sets up a minimal menu bar.
|
||||
|
||||
`GLFW_BUILD_UNIVERSAL` determines whether to build Universal Binaries.
|
||||
|
||||
|
||||
@subsection compile_options_win32 Windows specific CMake options
|
||||
|
||||
`USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the
|
||||
static library version of the Visual C++ runtime library. If set to `ON`, the
|
||||
DLL version of the Visual C++ library is used. It is recommended to set this to
|
||||
`ON`, as this keeps the executable smaller and benefits from security and bug
|
||||
fix updates of the Visual C++ runtime.
|
||||
|
||||
`GLFW_USE_DWM_SWAP_INTERVAL` determines whether the swap interval is set even
|
||||
when DWM compositing is enabled. If this is `ON`, the swap interval is set even
|
||||
if DWM is enabled. It is recommended to set this to `OFF`, as doing otherwise
|
||||
can lead to severe jitter.
|
||||
|
||||
`GLFW_USE_OPTIMUS_HPG` determines whether to export the `NvOptimusEnablement`
|
||||
symbol, which forces the use of the high-performance GPU on nVidia Optimus
|
||||
systems.
|
||||
|
||||
|
||||
@subsection compile_options_egl EGL specific CMake options
|
||||
|
||||
`GLFW_USE_EGL` determines whether to use EGL instead of the platform-specific
|
||||
context creation API. Note that EGL is not yet provided on all supported
|
||||
platforms.
|
||||
|
||||
|
||||
@section compile_manual Compiling GLFW manually
|
||||
|
||||
If you wish to compile GLFW without its CMake build environment then you will
|
||||
have to do at least some of the platform detection yourself. GLFW needs
|
||||
a number of configuration macros to be defined in order to know what it's being
|
||||
compiled for and has many optional, platform-specific ones for various features.
|
||||
|
||||
When building with CMake, the `glfw_config.h` configuration header is generated
|
||||
based on the current platform and CMake options. The GLFW CMake environment
|
||||
defines `_GLFW_USE_CONFIG_H`, which causes this header to be included by
|
||||
`internal.h`. Without this macro, GLFW will expect the necessary configuration
|
||||
macros to be defined on the command-line.
|
||||
|
||||
Three macros *must* be defined when compiling GLFW: one for selecting the window
|
||||
creation API, one selecting the context creation API and one client library.
|
||||
Exactly one of each kind must be defined for GLFW to compile and link.
|
||||
|
||||
The window creation API is used to create windows, handle input, monitors, gamma
|
||||
ramps and clipboard. The options are:
|
||||
|
||||
- `_GLFW_COCOA` to use the Cocoa frameworks
|
||||
- `_GLFW_WIN32` to use the Win32 API
|
||||
- `_GLFW_X11` to use the X Window System
|
||||
|
||||
The context creation API is used to enumerate pixel formats / framebuffer
|
||||
configurations and to create contexts. The options are:
|
||||
|
||||
- `_GLFW_NSGL` to use the Cocoa OpenGL framework
|
||||
- `_GLFW_WGL` to use the Win32 WGL API
|
||||
- `_GLFW_GLX` to use the X11 GLX API
|
||||
- `_GLFW_EGL` to use the EGL API (experimental)
|
||||
|
||||
The client library is the one providing the OpenGL or OpenGL ES API, which is
|
||||
used by GLFW to probe the created context. This is not the same thing as the
|
||||
client API, as many desktop OpenGL client libraries now expose the OpenGL ES API
|
||||
through extensions. The options are:
|
||||
|
||||
- `_GLFW_USE_OPENGL` for the desktop OpenGL (opengl32.dll, libGL.so or
|
||||
OpenGL.framework)
|
||||
- `_GLFW_USE_GLESV1` for OpenGL ES 1.x (experimental)
|
||||
- `_GLFW_USE_GLESV2` for OpenGL ES 2.x (experimental)
|
||||
|
||||
Note that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL,
|
||||
as the other context creation APIs do not interface with OpenGL ES client
|
||||
libraries.
|
||||
|
||||
If you are building GLFW as a shared library / dynamic library / DLL then you
|
||||
must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it.
|
||||
|
||||
If you are using the X11 window creation API then you *must* also select an entry
|
||||
point retrieval mechanism.
|
||||
|
||||
- `_GLFW_HAS_GLXGETPROCADDRESS` to use `glXGetProcAddress` (recommended)
|
||||
- `_GLFW_HAS_GLXGETPROCADDRESSARB` to use `glXGetProcAddressARB` (legacy)
|
||||
- `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use `glXGetProcAddressEXT` (legacy)
|
||||
- `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` (fallback)
|
||||
|
||||
If you are using the Cocoa window creation API, the following options are
|
||||
available:
|
||||
|
||||
- `_GLFW_USE_CHDIR` to `chdir` to the `Resources` subdirectory of the
|
||||
application bundle during @ref glfwInit (recommended)
|
||||
- `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window
|
||||
is created (recommended)
|
||||
|
||||
*/
|
174
extern/glfw/docs/context.dox
vendored
174
extern/glfw/docs/context.dox
vendored
@ -1,174 +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, each of which has its own context.
|
||||
|
||||
|
||||
@section context_object Context 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 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. OpenGL
|
||||
object sharing is implemented by the operating system and graphics driver and is
|
||||
described in the OpenGL 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 use the OpenGL or OpenGL ES APIs, you need to have a current
|
||||
context of the proper type. The context encapsulates all render state and all
|
||||
objects like textures and shaders.
|
||||
|
||||
Note that a context can only be current for a single thread at a time, and
|
||||
a thread can only have a single context at a time.
|
||||
|
||||
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
|
||||
|
||||
|
||||
@section context_swap Swapping buffers
|
||||
|
||||
See [swapping buffers](@ref window_swap) in the window handling guide.
|
||||
|
||||
|
||||
@section context_glext OpenGL extension handling
|
||||
|
||||
One of the benefits of OpenGL is its extensibility. Independent hardware
|
||||
vendors (IHVs) may include functionality in their OpenGL implementations that
|
||||
expand upon the OpenGL standard before that functionality is included in a new
|
||||
version of the OpenGL specification.
|
||||
|
||||
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. There are many different affixes, depending on who
|
||||
wrote the extension. A list of extensions, together with their specifications,
|
||||
can be found at the [OpenGL Registry](http://www.opengl.org/registry/).
|
||||
|
||||
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.
|
||||
|
||||
This can be done with GLFW, as will be described in this section, but usually
|
||||
you will instead want to use a dedicated extension loading library such as
|
||||
[GLEW](http://glew.sourceforge.net/). This kind of library greatly reduces the
|
||||
amount of work necessary to use both OpenGL extensions and modern versions of
|
||||
the OpenGL API. GLEW in particular has been extensively tested with and works
|
||||
well with GLFW.
|
||||
|
||||
|
||||
@subsection 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` and `PROC`
|
||||
are added to the ends.
|
||||
|
||||
|
||||
@subsection 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.
|
||||
|
||||
|
||||
@subsection context_glext_proc Fetching function pointers
|
||||
|
||||
Many extensions, though not all, require the use of new OpenGL functions.
|
||||
These entry points are often not exposed by your link libraries, making
|
||||
it necessary to fetch them at run time. With @ref glfwGetProcAddress you can
|
||||
retrieve the address of extension and non-extension OpenGL functions.
|
||||
|
||||
@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
|
||||
|
||||
*/
|
312
extern/glfw/docs/extra.css
vendored
312
extern/glfw/docs/extra.css
vendored
@ -1,312 +0,0 @@
|
||||
html {
|
||||
background-color:hsl(0,0%,95%);
|
||||
}
|
||||
|
||||
.glfwheader {
|
||||
font-size:16px;
|
||||
height:64px;
|
||||
max-width:920px;
|
||||
margin:0em auto;
|
||||
}
|
||||
|
||||
.glfwheader a#glfwhome {
|
||||
line-height:64px;
|
||||
padding-right:48px;
|
||||
float:left;
|
||||
color:hsl(0,0%,40%);
|
||||
font-size:2.5em;
|
||||
background-image:url("http://www.glfw.org/css/arrow.png");
|
||||
background-position:right top;
|
||||
background-repeat:no-repeat;
|
||||
}
|
||||
|
||||
.glfwnavbar {
|
||||
list-style-type:none;
|
||||
margin-top:0px;
|
||||
float:right;
|
||||
}
|
||||
|
||||
.glfwnavbar li {
|
||||
float:left;
|
||||
}
|
||||
|
||||
.glfwnavbar a,.glfwnavbar a:visited {
|
||||
line-height:64px;
|
||||
margin-left:2em;
|
||||
display:block;
|
||||
color:hsl(0,0%,40%);
|
||||
}
|
||||
|
||||
.glfwheader a#glfwhome,.glfwnavbar a,.glfwnavbar a:visited {
|
||||
transition:all 0.35s ease 0s;
|
||||
}
|
||||
|
||||
#titlearea,address.footer {
|
||||
color:hsl(0,0%,40%);
|
||||
background-color:hsl(0,0%,95%);
|
||||
border-bottom:none;
|
||||
}
|
||||
|
||||
address.footer {
|
||||
text-align:center;
|
||||
padding:2em;
|
||||
}
|
||||
|
||||
div#top {
|
||||
background-color:hsl(0,0%,40%);
|
||||
}
|
||||
|
||||
div#navrow1,div#navrow2,div#navrow3,div#navrow4 {
|
||||
background-color:hsl(0,0%,40%);
|
||||
background-image:none;
|
||||
max-width:920px;
|
||||
margin:0em auto;
|
||||
}
|
||||
|
||||
ul.tablist {
|
||||
min-width:700px;
|
||||
}
|
||||
|
||||
.tablist a,.tablist a:hover,.tablist li,.tablist li.current a {
|
||||
background-image:none;
|
||||
text-shadow:none;
|
||||
}
|
||||
|
||||
.tablist a,.tablist a:visited {
|
||||
color:hsl(0,0%,95%);
|
||||
text-shadow:none;
|
||||
}
|
||||
|
||||
.tablist li.current a {
|
||||
background:linear-gradient(to bottom,hsl(34,100%,60%) 0%,hsl(24,100%,50%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(24,100%,50%);
|
||||
text-shadow:0px -1px 1px hsl(24,100%,35%);
|
||||
color:hsl(0,0%,100%);
|
||||
}
|
||||
|
||||
div.contents {
|
||||
min-height:590px;
|
||||
}
|
||||
|
||||
div.contents,div.header {
|
||||
max-width:920px;
|
||||
margin:0em auto;
|
||||
padding:0em 2em 2em 2em;
|
||||
background-color:hsl(0,0%,100%);
|
||||
}
|
||||
|
||||
div.header {
|
||||
background-image:none;
|
||||
border-bottom:none;
|
||||
}
|
||||
|
||||
table.doxtable th,dl.reflist dt,div.levels {
|
||||
background:linear-gradient(to bottom,hsl(34,100%,60%) 0%,hsl(24,100%,50%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(24,100%,50%);
|
||||
text-shadow:0px -1px 1px hsl(24,100%,35%);
|
||||
color:hsl(0,0%,100%);
|
||||
}
|
||||
|
||||
dl.reflist dt a.el,div.levels span {
|
||||
color:hsl(24,100%,50%);
|
||||
padding:0.2em;
|
||||
border-radius:4px;
|
||||
background-color:hsl(24,100%,90%);
|
||||
text-shadow:none;
|
||||
}
|
||||
|
||||
div.memproto,div.qindex,div.ah {
|
||||
background:linear-gradient(to bottom,hsl(34,0%,95%) 0%,hsl(24,0%,90%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(24,0%,90%);
|
||||
text-shadow:0px 1px 1px hsl(24,0%,100%);
|
||||
color:hsl(0,0%,10%);
|
||||
}
|
||||
|
||||
div.memproto a {
|
||||
color:hsl(24,100%,50%);
|
||||
}
|
||||
|
||||
div.memproto td.paramname {
|
||||
text-shadow:0px 1px 1px hsl(24,0%,100%);
|
||||
}
|
||||
|
||||
div.memproto,div.qindex,div.ah {
|
||||
border:2px solid hsl(24,0%,90%);
|
||||
border-radius:4px;
|
||||
}
|
||||
|
||||
div.memdoc {
|
||||
background:none;
|
||||
box-shadow:none;
|
||||
border:none;
|
||||
}
|
||||
|
||||
td.paramname {
|
||||
color:hsl(24,100%,25%);
|
||||
}
|
||||
|
||||
dl.reflist dt {
|
||||
border:2px solid hsl(24,100%,50%);
|
||||
border-top-left-radius:4px;
|
||||
border-top-right-radius:4px;
|
||||
border-bottom:none;
|
||||
}
|
||||
|
||||
dl.reflist dd {
|
||||
border:2px solid hsl(24,100%,50%);
|
||||
border-bottom-right-radius:4px;
|
||||
border-bottom-left-radius:4px;
|
||||
border-top:none;
|
||||
background:none;
|
||||
box-shadow:none;
|
||||
}
|
||||
|
||||
table.doxtable {
|
||||
border-collapse:inherit;
|
||||
border-spacing:0px;
|
||||
border:2px solid hsl(24,100%,50%);
|
||||
border-radius:4px;
|
||||
}
|
||||
|
||||
table.doxtable td,table.doxtable th {
|
||||
border:none;
|
||||
}
|
||||
|
||||
tr.even,.directory tr.even,table.doxtable tr:nth-child(even) {
|
||||
background-color:hsl(0,0%,95%);
|
||||
}
|
||||
|
||||
body {
|
||||
color:hsl(0,0%,30%);
|
||||
}
|
||||
|
||||
h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
|
||||
color:hsl(0,0%,10%);
|
||||
border-bottom:none;
|
||||
}
|
||||
|
||||
a,a:hover,a:visited,a:visited:hover,a.el,a.el:visited,.glfwheader a#glfwhome:hover,.tablist a:hover {
|
||||
color:hsl(24,100%,50%);
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
.mdescLeft,.mdescRight,.memItemLeft,.memItemRight {
|
||||
background-color:hsl(0,0%,95%);
|
||||
}
|
||||
|
||||
div.directory {
|
||||
border-collapse:inherit;
|
||||
border-spacing:0px;
|
||||
border:2px solid hsl(24,100%,50%);
|
||||
border-radius:4px;
|
||||
}
|
||||
|
||||
.directory .levels span {
|
||||
color:hsl(24,100%,50%);
|
||||
padding:0.1em 0.5em;
|
||||
margin:auto 0.25em;
|
||||
border-radius:2px;
|
||||
background-color:hsl(24,100%,90%);
|
||||
text-shadow:none;
|
||||
}
|
||||
|
||||
td.memSeparator {
|
||||
height:2px;
|
||||
border:0px;
|
||||
background:linear-gradient(to right,hsl(0,0%,95%) 0%,hsl(0,0%,85%) 50%,hsl(0,0%,95%) 100%);
|
||||
}
|
||||
|
||||
dl.note,dl.pre,dl.post,dl.invariant {
|
||||
background:linear-gradient(to bottom,hsl(103,80%,90%) 0%,hsl(103,80%,85%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(103,40%,80%);
|
||||
color:hsl(103,80%,10%);
|
||||
border:2px solid hsl(103,40%,75%);
|
||||
}
|
||||
|
||||
dl.warning,dl.attention {
|
||||
background:linear-gradient(to bottom,hsl(34,80%,90%) 0%,hsl(34,80%,85%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(34,40%,80%);
|
||||
color:hsl(34,80%,10%);
|
||||
border:2px solid hsl(34,40%,75%);
|
||||
}
|
||||
|
||||
dl.deprecated,dl.bug {
|
||||
background:linear-gradient(to bottom,hsl(333,80%,90%) 0%,hsl(333,80%,85%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(333,40%,80%);
|
||||
color:hsl(333,80%,10%);
|
||||
border:2px solid hsl(333,40%,75%);
|
||||
}
|
||||
|
||||
dl.todo,dl.test {
|
||||
background:linear-gradient(to bottom,hsl(200,80%,90%) 0%,hsl(200,80%,85%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(200,40%,80%);
|
||||
color:hsl(200,80%,10%);
|
||||
border:2px solid hsl(200,40%,75%);
|
||||
}
|
||||
|
||||
dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test {
|
||||
border-radius:4px;
|
||||
padding:1em;
|
||||
text-shadow:0px 1px 1px hsl(0,0%,100%);
|
||||
}
|
||||
|
||||
div.toc {
|
||||
background:linear-gradient(to bottom,hsl(34,0%,95%) 0%,hsl(24,0%,90%) 100%);
|
||||
box-shadow:inset 0px 0px 32px hsl(24,0%,90%);
|
||||
text-shadow:0px 1px 1px hsl(24,0%,100%);
|
||||
color:hsl(0,0%,10%);
|
||||
border:2px solid hsl(24,0%,90%);
|
||||
border-radius:4px;
|
||||
float:none;
|
||||
width:auto;
|
||||
}
|
||||
|
||||
div.toc h3 {
|
||||
font-size:1.17em;
|
||||
}
|
||||
|
||||
div.toc ul {
|
||||
padding-left:1.5em;
|
||||
}
|
||||
|
||||
div.toc li {
|
||||
background:none;
|
||||
font-size:1em;
|
||||
padding-left:0em;
|
||||
list-style-type:disc;
|
||||
}
|
||||
|
||||
div.ah {
|
||||
background-image:none;
|
||||
}
|
||||
|
||||
div.fragment,pre.fragment {
|
||||
background-color:hsl(0,0%,20%);
|
||||
border-radius:4px;
|
||||
border-width:0px;
|
||||
padding:0.5em 2em;
|
||||
overflow:auto;
|
||||
border-left:4px solid hsl(0,0%,80%);
|
||||
}
|
||||
|
||||
div.line,pre.fragment {
|
||||
color:hsl(60,30%,96%);
|
||||
}
|
||||
|
||||
a.code,a.code:visited,span.preprocessor,span.comment {
|
||||
color:hsl(80,76%,53%);
|
||||
}
|
||||
|
||||
span.keyword,span.keywordtype,span.keywordflow {
|
||||
color:hsl(190,81%,67%);
|
||||
}
|
||||
|
||||
span.stringliteral {
|
||||
color:hsl(54,70%,68%);
|
||||
}
|
||||
|
||||
code {
|
||||
background-color:hsl(0,0%,95%);
|
||||
padding:0.1em;
|
||||
border-radius: 4px;
|
||||
}
|
7
extern/glfw/docs/footer.html
vendored
7
extern/glfw/docs/footer.html
vendored
@ -1,7 +0,0 @@
|
||||
<address class="footer">
|
||||
<p>
|
||||
Last update on $date for $projectname $projectnumber
|
||||
</p>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
34
extern/glfw/docs/header.html
vendored
34
extern/glfw/docs/header.html
vendored
@ -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 -->
|
116
extern/glfw/docs/internal.dox
vendored
116
extern/glfw/docs/internal.dox
vendored
@ -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 users of GLFW and never directly calls the
|
||||
user's code. 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 user,
|
||||
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`
|
||||
|
||||
*/
|
22
extern/glfw/docs/main.dox
vendored
22
extern/glfw/docs/main.dox
vendored
@ -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.0, 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.
|
||||
|
||||
*/
|
105
extern/glfw/docs/monitor.dox
vendored
105
extern/glfw/docs/monitor.dox
vendored
@ -1,105 +0,0 @@
|
||||
/*!
|
||||
|
||||
@page monitor Multi-monitor guide
|
||||
|
||||
@tableofcontents
|
||||
|
||||
|
||||
@section monitor_objects Monitor objects
|
||||
|
||||
The @ref GLFWmonitor object represents a currently connected monitor.
|
||||
|
||||
|
||||
@section monitor_monitors Retrieving monitors
|
||||
|
||||
The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is usually
|
||||
the user's preferred monitor and 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.
|
||||
|
||||
@code
|
||||
int count;
|
||||
GLFWmonitor** monitors = glfwGetMonitors(&count);
|
||||
@endcode
|
||||
|
||||
|
||||
@section monitor_modes Retrieving 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
|
||||
|
||||
|
||||
@section monitor_size Monitor physical size
|
||||
|
||||
The physical size in millimetres of a monitor, or an approximation 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
|
||||
|
||||
|
||||
@section monitor_name Monitor name
|
||||
|
||||
The name of a monitor is returned by @ref glfwGetMonitorName.
|
||||
|
||||
@code
|
||||
const char* name = glfwGetMonitorName(monitor);
|
||||
@endcode
|
||||
|
||||
The monitor name is a regular C string using the UTF-8 encoding. Note that
|
||||
monitor names are not guaranteed to be unique.
|
||||
|
||||
|
||||
@section monitor_gamma Monitor 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
|
||||
glfwSetGammaRamp(monitor, &ramp);
|
||||
@endcode
|
||||
|
||||
The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp.
|
||||
|
||||
@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
|
||||
|
||||
*/
|
327
extern/glfw/docs/moving.dox
vendored
327
extern/glfw/docs/moving.dox
vendored
@ -1,327 +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, use of the new multi-monitor functions are
|
||||
required to create full screen windows with GLFW 3.
|
||||
|
||||
|
||||
@section moving_removed Removed features
|
||||
|
||||
@subsection moving_threads Threading functions
|
||||
|
||||
The threading functions have been removed, including the 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 and rendered with from secondary
|
||||
threads, and the documentation explicitly states which functions may be used
|
||||
from secondary threads and which may only be used from the main thread, i.e. the
|
||||
thread that calls main.
|
||||
|
||||
|
||||
@subsection moving_image 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 the
|
||||
OpenGL texturing facilities. 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 seems unnecessary both to
|
||||
duplicate this work and to tie this duplicate to GLFW. Projects similar to
|
||||
GLFW, such as freeglut, could also gain from such a library. Also, would be no
|
||||
platform-specific part of such a library, as both OpenGL and stdio are available
|
||||
wherever GLFW is.
|
||||
|
||||
|
||||
@subsection moving_char_up 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 ü.
|
||||
|
||||
Note that this is only the removal of the *action parameter* of the character
|
||||
callback, *not* the removal of the character callback itself.
|
||||
|
||||
|
||||
@subsection moving_wheel Mouse wheel position
|
||||
|
||||
The `glfwGetMouseWheel` function has been removed. Scroll events do not
|
||||
represent an absolute state, but is instead an interpretation of a relative
|
||||
change in state, like character input. So, like character input, there is no
|
||||
sane 'current state' to return. The mouse wheel callback has been replaced by
|
||||
a [scroll callback](@ref GLFWscrollfun) that receives two-dimensional scroll
|
||||
offsets.
|
||||
|
||||
|
||||
@subsection moving_stdcall 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 users of GLFW 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.
|
||||
|
||||
|
||||
@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_opened Window open parameter
|
||||
|
||||
The `GLFW_OPENED` window parameter has been removed. As long as the
|
||||
[window object](@ref window_object) is around, the window is "open". To detect
|
||||
when the user attempts to close the window, see @ref glfwWindowShouldClose and
|
||||
the [close callback](@ref GLFWwindowclosefun).
|
||||
|
||||
|
||||
@subsection moving_autopoll Automatic polling of events
|
||||
|
||||
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, the event processing functions act on all windows at once.
|
||||
|
||||
|
||||
@subsection moving_terminate Automatic termination
|
||||
|
||||
GLFW 3 does not register @ref glfwTerminate with `atexit` at initialization. To
|
||||
properly release all resources allocated by GLFW, you should therefore call @ref
|
||||
glfwTerminate yourself before exiting.
|
||||
|
||||
|
||||
@subsection moving_glu GLU header inclusion
|
||||
|
||||
GLFW 3 does not include the GLU header by default and GLU itself has been
|
||||
deprecated, but you can request that the GLFW 3 header includes it by defining
|
||||
`GLFW_INCLUDE_GLU` before the inclusion of the GLFW 3 header.
|
||||
|
||||
|
||||
@section moving_changed Changes to existing features
|
||||
|
||||
@subsection moving_window_handles Window handles
|
||||
|
||||
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 of the `GLFWwindow*` type, i.e. a pointer
|
||||
to an opaque struct.
|
||||
|
||||
|
||||
@subsection moving_monitor Multi-monitor support
|
||||
|
||||
GLFW 3 provides support for multiple monitors, adding the `GLFWmonitor*` handle
|
||||
type and a set of related functions. To request a full screen mode window,
|
||||
instead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the
|
||||
window to use. There is @ref glfwGetPrimaryMonitor that provides behaviour
|
||||
similar to that of GLFW 2.
|
||||
|
||||
|
||||
@subsection moving_window_close Window closing
|
||||
|
||||
Window closing initiated by the user is now just an event like any other.
|
||||
Unlike GLFW 2, windows and contexts created with GLFW 3 will not disappear from
|
||||
underfoot. Each window now has a close flag, which is set when the user
|
||||
attempts to close it. By default, nothing else happens and the window stays
|
||||
open and visible. It is then up to you to either destroy the window, take some
|
||||
other action or simply ignore the request. You can query the close flag at any
|
||||
time with @ref glfwWindowShouldClose and set it at any time with @ref
|
||||
glfwSetWindowShouldClose.
|
||||
|
||||
The close callback no longer returns a value. Instead, it is called after the
|
||||
close flag has been set so it can override its value, if it chooses to, before
|
||||
event processing completes. You may however not call @ref glfwDestroyWindow
|
||||
from the close callback (or any other window related callback).
|
||||
|
||||
GLFW itself never clears the close flag, allowing you to set it for other
|
||||
reasons for the window to close as well, for example the user choosing Quit from
|
||||
the main menu.
|
||||
|
||||
|
||||
@subsection moving_context Explicit context management
|
||||
|
||||
Each GLFW 3 window has its own OpenGL context and only you, the user, can know
|
||||
which context should be current on which thread at any given time. Therefore,
|
||||
GLFW 3 makes no assumptions about when you want a certain context to be current,
|
||||
leaving that decision to you.
|
||||
|
||||
This means, among other things, that you need to call @ref
|
||||
glfwMakeContextCurrent after creating a window before you can call any OpenGL
|
||||
functions.
|
||||
|
||||
|
||||
@subsection moving_repeat Key repeat
|
||||
|
||||
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 input
|
||||
|
||||
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_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_cursor Cursor positioning
|
||||
|
||||
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_hints Persistent window hints
|
||||
|
||||
Window hints are no longer reset to their default values on window creation, but
|
||||
instead retain their values until modified by @ref glfwWindowHint (formerly
|
||||
`glfwOpenWindowHint`) or @ref glfwDefaultWindowHints, or until the library is
|
||||
terminated and re-initialized.
|
||||
|
||||
|
||||
@section moving_renamed Name changes
|
||||
|
||||
@subsection moving_renamed_files 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`.
|
||||
|
||||
|
||||
@subsection moving_renamed_functions 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 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` | |
|
||||
|
||||
*/
|
173
extern/glfw/docs/news.dox
vendored
173
extern/glfw/docs/news.dox
vendored
@ -1,173 +0,0 @@
|
||||
/*!
|
||||
|
||||
@page news New features
|
||||
|
||||
@tableofcontents
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
*/
|
308
extern/glfw/docs/quick.dox
vendored
308
extern/glfw/docs/quick.dox
vendored
@ -1,308 +0,0 @@
|
||||
/*!
|
||||
|
||||
@page quick Getting started
|
||||
|
||||
@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 always 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 small GLFW 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 runs a loop clearing
|
||||
the screen, rendering a triangle and processing events until the user closes the
|
||||
window. It can be found in the source distribution as `examples/simple.c`, and
|
||||
is by default compiled along with all other examples when you build GLFW.
|
||||
|
||||
To learn more about how to compile and link programs that use GLFW, see
|
||||
@ref build.
|
||||
|
||||
*/
|
496
extern/glfw/docs/window.dox
vendored
496
extern/glfw/docs/window.dox
vendored
@ -1,496 +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);
|
||||
@endcode
|
||||
|
||||
If window creation fails, `NULL` will be returned, so you need to check whether
|
||||
it did.
|
||||
|
||||
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 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 hard constraints:
|
||||
- `GLFW_STEREO`
|
||||
- `GLFW_CLIENT_API`
|
||||
|
||||
The following additional hints are hard constraints if requesting an OpenGL
|
||||
context:
|
||||
- `GLFW_OPENGL_FORWARD_COMPAT`
|
||||
- `GLFW_OPENGL_PROFILE`
|
||||
|
||||
Hints that do not apply to a given type of window or context are ignored.
|
||||
|
||||
|
||||
@subsection window_hints_wnd Window related hints
|
||||
|
||||
The `GLFW_RESIZABLE` hint specifies whether the 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 window will be initially
|
||||
visible. This hint is ignored for full screen windows.
|
||||
|
||||
The `GLFW_DECORATED` hint specifies whether the 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.
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
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.
|
||||
|
||||
The `GLFW_AUX_BUFFERS` hint specifies the desired number of auxiliary
|
||||
buffers.
|
||||
|
||||
The `GLFW_STEREO` hint specifies whether to use stereoscopic rendering.
|
||||
|
||||
The `GLFW_SAMPLES` hint specifies the desired number of samples to use for
|
||||
multisampling. Zero disables multisampling.
|
||||
|
||||
The `GLFW_SRGB_CAPABLE` hint specifies whether the framebuffer should be
|
||||
sRGB capable.
|
||||
|
||||
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`.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@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_RED_BITS` | 8 | 0 to `INT_MAX` |
|
||||
| `GLFW_GREEN_BITS` | 8 | 0 to `INT_MAX` |
|
||||
| `GLFW_BLUE_BITS` | 8 | 0 to `INT_MAX` |
|
||||
| `GLFW_ALPHA_BITS` | 8 | 0 to `INT_MAX` |
|
||||
| `GLFW_DEPTH_BITS` | 24 | 0 to `INT_MAX` |
|
||||
| `GLFW_STENCIL_BITS` | 8 | 0 to `INT_MAX` |
|
||||
| `GLFW_ACCUM_RED_BITS` | 0 | 0 to `INT_MAX` |
|
||||
| `GLFW_ACCUM_GREEN_BITS` | 0 | 0 to `INT_MAX` |
|
||||
| `GLFW_ACCUM_BLUE_BITS` | 0 | 0 to `INT_MAX` |
|
||||
| `GLFW_ACCUM_ALPHA_BITS` | 0 | 0 to `INT_MAX` |
|
||||
| `GLFW_AUX_BUFFERS` | 0 | 0 to `INT_MAX` |
|
||||
| `GLFW_SAMPLES` | 0 | 0 to `INT_MAX` |
|
||||
| `GLFW_REFRESH_RATE` | 0 | 0 to `INT_MAX` |
|
||||
| `GLFW_STEREO` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` |
|
||||
| `GLFW_SRGB_CAPABLE` | `GL_FALSE` | `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_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
|
||||
|
||||
|
||||
@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_size_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.
|
||||
|
||||
|
||||
@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 always 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.
|
||||
|
||||
*/
|
48
extern/glfw/examples/CMakeLists.txt
vendored
48
extern/glfw/examples/CMakeLists.txt
vendored
@ -1,49 +1,69 @@
|
||||
|
||||
link_libraries(glfw ${OPENGL_glu_LIBRARY})
|
||||
link_libraries(glfw "${OPENGL_glu_LIBRARY}")
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_definitions(-DGLFW_DLL)
|
||||
link_libraries(${OPENGL_gl_LIBRARY} ${MATH_LIBRARY})
|
||||
link_libraries("${OPENGL_gl_LIBRARY}" "${MATH_LIBRARY}")
|
||||
else()
|
||||
link_libraries(${glfw_LIBRARIES})
|
||||
endif()
|
||||
|
||||
include_directories(${GLFW_SOURCE_DIR}/include
|
||||
${GLFW_SOURCE_DIR}/deps)
|
||||
include_directories("${GLFW_SOURCE_DIR}/include"
|
||||
"${GLFW_SOURCE_DIR}/deps")
|
||||
|
||||
if (NOT APPLE)
|
||||
# HACK: This is NOTFOUND on OS X 10.8
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
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(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(Heightmap MACOSX_BUNDLE heightmap.c ${GLAD})
|
||||
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(SplitView 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(Heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Heightmap")
|
||||
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(SplitView PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Split View")
|
||||
set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
||||
|
||||
set_target_properties(Boing Gears Heightmap Particles Simple SplitView Wave PROPERTIES
|
||||
FOLDER "GLFW3/Examples")
|
||||
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})
|
||||
add_executable(heightmap WIN32 heightmap.c ${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)
|
||||
|
||||
set_target_properties(boing gears heightmap particles simple splitview wave PROPERTIES
|
||||
FOLDER "GLFW3/Examples")
|
||||
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 simple splitview wave)
|
||||
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
|
||||
@ -51,7 +71,7 @@ if (MSVC)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(BUNDLE_BINARIES Boing Gears Simple "Split View" Wave)
|
||||
set(BUNDLE_BINARIES Boing Gears Heightmap Particles Simple SplitView Wave)
|
||||
|
||||
set_target_properties(${BUNDLE_BINARIES} PROPERTIES
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
|
||||
|
43
extern/glfw/examples/boing.c
vendored
43
extern/glfw/examples/boing.c
vendored
@ -44,6 +44,8 @@ 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 );
|
||||
@ -80,8 +82,12 @@ typedef enum { DRAW_BALL, DRAW_BALL_SHADOW } DRAW_BALL_ENUM;
|
||||
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;
|
||||
@ -251,6 +257,37 @@ void key_callback( GLFWwindow* window, int key, int scancode, int action, int mo
|
||||
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.
|
||||
*
|
||||
@ -341,6 +378,9 @@ 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 ) )
|
||||
{
|
||||
@ -574,7 +614,6 @@ void DrawGrid( void )
|
||||
int main( void )
|
||||
{
|
||||
GLFWwindow* window;
|
||||
int width, height;
|
||||
|
||||
/* Init GLFW */
|
||||
if( !glfwInit() )
|
||||
@ -591,6 +630,8 @@ int main( void )
|
||||
|
||||
glfwSetFramebufferSizeCallback(window, reshape);
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval( 1 );
|
||||
|
285
extern/glfw/examples/heightmap.c
vendored
285
extern/glfw/examples/heightmap.c
vendored
@ -28,37 +28,9 @@
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include "getopt.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
/* OpenGL function pointers */
|
||||
static PFNGLGENBUFFERSPROC pglGenBuffers = NULL;
|
||||
static PFNGLGENVERTEXARRAYSPROC pglGenVertexArrays = NULL;
|
||||
static PFNGLDELETEVERTEXARRAYSPROC pglDeleteVertexArrays = NULL;
|
||||
static PFNGLCREATESHADERPROC pglCreateShader = NULL;
|
||||
static PFNGLSHADERSOURCEPROC pglShaderSource = NULL;
|
||||
static PFNGLCOMPILESHADERPROC pglCompileShader = NULL;
|
||||
static PFNGLGETSHADERIVPROC pglGetShaderiv = NULL;
|
||||
static PFNGLGETSHADERINFOLOGPROC pglGetShaderInfoLog = NULL;
|
||||
static PFNGLDELETESHADERPROC pglDeleteShader = NULL;
|
||||
static PFNGLCREATEPROGRAMPROC pglCreateProgram = NULL;
|
||||
static PFNGLATTACHSHADERPROC pglAttachShader = NULL;
|
||||
static PFNGLLINKPROGRAMPROC pglLinkProgram = NULL;
|
||||
static PFNGLUSEPROGRAMPROC pglUseProgram = NULL;
|
||||
static PFNGLGETPROGRAMIVPROC pglGetProgramiv = NULL;
|
||||
static PFNGLGETPROGRAMINFOLOGPROC pglGetProgramInfoLog = NULL;
|
||||
static PFNGLDELETEPROGRAMPROC pglDeleteProgram = NULL;
|
||||
static PFNGLGETUNIFORMLOCATIONPROC pglGetUniformLocation = NULL;
|
||||
static PFNGLUNIFORMMATRIX4FVPROC pglUniformMatrix4fv = NULL;
|
||||
static PFNGLGETATTRIBLOCATIONPROC pglGetAttribLocation = NULL;
|
||||
static PFNGLBINDVERTEXARRAYPROC pglBindVertexArray = NULL;
|
||||
static PFNGLBUFFERDATAPROC pglBufferData = NULL;
|
||||
static PFNGLBINDBUFFERPROC pglBindBuffer = NULL;
|
||||
static PFNGLBUFFERSUBDATAPROC pglBufferSubData = NULL;
|
||||
static PFNGLENABLEVERTEXATTRIBARRAYPROC pglEnableVertexAttribArray = NULL;
|
||||
static PFNGLVERTEXATTRIBPOINTERPROC pglVertexAttribPointer = NULL;
|
||||
|
||||
/* Map height updates */
|
||||
#define MAX_CIRCLE_SIZE (5.0f)
|
||||
@ -75,54 +47,11 @@ static PFNGLVERTEXATTRIBPOINTERPROC pglVertexAttribPointer = NULL;
|
||||
2 * (MAP_NUM_VERTICES - 1))
|
||||
|
||||
|
||||
/* OpenGL function pointers */
|
||||
|
||||
#define RESOLVE_GL_FCN(type, var, name) \
|
||||
if (status == GL_TRUE) \
|
||||
{\
|
||||
var = (type) glfwGetProcAddress((name));\
|
||||
if ((var) == NULL)\
|
||||
{\
|
||||
status = GL_FALSE;\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
static GLboolean init_opengl(void)
|
||||
{
|
||||
GLboolean status = GL_TRUE;
|
||||
RESOLVE_GL_FCN(PFNGLCREATESHADERPROC, pglCreateShader, "glCreateShader");
|
||||
RESOLVE_GL_FCN(PFNGLSHADERSOURCEPROC, pglShaderSource, "glShaderSource");
|
||||
RESOLVE_GL_FCN(PFNGLCOMPILESHADERPROC, pglCompileShader, "glCompileShader");
|
||||
RESOLVE_GL_FCN(PFNGLGETSHADERIVPROC, pglGetShaderiv, "glGetShaderiv");
|
||||
RESOLVE_GL_FCN(PFNGLGETSHADERINFOLOGPROC, pglGetShaderInfoLog, "glGetShaderInfoLog");
|
||||
RESOLVE_GL_FCN(PFNGLDELETESHADERPROC, pglDeleteShader, "glDeleteShader");
|
||||
RESOLVE_GL_FCN(PFNGLCREATEPROGRAMPROC, pglCreateProgram, "glCreateProgram");
|
||||
RESOLVE_GL_FCN(PFNGLATTACHSHADERPROC, pglAttachShader, "glAttachShader");
|
||||
RESOLVE_GL_FCN(PFNGLLINKPROGRAMPROC, pglLinkProgram, "glLinkProgram");
|
||||
RESOLVE_GL_FCN(PFNGLUSEPROGRAMPROC, pglUseProgram, "glUseProgram");
|
||||
RESOLVE_GL_FCN(PFNGLGETPROGRAMIVPROC, pglGetProgramiv, "glGetProgramiv");
|
||||
RESOLVE_GL_FCN(PFNGLGETPROGRAMINFOLOGPROC, pglGetProgramInfoLog, "glGetProgramInfoLog");
|
||||
RESOLVE_GL_FCN(PFNGLDELETEPROGRAMPROC, pglDeleteProgram, "glDeleteProgram");
|
||||
RESOLVE_GL_FCN(PFNGLGETUNIFORMLOCATIONPROC, pglGetUniformLocation, "glGetUniformLocation");
|
||||
RESOLVE_GL_FCN(PFNGLUNIFORMMATRIX4FVPROC, pglUniformMatrix4fv, "glUniformMatrix4fv");
|
||||
RESOLVE_GL_FCN(PFNGLGETATTRIBLOCATIONPROC, pglGetAttribLocation, "glGetAttribLocation");
|
||||
RESOLVE_GL_FCN(PFNGLGENVERTEXARRAYSPROC, pglGenVertexArrays, "glGenVertexArrays");
|
||||
RESOLVE_GL_FCN(PFNGLDELETEVERTEXARRAYSPROC, pglDeleteVertexArrays, "glDeleteVertexArrays");
|
||||
RESOLVE_GL_FCN(PFNGLBINDVERTEXARRAYPROC, pglBindVertexArray, "glBindVertexArray");
|
||||
RESOLVE_GL_FCN(PFNGLGENBUFFERSPROC, pglGenBuffers, "glGenBuffers");
|
||||
RESOLVE_GL_FCN(PFNGLBINDBUFFERPROC, pglBindBuffer, "glBindBuffer");
|
||||
RESOLVE_GL_FCN(PFNGLBUFFERDATAPROC, pglBufferData, "glBufferData");
|
||||
RESOLVE_GL_FCN(PFNGLBUFFERSUBDATAPROC, pglBufferSubData, "glBufferSubData");
|
||||
RESOLVE_GL_FCN(PFNGLENABLEVERTEXATTRIBARRAYPROC, pglEnableVertexAttribArray, "glEnableVertexAttribArray");
|
||||
RESOLVE_GL_FCN(PFNGLVERTEXATTRIBPOINTERPROC, pglVertexAttribPointer, "glVertexAttribPointer");
|
||||
return status;
|
||||
}
|
||||
/**********************************************************************
|
||||
* Default shader programs
|
||||
*********************************************************************/
|
||||
|
||||
static const char* default_vertex_shader =
|
||||
static const char* vertex_shader_text =
|
||||
"#version 150\n"
|
||||
"uniform mat4 project;\n"
|
||||
"uniform mat4 modelview;\n"
|
||||
@ -135,12 +64,12 @@ static const char* default_vertex_shader =
|
||||
" gl_Position = project * modelview * vec4(x, y, z, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* default_fragment_shader =
|
||||
static const char* fragment_shader_text =
|
||||
"#version 150\n"
|
||||
"out vec4 gl_FragColor;\n"
|
||||
"out vec4 color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = vec4(0.2, 1.0, 0.2, 1.0); \n"
|
||||
" color = vec4(0.2, 1.0, 0.2, 1.0); \n"
|
||||
"}\n";
|
||||
|
||||
/**********************************************************************
|
||||
@ -188,53 +117,27 @@ 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)
|
||||
static GLuint make_shader(GLenum type, const char* text)
|
||||
{
|
||||
GLuint shader;
|
||||
GLint shader_ok;
|
||||
GLsizei log_length;
|
||||
char info_log[8192];
|
||||
|
||||
shader = pglCreateShader(type);
|
||||
shader = glCreateShader(type);
|
||||
if (shader != 0)
|
||||
{
|
||||
pglShaderSource(shader, 1, (const GLchar**)&shader_src, NULL);
|
||||
pglCompileShader(shader);
|
||||
pglGetShaderiv(shader, GL_COMPILE_STATUS, &shader_ok);
|
||||
glShaderSource(shader, 1, (const GLchar**)&text, 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" );
|
||||
pglGetShaderInfoLog(shader, 8192, &log_length,info_log);
|
||||
glGetShaderInfoLog(shader, 8192, &log_length,info_log);
|
||||
fprintf(stderr, "ERROR: \n%s\n\n", info_log);
|
||||
pglDeleteShader(shader);
|
||||
glDeleteShader(shader);
|
||||
shader = 0;
|
||||
}
|
||||
}
|
||||
@ -243,7 +146,7 @@ static GLuint make_shader(GLenum type, const char* shader_src)
|
||||
|
||||
/* 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)
|
||||
static GLuint make_shader_program(const char* vs_text, const char* fs_text)
|
||||
{
|
||||
GLuint program = 0u;
|
||||
GLint program_ok;
|
||||
@ -252,30 +155,30 @@ static GLuint make_shader_program(const char* vertex_shader_src, const char* fra
|
||||
GLsizei log_length;
|
||||
char info_log[8192];
|
||||
|
||||
vertex_shader = make_shader(GL_VERTEX_SHADER, (vertex_shader_src == NULL) ? default_vertex_shader : vertex_shader_src);
|
||||
vertex_shader = make_shader(GL_VERTEX_SHADER, vs_text);
|
||||
if (vertex_shader != 0u)
|
||||
{
|
||||
fragment_shader = make_shader(GL_FRAGMENT_SHADER, (fragment_shader_src == NULL) ? default_fragment_shader : fragment_shader_src);
|
||||
fragment_shader = make_shader(GL_FRAGMENT_SHADER, fs_text);
|
||||
if (fragment_shader != 0u)
|
||||
{
|
||||
/* make the program that connect the two shader and link it */
|
||||
program = pglCreateProgram();
|
||||
program = glCreateProgram();
|
||||
if (program != 0u)
|
||||
{
|
||||
/* attach both shader and link */
|
||||
pglAttachShader(program, vertex_shader);
|
||||
pglAttachShader(program, fragment_shader);
|
||||
pglLinkProgram(program);
|
||||
pglGetProgramiv(program, GL_LINK_STATUS, &program_ok);
|
||||
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");
|
||||
pglGetProgramInfoLog(program, 8192, &log_length, info_log);
|
||||
glGetProgramInfoLog(program, 8192, &log_length, info_log);
|
||||
fprintf(stderr, "ERROR: \n%s\n\n", info_log);
|
||||
pglDeleteProgram(program);
|
||||
pglDeleteShader(fragment_shader);
|
||||
pglDeleteShader(vertex_shader);
|
||||
glDeleteProgram(program);
|
||||
glDeleteShader(fragment_shader);
|
||||
glDeleteShader(vertex_shader);
|
||||
program = 0u;
|
||||
}
|
||||
}
|
||||
@ -283,7 +186,7 @@ static GLuint make_shader_program(const char* vertex_shader_src, const char* fra
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to load fragment shader\n");
|
||||
pglDeleteShader(vertex_shader);
|
||||
glDeleteShader(vertex_shader);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -439,38 +342,38 @@ static void make_mesh(GLuint program)
|
||||
{
|
||||
GLuint attrloc;
|
||||
|
||||
pglGenVertexArrays(1, &mesh);
|
||||
pglGenBuffers(4, mesh_vbo);
|
||||
pglBindVertexArray(mesh);
|
||||
glGenVertexArrays(1, &mesh);
|
||||
glGenBuffers(4, mesh_vbo);
|
||||
glBindVertexArray(mesh);
|
||||
/* Prepare the data for drawing through a buffer inidices */
|
||||
pglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh_vbo[3]);
|
||||
pglBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint)* MAP_NUM_LINES * 2, map_line_indices, GL_STATIC_DRAW);
|
||||
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 = pglGetAttribLocation(program, "x");
|
||||
pglBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[0]);
|
||||
pglBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[0][0], GL_STATIC_DRAW);
|
||||
pglEnableVertexAttribArray(attrloc);
|
||||
pglVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
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 = pglGetAttribLocation(program, "z");
|
||||
pglBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[2]);
|
||||
pglBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[2][0], GL_STATIC_DRAW);
|
||||
pglEnableVertexAttribArray(attrloc);
|
||||
pglVertexAttribPointer(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 = pglGetAttribLocation(program, "y");
|
||||
pglBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[1]);
|
||||
pglBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0], GL_DYNAMIC_DRAW);
|
||||
pglEnableVertexAttribArray(attrloc);
|
||||
pglVertexAttribPointer(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)
|
||||
{
|
||||
pglBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0]);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0]);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
@ -488,17 +391,15 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||
}
|
||||
}
|
||||
|
||||
/* Print usage information */
|
||||
static void usage(void)
|
||||
static void error_callback(int error, const char* description)
|
||||
{
|
||||
printf("Usage: heightmap [-v <vertex_shader_path>] [-f <fragment_shader_path>]\n");
|
||||
printf(" heightmap [-h]\n");
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GLFWwindow* window;
|
||||
int ch, iter;
|
||||
int iter;
|
||||
double dt;
|
||||
double last_update_time;
|
||||
int frame;
|
||||
@ -506,80 +407,22 @@ int main(int argc, char** argv)
|
||||
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);
|
||||
}
|
||||
}
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
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);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
|
||||
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);
|
||||
}
|
||||
@ -588,32 +431,20 @@ int main(int argc, char** argv)
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
if (GL_TRUE != init_opengl())
|
||||
{
|
||||
fprintf(stderr, "ERROR: unable to resolve OpenGL function pointers\n");
|
||||
free(vertex_shader_src);
|
||||
free(fragment_shader_src);
|
||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||
|
||||
glfwTerminate();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* Prepare opengl resources for rendering */
|
||||
shader_program = make_shader_program(vertex_shader_src , fragment_shader_src);
|
||||
free(vertex_shader_src);
|
||||
free(fragment_shader_src);
|
||||
shader_program = make_shader_program(vertex_shader_text, fragment_shader_text);
|
||||
|
||||
if (shader_program == 0u)
|
||||
{
|
||||
fprintf(stderr, "ERROR: during creation of the shader program\n");
|
||||
usage();
|
||||
|
||||
glfwTerminate();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pglUseProgram(shader_program);
|
||||
uloc_project = pglGetUniformLocation(shader_program, "project");
|
||||
uloc_modelview = pglGetUniformLocation(shader_program, "modelview");
|
||||
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);
|
||||
@ -622,13 +453,13 @@ int main(int argc, char** argv)
|
||||
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);
|
||||
pglUniformMatrix4fv(uloc_project, 1, GL_FALSE, projection_matrix);
|
||||
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;
|
||||
pglUniformMatrix4fv(uloc_modelview, 1, GL_FALSE, modelview_matrix);
|
||||
glUniformMatrix4fv(uloc_modelview, 1, GL_FALSE, modelview_matrix);
|
||||
|
||||
/* Create mesh data */
|
||||
init_map();
|
||||
|
1061
extern/glfw/examples/particles.c
vendored
Normal file
1061
extern/glfw/examples/particles.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
extern/glfw/examples/simple.c
vendored
1
extern/glfw/examples/simple.c
vendored
@ -57,6 +57,7 @@ int main(void)
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
|
19
extern/glfw/examples/wave.c
vendored
19
extern/glfw/examples/wave.c
vendored
@ -28,10 +28,8 @@
|
||||
GLfloat alpha = 210.f, beta = -70.f;
|
||||
GLfloat zoom = 2.f;
|
||||
|
||||
GLboolean locked = GL_FALSE;
|
||||
|
||||
int cursorX;
|
||||
int cursorY;
|
||||
double cursorX;
|
||||
double cursorY;
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
@ -321,13 +319,10 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
||||
if (action == GLFW_PRESS)
|
||||
{
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
locked = GL_TRUE;
|
||||
glfwGetCursorPos(window, &cursorX, &cursorY);
|
||||
}
|
||||
else
|
||||
{
|
||||
locked = GL_FALSE;
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -337,14 +332,14 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
||||
|
||||
void cursor_position_callback(GLFWwindow* window, double x, double y)
|
||||
{
|
||||
if (locked)
|
||||
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
alpha += (GLfloat) (x - cursorX) / 10.f;
|
||||
beta += (GLfloat) (y - cursorY) / 10.f;
|
||||
}
|
||||
|
||||
cursorX = (int) x;
|
||||
cursorY = (int) y;
|
||||
cursorX = x;
|
||||
cursorY = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
1921
extern/glfw/include/GLFW/glfw3.h
vendored
1921
extern/glfw/include/GLFW/glfw3.h
vendored
File diff suppressed because it is too large
Load Diff
212
extern/glfw/include/GLFW/glfw3native.h
vendored
212
extern/glfw/include/GLFW/glfw3native.h
vendored
@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* GLFW 3.0 - www.glfw.org
|
||||
* GLFW 3.1 - www.glfw.org
|
||||
* A library for OpenGL, window and input
|
||||
*------------------------------------------------------------------------
|
||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||
@ -40,13 +40,13 @@ extern "C" {
|
||||
|
||||
/*! @defgroup native Native access
|
||||
*
|
||||
* **By using the native API, you assert that you know what you're doing and
|
||||
* how to fix problems caused by using it. If you don't, you shouldn't be
|
||||
* using it.**
|
||||
* **By using the native access functions you assert that you know what you're
|
||||
* doing and how to fix problems caused by using them. If you don't, you
|
||||
* shouldn't be using them.**
|
||||
*
|
||||
* 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`
|
||||
@ -71,8 +71,13 @@ extern "C" {
|
||||
*************************************************************************/
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||
// example to allow applications to correctly declare a GL_ARB_debug_output
|
||||
// callback) but windows.h assumes no one will define APIENTRY before it does
|
||||
#undef APIENTRY
|
||||
#include <windows.h>
|
||||
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#if defined(__OBJC__)
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
@ -80,8 +85,9 @@ extern "C" {
|
||||
#endif
|
||||
#elif defined(GLFW_EXPOSE_NATIVE_X11)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#else
|
||||
#error "No window API specified"
|
||||
#error "No window API selected"
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||
@ -93,7 +99,7 @@ extern "C" {
|
||||
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#error "No context API specified"
|
||||
#error "No context API selected"
|
||||
#endif
|
||||
|
||||
|
||||
@ -102,8 +108,49 @@ extern "C" {
|
||||
*************************************************************************/
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||
/*! @brief Returns the adapter device name of the specified monitor.
|
||||
*
|
||||
* @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
|
||||
* 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* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the display device name of the specified monitor.
|
||||
*
|
||||
* @return The UTF-8 encoded display device name (for example
|
||||
* `\\.\DISPLAY1\Monitor0`) 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);
|
||||
@ -111,15 +158,48 @@ 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);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||
/*! @brief Returns 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);
|
||||
@ -127,7 +207,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);
|
||||
@ -135,12 +224,61 @@ 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 `RRCrtc` of the specified monitor.
|
||||
*
|
||||
* @return The `RRCrtc` 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 RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns 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);
|
||||
@ -148,7 +286,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);
|
||||
@ -156,17 +303,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);
|
||||
|
BIN
extern/glfw/src/CMakeFiles/glfw.dir/context.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/context.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/glx_context.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/glx_context.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/init.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/init.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/input.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/input.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/linux_joystick.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/linux_joystick.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/monitor.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/monitor.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/posix_time.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/posix_time.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/posix_tls.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/posix_tls.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/window.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/window.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/x11_init.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/x11_init.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/x11_monitor.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/x11_monitor.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/x11_window.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/x11_window.c.o
vendored
Normal file
Binary file not shown.
BIN
extern/glfw/src/CMakeFiles/glfw.dir/xkb_unicode.c.o
vendored
Normal file
BIN
extern/glfw/src/CMakeFiles/glfw.dir/xkb_unicode.c.o
vendored
Normal file
Binary file not shown.
70
extern/glfw/src/CMakeLists.txt
vendored
70
extern/glfw/src/CMakeLists.txt
vendored
@ -1,44 +1,54 @@
|
||||
|
||||
include_directories(${GLFW_SOURCE_DIR}/src
|
||||
${GLFW_BINARY_DIR}/src
|
||||
include_directories("${GLFW_SOURCE_DIR}/src"
|
||||
"${GLFW_BINARY_DIR}/src"
|
||||
${glfw_INCLUDE_DIRS})
|
||||
|
||||
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 clipboard.c context.c gamma.c init.c input.c joystick.c
|
||||
monitor.c time.c window.c)
|
||||
set(common_HEADERS internal.h
|
||||
"${GLFW_BINARY_DIR}/src/glfw_config.h"
|
||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
|
||||
set(common_SOURCES context.c init.c input.c monitor.c window.c)
|
||||
|
||||
if (_GLFW_COCOA)
|
||||
set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} cocoa_clipboard.m cocoa_gamma.c
|
||||
cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_time.c
|
||||
cocoa_window.m)
|
||||
set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h iokit_joystick.h
|
||||
posix_tls.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_monitor.m
|
||||
cocoa_window.m iokit_joystick.m mach_time.c posix_tls.c)
|
||||
elseif (_GLFW_WIN32)
|
||||
set(glfw_HEADERS ${common_HEADERS} win32_platform.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} win32_clipboard.c win32_gamma.c
|
||||
win32_init.c win32_joystick.c win32_monitor.c win32_time.c
|
||||
win32_window.c)
|
||||
set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_tls.h
|
||||
winmm_joystick.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_monitor.c win32_time.c
|
||||
win32_tls.c win32_window.c winmm_joystick.c)
|
||||
elseif (_GLFW_X11)
|
||||
set(glfw_HEADERS ${common_HEADERS} x11_platform.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_gamma.c x11_init.c
|
||||
x11_joystick.c x11_monitor.c x11_time.c x11_window.c
|
||||
x11_unicode.c)
|
||||
set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h
|
||||
linux_joystick.h posix_time.h posix_tls.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c
|
||||
xkb_unicode.c linux_joystick.c posix_time.c posix_tls.c)
|
||||
elseif (_GLFW_WAYLAND)
|
||||
set(glfw_HEADERS ${common_HEADERS} wl_platform.h linux_joystick.h
|
||||
posix_time.h posix_tls.h xkb_unicode.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c
|
||||
linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c)
|
||||
elseif (_GLFW_MIR)
|
||||
set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h
|
||||
posix_time.h posix_tls.h xkb_unicode.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} mir_init.c mir_monitor.c mir_window.c
|
||||
linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c)
|
||||
endif()
|
||||
|
||||
if (_GLFW_EGL)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} egl_platform.h)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} egl_context.h)
|
||||
list(APPEND glfw_SOURCES ${common_SOURCES} egl_context.c)
|
||||
elseif (_GLFW_NSGL)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} nsgl_platform.h)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} nsgl_context.h)
|
||||
list(APPEND glfw_SOURCES ${common_SOURCES} nsgl_context.m)
|
||||
elseif (_GLFW_WGL)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} wgl_platform.h)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} wgl_context.h)
|
||||
list(APPEND glfw_SOURCES ${common_SOURCES} wgl_context.c)
|
||||
elseif (_GLFW_X11)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} glx_platform.h)
|
||||
list(APPEND glfw_HEADERS ${common_HEADERS} glx_context.h)
|
||||
list(APPEND glfw_SOURCES ${common_SOURCES} glx_context.c)
|
||||
endif()
|
||||
|
||||
@ -48,15 +58,14 @@ 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}"
|
||||
VERSION ${GLFW_VERSION}
|
||||
SOVERSION ${GLFW_VERSION_MAJOR}
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
FOLDER "GLFW3")
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
# Include version information in the output
|
||||
set_target_properties(glfw PROPERTIES VERSION ${GLFW_VERSION})
|
||||
if (UNIX)
|
||||
set_target_properties(glfw PROPERTIES SOVERSION ${GLFW_VERSION_MAJOR})
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
# The GLFW DLL needs a special compile-time macro and import library name
|
||||
set_target_properties(glfw PROPERTIES PREFIX "" IMPORT_PREFIX "")
|
||||
@ -79,7 +88,6 @@ if (BUILD_SHARED_LIBS)
|
||||
endif()
|
||||
|
||||
target_link_libraries(glfw ${glfw_LIBRARIES})
|
||||
target_link_libraries(glfw LINK_INTERFACE_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if (GLFW_INSTALL)
|
||||
|
38
extern/glfw/src/cmake_install.cmake
vendored
Normal file
38
extern/glfw/src/cmake_install.cmake
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
# Install script for directory: /home/fab/swp/swp/extern/glfw/src
|
||||
|
||||
# Set the install prefix
|
||||
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
|
||||
set(CMAKE_INSTALL_PREFIX "/usr/local")
|
||||
endif()
|
||||
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# Set the install configuration name.
|
||||
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
|
||||
if(BUILD_TYPE)
|
||||
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
|
||||
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_CONFIG_NAME "Release")
|
||||
endif()
|
||||
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
|
||||
endif()
|
||||
|
||||
# Set the component getting installed.
|
||||
if(NOT CMAKE_INSTALL_COMPONENT)
|
||||
if(COMPONENT)
|
||||
message(STATUS "Install component: \"${COMPONENT}\"")
|
||||
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_COMPONENT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Install shared libraries without execute permission?
|
||||
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
|
||||
set(CMAKE_INSTALL_SO_NO_EXE "0")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
|
||||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/home/fab/swp/swp/extern/glfw/src/libglfw3.a")
|
||||
endif()
|
||||
|
84
extern/glfw/src/cocoa_gamma.c
vendored
84
extern/glfw/src/cocoa_gamma.c
vendored
@ -1,84 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 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"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
||||
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
|
||||
|
||||
CGGetDisplayTransferByTable(monitor->ns.displayID,
|
||||
size,
|
||||
values,
|
||||
values + size,
|
||||
values + size * 2,
|
||||
&size);
|
||||
|
||||
_glfwAllocGammaArrays(ramp, size);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
ramp->red[i] = (unsigned short) (values[i] * 65535);
|
||||
ramp->green[i] = (unsigned short) (values[i + size] * 65535);
|
||||
ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
|
||||
}
|
||||
|
||||
free(values);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
int i;
|
||||
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
|
||||
|
||||
for (i = 0; i < ramp->size; i++)
|
||||
{
|
||||
values[i] = ramp->red[i] / 65535.f;
|
||||
values[i + ramp->size] = ramp->green[i] / 65535.f;
|
||||
values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
|
||||
}
|
||||
|
||||
CGSetDisplayTransferByTable(monitor->ns.displayID,
|
||||
ramp->size,
|
||||
values,
|
||||
values + ramp->size,
|
||||
values + ramp->size * 2);
|
||||
|
||||
free(values);
|
||||
}
|
||||
|
138
extern/glfw/src/cocoa_init.m
vendored
138
extern/glfw/src/cocoa_init.m
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -68,6 +68,128 @@ static void changeToResourcesDirectory(void)
|
||||
|
||||
#endif /* _GLFW_USE_CHDIR */
|
||||
|
||||
// Create key code translation tables
|
||||
//
|
||||
static void createKeyTables(void)
|
||||
{
|
||||
memset(_glfw.ns.publicKeys, -1, sizeof(_glfw.ns.publicKeys));
|
||||
|
||||
_glfw.ns.publicKeys[0x1D] = GLFW_KEY_0;
|
||||
_glfw.ns.publicKeys[0x12] = GLFW_KEY_1;
|
||||
_glfw.ns.publicKeys[0x13] = GLFW_KEY_2;
|
||||
_glfw.ns.publicKeys[0x14] = GLFW_KEY_3;
|
||||
_glfw.ns.publicKeys[0x15] = GLFW_KEY_4;
|
||||
_glfw.ns.publicKeys[0x17] = GLFW_KEY_5;
|
||||
_glfw.ns.publicKeys[0x16] = GLFW_KEY_6;
|
||||
_glfw.ns.publicKeys[0x1A] = GLFW_KEY_7;
|
||||
_glfw.ns.publicKeys[0x1C] = GLFW_KEY_8;
|
||||
_glfw.ns.publicKeys[0x19] = GLFW_KEY_9;
|
||||
_glfw.ns.publicKeys[0x00] = GLFW_KEY_A;
|
||||
_glfw.ns.publicKeys[0x0B] = GLFW_KEY_B;
|
||||
_glfw.ns.publicKeys[0x08] = GLFW_KEY_C;
|
||||
_glfw.ns.publicKeys[0x02] = GLFW_KEY_D;
|
||||
_glfw.ns.publicKeys[0x0E] = GLFW_KEY_E;
|
||||
_glfw.ns.publicKeys[0x03] = GLFW_KEY_F;
|
||||
_glfw.ns.publicKeys[0x05] = GLFW_KEY_G;
|
||||
_glfw.ns.publicKeys[0x04] = GLFW_KEY_H;
|
||||
_glfw.ns.publicKeys[0x22] = GLFW_KEY_I;
|
||||
_glfw.ns.publicKeys[0x26] = GLFW_KEY_J;
|
||||
_glfw.ns.publicKeys[0x28] = GLFW_KEY_K;
|
||||
_glfw.ns.publicKeys[0x25] = GLFW_KEY_L;
|
||||
_glfw.ns.publicKeys[0x2E] = GLFW_KEY_M;
|
||||
_glfw.ns.publicKeys[0x2D] = GLFW_KEY_N;
|
||||
_glfw.ns.publicKeys[0x1F] = GLFW_KEY_O;
|
||||
_glfw.ns.publicKeys[0x23] = GLFW_KEY_P;
|
||||
_glfw.ns.publicKeys[0x0C] = GLFW_KEY_Q;
|
||||
_glfw.ns.publicKeys[0x0F] = GLFW_KEY_R;
|
||||
_glfw.ns.publicKeys[0x01] = GLFW_KEY_S;
|
||||
_glfw.ns.publicKeys[0x11] = GLFW_KEY_T;
|
||||
_glfw.ns.publicKeys[0x20] = GLFW_KEY_U;
|
||||
_glfw.ns.publicKeys[0x09] = GLFW_KEY_V;
|
||||
_glfw.ns.publicKeys[0x0D] = GLFW_KEY_W;
|
||||
_glfw.ns.publicKeys[0x07] = GLFW_KEY_X;
|
||||
_glfw.ns.publicKeys[0x10] = GLFW_KEY_Y;
|
||||
_glfw.ns.publicKeys[0x06] = GLFW_KEY_Z;
|
||||
|
||||
_glfw.ns.publicKeys[0x27] = GLFW_KEY_APOSTROPHE;
|
||||
_glfw.ns.publicKeys[0x2A] = GLFW_KEY_BACKSLASH;
|
||||
_glfw.ns.publicKeys[0x2B] = GLFW_KEY_COMMA;
|
||||
_glfw.ns.publicKeys[0x18] = GLFW_KEY_EQUAL;
|
||||
_glfw.ns.publicKeys[0x32] = GLFW_KEY_GRAVE_ACCENT;
|
||||
_glfw.ns.publicKeys[0x21] = GLFW_KEY_LEFT_BRACKET;
|
||||
_glfw.ns.publicKeys[0x1B] = GLFW_KEY_MINUS;
|
||||
_glfw.ns.publicKeys[0x2F] = GLFW_KEY_PERIOD;
|
||||
_glfw.ns.publicKeys[0x1E] = GLFW_KEY_RIGHT_BRACKET;
|
||||
_glfw.ns.publicKeys[0x29] = GLFW_KEY_SEMICOLON;
|
||||
_glfw.ns.publicKeys[0x2C] = GLFW_KEY_SLASH;
|
||||
_glfw.ns.publicKeys[0x0A] = GLFW_KEY_WORLD_1;
|
||||
|
||||
_glfw.ns.publicKeys[0x33] = GLFW_KEY_BACKSPACE;
|
||||
_glfw.ns.publicKeys[0x39] = GLFW_KEY_CAPS_LOCK;
|
||||
_glfw.ns.publicKeys[0x75] = GLFW_KEY_DELETE;
|
||||
_glfw.ns.publicKeys[0x7D] = GLFW_KEY_DOWN;
|
||||
_glfw.ns.publicKeys[0x77] = GLFW_KEY_END;
|
||||
_glfw.ns.publicKeys[0x24] = GLFW_KEY_ENTER;
|
||||
_glfw.ns.publicKeys[0x35] = GLFW_KEY_ESCAPE;
|
||||
_glfw.ns.publicKeys[0x7A] = GLFW_KEY_F1;
|
||||
_glfw.ns.publicKeys[0x78] = GLFW_KEY_F2;
|
||||
_glfw.ns.publicKeys[0x63] = GLFW_KEY_F3;
|
||||
_glfw.ns.publicKeys[0x76] = GLFW_KEY_F4;
|
||||
_glfw.ns.publicKeys[0x60] = GLFW_KEY_F5;
|
||||
_glfw.ns.publicKeys[0x61] = GLFW_KEY_F6;
|
||||
_glfw.ns.publicKeys[0x62] = GLFW_KEY_F7;
|
||||
_glfw.ns.publicKeys[0x64] = GLFW_KEY_F8;
|
||||
_glfw.ns.publicKeys[0x65] = GLFW_KEY_F9;
|
||||
_glfw.ns.publicKeys[0x6D] = GLFW_KEY_F10;
|
||||
_glfw.ns.publicKeys[0x67] = GLFW_KEY_F11;
|
||||
_glfw.ns.publicKeys[0x6F] = GLFW_KEY_F12;
|
||||
_glfw.ns.publicKeys[0x69] = GLFW_KEY_F13;
|
||||
_glfw.ns.publicKeys[0x6B] = GLFW_KEY_F14;
|
||||
_glfw.ns.publicKeys[0x71] = GLFW_KEY_F15;
|
||||
_glfw.ns.publicKeys[0x6A] = GLFW_KEY_F16;
|
||||
_glfw.ns.publicKeys[0x40] = GLFW_KEY_F17;
|
||||
_glfw.ns.publicKeys[0x4F] = GLFW_KEY_F18;
|
||||
_glfw.ns.publicKeys[0x50] = GLFW_KEY_F19;
|
||||
_glfw.ns.publicKeys[0x5A] = GLFW_KEY_F20;
|
||||
_glfw.ns.publicKeys[0x73] = GLFW_KEY_HOME;
|
||||
_glfw.ns.publicKeys[0x72] = GLFW_KEY_INSERT;
|
||||
_glfw.ns.publicKeys[0x7B] = GLFW_KEY_LEFT;
|
||||
_glfw.ns.publicKeys[0x3A] = GLFW_KEY_LEFT_ALT;
|
||||
_glfw.ns.publicKeys[0x3B] = GLFW_KEY_LEFT_CONTROL;
|
||||
_glfw.ns.publicKeys[0x38] = GLFW_KEY_LEFT_SHIFT;
|
||||
_glfw.ns.publicKeys[0x37] = GLFW_KEY_LEFT_SUPER;
|
||||
_glfw.ns.publicKeys[0x6E] = GLFW_KEY_MENU;
|
||||
_glfw.ns.publicKeys[0x47] = GLFW_KEY_NUM_LOCK;
|
||||
_glfw.ns.publicKeys[0x79] = GLFW_KEY_PAGE_DOWN;
|
||||
_glfw.ns.publicKeys[0x74] = GLFW_KEY_PAGE_UP;
|
||||
_glfw.ns.publicKeys[0x7C] = GLFW_KEY_RIGHT;
|
||||
_glfw.ns.publicKeys[0x3D] = GLFW_KEY_RIGHT_ALT;
|
||||
_glfw.ns.publicKeys[0x3E] = GLFW_KEY_RIGHT_CONTROL;
|
||||
_glfw.ns.publicKeys[0x3C] = GLFW_KEY_RIGHT_SHIFT;
|
||||
_glfw.ns.publicKeys[0x36] = GLFW_KEY_RIGHT_SUPER;
|
||||
_glfw.ns.publicKeys[0x31] = GLFW_KEY_SPACE;
|
||||
_glfw.ns.publicKeys[0x30] = GLFW_KEY_TAB;
|
||||
_glfw.ns.publicKeys[0x7E] = GLFW_KEY_UP;
|
||||
|
||||
_glfw.ns.publicKeys[0x52] = GLFW_KEY_KP_0;
|
||||
_glfw.ns.publicKeys[0x53] = GLFW_KEY_KP_1;
|
||||
_glfw.ns.publicKeys[0x54] = GLFW_KEY_KP_2;
|
||||
_glfw.ns.publicKeys[0x55] = GLFW_KEY_KP_3;
|
||||
_glfw.ns.publicKeys[0x56] = GLFW_KEY_KP_4;
|
||||
_glfw.ns.publicKeys[0x57] = GLFW_KEY_KP_5;
|
||||
_glfw.ns.publicKeys[0x58] = GLFW_KEY_KP_6;
|
||||
_glfw.ns.publicKeys[0x59] = GLFW_KEY_KP_7;
|
||||
_glfw.ns.publicKeys[0x5B] = GLFW_KEY_KP_8;
|
||||
_glfw.ns.publicKeys[0x5C] = GLFW_KEY_KP_9;
|
||||
_glfw.ns.publicKeys[0x45] = GLFW_KEY_KP_ADD;
|
||||
_glfw.ns.publicKeys[0x41] = GLFW_KEY_KP_DECIMAL;
|
||||
_glfw.ns.publicKeys[0x4B] = GLFW_KEY_KP_DIVIDE;
|
||||
_glfw.ns.publicKeys[0x4C] = GLFW_KEY_KP_ENTER;
|
||||
_glfw.ns.publicKeys[0x51] = GLFW_KEY_KP_EQUAL;
|
||||
_glfw.ns.publicKeys[0x43] = GLFW_KEY_KP_MULTIPLY;
|
||||
_glfw.ns.publicKeys[0x4E] = GLFW_KEY_KP_SUBTRACT;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
@ -81,6 +203,8 @@ int _glfwPlatformInit(void)
|
||||
changeToResourcesDirectory();
|
||||
#endif
|
||||
|
||||
createKeyTables();
|
||||
|
||||
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
if (!_glfw.ns.eventSource)
|
||||
return GL_FALSE;
|
||||
@ -104,9 +228,12 @@ void _glfwPlatformTerminate(void)
|
||||
_glfw.ns.eventSource = NULL;
|
||||
}
|
||||
|
||||
[NSApp setDelegate:nil];
|
||||
[_glfw.ns.delegate release];
|
||||
_glfw.ns.delegate = nil;
|
||||
if (_glfw.ns.delegate)
|
||||
{
|
||||
[NSApp setDelegate:nil];
|
||||
[_glfw.ns.delegate release];
|
||||
_glfw.ns.delegate = nil;
|
||||
}
|
||||
|
||||
[_glfw.ns.autoreleasePool release];
|
||||
_glfw.ns.autoreleasePool = nil;
|
||||
@ -132,6 +259,9 @@ const char* _glfwPlatformGetVersionString(void)
|
||||
#if defined(_GLFW_USE_MENUBAR)
|
||||
" menubar"
|
||||
#endif
|
||||
#if defined(_GLFW_USE_RETINA)
|
||||
" retina"
|
||||
#endif
|
||||
#if defined(_GLFW_BUILD_DLL)
|
||||
" dynamic"
|
||||
#endif
|
||||
|
259
extern/glfw/src/cocoa_monitor.m
vendored
259
extern/glfw/src/cocoa_monitor.m
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
@ -34,17 +35,20 @@
|
||||
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||
#include <CoreVideo/CVBase.h>
|
||||
#include <CoreVideo/CVDisplayLink.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
|
||||
// Get the name of the specified display
|
||||
//
|
||||
static const char* getDisplayName(CGDirectDisplayID displayID)
|
||||
static char* getDisplayName(CGDirectDisplayID displayID)
|
||||
{
|
||||
char* name;
|
||||
CFDictionaryRef info, names;
|
||||
CFStringRef value;
|
||||
CFIndex size;
|
||||
|
||||
// NOTE: This uses a deprecated function because Apple has
|
||||
// (as of January 2015) not provided any alternative
|
||||
info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID),
|
||||
kIODisplayOnlyPreferredName);
|
||||
names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
||||
@ -52,6 +56,7 @@ static const char* getDisplayName(CGDirectDisplayID displayID)
|
||||
if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
|
||||
(const void**) &value))
|
||||
{
|
||||
// This may happen if a desktop Mac is running headless
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to retrieve display name");
|
||||
|
||||
CFRelease(info);
|
||||
@ -162,74 +167,57 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
|
||||
//
|
||||
GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
{
|
||||
CGDisplayModeRef bestMode = NULL;
|
||||
CFArrayRef modes;
|
||||
CFIndex count, i;
|
||||
unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
|
||||
unsigned int rateDiff, leastRateDiff = UINT_MAX;
|
||||
const int bpp = desired->redBits - desired->greenBits - desired->blueBits;
|
||||
CVDisplayLinkRef link;
|
||||
CGDisplayModeRef native = NULL;
|
||||
GLFWvidmode current;
|
||||
const GLFWvidmode* best;
|
||||
|
||||
best = _glfwChooseVideoMode(monitor, desired);
|
||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||
return GL_TRUE;
|
||||
|
||||
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
||||
|
||||
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||
count = CFArrayGetCount(modes);
|
||||
|
||||
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;
|
||||
|
||||
int modeBPP;
|
||||
|
||||
// Identify display mode pixel encoding
|
||||
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
|
||||
if (_glfwCompareVideoModes(best, &mode) == 0)
|
||||
{
|
||||
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
||||
|
||||
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
|
||||
modeBPP = 16;
|
||||
else
|
||||
modeBPP = 32;
|
||||
|
||||
CFRelease(format);
|
||||
}
|
||||
|
||||
const int modeWidth = (int) CGDisplayModeGetWidth(mode);
|
||||
const int modeHeight = (int) CGDisplayModeGetHeight(mode);
|
||||
const int modeRate = (int) CGDisplayModeGetRefreshRate(mode);
|
||||
|
||||
sizeDiff = (abs(modeBPP - bpp) << 25) |
|
||||
((modeWidth - desired->width) * (modeWidth - desired->width) +
|
||||
(modeHeight - desired->height) * (modeHeight - desired->height));
|
||||
|
||||
if (desired->refreshRate)
|
||||
rateDiff = abs(modeRate - desired->refreshRate);
|
||||
else
|
||||
rateDiff = UINT_MAX - modeRate;
|
||||
|
||||
if ((sizeDiff < leastSizeDiff) ||
|
||||
(sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
|
||||
{
|
||||
bestMode = mode;
|
||||
leastSizeDiff = sizeDiff;
|
||||
leastRateDiff = rateDiff;
|
||||
native = dm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bestMode)
|
||||
if (native)
|
||||
{
|
||||
CFRelease(modes);
|
||||
if (monitor->ns.previousMode == NULL)
|
||||
monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
||||
|
||||
CGDisplayFadeReservationToken token = beginFadeReservation();
|
||||
CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);
|
||||
endFadeReservation(token);
|
||||
}
|
||||
|
||||
CFRelease(modes);
|
||||
CVDisplayLinkRelease(link);
|
||||
|
||||
if (!native)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Monitor mode list changed");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
||||
|
||||
CGDisplayFadeReservationToken token = beginFadeReservation();
|
||||
|
||||
CGDisplayCapture(monitor->ns.displayID);
|
||||
CGDisplaySetDisplayMode(monitor->ns.displayID, bestMode, NULL);
|
||||
|
||||
endFadeReservation(token);
|
||||
|
||||
CFRelease(modes);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@ -237,12 +225,16 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
//
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||
{
|
||||
CGDisplayFadeReservationToken token = beginFadeReservation();
|
||||
if (monitor->ns.previousMode)
|
||||
{
|
||||
CGDisplayFadeReservationToken token = beginFadeReservation();
|
||||
CGDisplaySetDisplayMode(monitor->ns.displayID,
|
||||
monitor->ns.previousMode, NULL);
|
||||
endFadeReservation(token);
|
||||
|
||||
CGDisplaySetDisplayMode(monitor->ns.displayID, monitor->ns.previousMode, NULL);
|
||||
CGDisplayRelease(monitor->ns.displayID);
|
||||
|
||||
endFadeReservation(token);
|
||||
CGDisplayModeRelease(monitor->ns.previousMode);
|
||||
monitor->ns.previousMode = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -252,75 +244,65 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||
|
||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
{
|
||||
uint32_t i, found = 0, monitorCount;
|
||||
uint32_t i, found = 0, displayCount;
|
||||
_GLFWmonitor** monitors;
|
||||
CGDirectDisplayID* displays;
|
||||
|
||||
*count = 0;
|
||||
|
||||
CGGetActiveDisplayList(0, NULL, &monitorCount);
|
||||
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
||||
|
||||
displays = calloc(monitorCount, sizeof(CGDirectDisplayID));
|
||||
monitors = calloc(monitorCount, sizeof(_GLFWmonitor*));
|
||||
displays = calloc(displayCount, sizeof(CGDirectDisplayID));
|
||||
monitors = calloc(displayCount, sizeof(_GLFWmonitor*));
|
||||
|
||||
CGGetActiveDisplayList(monitorCount, displays, &monitorCount);
|
||||
|
||||
for (i = 0; i < monitorCount; i++)
|
||||
{
|
||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(getDisplayName(displays[i]),
|
||||
size.width, size.height);
|
||||
|
||||
monitors[found]->ns.displayID = displays[i];
|
||||
found++;
|
||||
}
|
||||
|
||||
free(displays);
|
||||
|
||||
for (i = 0; i < monitorCount; i++)
|
||||
{
|
||||
if (CGDisplayIsMain(monitors[i]->ns.displayID))
|
||||
{
|
||||
_GLFWmonitor* temp = monitors[0];
|
||||
monitors[0] = monitors[i];
|
||||
monitors[i] = temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
|
||||
|
||||
NSArray* screens = [NSScreen screens];
|
||||
|
||||
for (i = 0; i < monitorCount; i++)
|
||||
for (i = 0; i < displayCount; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
if (CGDisplayIsAsleep(displays[i]))
|
||||
continue;
|
||||
|
||||
CGDirectDisplayID screenDisplayID = CGDisplayMirrorsDisplay(displays[i]);
|
||||
if (screenDisplayID == kCGNullDirectDisplay)
|
||||
screenDisplayID = displays[i];
|
||||
|
||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||
char* name = getDisplayName(displays[i]);
|
||||
|
||||
monitors[found] = _glfwAllocMonitor(name, size.width, size.height);
|
||||
monitors[found]->ns.displayID = displays[i];
|
||||
|
||||
free(name);
|
||||
|
||||
for (j = 0; j < [screens count]; j++)
|
||||
{
|
||||
NSScreen* screen = [screens objectAtIndex:j];
|
||||
NSDictionary* dictionary = [screen deviceDescription];
|
||||
NSNumber* number = [dictionary objectForKey:@"NSScreenNumber"];
|
||||
|
||||
if (monitors[i]->ns.displayID == [number unsignedIntegerValue])
|
||||
if ([number unsignedIntegerValue] == screenDisplayID)
|
||||
{
|
||||
monitors[i]->ns.screen = screen;
|
||||
monitors[found]->ns.screen = screen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (monitors[i]->ns.screen == nil)
|
||||
if (monitors[found]->ns.screen)
|
||||
found++;
|
||||
else
|
||||
{
|
||||
_glfwDestroyMonitors(monitors, monitorCount);
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to find NSScreen for CGDisplay %s",
|
||||
monitors[i]->name);
|
||||
|
||||
free(monitors);
|
||||
return NULL;
|
||||
_glfwFreeMonitor(monitors[found]);
|
||||
monitors[found] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*count = monitorCount;
|
||||
free(displays);
|
||||
|
||||
*count = found;
|
||||
return monitors;
|
||||
}
|
||||
|
||||
@ -342,7 +324,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;
|
||||
|
||||
@ -356,14 +338,26 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
CGDisplayModeRef mode;
|
||||
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||
if (!modeIsGood(dm))
|
||||
continue;
|
||||
|
||||
mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||
if (modeIsGood(mode))
|
||||
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);
|
||||
@ -386,3 +380,60 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||
CVDisplayLinkRelease(link);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
||||
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
|
||||
|
||||
CGGetDisplayTransferByTable(monitor->ns.displayID,
|
||||
size,
|
||||
values,
|
||||
values + size,
|
||||
values + size * 2,
|
||||
&size);
|
||||
|
||||
_glfwAllocGammaArrays(ramp, size);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
ramp->red[i] = (unsigned short) (values[i] * 65535);
|
||||
ramp->green[i] = (unsigned short) (values[i + size] * 65535);
|
||||
ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
|
||||
}
|
||||
|
||||
free(values);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
int i;
|
||||
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
|
||||
|
||||
for (i = 0; i < ramp->size; i++)
|
||||
{
|
||||
values[i] = ramp->red[i] / 65535.f;
|
||||
values[i + ramp->size] = ramp->green[i] / 65535.f;
|
||||
values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
|
||||
}
|
||||
|
||||
CGSetDisplayTransferByTable(monitor->ns.displayID,
|
||||
ramp->size,
|
||||
values,
|
||||
values + ramp->size,
|
||||
values + ramp->size * 2);
|
||||
|
||||
free(values);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW native API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
|
||||
return monitor->ns.displayID;
|
||||
}
|
||||
|
||||
|
101
extern/glfw/src/cocoa_platform.h
vendored
101
extern/glfw/src/cocoa_platform.h
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -37,83 +37,57 @@
|
||||
typedef void* id;
|
||||
#endif
|
||||
|
||||
#include "posix_tls.h"
|
||||
|
||||
#if defined(_GLFW_NSGL)
|
||||
#include "nsgl_platform.h"
|
||||
#include "nsgl_context.h"
|
||||
#else
|
||||
#error "No supported context creation API selected"
|
||||
#endif
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
#include <IOKit/hid/IOHIDKeys.h>
|
||||
#include "iokit_joystick.h"
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
|
||||
#define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimeNS ns_time
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns
|
||||
|
||||
|
||||
//========================================================================
|
||||
// GLFW platform specific types
|
||||
//========================================================================
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific window structure
|
||||
//------------------------------------------------------------------------
|
||||
// Cocoa-specific per-window data
|
||||
//
|
||||
typedef struct _GLFWwindowNS
|
||||
{
|
||||
id object;
|
||||
id delegate;
|
||||
id view;
|
||||
unsigned int modifierFlags;
|
||||
|
||||
// The total sum of the distances the cursor has been warped
|
||||
// since the last cursor motion event was processed
|
||||
// This is kept to counteract Cocoa doing the same internally
|
||||
double warpDeltaX, warpDeltaY;
|
||||
|
||||
} _GLFWwindowNS;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Joystick information & state
|
||||
//------------------------------------------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
int present;
|
||||
char name[256];
|
||||
|
||||
IOHIDDeviceInterface** interface;
|
||||
|
||||
CFMutableArrayRef axisElements;
|
||||
CFMutableArrayRef buttonElements;
|
||||
CFMutableArrayRef hatElements;
|
||||
|
||||
float* axes;
|
||||
unsigned char* buttons;
|
||||
|
||||
} _GLFWjoy;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific library global data for Cocoa
|
||||
//------------------------------------------------------------------------
|
||||
// Cocoa-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryNS
|
||||
{
|
||||
struct {
|
||||
double base;
|
||||
double resolution;
|
||||
} timer;
|
||||
|
||||
CGEventSourceRef eventSource;
|
||||
id delegate;
|
||||
id autoreleasePool;
|
||||
id cursor;
|
||||
|
||||
short int publicKeys[256];
|
||||
char* clipboardString;
|
||||
|
||||
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];
|
||||
} _GLFWlibraryNS;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific monitor structure
|
||||
//------------------------------------------------------------------------
|
||||
// Cocoa-specific per-monitor data
|
||||
//
|
||||
typedef struct _GLFWmonitorNS
|
||||
{
|
||||
CGDirectDisplayID displayID;
|
||||
@ -123,27 +97,28 @@ typedef struct _GLFWmonitorNS
|
||||
} _GLFWmonitorNS;
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Prototypes for platform specific internal functions
|
||||
//========================================================================
|
||||
// Cocoa-specific per-cursor data
|
||||
//
|
||||
typedef struct _GLFWcursorNS
|
||||
{
|
||||
id object;
|
||||
|
||||
} _GLFWcursorNS;
|
||||
|
||||
|
||||
// Cocoa-specific global timer data
|
||||
//
|
||||
typedef struct _GLFWtimeNS
|
||||
{
|
||||
double base;
|
||||
double resolution;
|
||||
|
||||
} _GLFWtimeNS;
|
||||
|
||||
|
||||
// Time
|
||||
void _glfwInitTimer(void);
|
||||
|
||||
// Joystick input
|
||||
void _glfwInitJoysticks(void);
|
||||
void _glfwTerminateJoysticks(void);
|
||||
|
||||
// Fullscreen
|
||||
GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor);
|
||||
|
||||
// OpenGL support
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
|
||||
#endif // _cocoa_platform_h_
|
||||
|
691
extern/glfw/src/cocoa_window.m
vendored
691
extern/glfw/src/cocoa_window.m
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -26,10 +26,35 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// Needed for _NSGetProgname
|
||||
#include <crt_externs.h>
|
||||
|
||||
|
||||
// Returns the specified standard cursor
|
||||
//
|
||||
static NSCursor* getStandardCursor(int shape)
|
||||
{
|
||||
switch (shape)
|
||||
{
|
||||
case GLFW_ARROW_CURSOR:
|
||||
return [NSCursor arrowCursor];
|
||||
case GLFW_IBEAM_CURSOR:
|
||||
return [NSCursor IBeamCursor];
|
||||
case GLFW_CROSSHAIR_CURSOR:
|
||||
return [NSCursor crosshairCursor];
|
||||
case GLFW_HAND_CURSOR:
|
||||
return [NSCursor pointingHandCursor];
|
||||
case GLFW_HRESIZE_CURSOR:
|
||||
return [NSCursor resizeLeftRightCursor];
|
||||
case GLFW_VRESIZE_CURSOR:
|
||||
return [NSCursor resizeUpDownCursor];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Center the cursor in the view of the window
|
||||
//
|
||||
static void centerCursor(_GLFWwindow *window)
|
||||
@ -41,54 +66,40 @@ static void centerCursor(_GLFWwindow *window)
|
||||
|
||||
// Update the cursor to match the specified cursor mode
|
||||
//
|
||||
static void setModeCursor(_GLFWwindow* window, int mode)
|
||||
static void updateModeCursor(_GLFWwindow* window)
|
||||
{
|
||||
if (mode == GLFW_CURSOR_NORMAL)
|
||||
[[NSCursor arrowCursor] set];
|
||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
||||
{
|
||||
if (window->cursor)
|
||||
[(NSCursor*) window->cursor->ns.object set];
|
||||
else
|
||||
[[NSCursor arrowCursor] set];
|
||||
}
|
||||
else
|
||||
[(NSCursor*) _glfw.ns.cursor set];
|
||||
}
|
||||
|
||||
// Enter fullscreen mode
|
||||
// Enter full screen mode
|
||||
//
|
||||
static void enterFullscreenMode(_GLFWwindow* window)
|
||||
static GLboolean enterFullscreenMode(_GLFWwindow* window)
|
||||
{
|
||||
if ([window->ns.view isInFullScreenMode])
|
||||
return;
|
||||
GLboolean status;
|
||||
|
||||
_glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||
status = _glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||
|
||||
NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO],
|
||||
NSFullScreenModeAllScreens,
|
||||
nil];
|
||||
// NOTE: The window is resized despite mode setting failure to make
|
||||
// glfwSetWindowSize more robust
|
||||
[window->ns.object setFrame:[window->monitor->ns.screen frame]
|
||||
display:YES];
|
||||
|
||||
[window->ns.view enterFullScreenMode:window->monitor->ns.screen
|
||||
withOptions:options];
|
||||
|
||||
// HACK: Synthesize focus event as window does not become key when the view
|
||||
// is made full screen
|
||||
// TODO: Remove this when moving to a full screen window
|
||||
_glfwInputWindowFocus(window, GL_TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
// Leave fullscreen mode
|
||||
// Leave full screen mode
|
||||
//
|
||||
static void leaveFullscreenMode(_GLFWwindow* window)
|
||||
{
|
||||
if (![window->ns.view isInFullScreenMode])
|
||||
return;
|
||||
|
||||
// HACK: Synthesize focus event as window does not become key when the view
|
||||
// is made full screen
|
||||
// TODO: Remove this when moving to a full screen window
|
||||
_glfwInputWindowFocus(window, GL_FALSE);
|
||||
|
||||
_glfwRestoreVideoMode(window->monitor);
|
||||
|
||||
// Exit full screen after the video restore to avoid a nasty display
|
||||
// flickering during the fade
|
||||
[window->ns.view exitFullScreenModeWithOptions:nil];
|
||||
}
|
||||
|
||||
// Transforms the specified y-coordinate between the CG display and NS screen
|
||||
@ -122,7 +133,7 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
||||
_GLFWwindow* window;
|
||||
}
|
||||
|
||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWndow;
|
||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;
|
||||
|
||||
@end
|
||||
|
||||
@ -145,7 +156,11 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
||||
|
||||
- (void)windowDidResize:(NSNotification *)notification
|
||||
{
|
||||
[window->nsgl.context update];
|
||||
if (_glfw.focusedWindow == window &&
|
||||
window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
centerCursor(window);
|
||||
}
|
||||
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSRect fbRect = convertRectToBacking(window, contentRect);
|
||||
@ -153,21 +168,19 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
||||
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
||||
_glfwInputWindowDamage(window);
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
centerCursor(window);
|
||||
}
|
||||
|
||||
- (void)windowDidMove:(NSNotification *)notification
|
||||
{
|
||||
[window->nsgl.context update];
|
||||
if (_glfw.focusedWindow == window &&
|
||||
window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
centerCursor(window);
|
||||
}
|
||||
|
||||
int x, y;
|
||||
_glfwPlatformGetWindowPos(window, &x, &y);
|
||||
_glfwInputWindowPos(window, x, y);
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
centerCursor(window);
|
||||
}
|
||||
|
||||
- (void)windowDidMiniaturize:(NSNotification *)notification
|
||||
@ -177,22 +190,30 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
||||
|
||||
- (void)windowDidDeminiaturize:(NSNotification *)notification
|
||||
{
|
||||
if (window->monitor)
|
||||
enterFullscreenMode(window);
|
||||
|
||||
_glfwInputWindowIconify(window, GL_FALSE);
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||
{
|
||||
if (window->monitor)
|
||||
enterFullscreenMode(window);
|
||||
|
||||
if (_glfw.focusedWindow == window &&
|
||||
window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
centerCursor(window);
|
||||
}
|
||||
|
||||
_glfwInputWindowFocus(window, GL_TRUE);
|
||||
_glfwPlatformSetCursorMode(window, window->cursorMode);
|
||||
_glfwPlatformApplyCursorMode(window);
|
||||
}
|
||||
|
||||
- (void)windowDidResignKey:(NSNotification *)notification
|
||||
{
|
||||
if (window->monitor)
|
||||
leaveFullscreenMode(window);
|
||||
|
||||
_glfwInputWindowFocus(window, GL_FALSE);
|
||||
_glfwPlatformSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
||||
}
|
||||
|
||||
@end
|
||||
@ -217,30 +238,18 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
- (void)applicationDidHide:(NSNotification *)notification
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfw.windowListHead; window; window = window->next)
|
||||
_glfwInputWindowVisibility(window, GL_FALSE);
|
||||
}
|
||||
|
||||
- (void)applicationDidUnhide:(NSNotification *)notification
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfw.windowListHead; window; window = window->next)
|
||||
{
|
||||
if ([window->ns.object isVisible])
|
||||
_glfwInputWindowVisibility(window, GL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
||||
{
|
||||
_glfwInputMonitorChange();
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
[NSApp stop:nil];
|
||||
|
||||
_glfwPlatformPostEmptyEvent();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// Translates OS X key modifiers into GLFW ones
|
||||
@ -265,143 +274,10 @@ static int translateFlags(NSUInteger flags)
|
||||
//
|
||||
static int translateKey(unsigned int key)
|
||||
{
|
||||
// Keyboard symbol translation table
|
||||
static const unsigned int table[128] =
|
||||
{
|
||||
/* 00 */ GLFW_KEY_A,
|
||||
/* 01 */ GLFW_KEY_S,
|
||||
/* 02 */ GLFW_KEY_D,
|
||||
/* 03 */ GLFW_KEY_F,
|
||||
/* 04 */ GLFW_KEY_H,
|
||||
/* 05 */ GLFW_KEY_G,
|
||||
/* 06 */ GLFW_KEY_Z,
|
||||
/* 07 */ GLFW_KEY_X,
|
||||
/* 08 */ GLFW_KEY_C,
|
||||
/* 09 */ GLFW_KEY_V,
|
||||
/* 0a */ GLFW_KEY_WORLD_1,
|
||||
/* 0b */ GLFW_KEY_B,
|
||||
/* 0c */ GLFW_KEY_Q,
|
||||
/* 0d */ GLFW_KEY_W,
|
||||
/* 0e */ GLFW_KEY_E,
|
||||
/* 0f */ GLFW_KEY_R,
|
||||
/* 10 */ GLFW_KEY_Y,
|
||||
/* 11 */ GLFW_KEY_T,
|
||||
/* 12 */ GLFW_KEY_1,
|
||||
/* 13 */ GLFW_KEY_2,
|
||||
/* 14 */ GLFW_KEY_3,
|
||||
/* 15 */ GLFW_KEY_4,
|
||||
/* 16 */ GLFW_KEY_6,
|
||||
/* 17 */ GLFW_KEY_5,
|
||||
/* 18 */ GLFW_KEY_EQUAL,
|
||||
/* 19 */ GLFW_KEY_9,
|
||||
/* 1a */ GLFW_KEY_7,
|
||||
/* 1b */ GLFW_KEY_MINUS,
|
||||
/* 1c */ GLFW_KEY_8,
|
||||
/* 1d */ GLFW_KEY_0,
|
||||
/* 1e */ GLFW_KEY_RIGHT_BRACKET,
|
||||
/* 1f */ GLFW_KEY_O,
|
||||
/* 20 */ GLFW_KEY_U,
|
||||
/* 21 */ GLFW_KEY_LEFT_BRACKET,
|
||||
/* 22 */ GLFW_KEY_I,
|
||||
/* 23 */ GLFW_KEY_P,
|
||||
/* 24 */ GLFW_KEY_ENTER,
|
||||
/* 25 */ GLFW_KEY_L,
|
||||
/* 26 */ GLFW_KEY_J,
|
||||
/* 27 */ GLFW_KEY_APOSTROPHE,
|
||||
/* 28 */ GLFW_KEY_K,
|
||||
/* 29 */ GLFW_KEY_SEMICOLON,
|
||||
/* 2a */ GLFW_KEY_BACKSLASH,
|
||||
/* 2b */ GLFW_KEY_COMMA,
|
||||
/* 2c */ GLFW_KEY_SLASH,
|
||||
/* 2d */ GLFW_KEY_N,
|
||||
/* 2e */ GLFW_KEY_M,
|
||||
/* 2f */ GLFW_KEY_PERIOD,
|
||||
/* 30 */ GLFW_KEY_TAB,
|
||||
/* 31 */ GLFW_KEY_SPACE,
|
||||
/* 32 */ GLFW_KEY_GRAVE_ACCENT,
|
||||
/* 33 */ GLFW_KEY_BACKSPACE,
|
||||
/* 34 */ GLFW_KEY_UNKNOWN,
|
||||
/* 35 */ GLFW_KEY_ESCAPE,
|
||||
/* 36 */ GLFW_KEY_RIGHT_SUPER,
|
||||
/* 37 */ GLFW_KEY_LEFT_SUPER,
|
||||
/* 38 */ GLFW_KEY_LEFT_SHIFT,
|
||||
/* 39 */ GLFW_KEY_CAPS_LOCK,
|
||||
/* 3a */ GLFW_KEY_LEFT_ALT,
|
||||
/* 3b */ GLFW_KEY_LEFT_CONTROL,
|
||||
/* 3c */ GLFW_KEY_RIGHT_SHIFT,
|
||||
/* 3d */ GLFW_KEY_RIGHT_ALT,
|
||||
/* 3e */ GLFW_KEY_RIGHT_CONTROL,
|
||||
/* 3f */ GLFW_KEY_UNKNOWN, /* Function */
|
||||
/* 40 */ GLFW_KEY_F17,
|
||||
/* 41 */ GLFW_KEY_KP_DECIMAL,
|
||||
/* 42 */ GLFW_KEY_UNKNOWN,
|
||||
/* 43 */ GLFW_KEY_KP_MULTIPLY,
|
||||
/* 44 */ GLFW_KEY_UNKNOWN,
|
||||
/* 45 */ GLFW_KEY_KP_ADD,
|
||||
/* 46 */ GLFW_KEY_UNKNOWN,
|
||||
/* 47 */ GLFW_KEY_NUM_LOCK, /* Really KeypadClear... */
|
||||
/* 48 */ GLFW_KEY_UNKNOWN, /* VolumeUp */
|
||||
/* 49 */ GLFW_KEY_UNKNOWN, /* VolumeDown */
|
||||
/* 4a */ GLFW_KEY_UNKNOWN, /* Mute */
|
||||
/* 4b */ GLFW_KEY_KP_DIVIDE,
|
||||
/* 4c */ GLFW_KEY_KP_ENTER,
|
||||
/* 4d */ GLFW_KEY_UNKNOWN,
|
||||
/* 4e */ GLFW_KEY_KP_SUBTRACT,
|
||||
/* 4f */ GLFW_KEY_F18,
|
||||
/* 50 */ GLFW_KEY_F19,
|
||||
/* 51 */ GLFW_KEY_KP_EQUAL,
|
||||
/* 52 */ GLFW_KEY_KP_0,
|
||||
/* 53 */ GLFW_KEY_KP_1,
|
||||
/* 54 */ GLFW_KEY_KP_2,
|
||||
/* 55 */ GLFW_KEY_KP_3,
|
||||
/* 56 */ GLFW_KEY_KP_4,
|
||||
/* 57 */ GLFW_KEY_KP_5,
|
||||
/* 58 */ GLFW_KEY_KP_6,
|
||||
/* 59 */ GLFW_KEY_KP_7,
|
||||
/* 5a */ GLFW_KEY_F20,
|
||||
/* 5b */ GLFW_KEY_KP_8,
|
||||
/* 5c */ GLFW_KEY_KP_9,
|
||||
/* 5d */ GLFW_KEY_UNKNOWN,
|
||||
/* 5e */ GLFW_KEY_UNKNOWN,
|
||||
/* 5f */ GLFW_KEY_UNKNOWN,
|
||||
/* 60 */ GLFW_KEY_F5,
|
||||
/* 61 */ GLFW_KEY_F6,
|
||||
/* 62 */ GLFW_KEY_F7,
|
||||
/* 63 */ GLFW_KEY_F3,
|
||||
/* 64 */ GLFW_KEY_F8,
|
||||
/* 65 */ GLFW_KEY_F9,
|
||||
/* 66 */ GLFW_KEY_UNKNOWN,
|
||||
/* 67 */ GLFW_KEY_F11,
|
||||
/* 68 */ GLFW_KEY_UNKNOWN,
|
||||
/* 69 */ GLFW_KEY_F13,
|
||||
/* 6a */ GLFW_KEY_F16,
|
||||
/* 6b */ GLFW_KEY_F14,
|
||||
/* 6c */ GLFW_KEY_UNKNOWN,
|
||||
/* 6d */ GLFW_KEY_F10,
|
||||
/* 6e */ GLFW_KEY_UNKNOWN,
|
||||
/* 6f */ GLFW_KEY_F12,
|
||||
/* 70 */ GLFW_KEY_UNKNOWN,
|
||||
/* 71 */ GLFW_KEY_F15,
|
||||
/* 72 */ GLFW_KEY_INSERT, /* Really Help... */
|
||||
/* 73 */ GLFW_KEY_HOME,
|
||||
/* 74 */ GLFW_KEY_PAGE_UP,
|
||||
/* 75 */ GLFW_KEY_DELETE,
|
||||
/* 76 */ GLFW_KEY_F4,
|
||||
/* 77 */ GLFW_KEY_END,
|
||||
/* 78 */ GLFW_KEY_F2,
|
||||
/* 79 */ GLFW_KEY_PAGE_DOWN,
|
||||
/* 7a */ GLFW_KEY_F1,
|
||||
/* 7b */ GLFW_KEY_LEFT,
|
||||
/* 7c */ GLFW_KEY_RIGHT,
|
||||
/* 7d */ GLFW_KEY_DOWN,
|
||||
/* 7e */ GLFW_KEY_UP,
|
||||
/* 7f */ GLFW_KEY_UNKNOWN,
|
||||
};
|
||||
|
||||
if (key >= 128)
|
||||
if (key >= sizeof(_glfw.ns.publicKeys) / sizeof(_glfw.ns.publicKeys[0]))
|
||||
return GLFW_KEY_UNKNOWN;
|
||||
|
||||
return table[key];
|
||||
return _glfw.ns.publicKeys[key];
|
||||
}
|
||||
|
||||
|
||||
@ -409,7 +285,7 @@ static int translateKey(unsigned int key)
|
||||
// Content view class for the GLFW window
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
@interface GLFWContentView : NSView
|
||||
@interface GLFWContentView : NSOpenGLView
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
NSTrackingArea* trackingArea;
|
||||
@ -427,7 +303,7 @@ static int translateKey(unsigned int key)
|
||||
{
|
||||
if (_glfw.ns.cursor == nil)
|
||||
{
|
||||
NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
|
||||
NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(16, 16)];
|
||||
_glfw.ns.cursor = [[NSCursor alloc] initWithImage:data
|
||||
hotSpot:NSZeroPoint];
|
||||
[data release];
|
||||
@ -437,13 +313,16 @@ static int translateKey(unsigned int key)
|
||||
|
||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow
|
||||
{
|
||||
self = [super init];
|
||||
self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)
|
||||
pixelFormat:nil];
|
||||
if (self != nil)
|
||||
{
|
||||
window = initWindow;
|
||||
trackingArea = nil;
|
||||
|
||||
[self updateTrackingAreas];
|
||||
[self registerForDraggedTypes:[NSArray arrayWithObjects:
|
||||
NSFilenamesPboardType, nil]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@ -472,7 +351,7 @@ static int translateKey(unsigned int key)
|
||||
|
||||
- (void)cursorUpdate:(NSEvent *)event
|
||||
{
|
||||
setModeCursor(window, window->cursorMode);
|
||||
updateModeCursor(window);
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent *)event
|
||||
@ -499,14 +378,21 @@ static int translateKey(unsigned int key)
|
||||
- (void)mouseMoved:(NSEvent *)event
|
||||
{
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
_glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
|
||||
{
|
||||
_glfwInputCursorMotion(window,
|
||||
[event deltaX] - window->ns.warpDeltaX,
|
||||
[event deltaY] - window->ns.warpDeltaY);
|
||||
}
|
||||
else
|
||||
{
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSPoint p = [event locationInWindow];
|
||||
const NSPoint pos = [event locationInWindow];
|
||||
|
||||
_glfwInputCursorMotion(window, p.x, contentRect.size.height - p.y);
|
||||
_glfwInputCursorMotion(window, pos.x, contentRect.size.height - pos.y);
|
||||
}
|
||||
|
||||
window->ns.warpDeltaX = 0;
|
||||
window->ns.warpDeltaY = 0;
|
||||
}
|
||||
|
||||
- (void)rightMouseDown:(NSEvent *)event
|
||||
@ -567,6 +453,7 @@ static int translateKey(unsigned int key)
|
||||
const NSRect fbRect = convertRectToBacking(window, contentRect);
|
||||
|
||||
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||
_glfwInputWindowDamage(window);
|
||||
}
|
||||
|
||||
- (void)updateTrackingAreas
|
||||
@ -577,10 +464,12 @@ static int translateKey(unsigned int key)
|
||||
[trackingArea release];
|
||||
}
|
||||
|
||||
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
|
||||
NSTrackingActiveInKeyWindow |
|
||||
NSTrackingCursorUpdate |
|
||||
NSTrackingInVisibleRect;
|
||||
const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
|
||||
NSTrackingActiveInKeyWindow |
|
||||
NSTrackingEnabledDuringMouseDrag |
|
||||
NSTrackingCursorUpdate |
|
||||
NSTrackingInVisibleRect |
|
||||
NSTrackingAssumeInside;
|
||||
|
||||
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
||||
options:options
|
||||
@ -595,30 +484,45 @@ static int translateKey(unsigned int key)
|
||||
{
|
||||
const int key = translateKey([event keyCode]);
|
||||
const int mods = translateFlags([event modifierFlags]);
|
||||
|
||||
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
||||
|
||||
NSString* characters = [event characters];
|
||||
NSUInteger i, length = [characters length];
|
||||
const int plain = !(mods & GLFW_MOD_SUPER);
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
_glfwInputChar(window, [characters characterAtIndex:i]);
|
||||
{
|
||||
const unichar codepoint = [characters characterAtIndex:i];
|
||||
if ((codepoint & 0xff00) == 0xf700)
|
||||
continue;
|
||||
|
||||
_glfwInputChar(window, codepoint, mods, plain);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)event
|
||||
{
|
||||
int action;
|
||||
unsigned int newModifierFlags =
|
||||
const unsigned int modifierFlags =
|
||||
[event modifierFlags] & NSDeviceIndependentModifierFlagsMask;
|
||||
const int key = translateKey([event keyCode]);
|
||||
const int mods = translateFlags(modifierFlags);
|
||||
|
||||
if (newModifierFlags > window->ns.modifierFlags)
|
||||
if (modifierFlags == window->ns.modifierFlags)
|
||||
{
|
||||
if (window->keys[key] == GLFW_PRESS)
|
||||
action = GLFW_RELEASE;
|
||||
else
|
||||
action = GLFW_PRESS;
|
||||
}
|
||||
else if (modifierFlags > window->ns.modifierFlags)
|
||||
action = GLFW_PRESS;
|
||||
else
|
||||
action = GLFW_RELEASE;
|
||||
|
||||
window->ns.modifierFlags = newModifierFlags;
|
||||
window->ns.modifierFlags = modifierFlags;
|
||||
|
||||
const int key = translateKey([event keyCode]);
|
||||
const int mods = translateFlags([event modifierFlags]);
|
||||
_glfwInputKey(window, key, [event keyCode], action, mods);
|
||||
}
|
||||
|
||||
@ -656,6 +560,59 @@ static int translateKey(unsigned int key)
|
||||
_glfwInputScroll(window, deltaX, deltaY);
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask])
|
||||
== NSDragOperationGeneric)
|
||||
{
|
||||
[self setNeedsDisplay:YES];
|
||||
return NSDragOperationGeneric;
|
||||
}
|
||||
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
[self setNeedsDisplay:YES];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard* pasteboard = [sender draggingPasteboard];
|
||||
NSArray* files = [pasteboard propertyListForType:NSFilenamesPboardType];
|
||||
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
_glfwInputCursorMotion(window,
|
||||
[sender draggingLocation].x,
|
||||
contentRect.size.height - [sender draggingLocation].y);
|
||||
|
||||
const int count = [files count];
|
||||
if (count)
|
||||
{
|
||||
NSEnumerator* e = [files objectEnumerator];
|
||||
char** names = calloc(count, sizeof(char*));
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
names[i] = strdup([[e nextObject] UTF8String]);
|
||||
|
||||
_glfwInputDrop(window, count, (const char**) names);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
free(names[i]);
|
||||
free(names);
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -739,7 +696,7 @@ static NSString* findAppName(void)
|
||||
// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
|
||||
// could go away at any moment, lots of stuff that really should be
|
||||
// localize(d|able), etc. Loading a nib would save us this horror, but that
|
||||
// doesn't seem like a good thing to require of GLFW's clients.
|
||||
// doesn't seem like a good thing to require of GLFW users.
|
||||
//
|
||||
static void createMenuBar(void)
|
||||
{
|
||||
@ -836,7 +793,18 @@ static GLboolean initializeAppKit(void)
|
||||
createMenuBar();
|
||||
#endif
|
||||
|
||||
[NSApp finishLaunching];
|
||||
// There can only be one application delegate, but we allocate it the
|
||||
// first time a window is created to keep all window code in this file
|
||||
_glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
|
||||
if (_glfw.ns.delegate == nil)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to create application delegate");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
[NSApp setDelegate:_glfw.ns.delegate];
|
||||
[NSApp run];
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@ -846,6 +814,14 @@ static GLboolean initializeAppKit(void)
|
||||
static GLboolean createWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig)
|
||||
{
|
||||
window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
|
||||
if (window->ns.delegate == nil)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to create window delegate");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
unsigned int styleMask = 0;
|
||||
|
||||
if (wndconfig->monitor || !wndconfig->decorated)
|
||||
@ -859,8 +835,15 @@ static GLboolean createWindow(_GLFWwindow* window,
|
||||
styleMask |= NSResizableWindowMask;
|
||||
}
|
||||
|
||||
NSRect contentRect;
|
||||
|
||||
if (wndconfig->monitor)
|
||||
contentRect = [wndconfig->monitor->ns.screen frame];
|
||||
else
|
||||
contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
|
||||
|
||||
window->ns.object = [[GLFWWindow alloc]
|
||||
initWithContentRect:NSMakeRect(0, 0, wndconfig->width, wndconfig->height)
|
||||
initWithContentRect:contentRect
|
||||
styleMask:styleMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
@ -871,23 +854,30 @@ static GLboolean createWindow(_GLFWwindow* window,
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||
{
|
||||
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
||||
|
||||
if (wndconfig->resizable)
|
||||
[window->ns.object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
}
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
|
||||
if (wndconfig->monitor)
|
||||
{
|
||||
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
|
||||
[window->ns.object setHidesOnDeactivate:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[window->ns.object center];
|
||||
|
||||
if (wndconfig->floating)
|
||||
[window->ns.object setLevel:NSFloatingWindowLevel];
|
||||
}
|
||||
|
||||
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
||||
[window->ns.object setContentView:window->ns.view];
|
||||
[window->ns.object setDelegate:window->ns.delegate];
|
||||
[window->ns.object setAcceptsMouseMovedEvents:YES];
|
||||
[window->ns.object center];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||
@ -904,47 +894,42 @@ static GLboolean createWindow(_GLFWwindow* window,
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
if (!initializeAppKit())
|
||||
return GL_FALSE;
|
||||
|
||||
// There can only be one application delegate, but we allocate it the
|
||||
// first time a window is created to keep all window code in this file
|
||||
if (_glfw.ns.delegate == nil)
|
||||
{
|
||||
_glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
|
||||
if (_glfw.ns.delegate == nil)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to create application delegate");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
[NSApp setDelegate:_glfw.ns.delegate];
|
||||
}
|
||||
|
||||
window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
|
||||
if (window->ns.delegate == nil)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to create window delegate");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Don't use accumulation buffer support; it's not accelerated
|
||||
// Aux buffers probably aren't accelerated either
|
||||
|
||||
if (!createWindow(window, wndconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
if (!_glfwCreateContext(window, wndconfig, fbconfig))
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||
|
||||
#if defined(_GLFW_USE_RETINA)
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
#endif /*_GLFW_USE_RETINA*/
|
||||
|
||||
[window->ns.object setContentView:window->ns.view];
|
||||
// NOTE: If you set the pixel format before the context it creates another
|
||||
// context, only to have it destroyed by the next line
|
||||
// We cannot use the view to create the context because that interface
|
||||
// does not support context resource sharing
|
||||
[window->ns.view setOpenGLContext:window->nsgl.context];
|
||||
[window->ns.view setPixelFormat:window->nsgl.pixelFormat];
|
||||
[window->nsgl.context setView:window->ns.view];
|
||||
|
||||
if (wndconfig->monitor)
|
||||
enterFullscreenMode(window);
|
||||
{
|
||||
_glfwPlatformShowWindow(window);
|
||||
if (!enterFullscreenMode(window))
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@ -1019,11 +1004,27 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh
|
||||
*height = (int) fbRect.size.height;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
{
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect];
|
||||
|
||||
if (left)
|
||||
*left = contentRect.origin.x - frameRect.origin.x;
|
||||
if (top)
|
||||
*top = frameRect.origin.y + frameRect.size.height -
|
||||
contentRect.origin.y - contentRect.size.height;
|
||||
if (right)
|
||||
*right = frameRect.origin.x + frameRect.size.width -
|
||||
contentRect.origin.x - contentRect.size.width;
|
||||
if (bottom)
|
||||
*bottom = contentRect.origin.y - frameRect.origin.y;
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
{
|
||||
if (window->monitor)
|
||||
leaveFullscreenMode(window);
|
||||
|
||||
[window->ns.object miniaturize:nil];
|
||||
}
|
||||
|
||||
@ -1041,13 +1042,31 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
|
||||
[window->ns.object makeKeyAndOrderFront:nil];
|
||||
_glfwInputWindowVisibility(window, GL_TRUE);
|
||||
}
|
||||
|
||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
|
||||
{
|
||||
[window->ns.object orderFront:nil];
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
{
|
||||
[window->ns.object orderOut:nil];
|
||||
_glfwInputWindowVisibility(window, GL_FALSE);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
{
|
||||
return [window->ns.object isKeyWindow];
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||
{
|
||||
return [window->ns.object isMiniaturized];
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
{
|
||||
return [window->ns.object isVisible];
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
@ -1082,9 +1101,42 @@ void _glfwPlatformWaitEvents(void)
|
||||
_glfwPlatformPollEvents();
|
||||
}
|
||||
|
||||
void _glfwPlatformPostEmptyEvent(void)
|
||||
{
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined
|
||||
location:NSMakePoint(0, 0)
|
||||
modifierFlags:0
|
||||
timestamp:0
|
||||
windowNumber:0
|
||||
context:nil
|
||||
subtype:0
|
||||
data1:0
|
||||
data2:0];
|
||||
[NSApp postEvent:event atStart:YES];
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
{
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
|
||||
|
||||
if (xpos)
|
||||
*xpos = pos.x;
|
||||
if (ypos)
|
||||
*ypos = contentRect.size.height - pos.y - 1;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
{
|
||||
setModeCursor(window, window->cursorMode);
|
||||
updateModeCursor(window);
|
||||
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
|
||||
|
||||
window->ns.warpDeltaX += x - pos.x;
|
||||
window->ns.warpDeltaY += y - contentRect.size.height + pos.y;
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
@ -1093,7 +1145,6 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
}
|
||||
else
|
||||
{
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSPoint localPoint = NSMakePoint(x, contentRect.size.height - y - 1);
|
||||
const NSPoint globalPoint = [window->ns.object convertBaseToScreen:localPoint];
|
||||
|
||||
@ -1102,19 +1153,123 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
|
||||
{
|
||||
setModeCursor(window, mode);
|
||||
updateModeCursor(window);
|
||||
|
||||
if (mode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
centerCursor(window);
|
||||
}
|
||||
else
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
{
|
||||
NSImage* native;
|
||||
NSBitmapImageRep* rep;
|
||||
|
||||
rep = [[NSBitmapImageRep alloc]
|
||||
initWithBitmapDataPlanes:NULL
|
||||
pixelsWide:image->width
|
||||
pixelsHigh:image->height
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
hasAlpha:YES
|
||||
isPlanar:NO
|
||||
colorSpaceName:NSCalibratedRGBColorSpace
|
||||
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
|
||||
bytesPerRow:image->width * 4
|
||||
bitsPerPixel:32];
|
||||
|
||||
if (rep == nil)
|
||||
return GL_FALSE;
|
||||
|
||||
memcpy([rep bitmapData], image->pixels, image->width * image->height * 4);
|
||||
|
||||
native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];
|
||||
[native addRepresentation: rep];
|
||||
|
||||
cursor->ns.object = [[NSCursor alloc] initWithImage:native
|
||||
hotSpot:NSMakePoint(xhot, yhot)];
|
||||
|
||||
[native release];
|
||||
[rep release];
|
||||
|
||||
if (cursor->ns.object == nil)
|
||||
return GL_FALSE;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
cursor->ns.object = getStandardCursor(shape);
|
||||
if (!cursor->ns.object)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Cocoa: Invalid standard cursor");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
[cursor->ns.object retain];
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
{
|
||||
if (cursor->ns.object)
|
||||
[(NSCursor*) cursor->ns.object release];
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
{
|
||||
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_NORMAL &&
|
||||
[window->ns.view mouse:pos inRect:[window->ns.view frame]])
|
||||
{
|
||||
if (cursor)
|
||||
[(NSCursor*) cursor->ns.object set];
|
||||
else
|
||||
[[NSCursor arrowCursor] set];
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
||||
{
|
||||
NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil];
|
||||
|
||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||
[pasteboard declareTypes:types owner:nil];
|
||||
[pasteboard setString:[NSString stringWithUTF8String:string]
|
||||
forType:NSStringPboardType];
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||
{
|
||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||
|
||||
if (![[pasteboard types] containsObject:NSStringPboardType])
|
||||
{
|
||||
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSString* object = [pasteboard stringForType:NSStringPboardType];
|
||||
if (!object)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to retrieve object from pasteboard");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
free(_glfw.ns.clipboardString);
|
||||
_glfw.ns.clipboardString = strdup([object UTF8String]);
|
||||
|
||||
return _glfw.ns.clipboardString;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW native API //////
|
||||
|
215
extern/glfw/src/context.c
vendored
215
extern/glfw/src/context.c
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -87,21 +84,21 @@ static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
|
||||
{
|
||||
if (wndconfig->clientAPI != GLFW_OPENGL_API &&
|
||||
wndconfig->clientAPI != GLFW_OPENGL_ES_API)
|
||||
if (ctxconfig->api != GLFW_OPENGL_API &&
|
||||
ctxconfig->api != GLFW_OPENGL_ES_API)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid client API requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
if (ctxconfig->api == GLFW_OPENGL_API)
|
||||
{
|
||||
if ((wndconfig->glMajor < 1 || wndconfig->glMinor < 0) ||
|
||||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 5) ||
|
||||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 1) ||
|
||||
(wndconfig->glMajor == 3 && wndconfig->glMinor > 3))
|
||||
if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
|
||||
(ctxconfig->major == 1 && ctxconfig->minor > 5) ||
|
||||
(ctxconfig->major == 2 && ctxconfig->minor > 1) ||
|
||||
(ctxconfig->major == 3 && ctxconfig->minor > 3))
|
||||
{
|
||||
// OpenGL 1.0 is the smallest valid version
|
||||
// OpenGL 1.x series ended with version 1.5
|
||||
@ -110,7 +107,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Invalid OpenGL version %i.%i requested",
|
||||
wndconfig->glMajor, wndconfig->glMinor);
|
||||
ctxconfig->major, ctxconfig->minor);
|
||||
return GL_FALSE;
|
||||
}
|
||||
else
|
||||
@ -118,18 +115,18 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
// For now, let everything else through
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
if (ctxconfig->profile)
|
||||
{
|
||||
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE &&
|
||||
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
|
||||
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
|
||||
ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM,
|
||||
"Invalid OpenGL profile requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->glMajor < 3 ||
|
||||
(wndconfig->glMajor == 3 && wndconfig->glMinor < 2))
|
||||
if (ctxconfig->major < 3 ||
|
||||
(ctxconfig->major == 3 && ctxconfig->minor < 2))
|
||||
{
|
||||
// Desktop OpenGL context profiles are only defined for version 3.2
|
||||
// and above
|
||||
@ -141,7 +138,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->glForward && wndconfig->glMajor < 3)
|
||||
if (ctxconfig->forward && ctxconfig->major < 3)
|
||||
{
|
||||
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
@ -150,11 +147,11 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
else if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
else if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0 ||
|
||||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 1) ||
|
||||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 0))
|
||||
if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
|
||||
(ctxconfig->major == 1 && ctxconfig->minor > 1) ||
|
||||
(ctxconfig->major == 2 && ctxconfig->minor > 0))
|
||||
{
|
||||
// OpenGL ES 1.0 is the smallest valid version
|
||||
// OpenGL ES 1.x series ended with version 1.1
|
||||
@ -162,7 +159,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Invalid OpenGL ES version %i.%i requested",
|
||||
wndconfig->glMajor, wndconfig->glMinor);
|
||||
ctxconfig->major, ctxconfig->minor);
|
||||
return GL_FALSE;
|
||||
}
|
||||
else
|
||||
@ -170,7 +167,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
// For now, let everything else through
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
if (ctxconfig->profile)
|
||||
{
|
||||
// OpenGL ES does not support profiles
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
@ -178,7 +175,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->glForward)
|
||||
if (ctxconfig->forward)
|
||||
{
|
||||
// OpenGL ES does not support forward-compatibility
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
@ -187,10 +184,10 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->glRobustness)
|
||||
if (ctxconfig->robustness)
|
||||
{
|
||||
if (wndconfig->glRobustness != GLFW_NO_RESET_NOTIFICATION &&
|
||||
wndconfig->glRobustness != GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
|
||||
ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Invalid context robustness mode requested");
|
||||
@ -198,6 +195,17 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
}
|
||||
}
|
||||
|
||||
if (ctxconfig->release)
|
||||
{
|
||||
if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
|
||||
ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Invalid context release behavior requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@ -222,6 +230,12 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (desired->doublebuffer != current->doublebuffer)
|
||||
{
|
||||
// Double buffering is a hard constraint
|
||||
continue;
|
||||
}
|
||||
|
||||
// Count number of missing buffers
|
||||
{
|
||||
missing = 0;
|
||||
@ -235,8 +249,11 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
if (desired->stencilBits > 0 && current->stencilBits == 0)
|
||||
missing++;
|
||||
|
||||
if (desired->auxBuffers > 0 && current->auxBuffers < desired->auxBuffers)
|
||||
if (desired->auxBuffers > 0 &&
|
||||
current->auxBuffers < desired->auxBuffers)
|
||||
{
|
||||
missing += desired->auxBuffers - current->auxBuffers;
|
||||
}
|
||||
|
||||
if (desired->samples > 0 && current->samples == 0)
|
||||
{
|
||||
@ -254,19 +271,19 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
{
|
||||
colorDiff = 0;
|
||||
|
||||
if (desired->redBits > 0)
|
||||
if (desired->redBits != GLFW_DONT_CARE)
|
||||
{
|
||||
colorDiff += (desired->redBits - current->redBits) *
|
||||
(desired->redBits - current->redBits);
|
||||
}
|
||||
|
||||
if (desired->greenBits > 0)
|
||||
if (desired->greenBits != GLFW_DONT_CARE)
|
||||
{
|
||||
colorDiff += (desired->greenBits - current->greenBits) *
|
||||
(desired->greenBits - current->greenBits);
|
||||
}
|
||||
|
||||
if (desired->blueBits > 0)
|
||||
if (desired->blueBits != GLFW_DONT_CARE)
|
||||
{
|
||||
colorDiff += (desired->blueBits - current->blueBits) *
|
||||
(desired->blueBits - current->blueBits);
|
||||
@ -277,59 +294,56 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
{
|
||||
extraDiff = 0;
|
||||
|
||||
if (desired->alphaBits > 0)
|
||||
if (desired->alphaBits != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->alphaBits - current->alphaBits) *
|
||||
(desired->alphaBits - current->alphaBits);
|
||||
}
|
||||
|
||||
if (desired->depthBits > 0)
|
||||
if (desired->depthBits != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->depthBits - current->depthBits) *
|
||||
(desired->depthBits - current->depthBits);
|
||||
}
|
||||
|
||||
if (desired->stencilBits > 0)
|
||||
if (desired->stencilBits != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->stencilBits - current->stencilBits) *
|
||||
(desired->stencilBits - current->stencilBits);
|
||||
}
|
||||
|
||||
if (desired->accumRedBits > 0)
|
||||
if (desired->accumRedBits != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->accumRedBits - current->accumRedBits) *
|
||||
(desired->accumRedBits - current->accumRedBits);
|
||||
}
|
||||
|
||||
if (desired->accumGreenBits > 0)
|
||||
if (desired->accumGreenBits != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
|
||||
(desired->accumGreenBits - current->accumGreenBits);
|
||||
}
|
||||
|
||||
if (desired->accumBlueBits > 0)
|
||||
if (desired->accumBlueBits != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
|
||||
(desired->accumBlueBits - current->accumBlueBits);
|
||||
}
|
||||
|
||||
if (desired->accumAlphaBits > 0)
|
||||
if (desired->accumAlphaBits != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
|
||||
(desired->accumAlphaBits - current->accumAlphaBits);
|
||||
}
|
||||
|
||||
if (desired->samples > 0)
|
||||
if (desired->samples != GLFW_DONT_CARE)
|
||||
{
|
||||
extraDiff += (desired->samples - current->samples) *
|
||||
(desired->samples - current->samples);
|
||||
}
|
||||
|
||||
if (desired->sRGB)
|
||||
{
|
||||
if (!current->sRGB)
|
||||
extraDiff++;
|
||||
}
|
||||
if (desired->sRGB && !current->sRGB)
|
||||
extraDiff++;
|
||||
}
|
||||
|
||||
// Figure out if the current one is better than the best one found so far
|
||||
@ -358,20 +372,20 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
return closest;
|
||||
}
|
||||
|
||||
GLboolean _glfwRefreshContextAttribs(void)
|
||||
GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
||||
{
|
||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
||||
|
||||
if (!parseGLVersion(&window->clientAPI,
|
||||
&window->glMajor,
|
||||
&window->glMinor,
|
||||
&window->glRevision))
|
||||
if (!parseVersionString(&window->context.api,
|
||||
&window->context.major,
|
||||
&window->context.minor,
|
||||
&window->context.revision))
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
#if defined(_GLFW_USE_OPENGL)
|
||||
if (window->glMajor > 2)
|
||||
if (window->context.major > 2)
|
||||
{
|
||||
// OpenGL 3.0+ uses a different function for extension string retrieval
|
||||
// We cache it here instead of in glfwExtensionSupported mostly to alert
|
||||
@ -386,46 +400,47 @@ GLboolean _glfwRefreshContextAttribs(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (window->clientAPI == GLFW_OPENGL_API)
|
||||
if (window->context.api == GLFW_OPENGL_API)
|
||||
{
|
||||
// Read back context flags (OpenGL 3.0 and above)
|
||||
if (window->glMajor >= 3)
|
||||
if (window->context.major >= 3)
|
||||
{
|
||||
GLint flags;
|
||||
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||
|
||||
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
||||
window->glForward = GL_TRUE;
|
||||
window->context.forward = GL_TRUE;
|
||||
|
||||
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||
window->glDebug = GL_TRUE;
|
||||
else if (glfwExtensionSupported("GL_ARB_debug_output"))
|
||||
window->context.debug = GL_TRUE;
|
||||
else if (glfwExtensionSupported("GL_ARB_debug_output") &&
|
||||
ctxconfig->debug)
|
||||
{
|
||||
// HACK: This is a workaround for older drivers (pre KHR_debug)
|
||||
// not setting the debug bit in the context flags for
|
||||
// debug contexts
|
||||
window->glDebug = GL_TRUE;
|
||||
window->context.debug = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Read back OpenGL context profile (OpenGL 3.2 and above)
|
||||
if (window->glMajor > 3 ||
|
||||
(window->glMajor == 3 && window->glMinor >= 2))
|
||||
if (window->context.major > 3 ||
|
||||
(window->context.major == 3 && window->context.minor >= 2))
|
||||
{
|
||||
GLint mask;
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||
|
||||
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
||||
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||
window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||
else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
|
||||
window->glProfile = GLFW_OPENGL_CORE_PROFILE;
|
||||
window->context.profile = GLFW_OPENGL_CORE_PROFILE;
|
||||
else if (glfwExtensionSupported("GL_ARB_compatibility"))
|
||||
{
|
||||
// HACK: This is a workaround for the compatibility profile bit
|
||||
// not being set in the context flags if an OpenGL 3.2+
|
||||
// context was created without having requested a specific
|
||||
// version
|
||||
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||
window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,9 +454,9 @@ GLboolean _glfwRefreshContextAttribs(void)
|
||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
|
||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
||||
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
|
||||
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -456,23 +471,34 @@ GLboolean _glfwRefreshContextAttribs(void)
|
||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
|
||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
||||
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
|
||||
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
|
||||
}
|
||||
}
|
||||
|
||||
if (glfwExtensionSupported("GL_KHR_context_flush_control"))
|
||||
{
|
||||
GLint behavior;
|
||||
glGetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
|
||||
|
||||
if (behavior == GL_NONE)
|
||||
window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
|
||||
else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
|
||||
window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;
|
||||
}
|
||||
#endif // _GLFW_USE_OPENGL
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
|
||||
GLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig)
|
||||
{
|
||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
||||
|
||||
if (window->glMajor < wndconfig->glMajor ||
|
||||
(window->glMajor == wndconfig->glMajor &&
|
||||
window->glMinor < wndconfig->glMinor))
|
||||
if (window->context.major < ctxconfig->major ||
|
||||
(window->context.major == ctxconfig->major &&
|
||||
window->context.minor < ctxconfig->minor))
|
||||
{
|
||||
// The desired OpenGL version is greater than the actual version
|
||||
// This only happens if the machine lacks {GLX|WGL}_ARB_create_context
|
||||
@ -562,7 +588,6 @@ GLFWAPI void glfwSwapInterval(int interval)
|
||||
|
||||
GLFWAPI int glfwExtensionSupported(const char* extension)
|
||||
{
|
||||
const GLubyte* extensions;
|
||||
_GLFWwindow* window;
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GL_FALSE);
|
||||
@ -574,29 +599,14 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!extension || *extension == '\0')
|
||||
if (*extension == '\0')
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, NULL);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (window->glMajor < 3)
|
||||
{
|
||||
// Check if extension is in the old style OpenGL extensions string
|
||||
|
||||
extensions = glGetString(GL_EXTENSIONS);
|
||||
if (!extensions)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Failed to retrieve extension string");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (_glfwStringInExtensionString(extension, extensions))
|
||||
return GL_TRUE;
|
||||
}
|
||||
#if defined(_GLFW_USE_OPENGL)
|
||||
else
|
||||
if (window->context.major >= 3)
|
||||
{
|
||||
int i;
|
||||
GLint count;
|
||||
@ -619,7 +629,22 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif // _GLFW_USE_OPENGL
|
||||
{
|
||||
// Check if extension is in the old style OpenGL extensions string
|
||||
|
||||
const GLubyte* extensions = glGetString(GL_EXTENSIONS);
|
||||
if (!extensions)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Failed to retrieve extension string");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (_glfwStringInExtensionString(extension, extensions))
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
// Check if extension is in the platform-specific string
|
||||
return _glfwPlatformExtensionSupported(extension);
|
||||
|
93
extern/glfw/src/egl_context.c
vendored
93
extern/glfw/src/egl_context.c
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 EGL - www.glfw.org
|
||||
// GLFW 3.1 EGL - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -32,22 +32,6 @@
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
// Thread local storage attribute macro
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#define _GLFW_TLS __declspec(thread)
|
||||
#elif defined(__GNUC__)
|
||||
#define _GLFW_TLS __thread
|
||||
#else
|
||||
#define _GLFW_TLS
|
||||
#endif
|
||||
|
||||
|
||||
// The per-thread current context/window pointer
|
||||
//
|
||||
static _GLFW_TLS _GLFWwindow* _glfwCurrentWindow = NULL;
|
||||
|
||||
|
||||
// Return a description of the specified EGL error
|
||||
//
|
||||
static const char* getErrorString(EGLint error)
|
||||
@ -108,7 +92,7 @@ static int getConfigAttrib(EGLConfig config, int attrib)
|
||||
|
||||
// Return a list of available and usable framebuffer configs
|
||||
//
|
||||
static GLboolean chooseFBConfigs(const _GLFWwndconfig* wndconfig,
|
||||
static GLboolean chooseFBConfigs(const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* desired,
|
||||
EGLConfig* result)
|
||||
{
|
||||
@ -155,9 +139,9 @@ static GLboolean chooseFBConfigs(const _GLFWwndconfig* wndconfig,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (wndconfig->glMajor == 1)
|
||||
if (ctxconfig->major == 1)
|
||||
{
|
||||
if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
|
||||
continue;
|
||||
@ -168,7 +152,7 @@ static GLboolean chooseFBConfigs(const _GLFWwndconfig* wndconfig,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
else if (ctxconfig->api == GLFW_OPENGL_API)
|
||||
{
|
||||
if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
|
||||
continue;
|
||||
@ -183,6 +167,7 @@ static GLboolean chooseFBConfigs(const _GLFWwndconfig* wndconfig,
|
||||
u->stencilBits = getConfigAttrib(n, EGL_STENCIL_SIZE);
|
||||
|
||||
u->samples = getConfigAttrib(n, EGL_SAMPLES);
|
||||
u->doublebuffer = GL_TRUE;
|
||||
|
||||
u->egl = n;
|
||||
usableCount++;
|
||||
@ -207,6 +192,9 @@ static GLboolean chooseFBConfigs(const _GLFWwndconfig* wndconfig,
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
{
|
||||
if (!_glfwInitTLS())
|
||||
return GL_FALSE;
|
||||
|
||||
_glfw.egl.display = eglGetDisplay((EGLNativeDisplayType)_GLFW_EGL_NATIVE_DISPLAY);
|
||||
if (_glfw.egl.display == EGL_NO_DISPLAY)
|
||||
{
|
||||
@ -237,6 +225,8 @@ int _glfwInitContextAPI(void)
|
||||
void _glfwTerminateContextAPI(void)
|
||||
{
|
||||
eglTerminate(_glfw.egl.display);
|
||||
|
||||
_glfwTerminateTLS();
|
||||
}
|
||||
|
||||
#define setEGLattrib(attribName, attribValue) \
|
||||
@ -246,21 +236,20 @@ void _glfwTerminateContextAPI(void)
|
||||
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
}
|
||||
|
||||
// Prepare for creation of the OpenGL context
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
//
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
int attribs[40];
|
||||
EGLint count = 0;
|
||||
EGLConfig config;
|
||||
EGLContext share = NULL;
|
||||
|
||||
if (wndconfig->share)
|
||||
share = wndconfig->share->egl.context;
|
||||
if (ctxconfig->share)
|
||||
share = ctxconfig->share->egl.context;
|
||||
|
||||
if (!chooseFBConfigs(wndconfig, fbconfig, &config))
|
||||
if (!chooseFBConfigs(ctxconfig, fbconfig, &config))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: Failed to find a suitable EGLConfig");
|
||||
@ -270,6 +259,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
#if defined(_GLFW_X11)
|
||||
// Retrieve the visual corresponding to the chosen EGL config
|
||||
{
|
||||
EGLint count = 0;
|
||||
int mask;
|
||||
EGLint redBits, greenBits, blueBits, alphaBits, visualID = 0;
|
||||
XVisualInfo info;
|
||||
@ -306,8 +296,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
|
||||
window->egl.visual = XGetVisualInfo(_glfw.x11.display,
|
||||
mask, &info, &count);
|
||||
|
||||
if (window->egl.visual == NULL)
|
||||
if (!window->egl.visual)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: Failed to retrieve visual for EGLConfig");
|
||||
@ -316,7 +305,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
}
|
||||
#endif // _GLFW_X11
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (!eglBindAPI(EGL_OPENGL_ES_API))
|
||||
{
|
||||
@ -341,34 +330,34 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
{
|
||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
if (ctxconfig->api == GLFW_OPENGL_API)
|
||||
{
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
||||
mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
|
||||
|
||||
if (wndconfig->glForward)
|
||||
if (ctxconfig->forward)
|
||||
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||
|
||||
if (wndconfig->glDebug)
|
||||
if (ctxconfig->debug)
|
||||
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||
}
|
||||
|
||||
if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
|
||||
if (ctxconfig->robustness)
|
||||
{
|
||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
strategy = EGL_NO_RESET_NOTIFICATION_KHR;
|
||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
strategy = EGL_LOSE_CONTEXT_ON_RESET_KHR;
|
||||
|
||||
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||
}
|
||||
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||
{
|
||||
setEGLattrib(EGL_CONTEXT_MAJOR_VERSION_KHR, wndconfig->glMajor);
|
||||
setEGLattrib(EGL_CONTEXT_MINOR_VERSION_KHR, wndconfig->glMinor);
|
||||
setEGLattrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
|
||||
setEGLattrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
@ -386,12 +375,15 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
setEGLattrib(EGL_CONTEXT_CLIENT_VERSION, wndconfig->glMajor);
|
||||
if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||
setEGLattrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
|
||||
|
||||
setEGLattrib(EGL_NONE, EGL_NONE);
|
||||
}
|
||||
|
||||
// Context release behaviors (GL_KHR_context_flush_control) are not yet
|
||||
// supported on EGL but are not a hard constraint, so ignore and continue
|
||||
|
||||
window->egl.context = eglCreateContext(_glfw.egl.display,
|
||||
config, share, attribs);
|
||||
|
||||
@ -438,7 +430,7 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
||||
// Analyzes the specified context for possible recreation
|
||||
//
|
||||
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
#if defined(_GLFW_WIN32)
|
||||
@ -482,12 +474,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
}
|
||||
|
||||
_glfwCurrentWindow = window;
|
||||
}
|
||||
|
||||
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
|
||||
{
|
||||
return _glfwCurrentWindow;
|
||||
_glfwSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
@ -526,21 +513,21 @@ GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
|
||||
|
||||
GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_DISPLAY);
|
||||
return _glfw.egl.display;
|
||||
}
|
||||
|
||||
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
|
||||
return window->egl.context;
|
||||
}
|
||||
|
||||
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
|
||||
return window->egl.surface;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 EGL - www.glfw.org
|
||||
// GLFW 3.1 EGL - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -25,8 +25,8 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _egl_platform_h_
|
||||
#define _egl_platform_h_
|
||||
#ifndef _egl_context_h_
|
||||
#define _egl_context_h_
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
@ -40,18 +40,13 @@
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#define _GLFW_PLATFORM_FBCONFIG EGLConfig egl
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl
|
||||
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryEGL egl
|
||||
#define _GLFW_PLATFORM_FBCONFIG EGLConfig egl
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
|
||||
|
||||
|
||||
//========================================================================
|
||||
// GLFW platform specific types
|
||||
//========================================================================
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific OpenGL context structure
|
||||
//------------------------------------------------------------------------
|
||||
// EGL-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextEGL
|
||||
{
|
||||
EGLConfig config;
|
||||
@ -61,12 +56,12 @@ typedef struct _GLFWcontextEGL
|
||||
#if defined(_GLFW_X11)
|
||||
XVisualInfo* visual;
|
||||
#endif
|
||||
|
||||
} _GLFWcontextEGL;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific library global data for EGL
|
||||
//------------------------------------------------------------------------
|
||||
// EGL-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryEGL
|
||||
{
|
||||
EGLDisplay display;
|
||||
@ -77,4 +72,14 @@ typedef struct _GLFWlibraryEGL
|
||||
} _GLFWlibraryEGL;
|
||||
|
||||
|
||||
#endif // _egl_platform_h_
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
|
||||
#endif // _egl_context_h_
|
126
extern/glfw/src/gamma.c
vendored
126
extern/glfw/src/gamma.c
vendored
@ -1,126 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 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"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
||||
{
|
||||
ramp->red = calloc(size, sizeof(unsigned short));
|
||||
ramp->green = calloc(size, sizeof(unsigned short));
|
||||
ramp->blue = calloc(size, sizeof(unsigned short));
|
||||
ramp->size = size;
|
||||
}
|
||||
|
||||
void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
|
||||
{
|
||||
free(ramp->red);
|
||||
free(ramp->green);
|
||||
free(ramp->blue);
|
||||
|
||||
memset(ramp, 0, sizeof(GLFWgammaramp));
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
||||
{
|
||||
int i;
|
||||
unsigned short values[256];
|
||||
GLFWgammaramp ramp;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (gamma <= 0.f)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Gamma value must be greater than zero");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
double value;
|
||||
|
||||
// Calculate intensity
|
||||
value = i / 255.0;
|
||||
// Apply gamma curve
|
||||
value = pow(value, 1.0 / gamma) * 65535.0 + 0.5;
|
||||
|
||||
// Clamp to value range
|
||||
if (value > 65535.0)
|
||||
value = 65535.0;
|
||||
|
||||
values[i] = (unsigned short) value;
|
||||
}
|
||||
|
||||
ramp.red = values;
|
||||
ramp.green = values;
|
||||
ramp.blue = values;
|
||||
ramp.size = 256;
|
||||
|
||||
glfwSetGammaRamp(handle, &ramp);
|
||||
}
|
||||
|
||||
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||
_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp);
|
||||
|
||||
return &monitor->currentRamp;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (!monitor->originalRamp.size)
|
||||
_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp);
|
||||
|
||||
_glfwPlatformSetGammaRamp(monitor, ramp);
|
||||
}
|
||||
|
13
extern/glfw/src/glfw3.pc
vendored
Normal file
13
extern/glfw/src/glfw3.pc
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
prefix=/usr/local
|
||||
exec_prefix=${prefix}
|
||||
includedir=${prefix}/include
|
||||
libdir=${exec_prefix}/lib
|
||||
|
||||
Name: GLFW
|
||||
Description: A multi-platform library for OpenGL, window and input
|
||||
Version: 3.1.0
|
||||
URL: http://www.glfw.org/
|
||||
Requires.private: x11 xrandr xinerama xi xxf86vm xcursor gl
|
||||
Libs: -L${libdir} -lglfw3
|
||||
Libs.private: -lrt -lm
|
||||
Cflags: -I${includedir}
|
2
extern/glfw/src/glfw3.pc.in
vendored
2
extern/glfw/src/glfw3.pc.in
vendored
@ -4,7 +4,7 @@ includedir=${prefix}/include
|
||||
libdir=${exec_prefix}/lib@LIB_SUFFIX@
|
||||
|
||||
Name: GLFW
|
||||
Description: A portable library for OpenGL, window and input
|
||||
Description: A multi-platform library for OpenGL, window and input
|
||||
Version: @GLFW_VERSION_FULL@
|
||||
URL: http://www.glfw.org/
|
||||
Requires.private: @GLFW_PKG_DEPS@
|
||||
|
29
extern/glfw/src/glfw3Config.cmake
vendored
Normal file
29
extern/glfw/src/glfw3Config.cmake
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
# - Config file for the glfw3 package
|
||||
# It defines the following variables
|
||||
# GLFW3_INCLUDE_DIR, the path where GLFW headers are located
|
||||
# GLFW3_LIBRARY_DIR, folder in which the GLFW library is located
|
||||
# GLFW3_LIBRARY, library to link against to use GLFW
|
||||
|
||||
set(GLFW3_VERSION "3.1.0")
|
||||
|
||||
|
||||
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
|
||||
####### Any changes to this file will be overwritten by the next CMake run ####
|
||||
####### The input file was glfw3Config.cmake.in ########
|
||||
|
||||
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
|
||||
|
||||
macro(set_and_check _var _file)
|
||||
set(${_var} "${_file}")
|
||||
if(NOT EXISTS "${_file}")
|
||||
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
####################################################################################
|
||||
|
||||
set_and_check(GLFW3_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
|
||||
set_and_check(GLFW3_LIBRARY_DIR "${PACKAGE_PREFIX_DIR}/lib")
|
||||
|
||||
find_library(GLFW3_LIBRARY "glfw3" HINTS ${GLFW3_LIBRARY_DIR})
|
||||
|
15
extern/glfw/src/glfw3Config.cmake.in
vendored
Normal file
15
extern/glfw/src/glfw3Config.cmake.in
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# - Config file for the glfw3 package
|
||||
# It defines the following variables
|
||||
# GLFW3_INCLUDE_DIR, the path where GLFW headers are located
|
||||
# GLFW3_LIBRARY_DIR, folder in which the GLFW library is located
|
||||
# GLFW3_LIBRARY, library to link against to use GLFW
|
||||
|
||||
set(GLFW3_VERSION "@GLFW_VERSION_FULL@")
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(GLFW3_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/include")
|
||||
set_and_check(GLFW3_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@")
|
||||
|
||||
find_library(GLFW3_LIBRARY "@GLFW_LIB_NAME@" HINTS ${GLFW3_LIBRARY_DIR})
|
||||
|
46
extern/glfw/src/glfw3ConfigVersion.cmake
vendored
Normal file
46
extern/glfw/src/glfw3ConfigVersion.cmake
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
# This is a basic version file for the Config-mode of find_package().
|
||||
# It is used by write_basic_package_version_file() as input file for configure_file()
|
||||
# to create a version-file which can be installed along a config.cmake file.
|
||||
#
|
||||
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
||||
# the requested version string are exactly the same and it sets
|
||||
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
|
||||
# but only if the requested major version is the same as the current one.
|
||||
# The variable CVF_VERSION must be set before calling configure_file().
|
||||
|
||||
|
||||
set(PACKAGE_VERSION "3.1.0")
|
||||
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
|
||||
if("3.1.0" MATCHES "^([0-9]+)\\.")
|
||||
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
else()
|
||||
set(CVF_VERSION_MAJOR "3.1.0")
|
||||
endif()
|
||||
|
||||
if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif()
|
||||
|
||||
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
||||
math(EXPR installedBits "8 * 8")
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
10
extern/glfw/src/glfwConfig.cmake.in
vendored
10
extern/glfw/src/glfwConfig.cmake.in
vendored
@ -1,10 +0,0 @@
|
||||
# - Config file for the glfw package
|
||||
# It defines the following variables
|
||||
# GLFW_INCLUDE_DIR, the path where GLFW headers are located
|
||||
# GLFW_LIBRARY_DIR, folder in which the GLFW library is located
|
||||
# GLFW_LIBRARY, library to link against to use GLFW
|
||||
|
||||
set(GLFW_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include")
|
||||
set(GLFW_LIBRARY_DIR "@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@")
|
||||
|
||||
find_library(GLFW_LIBRARY "@GLFW_LIB_NAME@" HINTS ${GLFW_LIBRARY_DIR})
|
12
extern/glfw/src/glfwConfigVersion.cmake.in
vendored
12
extern/glfw/src/glfwConfigVersion.cmake.in
vendored
@ -1,12 +0,0 @@
|
||||
|
||||
set(PACKAGE_VERSION "@GLFW_VERSION_FULL@")
|
||||
|
||||
if ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@GLFW_VERSION_MAJOR@")
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL @GLFW_VERSION_MINOR@)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif()
|
||||
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -23,13 +23,15 @@
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// As config.h.in, this file is used by CMake to produce the config.h shared
|
||||
// configuration header file. If you are adding a feature requiring
|
||||
// conditional compilation, this is the proper place to add the macros.
|
||||
// As glfw_config.h.in, this file is used by CMake to produce the
|
||||
// glfw_config.h configuration header file. If you are adding a feature
|
||||
// requiring conditional compilation, this is where to add the macro.
|
||||
//========================================================================
|
||||
// As config.h, this file defines compile-time build options and macros for
|
||||
// all platforms supported by GLFW. As this is a generated file, don't modify
|
||||
// it. Instead, you should modify the config.h.in file.
|
||||
// As glfw_config.h, this file defines compile-time option macros for a
|
||||
// specific platform and development environment. If you are using the
|
||||
// GLFW CMake files, modify glfw_config.h.in instead of this file. If you
|
||||
// are using your own build system, make this file define the appropriate
|
||||
// macros in whatever way is suitable.
|
||||
//========================================================================
|
||||
|
||||
// Define this to 1 if building GLFW for X11
|
||||
@ -38,6 +40,10 @@
|
||||
/* #undef _GLFW_WIN32 */
|
||||
// Define this to 1 if building GLFW for Cocoa
|
||||
/* #undef _GLFW_COCOA */
|
||||
// Define this to 1 if building GLFW for Wayland
|
||||
/* #undef _GLFW_WAYLAND */
|
||||
// Define this to 1 if building GLFW for Mir
|
||||
/* #undef _GLFW_MIR */
|
||||
|
||||
// Define this to 1 if building GLFW for EGL
|
||||
/* #undef _GLFW_EGL */
|
||||
@ -51,8 +57,6 @@
|
||||
// Define this to 1 if building as a shared library / dynamic library / DLL
|
||||
/* #undef _GLFW_BUILD_DLL */
|
||||
|
||||
// Define this to 1 to disable dynamic loading of winmm
|
||||
/* #undef _GLFW_NO_DLOAD_WINMM */
|
||||
// Define this to 1 if glfwSwapInterval should ignore DWM compositing status
|
||||
/* #undef _GLFW_USE_DWM_SWAP_INTERVAL */
|
||||
// Define this to 1 to force use of high-performance GPU on Optimus systems
|
||||
@ -71,6 +75,8 @@
|
||||
/* #undef _GLFW_USE_CHDIR */
|
||||
// Define this to 1 if glfwCreateWindow should populate the menu bar
|
||||
/* #undef _GLFW_USE_MENUBAR */
|
||||
// Define this to 1 if windows should use full resolution on Retina displays
|
||||
/* #undef _GLFW_USE_RETINA */
|
||||
|
||||
// Define this to 1 if using OpenGL as the client library
|
||||
#define _GLFW_USE_OPENGL
|
||||
@ -79,6 +85,3 @@
|
||||
// Define this to 1 if using OpenGL ES 2.0 as the client library
|
||||
/* #undef _GLFW_USE_GLESV2 */
|
||||
|
||||
// The GLFW version as used by glfwGetVersionString
|
||||
#define _GLFW_VERSION_FULL "3.0.2"
|
||||
|
10
extern/glfw/src/glfw_config.h.in
vendored
10
extern/glfw/src/glfw_config.h.in
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -40,6 +40,10 @@
|
||||
#cmakedefine _GLFW_WIN32
|
||||
// Define this to 1 if building GLFW for Cocoa
|
||||
#cmakedefine _GLFW_COCOA
|
||||
// Define this to 1 if building GLFW for Wayland
|
||||
#cmakedefine _GLFW_WAYLAND
|
||||
// Define this to 1 if building GLFW for Mir
|
||||
#cmakedefine _GLFW_MIR
|
||||
|
||||
// Define this to 1 if building GLFW for EGL
|
||||
#cmakedefine _GLFW_EGL
|
||||
@ -53,8 +57,6 @@
|
||||
// Define this to 1 if building as a shared library / dynamic library / DLL
|
||||
#cmakedefine _GLFW_BUILD_DLL
|
||||
|
||||
// Define this to 1 to disable dynamic loading of winmm
|
||||
#cmakedefine _GLFW_NO_DLOAD_WINMM
|
||||
// Define this to 1 if glfwSwapInterval should ignore DWM compositing status
|
||||
#cmakedefine _GLFW_USE_DWM_SWAP_INTERVAL
|
||||
// Define this to 1 to force use of high-performance GPU on Optimus systems
|
||||
@ -73,6 +75,8 @@
|
||||
#cmakedefine _GLFW_USE_CHDIR
|
||||
// Define this to 1 if glfwCreateWindow should populate the menu bar
|
||||
#cmakedefine _GLFW_USE_MENUBAR
|
||||
// Define this to 1 if windows should use full resolution on Retina displays
|
||||
#cmakedefine _GLFW_USE_RETINA
|
||||
|
||||
// Define this to 1 if using OpenGL as the client library
|
||||
#cmakedefine _GLFW_USE_OPENGL
|
||||
|
198
extern/glfw/src/glx_context.c
vendored
198
extern/glfw/src/glx_context.c
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 GLX - www.glfw.org
|
||||
// GLFW 3.1 GLX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -42,20 +42,11 @@ void (*glXGetProcAddressEXT(const GLubyte* procName))();
|
||||
|
||||
|
||||
// Returns the specified attribute of the specified GLXFBConfig
|
||||
// NOTE: Do not call this unless we have found GLX 1.3+ or GLX_SGIX_fbconfig
|
||||
//
|
||||
static int getFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
|
||||
{
|
||||
int value;
|
||||
|
||||
if (_glfw.glx.SGIX_fbconfig)
|
||||
{
|
||||
_glfw.glx.GetFBConfigAttribSGIX(_glfw.x11.display,
|
||||
fbconfig, attrib, &value);
|
||||
}
|
||||
else
|
||||
glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
|
||||
|
||||
glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -78,24 +69,11 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul
|
||||
trustWindowBit = GL_FALSE;
|
||||
}
|
||||
|
||||
if (_glfw.glx.SGIX_fbconfig)
|
||||
{
|
||||
nativeConfigs = _glfw.glx.ChooseFBConfigSGIX(_glfw.x11.display,
|
||||
_glfw.x11.screen,
|
||||
NULL,
|
||||
&nativeCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
nativeConfigs = glXGetFBConfigs(_glfw.x11.display,
|
||||
_glfw.x11.screen,
|
||||
&nativeCount);
|
||||
}
|
||||
|
||||
nativeConfigs = glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen,
|
||||
&nativeCount);
|
||||
if (!nativeCount)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||
"GLX: No GLXFBConfigs returned");
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@ -107,10 +85,9 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul
|
||||
const GLXFBConfig n = nativeConfigs[i];
|
||||
_GLFWfbconfig* u = usableConfigs + usableCount;
|
||||
|
||||
if (!getFBConfigAttrib(n, GLX_DOUBLEBUFFER) ||
|
||||
!getFBConfigAttrib(n, GLX_VISUAL_ID))
|
||||
if (!getFBConfigAttrib(n, GLX_VISUAL_ID))
|
||||
{
|
||||
// Only consider double-buffered GLXFBConfigs with associated visuals
|
||||
// Only consider GLXFBConfigs with associated visuals
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -143,7 +120,11 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul
|
||||
u->accumAlphaBits = getFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
|
||||
|
||||
u->auxBuffers = getFBConfigAttrib(n, GLX_AUX_BUFFERS);
|
||||
u->stereo = getFBConfigAttrib(n, GLX_STEREO);
|
||||
|
||||
if (getFBConfigAttrib(n, GLX_STEREO))
|
||||
u->stereo = GL_TRUE;
|
||||
if (getFBConfigAttrib(n, GLX_DOUBLEBUFFER))
|
||||
u->doublebuffer = GL_TRUE;
|
||||
|
||||
if (_glfw.glx.ARB_multisample)
|
||||
u->samples = getFBConfigAttrib(n, GLX_SAMPLES);
|
||||
@ -171,15 +152,6 @@ static GLXContext createLegacyContext(_GLFWwindow* window,
|
||||
GLXFBConfig fbconfig,
|
||||
GLXContext share)
|
||||
{
|
||||
if (_glfw.glx.SGIX_fbconfig)
|
||||
{
|
||||
return _glfw.glx.CreateContextWithConfigSGIX(_glfw.x11.display,
|
||||
fbconfig,
|
||||
GLX_RGBA_TYPE,
|
||||
share,
|
||||
True);
|
||||
}
|
||||
|
||||
return glXCreateNewContext(_glfw.x11.display,
|
||||
fbconfig,
|
||||
GLX_RGBA_TYPE,
|
||||
@ -196,24 +168,11 @@ static GLXContext createLegacyContext(_GLFWwindow* window,
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
{
|
||||
if (!_glfwInitTLS())
|
||||
return GL_FALSE;
|
||||
|
||||
#ifdef _GLFW_DLOPEN_LIBGL
|
||||
int i;
|
||||
char* libGL_names[ ] =
|
||||
{
|
||||
"libGL.so",
|
||||
"libGL.so.1",
|
||||
"/usr/lib/libGL.so",
|
||||
"/usr/lib/libGL.so.1",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (i = 0; libGL_names[i] != NULL; i++)
|
||||
{
|
||||
_glfw.glx.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (_glfw.glx.libGL)
|
||||
break;
|
||||
}
|
||||
|
||||
_glfw.glx.libGL = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!_glfw.glx.libGL)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to find libGL");
|
||||
@ -221,19 +180,11 @@ int _glfwInitContextAPI(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pthread_key_create(&_glfw.glx.current, NULL) != 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"GLX: Failed to create context TLS");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Check if GLX is supported on this display
|
||||
if (!glXQueryExtension(_glfw.x11.display,
|
||||
&_glfw.glx.errorBase,
|
||||
&_glfw.glx.eventBase))
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX support not found");
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@ -246,6 +197,13 @@ int _glfwInitContextAPI(void)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (_glfw.glx.versionMajor == 1 && _glfw.glx.versionMinor < 3)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||
"GLX: GLX version 1.3 is required");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (_glfwPlatformExtensionSupported("GLX_EXT_swap_control"))
|
||||
{
|
||||
_glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
|
||||
@ -273,26 +231,6 @@ int _glfwInitContextAPI(void)
|
||||
_glfw.glx.MESA_swap_control = GL_TRUE;
|
||||
}
|
||||
|
||||
if (_glfwPlatformExtensionSupported("GLX_SGIX_fbconfig"))
|
||||
{
|
||||
_glfw.glx.GetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)
|
||||
_glfwPlatformGetProcAddress("glXGetFBConfigAttribSGIX");
|
||||
_glfw.glx.ChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)
|
||||
_glfwPlatformGetProcAddress("glXChooseFBConfigSGIX");
|
||||
_glfw.glx.CreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)
|
||||
_glfwPlatformGetProcAddress("glXCreateContextWithConfigSGIX");
|
||||
_glfw.glx.GetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)
|
||||
_glfwPlatformGetProcAddress("glXGetVisualFromFBConfigSGIX");
|
||||
|
||||
if (_glfw.glx.GetFBConfigAttribSGIX &&
|
||||
_glfw.glx.ChooseFBConfigSGIX &&
|
||||
_glfw.glx.CreateContextWithConfigSGIX &&
|
||||
_glfw.glx.GetVisualFromFBConfigSGIX)
|
||||
{
|
||||
_glfw.glx.SGIX_fbconfig = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_glfwPlatformExtensionSupported("GLX_ARB_multisample"))
|
||||
_glfw.glx.ARB_multisample = GL_TRUE;
|
||||
|
||||
@ -317,6 +255,9 @@ int _glfwInitContextAPI(void)
|
||||
if (_glfwPlatformExtensionSupported("GLX_EXT_create_context_es2_profile"))
|
||||
_glfw.glx.EXT_create_context_es2_profile = GL_TRUE;
|
||||
|
||||
if (_glfwPlatformExtensionSupported("GLX_ARB_context_flush_control"))
|
||||
_glfw.glx.ARB_context_flush_control = GL_TRUE;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@ -333,7 +274,7 @@ void _glfwTerminateContextAPI(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
pthread_key_delete(_glfw.glx.current);
|
||||
_glfwTerminateTLS();
|
||||
}
|
||||
|
||||
#define setGLXattrib(attribName, attribValue) \
|
||||
@ -343,18 +284,18 @@ void _glfwTerminateContextAPI(void)
|
||||
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
}
|
||||
|
||||
// Prepare for creation of the OpenGL context
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
//
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
int attribs[40];
|
||||
GLXFBConfig native;
|
||||
GLXContext share = NULL;
|
||||
|
||||
if (wndconfig->share)
|
||||
share = wndconfig->share->glx.context;
|
||||
if (ctxconfig->share)
|
||||
share = ctxconfig->share->glx.context;
|
||||
|
||||
if (!chooseFBConfig(fbconfig, &native))
|
||||
{
|
||||
@ -364,22 +305,15 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
}
|
||||
|
||||
// Retrieve the corresponding visual
|
||||
if (_glfw.glx.SGIX_fbconfig)
|
||||
{
|
||||
window->glx.visual =
|
||||
_glfw.glx.GetVisualFromFBConfigSGIX(_glfw.x11.display, native);
|
||||
}
|
||||
else
|
||||
window->glx.visual = glXGetVisualFromFBConfig(_glfw.x11.display, native);
|
||||
|
||||
if (window->glx.visual == NULL)
|
||||
window->glx.visual = glXGetVisualFromFBConfig(_glfw.x11.display, native);
|
||||
if (!window->glx.visual)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"GLX: Failed to retrieve visual for GLXFBConfig");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (!_glfw.glx.ARB_create_context ||
|
||||
!_glfw.glx.ARB_create_context_profile ||
|
||||
@ -392,7 +326,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->glForward)
|
||||
if (ctxconfig->forward)
|
||||
{
|
||||
if (!_glfw.glx.ARB_create_context)
|
||||
{
|
||||
@ -403,7 +337,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
if (ctxconfig->profile)
|
||||
{
|
||||
if (!_glfw.glx.ARB_create_context ||
|
||||
!_glfw.glx.ARB_create_context_profile)
|
||||
@ -421,46 +355,63 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
{
|
||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
if (ctxconfig->api == GLFW_OPENGL_API)
|
||||
{
|
||||
if (wndconfig->glForward)
|
||||
if (ctxconfig->forward)
|
||||
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||
|
||||
if (wndconfig->glDebug)
|
||||
if (ctxconfig->debug)
|
||||
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
if (ctxconfig->profile)
|
||||
{
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
||||
mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
}
|
||||
}
|
||||
else
|
||||
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||
|
||||
if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
|
||||
if (ctxconfig->robustness)
|
||||
{
|
||||
if (_glfw.glx.ARB_create_context_robustness)
|
||||
{
|
||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
|
||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
|
||||
|
||||
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
if (ctxconfig->release)
|
||||
{
|
||||
if (_glfw.glx.ARB_context_flush_control)
|
||||
{
|
||||
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
||||
{
|
||||
setGLXattrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
||||
}
|
||||
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||
{
|
||||
setGLXattrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||
{
|
||||
// NOTE: Only request an explicitly versioned context when
|
||||
// necessary, as explicitly requesting version 1.0 does not
|
||||
// always return the highest available version
|
||||
|
||||
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
||||
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
||||
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
@ -481,16 +432,16 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
True,
|
||||
attribs);
|
||||
|
||||
if (window->glx.context == NULL)
|
||||
if (!window->glx.context)
|
||||
{
|
||||
// HACK: This is a fallback for the broken Mesa implementation of
|
||||
// GLX_ARB_create_context_profile, which fails default 1.0
|
||||
// context creation with a GLXBadProfileARB error in violation
|
||||
// of the extension spec
|
||||
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
|
||||
wndconfig->clientAPI == GLFW_OPENGL_API &&
|
||||
wndconfig->glProfile == GLFW_OPENGL_ANY_PROFILE &&
|
||||
wndconfig->glForward == GL_FALSE)
|
||||
ctxconfig->api == GLFW_OPENGL_API &&
|
||||
ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
|
||||
ctxconfig->forward == GL_FALSE)
|
||||
{
|
||||
window->glx.context = createLegacyContext(window, native, share);
|
||||
}
|
||||
@ -501,7 +452,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
|
||||
_glfwReleaseXErrorHandler();
|
||||
|
||||
if (window->glx.context == NULL)
|
||||
if (!window->glx.context)
|
||||
{
|
||||
_glfwInputXError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context");
|
||||
return GL_FALSE;
|
||||
@ -545,12 +496,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
else
|
||||
glXMakeCurrent(_glfw.x11.display, None, NULL);
|
||||
|
||||
pthread_setspecific(_glfw.glx.current, window);
|
||||
}
|
||||
|
||||
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
|
||||
{
|
||||
return (_GLFWwindow*) pthread_getspecific(_glfw.glx.current);
|
||||
_glfwSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 GLX - www.glfw.org
|
||||
// GLFW 3.1 GLX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -25,8 +25,8 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _glx_platform_h_
|
||||
#define _glx_platform_h_
|
||||
#ifndef _glx_context_h_
|
||||
#define _glx_context_h_
|
||||
|
||||
#define GLX_GLXEXT_LEGACY
|
||||
#include <GL/glx.h>
|
||||
@ -41,8 +41,6 @@
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
// We support four different ways for getting addresses for GL/GLX
|
||||
// extension functions: glXGetProcAddress, glXGetProcAddressARB,
|
||||
// glXGetProcAddressEXT, and dlsym
|
||||
@ -59,53 +57,40 @@
|
||||
#error "No OpenGL entry point retrieval mechanism was enabled"
|
||||
#endif
|
||||
|
||||
#define _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
|
||||
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryGLX glx
|
||||
#define _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx
|
||||
|
||||
#ifndef GLX_MESA_swap_control
|
||||
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
|
||||
#endif
|
||||
|
||||
|
||||
//========================================================================
|
||||
// GLFW platform specific types
|
||||
//========================================================================
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific OpenGL context structure
|
||||
//------------------------------------------------------------------------
|
||||
// GLX-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextGLX
|
||||
{
|
||||
GLXContext context; // OpenGL rendering context
|
||||
XVisualInfo* visual; // Visual for selected GLXFBConfig
|
||||
// Rendering context
|
||||
GLXContext context;
|
||||
// Visual of selected GLXFBConfig
|
||||
XVisualInfo* visual;
|
||||
|
||||
} _GLFWcontextGLX;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific library global data for GLX
|
||||
//------------------------------------------------------------------------
|
||||
// GLX-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryGLX
|
||||
{
|
||||
// Server-side GLX version
|
||||
int versionMajor, versionMinor;
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
|
||||
// TLS key for per-thread current context/window
|
||||
pthread_key_t current;
|
||||
|
||||
// GLX extensions
|
||||
PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
|
||||
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
|
||||
PFNGLXGETFBCONFIGATTRIBSGIXPROC GetFBConfigAttribSGIX;
|
||||
PFNGLXCHOOSEFBCONFIGSGIXPROC ChooseFBConfigSGIX;
|
||||
PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC CreateContextWithConfigSGIX;
|
||||
PFNGLXGETVISUALFROMFBCONFIGSGIXPROC GetVisualFromFBConfigSGIX;
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
||||
GLboolean SGIX_fbconfig;
|
||||
GLboolean SGI_swap_control;
|
||||
GLboolean EXT_swap_control;
|
||||
GLboolean MESA_swap_control;
|
||||
@ -115,11 +100,21 @@ typedef struct _GLFWlibraryGLX
|
||||
GLboolean ARB_create_context_profile;
|
||||
GLboolean ARB_create_context_robustness;
|
||||
GLboolean EXT_create_context_es2_profile;
|
||||
GLboolean ARB_context_flush_control;
|
||||
|
||||
#if defined(_GLFW_DLOPEN_LIBGL)
|
||||
void* libGL; // dlopen handle for libGL.so
|
||||
// dlopen handle for libGL.so (for glfwGetProcAddress)
|
||||
void* libGL;
|
||||
#endif
|
||||
|
||||
} _GLFWlibraryGLX;
|
||||
|
||||
|
||||
#endif // _glx_platform_h_
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
|
||||
#endif // _glx_context_h_
|
16
extern/glfw/src/init.c
vendored
16
extern/glfw/src/init.c
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -33,14 +33,15 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
// The three global variables below comprise all global data in GLFW, except for
|
||||
// various static const translation tables. Any other global variable is a bug.
|
||||
|
||||
// Global state shared between compilation units of GLFW
|
||||
// These are documented in internal.h
|
||||
//
|
||||
GLboolean _glfwInitialized = GL_FALSE;
|
||||
_GLFWlibrary _glfw;
|
||||
|
||||
|
||||
// The current error callback
|
||||
// This is outside of _glfw so it can be initialized and usable before
|
||||
// glfwInit is called, which lets that function report errors
|
||||
//
|
||||
@ -128,7 +129,7 @@ GLFWAPI int glfwInit(void)
|
||||
}
|
||||
|
||||
_glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
|
||||
if (_glfw.monitors == NULL)
|
||||
if (!_glfw.monitorCount)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "No monitors found");
|
||||
_glfwPlatformTerminate();
|
||||
@ -152,10 +153,12 @@ GLFWAPI void glfwTerminate(void)
|
||||
|
||||
memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
|
||||
|
||||
// Close all remaining windows
|
||||
while (_glfw.windowListHead)
|
||||
glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
|
||||
|
||||
while (_glfw.cursorListHead)
|
||||
glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead);
|
||||
|
||||
for (i = 0; i < _glfw.monitorCount; i++)
|
||||
{
|
||||
_GLFWmonitor* monitor = _glfw.monitors[i];
|
||||
@ -163,12 +166,13 @@ GLFWAPI void glfwTerminate(void)
|
||||
_glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
|
||||
}
|
||||
|
||||
_glfwDestroyMonitors(_glfw.monitors, _glfw.monitorCount);
|
||||
_glfwFreeMonitors(_glfw.monitors, _glfw.monitorCount);
|
||||
_glfw.monitors = NULL;
|
||||
_glfw.monitorCount = 0;
|
||||
|
||||
_glfwPlatformTerminate();
|
||||
|
||||
memset(&_glfw, 0, sizeof(_glfw));
|
||||
_glfwInitialized = GL_FALSE;
|
||||
}
|
||||
|
||||
|
328
extern/glfw/src/input.c
vendored
328
extern/glfw/src/input.c
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -27,6 +27,11 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#if defined(_MSC_VER)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
// Internal key state used for sticky keys
|
||||
#define _GLFW_STICK 3
|
||||
|
||||
@ -50,27 +55,30 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
|
||||
|
||||
window->cursorMode = newMode;
|
||||
|
||||
if (window == _glfw.focusedWindow)
|
||||
if (_glfw.focusedWindow == window)
|
||||
{
|
||||
if (oldMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
window->cursorPosX = _glfw.cursorPosX;
|
||||
window->cursorPosY = _glfw.cursorPosY;
|
||||
|
||||
_glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY);
|
||||
_glfwPlatformSetCursorPos(window,
|
||||
_glfw.cursorPosX,
|
||||
_glfw.cursorPosY);
|
||||
}
|
||||
else if (newMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
_glfw.cursorPosX = window->cursorPosX;
|
||||
_glfw.cursorPosY = window->cursorPosY;
|
||||
_glfwPlatformGetCursorPos(window,
|
||||
&_glfw.cursorPosX,
|
||||
&_glfw.cursorPosY);
|
||||
|
||||
window->cursorPosX = _glfw.cursorPosX;
|
||||
window->cursorPosY = _glfw.cursorPosY;
|
||||
|
||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
||||
_glfwPlatformSetCursorPos(window, width / 2, height / 2);
|
||||
}
|
||||
|
||||
_glfwPlatformSetCursorMode(window, newMode);
|
||||
_glfwPlatformApplyCursorMode(window);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,8 +96,8 @@ static void setStickyKeys(_GLFWwindow* window, int enabled)
|
||||
// Release all sticky keys
|
||||
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||
{
|
||||
if (window->key[i] == _GLFW_STICK)
|
||||
window->key[i] = GLFW_RELEASE;
|
||||
if (window->keys[i] == _GLFW_STICK)
|
||||
window->keys[i] = GLFW_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,8 +118,8 @@ static void setStickyMouseButtons(_GLFWwindow* window, int enabled)
|
||||
// Release all sticky mouse buttons
|
||||
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||
{
|
||||
if (window->mouseButton[i] == _GLFW_STICK)
|
||||
window->mouseButton[i] = GLFW_RELEASE;
|
||||
if (window->mouseButtons[i] == _GLFW_STICK)
|
||||
window->mouseButtons[i] = GLFW_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,36 +133,42 @@ static void setStickyMouseButtons(_GLFWwindow* window, int enabled)
|
||||
|
||||
void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
GLboolean repeated = GL_FALSE;
|
||||
|
||||
if (action == GLFW_RELEASE && window->key[key] == GLFW_RELEASE)
|
||||
return;
|
||||
|
||||
if (key >= 0 && key <= GLFW_KEY_LAST)
|
||||
{
|
||||
if (action == GLFW_PRESS && window->key[key] == GLFW_PRESS)
|
||||
GLboolean repeated = GL_FALSE;
|
||||
|
||||
if (action == GLFW_RELEASE && window->keys[key] == GLFW_RELEASE)
|
||||
return;
|
||||
|
||||
if (action == GLFW_PRESS && window->keys[key] == GLFW_PRESS)
|
||||
repeated = GL_TRUE;
|
||||
|
||||
if (action == GLFW_RELEASE && window->stickyKeys)
|
||||
window->key[key] = _GLFW_STICK;
|
||||
window->keys[key] = _GLFW_STICK;
|
||||
else
|
||||
window->key[key] = (char) action;
|
||||
}
|
||||
window->keys[key] = (char) action;
|
||||
|
||||
if (repeated)
|
||||
action = GLFW_REPEAT;
|
||||
if (repeated)
|
||||
action = GLFW_REPEAT;
|
||||
}
|
||||
|
||||
if (window->callbacks.key)
|
||||
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
||||
}
|
||||
|
||||
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint)
|
||||
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, int plain)
|
||||
{
|
||||
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
||||
return;
|
||||
|
||||
if (window->callbacks.character)
|
||||
window->callbacks.character((GLFWwindow*) window, codepoint);
|
||||
if (window->callbacks.charmods)
|
||||
window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
|
||||
|
||||
if (plain)
|
||||
{
|
||||
if (window->callbacks.character)
|
||||
window->callbacks.character((GLFWwindow*) window, codepoint);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
||||
@ -170,9 +184,9 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
||||
|
||||
// Register mouse button action
|
||||
if (action == GLFW_RELEASE && window->stickyMouseButtons)
|
||||
window->mouseButton[button] = _GLFW_STICK;
|
||||
window->mouseButtons[button] = _GLFW_STICK;
|
||||
else
|
||||
window->mouseButton[button] = (char) action;
|
||||
window->mouseButtons[button] = (char) action;
|
||||
|
||||
if (window->callbacks.mouseButton)
|
||||
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
||||
@ -187,22 +201,13 @@ void _glfwInputCursorMotion(_GLFWwindow* window, double x, double y)
|
||||
|
||||
window->cursorPosX += x;
|
||||
window->cursorPosY += y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (window->cursorPosX == x && window->cursorPosY == y)
|
||||
return;
|
||||
|
||||
window->cursorPosX = x;
|
||||
window->cursorPosY = y;
|
||||
x = window->cursorPosX;
|
||||
y = window->cursorPosY;
|
||||
}
|
||||
|
||||
if (window->callbacks.cursorPos)
|
||||
{
|
||||
window->callbacks.cursorPos((GLFWwindow*) window,
|
||||
window->cursorPosX,
|
||||
window->cursorPosY);
|
||||
}
|
||||
window->callbacks.cursorPos((GLFWwindow*) window, x, y);
|
||||
}
|
||||
|
||||
void _glfwInputCursorEnter(_GLFWwindow* window, int entered)
|
||||
@ -211,6 +216,12 @@ void _glfwInputCursorEnter(_GLFWwindow* window, int entered)
|
||||
window->callbacks.cursorEnter((GLFWwindow*) window, entered);
|
||||
}
|
||||
|
||||
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names)
|
||||
{
|
||||
if (window->callbacks.drop)
|
||||
window->callbacks.drop((GLFWwindow*) window, count, names);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
@ -271,14 +282,14 @@ GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
||||
return GLFW_RELEASE;
|
||||
}
|
||||
|
||||
if (window->key[key] == _GLFW_STICK)
|
||||
if (window->keys[key] == _GLFW_STICK)
|
||||
{
|
||||
// Sticky mode: release key now
|
||||
window->key[key] = GLFW_RELEASE;
|
||||
window->keys[key] = GLFW_RELEASE;
|
||||
return GLFW_PRESS;
|
||||
}
|
||||
|
||||
return (int) window->key[key];
|
||||
return (int) window->keys[key];
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
|
||||
@ -294,27 +305,36 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
|
||||
return GLFW_RELEASE;
|
||||
}
|
||||
|
||||
if (window->mouseButton[button] == _GLFW_STICK)
|
||||
if (window->mouseButtons[button] == _GLFW_STICK)
|
||||
{
|
||||
// Sticky mode: release mouse button now
|
||||
window->mouseButton[button] = GLFW_RELEASE;
|
||||
window->mouseButtons[button] = GLFW_RELEASE;
|
||||
return GLFW_PRESS;
|
||||
}
|
||||
|
||||
return (int) window->mouseButton[button];
|
||||
return (int) window->mouseButtons[button];
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
if (ypos)
|
||||
*ypos = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (xpos)
|
||||
*xpos = window->cursorPosX;
|
||||
|
||||
if (ypos)
|
||||
*ypos = window->cursorPosY;
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = window->cursorPosX;
|
||||
if (ypos)
|
||||
*ypos = window->cursorPosY;
|
||||
}
|
||||
else
|
||||
_glfwPlatformGetCursorPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||
@ -326,20 +346,102 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||
if (_glfw.focusedWindow != window)
|
||||
return;
|
||||
|
||||
// Don't do anything if the cursor position did not change
|
||||
if (xpos == window->cursorPosX && ypos == window->cursorPosY)
|
||||
return;
|
||||
|
||||
// Set GLFW cursor position
|
||||
window->cursorPosX = xpos;
|
||||
window->cursorPosY = ypos;
|
||||
|
||||
// Do not move physical cursor if it is disabled
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
// Only update the accumulated position if the cursor is disabled
|
||||
window->cursorPosX = xpos;
|
||||
window->cursorPosY = ypos;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update system cursor position
|
||||
_glfwPlatformSetCursorPos(window, xpos, ypos);
|
||||
}
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
||||
{
|
||||
_GLFWcursor* cursor;
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
cursor = calloc(1, sizeof(_GLFWcursor));
|
||||
cursor->next = _glfw.cursorListHead;
|
||||
_glfw.cursorListHead = cursor;
|
||||
|
||||
if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot))
|
||||
{
|
||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (GLFWcursor*) cursor;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
|
||||
{
|
||||
_GLFWcursor* cursor;
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
cursor = calloc(1, sizeof(_GLFWcursor));
|
||||
cursor->next = _glfw.cursorListHead;
|
||||
_glfw.cursorListHead = cursor;
|
||||
|
||||
if (!_glfwPlatformCreateStandardCursor(cursor, shape))
|
||||
{
|
||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (GLFWcursor*) cursor;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
||||
{
|
||||
_GLFWcursor* cursor = (_GLFWcursor*) handle;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (cursor == NULL)
|
||||
return;
|
||||
|
||||
// Update physical cursor position
|
||||
_glfwPlatformSetCursorPos(window, xpos, ypos);
|
||||
// Make sure the cursor is not being used by any window
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfw.windowListHead; window; window = window->next)
|
||||
{
|
||||
if (window->cursor == cursor)
|
||||
glfwSetCursor((GLFWwindow*) window, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
_glfwPlatformDestroyCursor(cursor);
|
||||
|
||||
// Unlink cursor from global linked list
|
||||
{
|
||||
_GLFWcursor** prev = &_glfw.cursorListHead;
|
||||
|
||||
while (*prev != cursor)
|
||||
prev = &((*prev)->next);
|
||||
|
||||
*prev = cursor->next;
|
||||
}
|
||||
|
||||
free(cursor);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) windowHandle;
|
||||
_GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformSetCursor(window, cursor);
|
||||
|
||||
window->cursor = cursor;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
||||
@ -358,6 +460,14 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
||||
GLFWmousebuttonfun cbfun)
|
||||
{
|
||||
@ -394,3 +504,93 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.drop, 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;
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformSetClipboardString(window, string);
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
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);
|
||||
}
|
||||
|
||||
|
242
extern/glfw/src/internal.h
vendored
242
extern/glfw/src/internal.h
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -33,7 +33,7 @@
|
||||
#include "glfw_config.h"
|
||||
#endif
|
||||
|
||||
#define _GLFW_VERSION_NUMBER "3.0.4"
|
||||
#define _GLFW_VERSION_NUMBER "3.1.0"
|
||||
|
||||
#if defined(_GLFW_USE_OPENGL)
|
||||
// This is the default for glfw3.h
|
||||
@ -58,12 +58,13 @@
|
||||
#include "../deps/GL/glext.h"
|
||||
#endif
|
||||
|
||||
typedef struct _GLFWhints _GLFWhints;
|
||||
typedef struct _GLFWwndconfig _GLFWwndconfig;
|
||||
typedef struct _GLFWctxconfig _GLFWctxconfig;
|
||||
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
||||
typedef struct _GLFWwindow _GLFWwindow;
|
||||
typedef struct _GLFWlibrary _GLFWlibrary;
|
||||
typedef struct _GLFWmonitor _GLFWmonitor;
|
||||
typedef struct _GLFWcursor _GLFWcursor;
|
||||
|
||||
#if defined(_GLFW_COCOA)
|
||||
#include "cocoa_platform.h"
|
||||
@ -71,6 +72,10 @@ typedef struct _GLFWmonitor _GLFWmonitor;
|
||||
#include "win32_platform.h"
|
||||
#elif defined(_GLFW_X11)
|
||||
#include "x11_platform.h"
|
||||
#elif defined(_GLFW_WAYLAND)
|
||||
#include "wl_platform.h"
|
||||
#elif defined(_GLFW_MIR)
|
||||
#include "mir_platform.h"
|
||||
#else
|
||||
#error "No supported window creation API selected"
|
||||
#endif
|
||||
@ -107,7 +112,7 @@ typedef struct _GLFWmonitor _GLFWmonitor;
|
||||
// Helper macros
|
||||
//========================================================================
|
||||
|
||||
// Checks for whether the library has been intitalized
|
||||
// Checks for whether the library has been initialized
|
||||
#define _GLFW_REQUIRE_INIT() \
|
||||
if (!_glfwInitialized) \
|
||||
{ \
|
||||
@ -132,14 +137,14 @@ typedef struct _GLFWmonitor _GLFWmonitor;
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Internal types
|
||||
// Platform-independent structures
|
||||
//========================================================================
|
||||
|
||||
/*! @brief Window and context configuration.
|
||||
/*! @brief Window configuration.
|
||||
*
|
||||
* Parameters relating to the creation of the context and window but not
|
||||
* directly related to the framebuffer. This is used to pass window and
|
||||
* context creation parameters from shared code to the platform API.
|
||||
* Parameters relating to the creation of the window but not directly related
|
||||
* to the framebuffer. This is used to pass window creation parameters from
|
||||
* shared code to the platform API.
|
||||
*/
|
||||
struct _GLFWwndconfig
|
||||
{
|
||||
@ -149,14 +154,29 @@ struct _GLFWwndconfig
|
||||
GLboolean resizable;
|
||||
GLboolean visible;
|
||||
GLboolean decorated;
|
||||
int clientAPI;
|
||||
int glMajor;
|
||||
int glMinor;
|
||||
GLboolean glForward;
|
||||
GLboolean glDebug;
|
||||
int glProfile;
|
||||
int glRobustness;
|
||||
GLboolean focused;
|
||||
GLboolean autoIconify;
|
||||
GLboolean floating;
|
||||
_GLFWmonitor* monitor;
|
||||
};
|
||||
|
||||
|
||||
/*! @brief Context configuration.
|
||||
*
|
||||
* Parameters relating to the creation of the context but not directly related
|
||||
* to the framebuffer. This is used to pass context creation parameters from
|
||||
* shared code to the platform API.
|
||||
*/
|
||||
struct _GLFWctxconfig
|
||||
{
|
||||
int api;
|
||||
int major;
|
||||
int minor;
|
||||
GLboolean forward;
|
||||
GLboolean debug;
|
||||
int profile;
|
||||
int robustness;
|
||||
int release;
|
||||
_GLFWwindow* share;
|
||||
};
|
||||
|
||||
@ -164,7 +184,7 @@ struct _GLFWwndconfig
|
||||
/*! @brief Framebuffer configuration.
|
||||
*
|
||||
* This describes buffers and their sizes. It also contains
|
||||
* a platform-specific ID used to map back to the backend API's object.
|
||||
* a platform-specific ID used to map back to the backend API object.
|
||||
*
|
||||
* It is used to pass framebuffer parameters from shared code to the platform
|
||||
* API and also to enumerate and select available framebuffer configs.
|
||||
@ -182,11 +202,12 @@ struct _GLFWfbconfig
|
||||
int accumBlueBits;
|
||||
int accumAlphaBits;
|
||||
int auxBuffers;
|
||||
GLboolean stereo;
|
||||
int stereo;
|
||||
int samples;
|
||||
GLboolean sRGB;
|
||||
int sRGB;
|
||||
int doublebuffer;
|
||||
|
||||
// This is defined in the context API's platform.h
|
||||
// This is defined in the context API's context.h
|
||||
_GLFW_PLATFORM_FBCONFIG;
|
||||
};
|
||||
|
||||
@ -198,29 +219,34 @@ struct _GLFWwindow
|
||||
struct _GLFWwindow* next;
|
||||
|
||||
// Window settings and state
|
||||
GLboolean iconified;
|
||||
GLboolean resizable;
|
||||
GLboolean decorated;
|
||||
GLboolean visible;
|
||||
GLboolean autoIconify;
|
||||
GLboolean floating;
|
||||
GLboolean closed;
|
||||
void* userPointer;
|
||||
GLFWvidmode videoMode;
|
||||
_GLFWmonitor* monitor;
|
||||
_GLFWcursor* cursor;
|
||||
|
||||
// Window input state
|
||||
GLboolean stickyKeys;
|
||||
GLboolean stickyMouseButtons;
|
||||
double cursorPosX, cursorPosY;
|
||||
int cursorMode;
|
||||
char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||
char key[GLFW_KEY_LAST + 1];
|
||||
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||
char keys[GLFW_KEY_LAST + 1];
|
||||
|
||||
// OpenGL extensions and context attributes
|
||||
int clientAPI;
|
||||
int glMajor, glMinor, glRevision;
|
||||
GLboolean glForward, glDebug;
|
||||
int glProfile;
|
||||
int glRobustness;
|
||||
struct {
|
||||
int api;
|
||||
int major, minor, revision;
|
||||
GLboolean forward, debug;
|
||||
int profile;
|
||||
int robustness;
|
||||
int release;
|
||||
} context;
|
||||
|
||||
#if defined(_GLFW_USE_OPENGL)
|
||||
PFNGLGETSTRINGIPROC GetStringi;
|
||||
#endif
|
||||
@ -239,11 +265,13 @@ struct _GLFWwindow
|
||||
GLFWscrollfun scroll;
|
||||
GLFWkeyfun key;
|
||||
GLFWcharfun character;
|
||||
GLFWcharmodsfun charmods;
|
||||
GLFWdropfun drop;
|
||||
} callbacks;
|
||||
|
||||
// This is defined in the window API's platform.h
|
||||
_GLFW_PLATFORM_WINDOW_STATE;
|
||||
// This is defined in the context API's platform.h
|
||||
// This is defined in the context API's context.h
|
||||
_GLFW_PLATFORM_CONTEXT_STATE;
|
||||
};
|
||||
|
||||
@ -269,6 +297,16 @@ struct _GLFWmonitor
|
||||
};
|
||||
|
||||
|
||||
/*! @brief Cursor structure
|
||||
*/
|
||||
struct _GLFWcursor
|
||||
{
|
||||
_GLFWcursor* next;
|
||||
|
||||
// This is defined in the window API's platform.h
|
||||
_GLFW_PLATFORM_CURSOR_STATE;
|
||||
};
|
||||
|
||||
/*! @brief Library global data.
|
||||
*/
|
||||
struct _GLFWlibrary
|
||||
@ -285,24 +323,31 @@ struct _GLFWlibrary
|
||||
int accumBlueBits;
|
||||
int accumAlphaBits;
|
||||
int auxBuffers;
|
||||
GLboolean stereo;
|
||||
GLboolean resizable;
|
||||
GLboolean visible;
|
||||
GLboolean decorated;
|
||||
int stereo;
|
||||
int resizable;
|
||||
int visible;
|
||||
int decorated;
|
||||
int focused;
|
||||
int autoIconify;
|
||||
int floating;
|
||||
int samples;
|
||||
GLboolean sRGB;
|
||||
int sRGB;
|
||||
int refreshRate;
|
||||
int clientAPI;
|
||||
int glMajor;
|
||||
int glMinor;
|
||||
GLboolean glForward;
|
||||
GLboolean glDebug;
|
||||
int glProfile;
|
||||
int glRobustness;
|
||||
int doublebuffer;
|
||||
int api;
|
||||
int major;
|
||||
int minor;
|
||||
int forward;
|
||||
int debug;
|
||||
int profile;
|
||||
int robustness;
|
||||
int release;
|
||||
} hints;
|
||||
|
||||
double cursorPosX, cursorPosY;
|
||||
|
||||
_GLFWcursor* cursorListHead;
|
||||
|
||||
_GLFWwindow* windowListHead;
|
||||
_GLFWwindow* focusedWindow;
|
||||
|
||||
@ -315,8 +360,14 @@ struct _GLFWlibrary
|
||||
|
||||
// This is defined in the window API's platform.h
|
||||
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
|
||||
// This is defined in the context API's platform.h
|
||||
_GLFW_PLATFORM_LIBRARY_OPENGL_STATE;
|
||||
// This is defined in the context API's context.h
|
||||
_GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;
|
||||
// This is defined in the platform's time.h
|
||||
_GLFW_PLATFORM_LIBRARY_TIME_STATE;
|
||||
// This is defined in the platform's joystick.h
|
||||
_GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
|
||||
// This is defined in the platform's tls.h
|
||||
_GLFW_PLATFORM_LIBRARY_TLS_STATE;
|
||||
};
|
||||
|
||||
|
||||
@ -359,17 +410,21 @@ void _glfwPlatformTerminate(void);
|
||||
*/
|
||||
const char* _glfwPlatformGetVersionString(void);
|
||||
|
||||
/*! @copydoc glfwGetCursorPos
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos);
|
||||
|
||||
/*! @copydoc glfwSetCursorPos
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
||||
|
||||
/*! @brief Sets up the specified cursor mode for the specified window.
|
||||
* @param[in] window The window whose cursor mode to change.
|
||||
* @param[in] mode The desired cursor mode.
|
||||
/*! @brief Applies the cursor mode of the specified window to the system.
|
||||
* @param[in] window The window whose cursor mode to apply.
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
|
||||
void _glfwPlatformApplyCursorMode(_GLFWwindow* window);
|
||||
|
||||
/*! @copydoc glfwGetMonitors
|
||||
* @ingroup platform
|
||||
@ -457,6 +512,7 @@ void _glfwPlatformSetTime(double time);
|
||||
*/
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
|
||||
/*! @ingroup platform
|
||||
@ -493,6 +549,11 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
|
||||
*/
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
|
||||
|
||||
/*! @copydoc glfwGetWindowFrameSize
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||
|
||||
/*! @copydoc glfwIconifyWindow
|
||||
* @ingroup platform
|
||||
*/
|
||||
@ -508,11 +569,30 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window);
|
||||
*/
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
||||
|
||||
/*! @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window);
|
||||
|
||||
/*! @copydoc glfwHideWindow
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
||||
|
||||
/*! @brief Returns whether the window is focused.
|
||||
* @ingroup platform
|
||||
*/
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window);
|
||||
|
||||
/*! @brief Returns whether the window is iconified.
|
||||
* @ingroup platform
|
||||
*/
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
||||
|
||||
/*! @brief Returns whether the window is visible.
|
||||
* @ingroup platform
|
||||
*/
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window);
|
||||
|
||||
/*! @copydoc glfwPollEvents
|
||||
* @ingroup platform
|
||||
*/
|
||||
@ -523,6 +603,11 @@ void _glfwPlatformPollEvents(void);
|
||||
*/
|
||||
void _glfwPlatformWaitEvents(void);
|
||||
|
||||
/*! @copydoc glfwPostEmptyEvent
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformPostEmptyEvent(void);
|
||||
|
||||
/*! @copydoc glfwMakeContextCurrent
|
||||
* @ingroup platform
|
||||
*/
|
||||
@ -543,7 +628,8 @@ void _glfwPlatformSwapBuffers(_GLFWwindow* window);
|
||||
*/
|
||||
void _glfwPlatformSwapInterval(int interval);
|
||||
|
||||
/*! @ingroup platform
|
||||
/*! @copydoc glfwExtensionSupported
|
||||
* @ingroup platform
|
||||
*/
|
||||
int _glfwPlatformExtensionSupported(const char* extension);
|
||||
|
||||
@ -552,6 +638,26 @@ int _glfwPlatformExtensionSupported(const char* extension);
|
||||
*/
|
||||
GLFWglproc _glfwPlatformGetProcAddress(const char* procname);
|
||||
|
||||
/*! @copydoc glfwCreateCursor
|
||||
* @ingroup platform
|
||||
*/
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||
|
||||
/*! @copydoc glfwCreateStandardCursor
|
||||
* @ingroup platform
|
||||
*/
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape);
|
||||
|
||||
/*! @copydoc glfwDestroyCursor
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor);
|
||||
|
||||
/*! @copydoc glfwSetCursor
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Event API functions
|
||||
@ -597,14 +703,6 @@ void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
|
||||
*/
|
||||
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
||||
|
||||
/*! @brief Notifies shared code of a window show/hide event.
|
||||
* @param[in] window The window that received the event.
|
||||
* @param[in] visible `GL_TRUE` if the window was shown, or `GL_FALSE` if it
|
||||
* was hidden.
|
||||
* @ingroup event
|
||||
*/
|
||||
void _glfwInputWindowVisibility(_GLFWwindow* window, int visible);
|
||||
|
||||
/*! @brief Notifies shared code of a window damage event.
|
||||
* @param[in] window The window that received the event.
|
||||
*/
|
||||
@ -629,9 +727,12 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
||||
/*! @brief Notifies shared code of a Unicode character input event.
|
||||
* @param[in] window The window that received the event.
|
||||
* @param[in] codepoint The Unicode code point of the input character.
|
||||
* @param[in] mods Bit field describing which modifier keys were held down.
|
||||
* @param[in] plain `GL_TRUE` if the character is regular text input, or
|
||||
* `GL_FALSE` otherwise.
|
||||
* @ingroup event
|
||||
*/
|
||||
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint);
|
||||
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, int plain);
|
||||
|
||||
/*! @brief Notifies shared code of a scroll event.
|
||||
* @param[in] window The window that received the event.
|
||||
@ -679,6 +780,14 @@ void _glfwInputMonitorChange(void);
|
||||
*/
|
||||
void _glfwInputError(int error, const char* format, ...);
|
||||
|
||||
/*! @brief Notifies dropped object over window.
|
||||
* @param[in] window The window that received the event.
|
||||
* @param[in] count The number of dropped objects.
|
||||
* @param[in] names The names of the dropped objects.
|
||||
* @ingroup event
|
||||
*/
|
||||
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Utility functions
|
||||
@ -720,13 +829,14 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
unsigned int count);
|
||||
|
||||
/*! @brief Retrieves the attributes of the current context.
|
||||
* @param[in] ctxconfig The desired context attributes.
|
||||
* @return `GL_TRUE` if successful, or `GL_FALSE` if the context is unusable.
|
||||
* @ingroup utility
|
||||
*/
|
||||
GLboolean _glfwRefreshContextAttribs(void);
|
||||
GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig);
|
||||
|
||||
/*! @brief Checks whether the desired context attributes are valid.
|
||||
* @param[in] wndconfig The context attributes to check.
|
||||
* @param[in] ctxconfig The context attributes to check.
|
||||
* @return `GL_TRUE` if the context attributes are valid, or `GL_FALSE`
|
||||
* otherwise.
|
||||
* @ingroup utility
|
||||
@ -735,16 +845,16 @@ GLboolean _glfwRefreshContextAttribs(void);
|
||||
* exists and whether all relevant options have supported and non-conflicting
|
||||
* values.
|
||||
*/
|
||||
GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig);
|
||||
GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
|
||||
|
||||
/*! @brief Checks whether the current context fulfils the specified hard
|
||||
* constraints.
|
||||
* @param[in] wndconfig The desired context attributes.
|
||||
* @param[in] ctxconfig The desired context attributes.
|
||||
* @return `GL_TRUE` if the context fulfils the hard constraints, or `GL_FALSE`
|
||||
* otherwise.
|
||||
* @ingroup utility
|
||||
*/
|
||||
GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig);
|
||||
GLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig);
|
||||
|
||||
/*! @ingroup utility
|
||||
*/
|
||||
@ -762,15 +872,15 @@ void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
||||
* @return The newly created object.
|
||||
* @ingroup utility
|
||||
*/
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM);
|
||||
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
|
||||
|
||||
/*! @brief Frees a monitor object and any data associated with it.
|
||||
* @ingroup utility
|
||||
*/
|
||||
void _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||
void _glfwFreeMonitor(_GLFWmonitor* monitor);
|
||||
|
||||
/*! @ingroup utility
|
||||
*/
|
||||
void _glfwDestroyMonitors(_GLFWmonitor** monitors, int count);
|
||||
void _glfwFreeMonitors(_GLFWmonitor** monitors, int count);
|
||||
|
||||
#endif // _internal_h_
|
||||
|
61
extern/glfw/src/iokit_joystick.h
vendored
Normal file
61
extern/glfw/src/iokit_joystick.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
//========================================================================
|
||||
// GLFW 3.1 IOKit - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2014 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.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _iokit_joystick_h_
|
||||
#define _iokit_joystick_h_
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
#include <IOKit/hid/IOHIDKeys.h>
|
||||
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
|
||||
_GLFWjoystickIOKit iokit_js[GLFW_JOYSTICK_LAST + 1]
|
||||
|
||||
|
||||
// IOKit-specific per-joystick data
|
||||
//
|
||||
typedef struct _GLFWjoystickIOKit
|
||||
{
|
||||
int present;
|
||||
char name[256];
|
||||
|
||||
IOHIDDeviceInterface** interface;
|
||||
|
||||
CFMutableArrayRef axisElements;
|
||||
CFMutableArrayRef buttonElements;
|
||||
CFMutableArrayRef hatElements;
|
||||
|
||||
float* axes;
|
||||
unsigned char* buttons;
|
||||
|
||||
} _GLFWjoystickIOKit;
|
||||
|
||||
|
||||
void _glfwInitJoysticks(void);
|
||||
void _glfwTerminateJoysticks(void);
|
||||
|
||||
#endif // _iokit_joystick_h_
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 IOKit - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
||||
@ -58,7 +58,7 @@ static void getElementsCFArrayHandler(const void* value, void* parameter);
|
||||
|
||||
// Adds an element to the specified joystick
|
||||
//
|
||||
static void addJoystickElement(_GLFWjoy* joystick, CFTypeRef elementRef)
|
||||
static void addJoystickElement(_GLFWjoystickIOKit* joystick, CFTypeRef elementRef)
|
||||
{
|
||||
long elementType, usagePage, usage;
|
||||
CFMutableArrayRef elementsArray = NULL;
|
||||
@ -146,12 +146,12 @@ static void addJoystickElement(_GLFWjoy* joystick, CFTypeRef elementRef)
|
||||
static void getElementsCFArrayHandler(const void* value, void* parameter)
|
||||
{
|
||||
if (CFGetTypeID(value) == CFDictionaryGetTypeID())
|
||||
addJoystickElement((_GLFWjoy*) parameter, (CFTypeRef) value);
|
||||
addJoystickElement((_GLFWjoystickIOKit*) parameter, (CFTypeRef) value);
|
||||
}
|
||||
|
||||
// Returns the value of the specified element of the specified joystick
|
||||
//
|
||||
static long getElementValue(_GLFWjoy* joystick, _GLFWjoyelement* element)
|
||||
static long getElementValue(_GLFWjoystickIOKit* joystick, _GLFWjoyelement* element)
|
||||
{
|
||||
IOReturn result = kIOReturnSuccess;
|
||||
IOHIDEventStruct hidEvent;
|
||||
@ -178,7 +178,7 @@ static long getElementValue(_GLFWjoy* joystick, _GLFWjoyelement* element)
|
||||
|
||||
// Removes the specified joystick
|
||||
//
|
||||
static void removeJoystick(_GLFWjoy* joystick)
|
||||
static void removeJoystick(_GLFWjoystickIOKit* joystick)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -203,14 +203,14 @@ static void removeJoystick(_GLFWjoy* joystick)
|
||||
(*(joystick->interface))->close(joystick->interface);
|
||||
(*(joystick->interface))->Release(joystick->interface);
|
||||
|
||||
memset(joystick, 0, sizeof(_GLFWjoy));
|
||||
memset(joystick, 0, sizeof(_GLFWjoystickIOKit));
|
||||
}
|
||||
|
||||
// Callback for user-initiated joystick removal
|
||||
//
|
||||
static void removalCallback(void* target, IOReturn result, void* refcon, void* sender)
|
||||
{
|
||||
removeJoystick((_GLFWjoy*) refcon);
|
||||
removeJoystick((_GLFWjoystickIOKit*) refcon);
|
||||
}
|
||||
|
||||
// Polls for joystick events and updates GLFW state
|
||||
@ -223,7 +223,7 @@ static void pollJoystickEvents(void)
|
||||
{
|
||||
CFIndex i;
|
||||
int buttonIndex = 0;
|
||||
_GLFWjoy* joystick = _glfw.ns.joysticks + joy;
|
||||
_GLFWjoystickIOKit* joystick = _glfw.iokit_js + joy;
|
||||
|
||||
if (!joystick->present)
|
||||
continue;
|
||||
@ -324,49 +324,50 @@ void _glfwInitJoysticks(void)
|
||||
HRESULT plugInResult = S_OK;
|
||||
SInt32 score = 0;
|
||||
|
||||
long usagePage, usage;
|
||||
long usagePage = 0;
|
||||
long usage = 0;
|
||||
|
||||
// Check device type
|
||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
||||
CFSTR(kIOHIDPrimaryUsagePageKey),
|
||||
kCFAllocatorDefault, kNilOptions);
|
||||
if (valueRef)
|
||||
{
|
||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage);
|
||||
CFRelease(valueRef);
|
||||
}
|
||||
|
||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
||||
CFSTR(kIOHIDPrimaryUsageKey),
|
||||
kCFAllocatorDefault, kNilOptions);
|
||||
if (valueRef)
|
||||
{
|
||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usage);
|
||||
CFRelease(valueRef);
|
||||
}
|
||||
|
||||
if (usagePage != kHIDPage_GenericDesktop)
|
||||
{
|
||||
// This device is not relevant to GLFW
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((usage != kHIDUsage_GD_Joystick &&
|
||||
usage != kHIDUsage_GD_GamePad &&
|
||||
usage != kHIDUsage_GD_MultiAxisController))
|
||||
{
|
||||
// This device is not relevant to GLFW
|
||||
continue;
|
||||
}
|
||||
|
||||
result = IORegistryEntryCreateCFProperties(ioHIDDeviceObject,
|
||||
&propsRef,
|
||||
kCFAllocatorDefault,
|
||||
kNilOptions);
|
||||
|
||||
|
||||
if (result != kIOReturnSuccess)
|
||||
continue;
|
||||
|
||||
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsagePageKey));
|
||||
if (valueRef)
|
||||
{
|
||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage);
|
||||
if (usagePage != kHIDPage_GenericDesktop)
|
||||
{
|
||||
// This device is not relevant to GLFW
|
||||
CFRelease(valueRef);
|
||||
continue;
|
||||
}
|
||||
|
||||
CFRelease(valueRef);
|
||||
}
|
||||
|
||||
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsageKey));
|
||||
if (valueRef)
|
||||
{
|
||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usage);
|
||||
|
||||
if ((usage != kHIDUsage_GD_Joystick &&
|
||||
usage != kHIDUsage_GD_GamePad &&
|
||||
usage != kHIDUsage_GD_MultiAxisController))
|
||||
{
|
||||
// This device is not relevant to GLFW
|
||||
CFRelease(valueRef);
|
||||
continue;
|
||||
}
|
||||
|
||||
CFRelease(valueRef);
|
||||
}
|
||||
|
||||
_GLFWjoy* joystick = _glfw.ns.joysticks + joy;
|
||||
_GLFWjoystickIOKit* joystick = _glfw.iokit_js + joy;
|
||||
joystick->present = GL_TRUE;
|
||||
|
||||
result = IOCreatePlugInInterfaceForService(ioHIDDeviceObject,
|
||||
@ -376,7 +377,10 @@ void _glfwInitJoysticks(void)
|
||||
&score);
|
||||
|
||||
if (kIOReturnSuccess != result)
|
||||
{
|
||||
CFRelease(propsRef);
|
||||
return;
|
||||
}
|
||||
|
||||
plugInResult = (*ppPlugInInterface)->QueryInterface(
|
||||
ppPlugInInterface,
|
||||
@ -384,7 +388,10 @@ void _glfwInitJoysticks(void)
|
||||
(void *) &(joystick->interface));
|
||||
|
||||
if (plugInResult != S_OK)
|
||||
{
|
||||
CFRelease(propsRef);
|
||||
return;
|
||||
}
|
||||
|
||||
(*ppPlugInInterface)->Release(ppPlugInInterface);
|
||||
|
||||
@ -402,7 +409,6 @@ void _glfwInitJoysticks(void)
|
||||
joystick->name,
|
||||
sizeof(joystick->name),
|
||||
kCFStringEncodingUTF8);
|
||||
CFRelease(valueRef);
|
||||
}
|
||||
|
||||
joystick->axisElements = CFArrayCreateMutable(NULL, 0, NULL);
|
||||
@ -417,9 +423,10 @@ void _glfwInitJoysticks(void)
|
||||
range,
|
||||
getElementsCFArrayHandler,
|
||||
(void*) joystick);
|
||||
CFRelease(valueRef);
|
||||
}
|
||||
|
||||
CFRelease(propsRef);
|
||||
|
||||
joystick->axes = calloc(CFArrayGetCount(joystick->axisElements),
|
||||
sizeof(float));
|
||||
joystick->buttons = calloc(CFArrayGetCount(joystick->buttonElements) +
|
||||
@ -439,8 +446,15 @@ void _glfwTerminateJoysticks(void)
|
||||
|
||||
for (i = 0; i < GLFW_JOYSTICK_LAST + 1; i++)
|
||||
{
|
||||
_GLFWjoy* joystick = &_glfw.ns.joysticks[i];
|
||||
_GLFWjoystickIOKit* joystick = &_glfw.iokit_js[i];
|
||||
removeJoystick(joystick);
|
||||
|
||||
if (joystick->axisElements)
|
||||
CFRelease(joystick->axisElements);
|
||||
if (joystick->buttonElements)
|
||||
CFRelease(joystick->buttonElements);
|
||||
if (joystick->hatElements)
|
||||
CFRelease(joystick->hatElements);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,12 +467,12 @@ int _glfwPlatformJoystickPresent(int joy)
|
||||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
return _glfw.ns.joysticks[joy].present;
|
||||
return _glfw.iokit_js[joy].present;
|
||||
}
|
||||
|
||||
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
||||
{
|
||||
_GLFWjoy* joystick = _glfw.ns.joysticks + joy;
|
||||
_GLFWjoystickIOKit* joystick = _glfw.iokit_js + joy;
|
||||
|
||||
pollJoystickEvents();
|
||||
|
||||
@ -471,7 +485,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
||||
|
||||
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
||||
{
|
||||
_GLFWjoy* joystick = _glfw.ns.joysticks + joy;
|
||||
_GLFWjoystickIOKit* joystick = _glfw.iokit_js + joy;
|
||||
|
||||
pollJoystickEvents();
|
||||
|
||||
@ -487,6 +501,6 @@ const char* _glfwPlatformGetJoystickName(int joy)
|
||||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
return _glfw.ns.joysticks[joy].name;
|
||||
return _glfw.iokit_js[joy].name;
|
||||
}
|
||||
|
90
extern/glfw/src/joystick.c
vendored
90
extern/glfw/src/joystick.c
vendored
@ -1,90 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - 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);
|
||||
}
|
||||
|
BIN
extern/glfw/src/libglfw3.a
vendored
Normal file
BIN
extern/glfw/src/libglfw3.a
vendored
Normal file
Binary file not shown.
322
extern/glfw/src/linux_joystick.c
vendored
Normal file
322
extern/glfw/src/linux_joystick.c
vendored
Normal file
@ -0,0 +1,322 @@
|
||||
//========================================================================
|
||||
// GLFW 3.1 Linux - 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"
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/joystick.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#endif // __linux__
|
||||
|
||||
|
||||
// Attempt to open the specified joystick device
|
||||
//
|
||||
static void openJoystickDevice(const char* path)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
char axisCount, buttonCount;
|
||||
char name[256];
|
||||
int joy, fd, version;
|
||||
|
||||
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
|
||||
{
|
||||
if (!_glfw.linux_js.js[joy].present)
|
||||
continue;
|
||||
|
||||
if (strcmp(_glfw.linux_js.js[joy].path, path) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
|
||||
{
|
||||
if (!_glfw.linux_js.js[joy].present)
|
||||
break;
|
||||
}
|
||||
|
||||
if (joy > GLFW_JOYSTICK_LAST)
|
||||
return;
|
||||
|
||||
fd = open(path, O_RDONLY | O_NONBLOCK);
|
||||
if (fd == -1)
|
||||
return;
|
||||
|
||||
_glfw.linux_js.js[joy].fd = fd;
|
||||
|
||||
// Verify that the joystick driver version is at least 1.0
|
||||
ioctl(fd, JSIOCGVERSION, &version);
|
||||
if (version < 0x010000)
|
||||
{
|
||||
// It's an old 0.x interface (we don't support it)
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
|
||||
strncpy(name, "Unknown", sizeof(name));
|
||||
|
||||
_glfw.linux_js.js[joy].name = strdup(name);
|
||||
_glfw.linux_js.js[joy].path = strdup(path);
|
||||
|
||||
ioctl(fd, JSIOCGAXES, &axisCount);
|
||||
_glfw.linux_js.js[joy].axisCount = (int) axisCount;
|
||||
|
||||
ioctl(fd, JSIOCGBUTTONS, &buttonCount);
|
||||
_glfw.linux_js.js[joy].buttonCount = (int) buttonCount;
|
||||
|
||||
_glfw.linux_js.js[joy].axes = calloc(axisCount, sizeof(float));
|
||||
_glfw.linux_js.js[joy].buttons = calloc(buttonCount, 1);
|
||||
|
||||
_glfw.linux_js.js[joy].present = GL_TRUE;
|
||||
#endif // __linux__
|
||||
}
|
||||
|
||||
// Polls for and processes events for all present joysticks
|
||||
//
|
||||
static void pollJoystickEvents(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
int i;
|
||||
struct js_event e;
|
||||
ssize_t offset = 0;
|
||||
char buffer[16384];
|
||||
|
||||
const ssize_t size = read(_glfw.linux_js.inotify, buffer, sizeof(buffer));
|
||||
|
||||
while (size > offset)
|
||||
{
|
||||
regmatch_t match;
|
||||
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
|
||||
|
||||
if (regexec(&_glfw.linux_js.regex, e->name, 1, &match, 0) == 0)
|
||||
{
|
||||
char path[20];
|
||||
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
|
||||
openJoystickDevice(path);
|
||||
}
|
||||
|
||||
offset += sizeof(struct inotify_event) + e->len;
|
||||
}
|
||||
|
||||
for (i = 0; i <= GLFW_JOYSTICK_LAST; i++)
|
||||
{
|
||||
if (!_glfw.linux_js.js[i].present)
|
||||
continue;
|
||||
|
||||
// Read all queued events (non-blocking)
|
||||
for (;;)
|
||||
{
|
||||
errno = 0;
|
||||
if (read(_glfw.linux_js.js[i].fd, &e, sizeof(e)) < 0)
|
||||
{
|
||||
if (errno == ENODEV)
|
||||
{
|
||||
// The joystick was disconnected
|
||||
|
||||
free(_glfw.linux_js.js[i].axes);
|
||||
free(_glfw.linux_js.js[i].buttons);
|
||||
free(_glfw.linux_js.js[i].name);
|
||||
free(_glfw.linux_js.js[i].path);
|
||||
|
||||
memset(&_glfw.linux_js.js[i], 0, sizeof(_glfw.linux_js.js[i]));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// We don't care if it's an init event or not
|
||||
e.type &= ~JS_EVENT_INIT;
|
||||
|
||||
switch (e.type)
|
||||
{
|
||||
case JS_EVENT_AXIS:
|
||||
_glfw.linux_js.js[i].axes[e.number] =
|
||||
(float) e.value / 32767.0f;
|
||||
break;
|
||||
|
||||
case JS_EVENT_BUTTON:
|
||||
_glfw.linux_js.js[i].buttons[e.number] =
|
||||
e.value ? GLFW_PRESS : GLFW_RELEASE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // __linux__
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialize joystick interface
|
||||
//
|
||||
int _glfwInitJoysticks(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
const char* dirname = "/dev/input";
|
||||
DIR* dir;
|
||||
|
||||
_glfw.linux_js.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||
if (_glfw.linux_js.inotify == -1)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Linux: Failed to initialize inotify: %s",
|
||||
strerror(errno));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// HACK: Register for IN_ATTRIB as well to get notified when udev is done
|
||||
// This works well in practice but the true way is libudev
|
||||
|
||||
_glfw.linux_js.watch = inotify_add_watch(_glfw.linux_js.inotify,
|
||||
dirname,
|
||||
IN_CREATE | IN_ATTRIB);
|
||||
if (_glfw.linux_js.watch == -1)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Linux: Failed to watch for joystick connections in %s: %s",
|
||||
dirname,
|
||||
strerror(errno));
|
||||
// Continue without device connection notifications
|
||||
}
|
||||
|
||||
if (regcomp(&_glfw.linux_js.regex, "^js[0-9]\\+$", 0) != 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
dir = opendir(dirname);
|
||||
if (dir)
|
||||
{
|
||||
struct dirent* entry;
|
||||
|
||||
while ((entry = readdir(dir)))
|
||||
{
|
||||
char path[20];
|
||||
regmatch_t match;
|
||||
|
||||
if (regexec(&_glfw.linux_js.regex, entry->d_name, 1, &match, 0) != 0)
|
||||
continue;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
|
||||
openJoystickDevice(path);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Linux: Failed to open joystick device directory %s: %s",
|
||||
dirname,
|
||||
strerror(errno));
|
||||
// Continue with no joysticks detected
|
||||
}
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
// Close all opened joystick handles
|
||||
//
|
||||
void _glfwTerminateJoysticks(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= GLFW_JOYSTICK_LAST; i++)
|
||||
{
|
||||
if (_glfw.linux_js.js[i].present)
|
||||
{
|
||||
close(_glfw.linux_js.js[i].fd);
|
||||
free(_glfw.linux_js.js[i].axes);
|
||||
free(_glfw.linux_js.js[i].buttons);
|
||||
free(_glfw.linux_js.js[i].name);
|
||||
free(_glfw.linux_js.js[i].path);
|
||||
}
|
||||
}
|
||||
|
||||
regfree(&_glfw.linux_js.regex);
|
||||
|
||||
if (_glfw.linux_js.watch > 0)
|
||||
close(_glfw.linux_js.watch);
|
||||
|
||||
if (_glfw.linux_js.inotify > 0)
|
||||
close(_glfw.linux_js.inotify);
|
||||
#endif // __linux__
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformJoystickPresent(int joy)
|
||||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
return _glfw.linux_js.js[joy].present;
|
||||
}
|
||||
|
||||
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
||||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
*count = _glfw.linux_js.js[joy].axisCount;
|
||||
return _glfw.linux_js.js[joy].axes;
|
||||
}
|
||||
|
||||
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
||||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
*count = _glfw.linux_js.js[joy].buttonCount;
|
||||
return _glfw.linux_js.js[joy].buttons;
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetJoystickName(int joy)
|
||||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
return _glfw.linux_js.js[joy].name;
|
||||
}
|
||||
|
63
extern/glfw/src/linux_joystick.h
vendored
Normal file
63
extern/glfw/src/linux_joystick.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
//========================================================================
|
||||
// GLFW 3.1 Linux - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _linux_joystick_h_
|
||||
#define _linux_joystick_h_
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
|
||||
_GLFWjoystickLinux linux_js
|
||||
|
||||
|
||||
// Linux-specific joystick API data
|
||||
//
|
||||
typedef struct _GLFWjoystickLinux
|
||||
{
|
||||
struct
|
||||
{
|
||||
int present;
|
||||
int fd;
|
||||
float* axes;
|
||||
int axisCount;
|
||||
unsigned char* buttons;
|
||||
int buttonCount;
|
||||
char* name;
|
||||
char* path;
|
||||
} js[GLFW_JOYSTICK_LAST + 1];
|
||||
|
||||
#if defined(__linux__)
|
||||
int inotify;
|
||||
int watch;
|
||||
regex_t regex;
|
||||
#endif /*__linux__*/
|
||||
} _GLFWjoystickLinux;
|
||||
|
||||
|
||||
int _glfwInitJoysticks(void);
|
||||
void _glfwTerminateJoysticks(void);
|
||||
|
||||
#endif // _linux_joystick_h_
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -48,8 +48,8 @@ void _glfwInitTimer(void)
|
||||
mach_timebase_info_data_t info;
|
||||
mach_timebase_info(&info);
|
||||
|
||||
_glfw.ns.timer.resolution = (double) info.numer / (info.denom * 1.0e9);
|
||||
_glfw.ns.timer.base = getRawTime();
|
||||
_glfw.ns_time.resolution = (double) info.numer / (info.denom * 1.0e9);
|
||||
_glfw.ns_time.base = getRawTime();
|
||||
}
|
||||
|
||||
|
||||
@ -59,13 +59,13 @@ void _glfwInitTimer(void)
|
||||
|
||||
double _glfwPlatformGetTime(void)
|
||||
{
|
||||
return (double) (getRawTime() - _glfw.ns.timer.base) *
|
||||
_glfw.ns.timer.resolution;
|
||||
return (double) (getRawTime() - _glfw.ns_time.base) *
|
||||
_glfw.ns_time.resolution;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetTime(double time)
|
||||
{
|
||||
_glfw.ns.timer.base = getRawTime() -
|
||||
(uint64_t) (time / _glfw.ns.timer.resolution);
|
||||
_glfw.ns_time.base = getRawTime() -
|
||||
(uint64_t) (time / _glfw.ns_time.resolution);
|
||||
}
|
||||
|
101
extern/glfw/src/mir_init.c
vendored
Normal file
101
extern/glfw/src/mir_init.c
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
//========================================================================
|
||||
// GLFW 3.1 Mir - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformInit(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
_glfw.mir.connection = mir_connect_sync(NULL, __PRETTY_FUNCTION__);
|
||||
|
||||
if (!mir_connection_is_valid(_glfw.mir.connection))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unable to connect to server: %s",
|
||||
mir_connection_get_error_message(_glfw.mir.connection));
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfw.mir.display =
|
||||
mir_connection_get_egl_native_display(_glfw.mir.connection);
|
||||
|
||||
if (!_glfwInitContextAPI())
|
||||
return GL_FALSE;
|
||||
|
||||
_glfwInitTimer();
|
||||
_glfwInitJoysticks();
|
||||
|
||||
_glfw.mir.event_queue = calloc(1, sizeof(EventQueue));
|
||||
_glfwInitEventQueue(_glfw.mir.event_queue);
|
||||
|
||||
error = pthread_mutex_init(&_glfw.mir.event_mutex, NULL);
|
||||
if (error)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Failed to create event mutex: %s\n",
|
||||
strerror(error));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminate(void)
|
||||
{
|
||||
_glfwTerminateContextAPI();
|
||||
_glfwTerminateJoysticks();
|
||||
|
||||
_glfwDeleteEventQueue(_glfw.mir.event_queue);
|
||||
|
||||
pthread_mutex_destroy(&_glfw.mir.event_mutex);
|
||||
|
||||
mir_connection_release(_glfw.mir.connection);
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
{
|
||||
const char* version = _GLFW_VERSION_NUMBER " Mir EGL"
|
||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
" clock_gettime"
|
||||
#endif
|
||||
#if defined(_GLFW_BUILD_DLL)
|
||||
" shared"
|
||||
#endif
|
||||
;
|
||||
|
||||
return version;
|
||||
}
|
||||
|
138
extern/glfw/src/mir_monitor.c
vendored
Normal file
138
extern/glfw/src/mir_monitor.c
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
//========================================================================
|
||||
// GLFW 3.1 Mir - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
{
|
||||
int i, found = 0;
|
||||
_GLFWmonitor** monitors = NULL;
|
||||
MirDisplayConfiguration* displayConfig =
|
||||
mir_connection_create_display_config(_glfw.mir.connection);
|
||||
|
||||
*count = 0;
|
||||
|
||||
for (i = 0; i < displayConfig->num_outputs; i++)
|
||||
{
|
||||
const MirDisplayOutput* out = displayConfig->outputs + i;
|
||||
|
||||
if (out->used &&
|
||||
out->connected &&
|
||||
out->num_modes &&
|
||||
out->current_mode < out->num_modes)
|
||||
{
|
||||
found++;
|
||||
monitors = realloc(monitors, sizeof(_GLFWmonitor*) * found);
|
||||
monitors[i] = _glfwAllocMonitor("Unknown",
|
||||
out->physical_width_mm,
|
||||
out->physical_height_mm);
|
||||
|
||||
monitors[i]->mir.x = out->position_x;
|
||||
monitors[i]->mir.y = out->position_y;
|
||||
monitors[i]->mir.output_id = out->output_id;
|
||||
monitors[i]->mir.cur_mode = out->current_mode;
|
||||
|
||||
monitors[i]->modes = _glfwPlatformGetVideoModes(monitors[i],
|
||||
&monitors[i]->modeCount);
|
||||
}
|
||||
}
|
||||
|
||||
mir_display_config_destroy(displayConfig);
|
||||
|
||||
*count = found;
|
||||
return monitors;
|
||||
}
|
||||
|
||||
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
|
||||
{
|
||||
return first->mir.output_id == second->mir.output_id;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = monitor->mir.x;
|
||||
if (ypos)
|
||||
*ypos = monitor->mir.y;
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
{
|
||||
int i;
|
||||
GLFWvidmode* modes = NULL;
|
||||
MirDisplayConfiguration* displayConfig =
|
||||
mir_connection_create_display_config(_glfw.mir.connection);
|
||||
|
||||
for (i = 0; i < displayConfig->num_outputs; i++)
|
||||
{
|
||||
const MirDisplayOutput* out = displayConfig->outputs + i;
|
||||
if (out->output_id != monitor->mir.output_id)
|
||||
continue;
|
||||
|
||||
modes = calloc(out->num_modes, sizeof(GLFWvidmode));
|
||||
|
||||
for (*found = 0; *found < out->num_modes; (*found)++)
|
||||
{
|
||||
modes[*found].width = out->modes[*found].horizontal_resolution;
|
||||
modes[*found].height = out->modes[*found].vertical_resolution;
|
||||
modes[*found].refreshRate = out->modes[*found].refresh_rate;
|
||||
modes[*found].redBits = 8;
|
||||
modes[*found].greenBits = 8;
|
||||
modes[*found].blueBits = 8;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
mir_display_config_destroy(displayConfig);
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
*mode = monitor->modes[monitor->mir.cur_mode];
|
||||
}
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
110
extern/glfw/src/mir_platform.h
vendored
Normal file
110
extern/glfw/src/mir_platform.h
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
//========================================================================
|
||||
// GLFW 3.1 Mir - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _mir_platform_h_
|
||||
#define _mir_platform_h_
|
||||
|
||||
#include <mir_toolkit/mir_client_library.h>
|
||||
|
||||
#include "posix_tls.h"
|
||||
#include "posix_time.h"
|
||||
#include "linux_joystick.h"
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#if defined(_GLFW_EGL)
|
||||
#include "egl_context.h"
|
||||
#else
|
||||
#error "The Mir backend depends on EGL platform support"
|
||||
#endif
|
||||
|
||||
#define _GLFW_EGL_NATIVE_WINDOW window->mir.window
|
||||
#define _GLFW_EGL_NATIVE_DISPLAY _glfw.mir.display
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowMir mir
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorMir mir
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryMir mir
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorMir mir
|
||||
|
||||
// Mir-specific Event Queue
|
||||
//
|
||||
typedef struct EventQueue
|
||||
{
|
||||
TAILQ_HEAD(, EventNode) head;
|
||||
} EventQueue;
|
||||
|
||||
// Mir-specific per-window data
|
||||
//
|
||||
typedef struct _GLFWwindowMir
|
||||
{
|
||||
MirSurface* surface;
|
||||
int width;
|
||||
int height;
|
||||
MirEGLNativeWindowType window;
|
||||
|
||||
} _GLFWwindowMir;
|
||||
|
||||
|
||||
// Mir-specific per-monitor data
|
||||
//
|
||||
typedef struct _GLFWmonitorMir
|
||||
{
|
||||
int cur_mode;
|
||||
int output_id;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
} _GLFWmonitorMir;
|
||||
|
||||
|
||||
// Mir-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryMir
|
||||
{
|
||||
MirConnection* connection;
|
||||
MirEGLNativeDisplayType display;
|
||||
EventQueue* event_queue;
|
||||
|
||||
pthread_mutex_t event_mutex;
|
||||
pthread_cond_t event_cond;
|
||||
|
||||
} _GLFWlibraryMir;
|
||||
|
||||
|
||||
// Mir-specific per-cursor data
|
||||
// TODO: Only system cursors are implemented in Mir atm. Need to wait for support.
|
||||
//
|
||||
typedef struct _GLFWcursorMir
|
||||
{
|
||||
} _GLFWcursorMir;
|
||||
|
||||
|
||||
extern void _glfwInitEventQueue(EventQueue* queue);
|
||||
extern void _glfwDeleteEventQueue(EventQueue* queue);
|
||||
|
||||
#endif // _mir_platform_h_
|
687
extern/glfw/src/mir_window.c
vendored
Normal file
687
extern/glfw/src/mir_window.c
vendored
Normal file
@ -0,0 +1,687 @@
|
||||
//========================================================================
|
||||
// GLFW 3.1 Mir - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
|
||||
//
|
||||
// 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"
|
||||
#include "xkb_unicode.h"
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
typedef struct EventNode
|
||||
{
|
||||
TAILQ_ENTRY(EventNode) entries;
|
||||
MirEvent* event;
|
||||
_GLFWwindow* window;
|
||||
} EventNode;
|
||||
|
||||
static void deleteNode(EventQueue* queue, EventNode* node)
|
||||
{
|
||||
free(node->event);
|
||||
free(node);
|
||||
}
|
||||
|
||||
static int emptyEventQueue(EventQueue* queue)
|
||||
{
|
||||
return queue->head.tqh_first == NULL ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
static EventNode* newEventNode(MirEvent const* event, _GLFWwindow* context)
|
||||
{
|
||||
EventNode* new_node = calloc(1, sizeof(EventNode));
|
||||
new_node->event = calloc(1, sizeof(MirEvent));
|
||||
new_node->window = context;
|
||||
|
||||
memcpy(new_node->event, event, sizeof(MirEvent));
|
||||
return new_node;
|
||||
}
|
||||
|
||||
static void enqueueEvent(MirEvent const* event, _GLFWwindow* context)
|
||||
{
|
||||
pthread_mutex_lock(&_glfw.mir.event_mutex);
|
||||
|
||||
EventNode* new_node = newEventNode(event, context);
|
||||
TAILQ_INSERT_TAIL(&_glfw.mir.event_queue->head, new_node, entries);
|
||||
|
||||
pthread_cond_signal(&_glfw.mir.event_cond);
|
||||
|
||||
pthread_mutex_unlock(&_glfw.mir.event_mutex);
|
||||
}
|
||||
|
||||
static EventNode* dequeueEvent(EventQueue* queue)
|
||||
{
|
||||
EventNode* node = NULL;
|
||||
|
||||
pthread_mutex_lock(&_glfw.mir.event_mutex);
|
||||
|
||||
node = queue->head.tqh_first;
|
||||
|
||||
if (node)
|
||||
TAILQ_REMOVE(&queue->head, node, entries);
|
||||
|
||||
pthread_mutex_unlock(&_glfw.mir.event_mutex);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static MirPixelFormat findValidPixelFormat(void)
|
||||
{
|
||||
unsigned int i, validFormats, mirPixelFormats = 32;
|
||||
MirPixelFormat formats[mir_pixel_formats];
|
||||
|
||||
mir_connection_get_available_surface_formats(_glfw.mir.connection, formats,
|
||||
mirPixelFormats, &validFormats);
|
||||
|
||||
for (i = 0; i < validFormats; i++)
|
||||
{
|
||||
if (formats[i] == mir_pixel_format_abgr_8888 ||
|
||||
formats[i] == mir_pixel_format_xbgr_8888 ||
|
||||
formats[i] == mir_pixel_format_argb_8888 ||
|
||||
formats[i] == mir_pixel_format_xrgb_8888)
|
||||
{
|
||||
return formats[i];
|
||||
}
|
||||
}
|
||||
|
||||
return mir_pixel_format_invalid;
|
||||
}
|
||||
|
||||
static int mirModToGLFWMod(uint32_t mods)
|
||||
{
|
||||
int publicMods = 0x0;
|
||||
|
||||
if (mods & mir_key_modifier_alt)
|
||||
publicMods |= GLFW_MOD_ALT;
|
||||
else if (mods & mir_key_modifier_shift)
|
||||
publicMods |= GLFW_MOD_SHIFT;
|
||||
else if (mods & mir_key_modifier_ctrl)
|
||||
publicMods |= GLFW_MOD_CONTROL;
|
||||
else if (mods & mir_key_modifier_meta)
|
||||
publicMods |= GLFW_MOD_SUPER;
|
||||
|
||||
return publicMods;
|
||||
}
|
||||
|
||||
// Taken from wl_init.c
|
||||
static int toGLFWKeyCode(uint32_t key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KEY_GRAVE: return GLFW_KEY_GRAVE_ACCENT;
|
||||
case KEY_1: return GLFW_KEY_1;
|
||||
case KEY_2: return GLFW_KEY_2;
|
||||
case KEY_3: return GLFW_KEY_3;
|
||||
case KEY_4: return GLFW_KEY_4;
|
||||
case KEY_5: return GLFW_KEY_5;
|
||||
case KEY_6: return GLFW_KEY_6;
|
||||
case KEY_7: return GLFW_KEY_7;
|
||||
case KEY_8: return GLFW_KEY_8;
|
||||
case KEY_9: return GLFW_KEY_9;
|
||||
case KEY_0: return GLFW_KEY_0;
|
||||
case KEY_MINUS: return GLFW_KEY_MINUS;
|
||||
case KEY_EQUAL: return GLFW_KEY_EQUAL;
|
||||
case KEY_Q: return GLFW_KEY_Q;
|
||||
case KEY_W: return GLFW_KEY_W;
|
||||
case KEY_E: return GLFW_KEY_E;
|
||||
case KEY_R: return GLFW_KEY_R;
|
||||
case KEY_T: return GLFW_KEY_T;
|
||||
case KEY_Y: return GLFW_KEY_Y;
|
||||
case KEY_U: return GLFW_KEY_U;
|
||||
case KEY_I: return GLFW_KEY_I;
|
||||
case KEY_O: return GLFW_KEY_O;
|
||||
case KEY_P: return GLFW_KEY_P;
|
||||
case KEY_LEFTBRACE: return GLFW_KEY_LEFT_BRACKET;
|
||||
case KEY_RIGHTBRACE: return GLFW_KEY_RIGHT_BRACKET;
|
||||
case KEY_A: return GLFW_KEY_A;
|
||||
case KEY_S: return GLFW_KEY_S;
|
||||
case KEY_D: return GLFW_KEY_D;
|
||||
case KEY_F: return GLFW_KEY_F;
|
||||
case KEY_G: return GLFW_KEY_G;
|
||||
case KEY_H: return GLFW_KEY_H;
|
||||
case KEY_J: return GLFW_KEY_J;
|
||||
case KEY_K: return GLFW_KEY_K;
|
||||
case KEY_L: return GLFW_KEY_L;
|
||||
case KEY_SEMICOLON: return GLFW_KEY_SEMICOLON;
|
||||
case KEY_APOSTROPHE: return GLFW_KEY_APOSTROPHE;
|
||||
case KEY_Z: return GLFW_KEY_Z;
|
||||
case KEY_X: return GLFW_KEY_X;
|
||||
case KEY_C: return GLFW_KEY_C;
|
||||
case KEY_V: return GLFW_KEY_V;
|
||||
case KEY_B: return GLFW_KEY_B;
|
||||
case KEY_N: return GLFW_KEY_N;
|
||||
case KEY_M: return GLFW_KEY_M;
|
||||
case KEY_COMMA: return GLFW_KEY_COMMA;
|
||||
case KEY_DOT: return GLFW_KEY_PERIOD;
|
||||
case KEY_SLASH: return GLFW_KEY_SLASH;
|
||||
case KEY_BACKSLASH: return GLFW_KEY_BACKSLASH;
|
||||
case KEY_ESC: return GLFW_KEY_ESCAPE;
|
||||
case KEY_TAB: return GLFW_KEY_TAB;
|
||||
case KEY_LEFTSHIFT: return GLFW_KEY_LEFT_SHIFT;
|
||||
case KEY_RIGHTSHIFT: return GLFW_KEY_RIGHT_SHIFT;
|
||||
case KEY_LEFTCTRL: return GLFW_KEY_LEFT_CONTROL;
|
||||
case KEY_RIGHTCTRL: return GLFW_KEY_RIGHT_CONTROL;
|
||||
case KEY_LEFTALT: return GLFW_KEY_LEFT_ALT;
|
||||
case KEY_RIGHTALT: return GLFW_KEY_RIGHT_ALT;
|
||||
case KEY_LEFTMETA: return GLFW_KEY_LEFT_SUPER;
|
||||
case KEY_RIGHTMETA: return GLFW_KEY_RIGHT_SUPER;
|
||||
case KEY_MENU: return GLFW_KEY_MENU;
|
||||
case KEY_NUMLOCK: return GLFW_KEY_NUM_LOCK;
|
||||
case KEY_CAPSLOCK: return GLFW_KEY_CAPS_LOCK;
|
||||
case KEY_PRINT: return GLFW_KEY_PRINT_SCREEN;
|
||||
case KEY_SCROLLLOCK: return GLFW_KEY_SCROLL_LOCK;
|
||||
case KEY_PAUSE: return GLFW_KEY_PAUSE;
|
||||
case KEY_DELETE: return GLFW_KEY_DELETE;
|
||||
case KEY_BACKSPACE: return GLFW_KEY_BACKSPACE;
|
||||
case KEY_ENTER: return GLFW_KEY_ENTER;
|
||||
case KEY_HOME: return GLFW_KEY_HOME;
|
||||
case KEY_END: return GLFW_KEY_END;
|
||||
case KEY_PAGEUP: return GLFW_KEY_PAGE_UP;
|
||||
case KEY_PAGEDOWN: return GLFW_KEY_PAGE_DOWN;
|
||||
case KEY_INSERT: return GLFW_KEY_INSERT;
|
||||
case KEY_LEFT: return GLFW_KEY_LEFT;
|
||||
case KEY_RIGHT: return GLFW_KEY_RIGHT;
|
||||
case KEY_DOWN: return GLFW_KEY_DOWN;
|
||||
case KEY_UP: return GLFW_KEY_UP;
|
||||
case KEY_F1: return GLFW_KEY_F1;
|
||||
case KEY_F2: return GLFW_KEY_F2;
|
||||
case KEY_F3: return GLFW_KEY_F3;
|
||||
case KEY_F4: return GLFW_KEY_F4;
|
||||
case KEY_F5: return GLFW_KEY_F5;
|
||||
case KEY_F6: return GLFW_KEY_F6;
|
||||
case KEY_F7: return GLFW_KEY_F7;
|
||||
case KEY_F8: return GLFW_KEY_F8;
|
||||
case KEY_F9: return GLFW_KEY_F9;
|
||||
case KEY_F10: return GLFW_KEY_F10;
|
||||
case KEY_F11: return GLFW_KEY_F11;
|
||||
case KEY_F12: return GLFW_KEY_F12;
|
||||
case KEY_F13: return GLFW_KEY_F13;
|
||||
case KEY_F14: return GLFW_KEY_F14;
|
||||
case KEY_F15: return GLFW_KEY_F15;
|
||||
case KEY_F16: return GLFW_KEY_F16;
|
||||
case KEY_F17: return GLFW_KEY_F17;
|
||||
case KEY_F18: return GLFW_KEY_F18;
|
||||
case KEY_F19: return GLFW_KEY_F19;
|
||||
case KEY_F20: return GLFW_KEY_F20;
|
||||
case KEY_F21: return GLFW_KEY_F21;
|
||||
case KEY_F22: return GLFW_KEY_F22;
|
||||
case KEY_F23: return GLFW_KEY_F23;
|
||||
case KEY_F24: return GLFW_KEY_F24;
|
||||
case KEY_KPSLASH: return GLFW_KEY_KP_DIVIDE;
|
||||
case KEY_KPDOT: return GLFW_KEY_KP_MULTIPLY;
|
||||
case KEY_KPMINUS: return GLFW_KEY_KP_SUBTRACT;
|
||||
case KEY_KPPLUS: return GLFW_KEY_KP_ADD;
|
||||
case KEY_KP0: return GLFW_KEY_KP_0;
|
||||
case KEY_KP1: return GLFW_KEY_KP_1;
|
||||
case KEY_KP2: return GLFW_KEY_KP_2;
|
||||
case KEY_KP3: return GLFW_KEY_KP_3;
|
||||
case KEY_KP4: return GLFW_KEY_KP_4;
|
||||
case KEY_KP5: return GLFW_KEY_KP_5;
|
||||
case KEY_KP6: return GLFW_KEY_KP_6;
|
||||
case KEY_KP7: return GLFW_KEY_KP_7;
|
||||
case KEY_KP8: return GLFW_KEY_KP_8;
|
||||
case KEY_KP9: return GLFW_KEY_KP_9;
|
||||
case KEY_KPCOMMA: return GLFW_KEY_KP_DECIMAL;
|
||||
case KEY_KPEQUAL: return GLFW_KEY_KP_EQUAL;
|
||||
case KEY_KPENTER: return GLFW_KEY_KP_ENTER;
|
||||
default: return GLFW_KEY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static void handleKeyEvent(const MirKeyEvent key, _GLFWwindow* window)
|
||||
{
|
||||
const int pressed = key.action == mir_key_action_up ? GLFW_RELEASE : GLFW_PRESS;
|
||||
const int mods = mirModToGLFWMod(key.modifiers);
|
||||
const long text = _glfwKeySym2Unicode(key.key_code);
|
||||
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
||||
|
||||
_glfwInputKey(window, toGLFWKeyCode(key.scan_code), key.scan_code, pressed, mods);
|
||||
|
||||
if (text != -1)
|
||||
_glfwInputChar(window, text, mods, plain);
|
||||
}
|
||||
|
||||
static void handleMouseButton(_GLFWwindow* window,
|
||||
int pressed, int mods, MirMotionButton button)
|
||||
{
|
||||
static int lastButton;
|
||||
int publicButton;
|
||||
const int publicMods = mirModToGLFWMod(mods);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
case mir_motion_button_primary:
|
||||
publicButton = GLFW_MOUSE_BUTTON_LEFT;
|
||||
break;
|
||||
case mir_motion_button_secondary:
|
||||
publicButton = GLFW_MOUSE_BUTTON_RIGHT;
|
||||
break;
|
||||
case mir_motion_button_tertiary:
|
||||
publicButton = GLFW_MOUSE_BUTTON_MIDDLE;
|
||||
break;
|
||||
case mir_motion_button_forward:
|
||||
// FIXME What is the forward button?
|
||||
publicButton = GLFW_MOUSE_BUTTON_4;
|
||||
break;
|
||||
case mir_motion_button_back:
|
||||
// FIXME What is the back button?
|
||||
publicButton = GLFW_MOUSE_BUTTON_5;
|
||||
break;
|
||||
default:
|
||||
publicButton = lastButton;
|
||||
break;
|
||||
}
|
||||
|
||||
lastButton = publicButton;
|
||||
|
||||
_glfwInputMouseClick(window, publicButton, pressed, publicMods);
|
||||
}
|
||||
|
||||
static void handleMouseMotion(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
_glfwInputCursorMotion(window, x, y);
|
||||
}
|
||||
|
||||
static void handleMouseScroll(_GLFWwindow* window, int dx, int dy)
|
||||
{
|
||||
_glfwInputScroll(window, dx, dy);
|
||||
}
|
||||
|
||||
static void handleMouseEvent(const MirMotionEvent motion,
|
||||
int cord_index,
|
||||
_GLFWwindow* window)
|
||||
{
|
||||
switch (motion.action)
|
||||
{
|
||||
case mir_motion_action_down:
|
||||
case mir_motion_action_pointer_down:
|
||||
handleMouseButton(window, GLFW_PRESS,
|
||||
motion.modifiers, motion.button_state);
|
||||
break;
|
||||
case mir_motion_action_up:
|
||||
case mir_motion_action_pointer_up:
|
||||
handleMouseButton(window, GLFW_RELEASE,
|
||||
motion.modifiers, motion.button_state);
|
||||
break;
|
||||
case mir_motion_action_hover_move:
|
||||
case mir_motion_action_move:
|
||||
handleMouseMotion(window,
|
||||
motion.pointer_coordinates[cord_index].x,
|
||||
motion.pointer_coordinates[cord_index].y);
|
||||
break;
|
||||
case mir_motion_action_outside:
|
||||
break;
|
||||
case mir_motion_action_scroll:
|
||||
handleMouseScroll(window,
|
||||
motion.pointer_coordinates[cord_index].hscroll,
|
||||
motion.pointer_coordinates[cord_index].vscroll);
|
||||
break;
|
||||
case mir_motion_action_cancel:
|
||||
case mir_motion_action_hover_enter:
|
||||
case mir_motion_action_hover_exit:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void handleMotionEvent(const MirMotionEvent motion, _GLFWwindow* window)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < motion.pointer_count; i++)
|
||||
handleMouseEvent(motion, i, window);
|
||||
}
|
||||
|
||||
static void handleInput(MirEvent const* event, _GLFWwindow* window)
|
||||
{
|
||||
switch (event->type)
|
||||
{
|
||||
case mir_event_type_key:
|
||||
handleKeyEvent(event->key, window);
|
||||
break;
|
||||
case mir_event_type_motion:
|
||||
handleMotionEvent(event->motion, window);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void addNewEvent(MirSurface* surface, MirEvent const* event, void* context)
|
||||
{
|
||||
enqueueEvent(event, context);
|
||||
}
|
||||
|
||||
static int createSurface(_GLFWwindow* window)
|
||||
{
|
||||
MirSurfaceParameters params =
|
||||
{
|
||||
.name = "MirSurface",
|
||||
.width = window->mir.width,
|
||||
.height = window->mir.height,
|
||||
.pixel_format = mir_pixel_format_invalid,
|
||||
.buffer_usage = mir_buffer_usage_hardware,
|
||||
.output_id = mir_display_output_id_invalid
|
||||
};
|
||||
|
||||
MirEventDelegate delegate =
|
||||
{
|
||||
addNewEvent,
|
||||
window
|
||||
};
|
||||
|
||||
params.pixel_format = findValidPixelFormat();
|
||||
if (params.pixel_format == mir_pixel_format_invalid)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unable to find a correct pixel format");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
window->mir.surface =
|
||||
mir_connection_create_surface_sync(_glfw.mir.connection, ¶ms);
|
||||
if (!mir_surface_is_valid(window->mir.surface))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unable to create surface: %s",
|
||||
mir_surface_get_error_message(window->mir.surface));
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
mir_surface_set_event_handler(window->mir.surface, &delegate);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwInitEventQueue(EventQueue* queue)
|
||||
{
|
||||
TAILQ_INIT(&queue->head);
|
||||
}
|
||||
|
||||
void _glfwDeleteEventQueue(EventQueue* queue)
|
||||
{
|
||||
if (queue)
|
||||
{
|
||||
EventNode* node, *node_next;
|
||||
node = queue->head.tqh_first;
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
node_next = node->entries.tqe_next;
|
||||
|
||||
TAILQ_REMOVE(&queue->head, node, entries);
|
||||
deleteNode(queue, node);
|
||||
|
||||
node = node_next;
|
||||
}
|
||||
|
||||
free(queue);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
if (wndconfig->monitor)
|
||||
{
|
||||
GLFWvidmode mode;
|
||||
_glfwPlatformGetVideoMode(wndconfig->monitor, &mode);
|
||||
|
||||
mir_surface_set_state(window->mir.surface, mir_surface_state_fullscreen);
|
||||
|
||||
if (wndconfig->width > mode.width || wndconfig->height > mode.height)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Requested surface size is to large (%i %i)",
|
||||
wndconfig->width, wndconfig->height);
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
window->mir.width = wndconfig->width;
|
||||
window->mir.height = wndconfig->height;
|
||||
|
||||
if (!createSurface(window))
|
||||
return GL_FALSE;
|
||||
|
||||
window->mir.window = mir_surface_get_egl_native_window(window->mir.surface);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
{
|
||||
if (mir_surface_is_valid(window->mir.surface))
|
||||
{
|
||||
mir_surface_release_sync(window->mir.surface);
|
||||
window->mir.surface = NULL;
|
||||
}
|
||||
|
||||
_glfwDestroyContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
*width = window->mir.width;
|
||||
if (height)
|
||||
*height = window->mir.height;
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
{
|
||||
mir_surface_set_state(window->mir.surface, mir_surface_state_minimized);
|
||||
}
|
||||
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
{
|
||||
mir_surface_set_state(window->mir.surface, mir_surface_state_restored);
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
EventNode* node = NULL;
|
||||
|
||||
while ((node = dequeueEvent(_glfw.mir.event_queue)))
|
||||
{
|
||||
handleInput(node->event, node->window);
|
||||
deleteNode(_glfw.mir.event_queue, node);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEvents(void)
|
||||
{
|
||||
pthread_mutex_lock(&_glfw.mir.event_mutex);
|
||||
|
||||
if (emptyEventQueue(_glfw.mir.event_queue))
|
||||
pthread_cond_wait(&_glfw.mir.event_cond, &_glfw.mir.event_mutex);
|
||||
|
||||
pthread_mutex_unlock(&_glfw.mir.event_mutex);
|
||||
|
||||
_glfwPlatformPollEvents();
|
||||
}
|
||||
|
||||
void _glfwPlatformPostEmptyEvent(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
*width = window->mir.width;
|
||||
if (height)
|
||||
*height = window->mir.height;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s!", __PRETTY_FUNCTION__);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
151
extern/glfw/src/monitor.c
vendored
151
extern/glfw/src/monitor.c
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -27,46 +27,33 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <malloc.h>
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
|
||||
// Lexical comparison function for GLFW video modes, used by qsort
|
||||
//
|
||||
static int compareVideoModes(const void* firstPtr, const void* secondPtr)
|
||||
{
|
||||
int firstBPP, secondBPP, firstSize, secondSize;
|
||||
GLFWvidmode* first = (GLFWvidmode*) firstPtr;
|
||||
GLFWvidmode* second = (GLFWvidmode*) secondPtr;
|
||||
const GLFWvidmode* first = firstPtr;
|
||||
const GLFWvidmode* second = secondPtr;
|
||||
|
||||
// First sort on color bits per pixel
|
||||
|
||||
firstBPP = first->redBits +
|
||||
first->greenBits +
|
||||
first->blueBits;
|
||||
secondBPP = second->redBits +
|
||||
second->greenBits +
|
||||
second->blueBits;
|
||||
|
||||
firstBPP = first->redBits + first->greenBits + first->blueBits;
|
||||
secondBPP = second->redBits + second->greenBits + second->blueBits;
|
||||
if (firstBPP != secondBPP)
|
||||
return firstBPP - secondBPP;
|
||||
|
||||
// Then sort on screen area, in pixels
|
||||
|
||||
firstSize = first->width * first->height;
|
||||
secondSize = second->width * second->height;
|
||||
|
||||
if (firstSize != secondSize)
|
||||
return firstSize - secondSize;
|
||||
|
||||
// Lastly sort on refresh rate
|
||||
|
||||
return first->refreshRate - second->refreshRate;
|
||||
}
|
||||
|
||||
@ -113,7 +100,7 @@ void _glfwInputMonitorChange(void)
|
||||
{
|
||||
if (_glfwPlatformIsSameMonitor(_glfw.monitors[i], monitors[j]))
|
||||
{
|
||||
_glfwDestroyMonitor(_glfw.monitors[i]);
|
||||
_glfwFreeMonitor(_glfw.monitors[i]);
|
||||
_glfw.monitors[i] = monitors[j];
|
||||
break;
|
||||
}
|
||||
@ -167,7 +154,7 @@ void _glfwInputMonitorChange(void)
|
||||
_glfw.callbacks.monitor((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED);
|
||||
}
|
||||
|
||||
_glfwDestroyMonitors(monitors, monitorCount);
|
||||
_glfwFreeMonitors(monitors, monitorCount);
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +162,7 @@ void _glfwInputMonitorChange(void)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM)
|
||||
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
|
||||
{
|
||||
_GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor));
|
||||
monitor->name = strdup(name);
|
||||
@ -185,7 +172,7 @@ _GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM)
|
||||
return monitor;
|
||||
}
|
||||
|
||||
void _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||
void _glfwFreeMonitor(_GLFWmonitor* monitor)
|
||||
{
|
||||
if (monitor == NULL)
|
||||
return;
|
||||
@ -198,12 +185,29 @@ void _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||
free(monitor);
|
||||
}
|
||||
|
||||
void _glfwDestroyMonitors(_GLFWmonitor** monitors, int count)
|
||||
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
||||
{
|
||||
ramp->red = calloc(size, sizeof(unsigned short));
|
||||
ramp->green = calloc(size, sizeof(unsigned short));
|
||||
ramp->blue = calloc(size, sizeof(unsigned short));
|
||||
ramp->size = size;
|
||||
}
|
||||
|
||||
void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
|
||||
{
|
||||
free(ramp->red);
|
||||
free(ramp->green);
|
||||
free(ramp->blue);
|
||||
|
||||
memset(ramp, 0, sizeof(GLFWgammaramp));
|
||||
}
|
||||
|
||||
void _glfwFreeMonitors(_GLFWmonitor** monitors, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
_glfwDestroyMonitor(monitors[i]);
|
||||
_glfwFreeMonitor(monitors[i]);
|
||||
|
||||
free(monitors);
|
||||
}
|
||||
@ -225,15 +229,21 @@ const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
||||
{
|
||||
current = monitor->modes + i;
|
||||
|
||||
colorDiff = abs((current->redBits + current->greenBits + current->blueBits) -
|
||||
(desired->redBits + desired->greenBits + desired->blueBits));
|
||||
colorDiff = 0;
|
||||
|
||||
if (desired->redBits != GLFW_DONT_CARE)
|
||||
colorDiff += abs(current->redBits - desired->redBits);
|
||||
if (desired->greenBits != GLFW_DONT_CARE)
|
||||
colorDiff += abs(current->greenBits - desired->greenBits);
|
||||
if (desired->blueBits != GLFW_DONT_CARE)
|
||||
colorDiff += abs(current->blueBits - desired->blueBits);
|
||||
|
||||
sizeDiff = abs((current->width - desired->width) *
|
||||
(current->width - desired->width) +
|
||||
(current->height - desired->height) *
|
||||
(current->height - desired->height));
|
||||
|
||||
if (desired->refreshRate)
|
||||
if (desired->refreshRate != GLFW_DONT_CARE)
|
||||
rateDiff = abs(current->refreshRate - desired->refreshRate);
|
||||
else
|
||||
rateDiff = UINT_MAX - current->refreshRate;
|
||||
@ -300,20 +310,32 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
|
||||
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
if (ypos)
|
||||
*ypos = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformGetMonitorPos(monitor, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* width, int* height)
|
||||
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
if (widthMM)
|
||||
*widthMM = 0;
|
||||
if (heightMM)
|
||||
*heightMM = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (width)
|
||||
*width = monitor->widthMM;
|
||||
if (height)
|
||||
*height = monitor->heightMM;
|
||||
if (widthMM)
|
||||
*widthMM = monitor->widthMM;
|
||||
if (heightMM)
|
||||
*heightMM = monitor->heightMM;
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
||||
@ -355,3 +377,66 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
||||
return &monitor->currentMode;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
||||
{
|
||||
int i;
|
||||
unsigned short values[256];
|
||||
GLFWgammaramp ramp;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (gamma <= 0.f)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Gamma value must be greater than zero");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
double value;
|
||||
|
||||
// Calculate intensity
|
||||
value = i / 255.0;
|
||||
// Apply gamma curve
|
||||
value = pow(value, 1.0 / gamma) * 65535.0 + 0.5;
|
||||
|
||||
// Clamp to value range
|
||||
if (value > 65535.0)
|
||||
value = 65535.0;
|
||||
|
||||
values[i] = (unsigned short) value;
|
||||
}
|
||||
|
||||
ramp.red = values;
|
||||
ramp.green = values;
|
||||
ramp.blue = values;
|
||||
ramp.size = 256;
|
||||
|
||||
glfwSetGammaRamp(handle, &ramp);
|
||||
}
|
||||
|
||||
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||
_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp);
|
||||
|
||||
return &monitor->currentRamp;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (!monitor->originalRamp.size)
|
||||
_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp);
|
||||
|
||||
_glfwPlatformSetGammaRamp(monitor, ramp);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -24,41 +24,39 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _nsgl_platform_h_
|
||||
#define _nsgl_platform_h_
|
||||
|
||||
#ifndef _nsgl_context_h_
|
||||
#define _nsgl_context_h_
|
||||
|
||||
#define _GLFW_PLATFORM_FBCONFIG
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl
|
||||
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryNSGL nsgl
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl
|
||||
|
||||
|
||||
//========================================================================
|
||||
// GLFW platform specific types
|
||||
//========================================================================
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific OpenGL context structure
|
||||
//------------------------------------------------------------------------
|
||||
// NSGL-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextNSGL
|
||||
{
|
||||
id pixelFormat;
|
||||
id context;
|
||||
|
||||
} _GLFWcontextNSGL;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Platform-specific library global data for NSGL
|
||||
//------------------------------------------------------------------------
|
||||
// NSGL-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryNSGL
|
||||
{
|
||||
// dlopen handle for dynamically loading OpenGL extension entry points
|
||||
// dlopen handle for OpenGL.framework (for glfwGetProcAddress)
|
||||
void* framework;
|
||||
|
||||
// TLS key for per-thread current context/window
|
||||
pthread_key_t current;
|
||||
|
||||
} _GLFWlibraryNSGL;
|
||||
|
||||
|
||||
#endif // _nsgl_platform_h_
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
|
||||
#endif // _nsgl_context_h_
|
139
extern/glfw/src/nsgl_context.m
vendored
139
extern/glfw/src/nsgl_context.m
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 OS X - www.glfw.org
|
||||
// GLFW 3.1 OS X - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
@ -26,8 +26,6 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
@ -37,12 +35,8 @@
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
{
|
||||
if (pthread_key_create(&_glfw.nsgl.current, NULL) != 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"NSGL: Failed to create context TLS");
|
||||
if (!_glfwInitTLS())
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfw.nsgl.framework =
|
||||
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
||||
@ -60,25 +54,18 @@ int _glfwInitContextAPI(void)
|
||||
//
|
||||
void _glfwTerminateContextAPI(void)
|
||||
{
|
||||
pthread_key_delete(_glfw.nsgl.current);
|
||||
_glfwTerminateTLS();
|
||||
}
|
||||
|
||||
// Create the OpenGL context
|
||||
//
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
unsigned int attributeCount = 0;
|
||||
|
||||
// OS X needs non-zero color size, so set resonable values
|
||||
int colorBits = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits;
|
||||
if (colorBits == 0)
|
||||
colorBits = 24;
|
||||
else if (colorBits < 15)
|
||||
colorBits = 15;
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||
"NSGL: This API does not support OpenGL ES");
|
||||
@ -86,7 +73,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (wndconfig->glMajor == 3 && wndconfig->glMinor < 2)
|
||||
if (ctxconfig->major == 3 && ctxconfig->minor < 2)
|
||||
{
|
||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||
"NSGL: The targeted version of OS X does not "
|
||||
@ -94,9 +81,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->glMajor > 2)
|
||||
if (ctxconfig->major > 2)
|
||||
{
|
||||
if (!wndconfig->glForward)
|
||||
if (!ctxconfig->forward)
|
||||
{
|
||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||
"NSGL: The targeted version of OS X only "
|
||||
@ -105,7 +92,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE)
|
||||
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
|
||||
{
|
||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||
"NSGL: The targeted version of OS X only "
|
||||
@ -116,7 +103,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
}
|
||||
#else
|
||||
// Fail if OpenGL 3.0 or above was requested
|
||||
if (wndconfig->glMajor > 2)
|
||||
if (ctxconfig->major > 2)
|
||||
{
|
||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||
"NSGL: The targeted version of OS X does not "
|
||||
@ -125,14 +112,11 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
}
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
|
||||
// Fail if a robustness strategy was requested
|
||||
if (wndconfig->glRobustness)
|
||||
{
|
||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||
"NSGL: OS X does not support OpenGL robustness "
|
||||
"strategies");
|
||||
return GL_FALSE;
|
||||
}
|
||||
// Context robustness modes (GL_KHR_robustness) are not yet supported on
|
||||
// OS X but are not a hard constraint, so ignore and continue
|
||||
|
||||
// Context release behaviors (GL_KHR_context_flush_control) are not yet
|
||||
// supported on OS X but are not a hard constraint, so ignore and continue
|
||||
|
||||
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
|
||||
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
|
||||
@ -140,45 +124,89 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
// Arbitrary array size here
|
||||
NSOpenGLPixelFormatAttribute attributes[40];
|
||||
|
||||
ADD_ATTR(NSOpenGLPFADoubleBuffer);
|
||||
ADD_ATTR(NSOpenGLPFAAccelerated);
|
||||
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (wndconfig->glMajor > 2)
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||
if (ctxconfig->major >= 4)
|
||||
{
|
||||
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
|
||||
}
|
||||
else
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
if (ctxconfig->major >= 3)
|
||||
{
|
||||
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||
}
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
|
||||
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
|
||||
if (ctxconfig->major <= 2)
|
||||
{
|
||||
if (fbconfig->auxBuffers != GLFW_DONT_CARE)
|
||||
ADD_ATTR2(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
||||
|
||||
if (fbconfig->alphaBits > 0)
|
||||
if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
|
||||
fbconfig->accumGreenBits != GLFW_DONT_CARE &&
|
||||
fbconfig->accumBlueBits != GLFW_DONT_CARE &&
|
||||
fbconfig->accumAlphaBits != GLFW_DONT_CARE)
|
||||
{
|
||||
const int accumBits = fbconfig->accumRedBits +
|
||||
fbconfig->accumGreenBits +
|
||||
fbconfig->accumBlueBits +
|
||||
fbconfig->accumAlphaBits;
|
||||
|
||||
ADD_ATTR2(NSOpenGLPFAAccumSize, accumBits);
|
||||
}
|
||||
}
|
||||
|
||||
if (fbconfig->redBits != GLFW_DONT_CARE &&
|
||||
fbconfig->greenBits != GLFW_DONT_CARE &&
|
||||
fbconfig->blueBits != GLFW_DONT_CARE)
|
||||
{
|
||||
int colorBits = fbconfig->redBits +
|
||||
fbconfig->greenBits +
|
||||
fbconfig->blueBits;
|
||||
|
||||
// OS X needs non-zero color size, so set reasonable values
|
||||
if (colorBits == 0)
|
||||
colorBits = 24;
|
||||
else if (colorBits < 15)
|
||||
colorBits = 15;
|
||||
|
||||
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
|
||||
}
|
||||
|
||||
if (fbconfig->alphaBits != GLFW_DONT_CARE)
|
||||
ADD_ATTR2(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
|
||||
|
||||
if (fbconfig->depthBits > 0)
|
||||
if (fbconfig->depthBits != GLFW_DONT_CARE)
|
||||
ADD_ATTR2(NSOpenGLPFADepthSize, fbconfig->depthBits);
|
||||
|
||||
if (fbconfig->stencilBits > 0)
|
||||
if (fbconfig->stencilBits != GLFW_DONT_CARE)
|
||||
ADD_ATTR2(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
|
||||
|
||||
int accumBits = fbconfig->accumRedBits + fbconfig->accumGreenBits +
|
||||
fbconfig->accumBlueBits + fbconfig->accumAlphaBits;
|
||||
|
||||
if (accumBits > 0)
|
||||
ADD_ATTR2(NSOpenGLPFAAccumSize, accumBits);
|
||||
|
||||
if (fbconfig->auxBuffers > 0)
|
||||
ADD_ATTR2(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
||||
|
||||
if (fbconfig->stereo)
|
||||
ADD_ATTR(NSOpenGLPFAStereo);
|
||||
|
||||
if (fbconfig->samples > 0)
|
||||
if (fbconfig->doublebuffer)
|
||||
ADD_ATTR(NSOpenGLPFADoubleBuffer);
|
||||
|
||||
if (fbconfig->samples != GLFW_DONT_CARE)
|
||||
{
|
||||
ADD_ATTR2(NSOpenGLPFASampleBuffers, 1);
|
||||
ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);
|
||||
if (fbconfig->samples == 0)
|
||||
{
|
||||
ADD_ATTR2(NSOpenGLPFASampleBuffers, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADD_ATTR2(NSOpenGLPFASampleBuffers, 1);
|
||||
ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
||||
// frambuffer, so there's no need (and no way) to request it
|
||||
// framebuffer, so there's no need (and no way) to request it
|
||||
|
||||
ADD_ATTR(0);
|
||||
|
||||
@ -196,8 +224,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
|
||||
NSOpenGLContext* share = NULL;
|
||||
|
||||
if (wndconfig->share)
|
||||
share = wndconfig->share->nsgl.context;
|
||||
if (ctxconfig->share)
|
||||
share = ctxconfig->share->nsgl.context;
|
||||
|
||||
window->nsgl.context =
|
||||
[[NSOpenGLContext alloc] initWithFormat:window->nsgl.pixelFormat
|
||||
@ -235,12 +263,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
else
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
|
||||
pthread_setspecific(_glfw.nsgl.current, window);
|
||||
}
|
||||
|
||||
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
|
||||
{
|
||||
return (_GLFWwindow*) pthread_getspecific(_glfw.nsgl.current);
|
||||
_glfwSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 X11 - www.glfw.org
|
||||
// GLFW 3.1 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -30,13 +30,12 @@
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
// Return raw time
|
||||
//
|
||||
static uint64_t getRawTime(void)
|
||||
{
|
||||
#if defined(CLOCK_MONOTONIC)
|
||||
if (_glfw.x11.timer.monotonic)
|
||||
if (_glfw.posix_time.monotonic)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
@ -67,16 +66,16 @@ void _glfwInitTimer(void)
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
||||
{
|
||||
_glfw.x11.timer.monotonic = GL_TRUE;
|
||||
_glfw.x11.timer.resolution = 1e-9;
|
||||
_glfw.posix_time.monotonic = GL_TRUE;
|
||||
_glfw.posix_time.resolution = 1e-9;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
_glfw.x11.timer.resolution = 1e-6;
|
||||
_glfw.posix_time.resolution = 1e-6;
|
||||
}
|
||||
|
||||
_glfw.x11.timer.base = getRawTime();
|
||||
_glfw.posix_time.base = getRawTime();
|
||||
}
|
||||
|
||||
|
||||
@ -86,13 +85,13 @@ void _glfwInitTimer(void)
|
||||
|
||||
double _glfwPlatformGetTime(void)
|
||||
{
|
||||
return (double) (getRawTime() - _glfw.x11.timer.base) *
|
||||
_glfw.x11.timer.resolution;
|
||||
return (double) (getRawTime() - _glfw.posix_time.base) *
|
||||
_glfw.posix_time.resolution;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetTime(double time)
|
||||
{
|
||||
_glfw.x11.timer.base = getRawTime() -
|
||||
(uint64_t) (time / _glfw.x11.timer.resolution);
|
||||
_glfw.posix_time.base = getRawTime() -
|
||||
(uint64_t) (time / _glfw.posix_time.resolution);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.0 - www.glfw.org
|
||||
// GLFW 3.1 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
@ -25,22 +25,25 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
#ifndef _posix_time_h_
|
||||
#define _posix_time_h_
|
||||
|
||||
#define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimePOSIX posix_time
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWAPI double glfwGetTime(void)
|
||||
// POSIX-specific global timer data
|
||||
//
|
||||
typedef struct _GLFWtimePOSIX
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
|
||||
return _glfwPlatformGetTime();
|
||||
}
|
||||
GLboolean monotonic;
|
||||
double resolution;
|
||||
uint64_t base;
|
||||
|
||||
GLFWAPI void glfwSetTime(double time)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformSetTime(time);
|
||||
}
|
||||
} _GLFWtimePOSIX;
|
||||
|
||||
|
||||
void _glfwInitTimer(void);
|
||||
|
||||
#endif // _posix_time_h_
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user