mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 06:14:35 +00:00
Merge branch 'master' of github.com:raedwulf/glfw into clipboard
Conflicts: src/CMakeLists.txt tests/CMakeLists.txt
This commit is contained in:
commit
5937af089e
38
.gitignore
vendored
38
.gitignore
vendored
@ -3,9 +3,37 @@ cmake_install.cmake
|
|||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
Makefile
|
Makefile
|
||||||
cmake_uninstall.cmake
|
cmake_uninstall.cmake
|
||||||
|
.DS_Store
|
||||||
|
docs/Doxyfile
|
||||||
src/config.h
|
src/config.h
|
||||||
src/x11/libglfw.pc
|
src/libglfw.pc
|
||||||
src/win32/libglfw.pc
|
src/libglfw.so
|
||||||
src/cocoa/libglfw.pc
|
src/libglfw.a
|
||||||
*.so
|
src/libglfw.dylib
|
||||||
*.a
|
examples/boing
|
||||||
|
examples/gears
|
||||||
|
examples/heightmap
|
||||||
|
examples/splitview
|
||||||
|
examples/triangle
|
||||||
|
examples/wave
|
||||||
|
examples/*.app
|
||||||
|
examples/*.exe
|
||||||
|
tests/accuracy
|
||||||
|
tests/defaults
|
||||||
|
tests/dynamic
|
||||||
|
tests/events
|
||||||
|
tests/fsaa
|
||||||
|
tests/fsfocus
|
||||||
|
tests/gamma
|
||||||
|
tests/glfwinfo
|
||||||
|
tests/iconify
|
||||||
|
tests/joysticks
|
||||||
|
tests/listmodes
|
||||||
|
tests/peter
|
||||||
|
tests/reopen
|
||||||
|
tests/sharing
|
||||||
|
tests/tearing
|
||||||
|
tests/title
|
||||||
|
tests/windows
|
||||||
|
tests/*.app
|
||||||
|
tests/*.exe
|
||||||
|
@ -13,9 +13,6 @@ set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA
|
|||||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
|
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
|
||||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
|
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
|
||||||
|
|
||||||
include(CheckFunctionExists)
|
|
||||||
include(CheckSymbolExists)
|
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -28,7 +25,6 @@ if (WIN32)
|
|||||||
set(_GLFW_WIN32_WGL 1)
|
set(_GLFW_WIN32_WGL 1)
|
||||||
|
|
||||||
# Set up library and include paths
|
# Set up library and include paths
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
|
|
||||||
list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
|
list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
|
||||||
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
|
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
@ -36,23 +32,34 @@ endif (WIN32)
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Set up GLFW for Xlib and GLX on Unix-like systems with X Windows
|
# Set up GLFW for Xlib and GLX on Unix-like systems with X Windows
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (UNIX AND NOT APPLE AND NOT CYGWIN)
|
if (UNIX AND NOT APPLE)
|
||||||
message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
|
message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
|
||||||
|
|
||||||
# Define the platform identifier
|
# Define the platform identifier
|
||||||
set(_GLFW_X11_GLX 1)
|
set(_GLFW_X11_GLX 1)
|
||||||
|
|
||||||
# Set up library and include paths
|
# Set up library and include paths
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY})
|
list(APPEND GLFW_INCLUDE_DIR ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR})
|
||||||
list(APPEND GLFW_INCLUDE_DIR ${X11_X11_INCLUDE_PATH})
|
list(APPEND GLFW_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY})
|
||||||
list(APPEND GLFW_LIBRARIES ${X11_X11_LIB})
|
|
||||||
list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
|
|
||||||
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
|
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CheckX11Extensions.cmake)
|
find_library(MATH_LIBRARY m)
|
||||||
|
if (MATH_LIBRARY)
|
||||||
|
list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY})
|
||||||
|
endif(MATH_LIBRARY)
|
||||||
|
|
||||||
|
find_library(RT_LIBRARY rt)
|
||||||
|
if (RT_LIBRARY)
|
||||||
|
list(APPEND GLFW_LIBRARIES ${RT_LIBRARY})
|
||||||
|
endif(RT_LIBRARY)
|
||||||
|
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
|
||||||
|
include(${GLFW_SOURCE_DIR}/CMake/CheckX11Extensions.cmake)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${GLFW_LIBRARIES})
|
||||||
|
|
||||||
# Check for XRandR (modern resolution switching extension)
|
# Check for XRandR (modern resolution switching extension)
|
||||||
CHECK_X11_XRANDR()
|
check_x11_xrandr()
|
||||||
if (X11_XRANDR_FOUND)
|
if (X11_XRANDR_FOUND)
|
||||||
set(_GLFW_HAS_XRANDR 1)
|
set(_GLFW_HAS_XRANDR 1)
|
||||||
list(APPEND GLFW_INCLUDE_DIR ${X11_XRANDR_INCLUDE_DIR})
|
list(APPEND GLFW_INCLUDE_DIR ${X11_XRANDR_INCLUDE_DIR})
|
||||||
@ -60,7 +67,7 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
|
|||||||
endif(X11_XRANDR_FOUND)
|
endif(X11_XRANDR_FOUND)
|
||||||
|
|
||||||
# Check for Xf86VidMode (fallback legacy resolution switching extension)
|
# Check for Xf86VidMode (fallback legacy resolution switching extension)
|
||||||
CHECK_X11_XF86VIDMODE()
|
check_x11_xf86vidmode()
|
||||||
if (X11_XF86VIDMODE_FOUND)
|
if (X11_XF86VIDMODE_FOUND)
|
||||||
set(_GLFW_HAS_XF86VIDMODE 1)
|
set(_GLFW_HAS_XF86VIDMODE 1)
|
||||||
list(APPEND GLFW_INCLUDE_DIR ${X11_XF86VIDMODE_INCLUDE_DIR})
|
list(APPEND GLFW_INCLUDE_DIR ${X11_XF86VIDMODE_INCLUDE_DIR})
|
||||||
@ -68,17 +75,17 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
|
|||||||
endif(X11_XF86VIDMODE_FOUND)
|
endif(X11_XF86VIDMODE_FOUND)
|
||||||
|
|
||||||
# Check for Xkb (X keyboard extension)
|
# Check for Xkb (X keyboard extension)
|
||||||
CHECK_FUNCTION_EXISTS(XkbQueryExtension _GLFW_HAS_XKB)
|
check_function_exists(XkbQueryExtension _GLFW_HAS_XKB)
|
||||||
|
|
||||||
# Check for glXGetProcAddress
|
# Check for glXGetProcAddress
|
||||||
CHECK_FUNCTION_EXISTS(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
|
check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
|
||||||
|
|
||||||
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
|
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
|
||||||
CHECK_FUNCTION_EXISTS(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB)
|
check_function_exists(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||||
endif (NOT _GLFW_HAS_GLXGETPROCADDRESS)
|
endif (NOT _GLFW_HAS_GLXGETPROCADDRESS)
|
||||||
|
|
||||||
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
|
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||||
CHECK_FUNCTION_EXISTS(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT)
|
check_function_exists(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT)
|
||||||
endif (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
|
endif (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||||
|
|
||||||
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND
|
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND
|
||||||
@ -92,7 +99,7 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
|
|||||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
set(_GLFW_USE_LINUX_JOYSTICKS 1)
|
set(_GLFW_USE_LINUX_JOYSTICKS 1)
|
||||||
endif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
endif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
endif(UNIX AND NOT APPLE AND NOT CYGWIN)
|
endif(UNIX AND NOT APPLE)
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Set up GLFW for Cocoa and NSOpenGL on Mac OS X
|
# Set up GLFW for Cocoa and NSOpenGL on Mac OS X
|
||||||
@ -105,20 +112,24 @@ if (UNIX AND APPLE)
|
|||||||
|
|
||||||
option(GLFW_BUILD_UNIVERSAL "Build the GLFW library and examples as Universal Binaries" FALSE)
|
option(GLFW_BUILD_UNIVERSAL "Build the GLFW library and examples as Universal Binaries" FALSE)
|
||||||
|
|
||||||
# Universal build, decent set of warning flags...
|
# Universal build
|
||||||
if (GLFW_BUILD_UNIVERSAL)
|
if (GLFW_BUILD_UNIVERSAL)
|
||||||
message(STATUS "Building GLFW as Universal Binaries")
|
message(STATUS "Building GLFW as Universal Binaries")
|
||||||
set(CMAKE_OSX_ARCHITECTURES ppc;i386;ppc64;x86_64)
|
set(CMAKE_OSX_ARCHITECTURES ppc;i386;ppc64;x86_64)
|
||||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
|
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
|
||||||
set(CMAKE_C_FLAGS "-mmacosx-version-min=10.5 -Wall -Wextra -Wno-unused-parameter -Werror")
|
set(CMAKE_C_FLAGS "-mmacosx-version-min=10.5")
|
||||||
else(GLFW_BUILD_UNIVERSAL)
|
else(GLFW_BUILD_UNIVERSAL)
|
||||||
message(STATUS "Building GLFW only for the native architecture")
|
message(STATUS "Building GLFW only for the native architecture")
|
||||||
endif(GLFW_BUILD_UNIVERSAL)
|
endif(GLFW_BUILD_UNIVERSAL)
|
||||||
|
|
||||||
# Set up library and include paths
|
# Set up library and include paths
|
||||||
find_library(COCOA_FRAMEWORK Cocoa)
|
find_library(COCOA_FRAMEWORK Cocoa)
|
||||||
|
find_library(IOKIT_FRAMEWORK IOKit)
|
||||||
|
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
|
||||||
list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK})
|
list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK})
|
||||||
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
|
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
|
||||||
|
list(APPEND GLFW_LIBRARIES ${IOKIT_FRAMEWORK})
|
||||||
|
list(APPEND GLFW_LIBRARIES ${CORE_FOUNDATION_FRAMEWORK})
|
||||||
endif(UNIX AND APPLE)
|
endif(UNIX AND APPLE)
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -155,12 +166,9 @@ install(FILES COPYING.txt readme.html
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# -- Documentation generation
|
# -- Documentation generation
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
#include("${CMAKE_CURRENT_SOURCE_DIR}/documentation.cmake")
|
configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in"
|
||||||
#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in"
|
"${GLFW_BINARY_DIR}/docs/Doxyfile"
|
||||||
# "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
|
@ONLY)
|
||||||
# IMMEDIATE @ONLY)
|
|
||||||
#add_doxygen_target("${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
|
|
||||||
#add_subdirectory(docs)
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Uninstall operation
|
# Uninstall operation
|
||||||
|
1687
docs/Doxyfile.in
Normal file
1687
docs/Doxyfile.in
Normal file
File diff suppressed because it is too large
Load Diff
@ -32,10 +32,3 @@ if(MSVC)
|
|||||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
if(CYGWIN)
|
|
||||||
# Set cross-compile and subsystem compile and link flags
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
|
||||||
COMPILE_FLAGS "-mno-cygwin"
|
|
||||||
LINK_FLAGS "-mno-cygwin -mwindows")
|
|
||||||
endif(CYGWIN)
|
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ int main( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowSizeCallback( reshape );
|
glfwSetWindowSizeCallback( reshape );
|
||||||
glfwEnable( window, GLFW_STICKY_KEYS );
|
glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE );
|
||||||
glfwSwapInterval( 1 );
|
glfwSwapInterval( 1 );
|
||||||
glfwSetTime( 0.0 );
|
glfwSetTime( 0.0 );
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ int main(int argc, char *argv[])
|
|||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwEnable( window, GLFW_KEY_REPEAT );
|
glfwSetInputMode( window, GLFW_KEY_REPEAT, GL_TRUE );
|
||||||
glfwSwapInterval( 1 );
|
glfwSwapInterval( 1 );
|
||||||
|
|
||||||
// Parse command-line options
|
// Parse command-line options
|
||||||
|
@ -573,7 +573,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GL_TRUE != glfwInit())
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: Unable to initialize GLFW\n");
|
fprintf(stderr, "ERROR: Unable to initialize GLFW\n");
|
||||||
usage();
|
usage();
|
||||||
@ -583,7 +583,7 @@ int main(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
|
glfwOpenWindowHint(GLFW_WINDOW_RESIZABLE, GL_FALSE);
|
||||||
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
|
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
|
||||||
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
|
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
|
||||||
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
@ -462,10 +462,10 @@ int main(void)
|
|||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
// Enable sticky keys
|
// Enable sticky keys
|
||||||
glfwEnable(window, GLFW_STICKY_KEYS);
|
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
|
||||||
|
|
||||||
// Enable mouse cursor (only needed for fullscreen mode)
|
// Enable mouse cursor (only needed for fullscreen mode)
|
||||||
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||||
|
|
||||||
// Set callback functions
|
// Set callback functions
|
||||||
glfwSetWindowSizeCallback(windowSizeFun);
|
glfwSetWindowSizeCallback(windowSizeFun);
|
||||||
|
@ -30,7 +30,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we can capture the escape key being pressed below
|
// Ensure we can capture the escape key being pressed below
|
||||||
glfwEnable(window, GLFW_STICKY_KEYS);
|
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
|
||||||
|
|
||||||
// Enable vertical sync (on cards that support it)
|
// Enable vertical sync (on cards that support it)
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
@ -309,13 +309,13 @@ void mouse_button_callback(GLFWwindow window, int button, int action)
|
|||||||
|
|
||||||
if (action == GLFW_PRESS)
|
if (action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
|
||||||
locked = GL_TRUE;
|
locked = GL_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
locked = GL_FALSE;
|
locked = GL_FALSE;
|
||||||
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Keyboard handler
|
// Keyboard handler
|
||||||
glfwSetKeyCallback(key_callback);
|
glfwSetKeyCallback(key_callback);
|
||||||
glfwEnable(window, GLFW_KEY_REPEAT);
|
glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE);
|
||||||
|
|
||||||
// Window resize handler
|
// Window resize handler
|
||||||
glfwSetWindowSizeCallback(window_resize_callback);
|
glfwSetWindowSizeCallback(window_resize_callback);
|
||||||
|
@ -39,16 +39,6 @@ extern "C" {
|
|||||||
* Global definitions
|
* Global definitions
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/* We need a NULL pointer from time to time */
|
|
||||||
#ifndef NULL
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define NULL 0
|
|
||||||
#else
|
|
||||||
#define NULL ((void*) 0)
|
|
||||||
#endif
|
|
||||||
#endif /* NULL */
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
|
/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
|
||||||
|
|
||||||
/* Please report any probles that you find with your compiler, which may
|
/* Please report any probles that you find with your compiler, which may
|
||||||
@ -75,7 +65,6 @@ extern "C" {
|
|||||||
#else
|
#else
|
||||||
#define APIENTRY
|
#define APIENTRY
|
||||||
#endif
|
#endif
|
||||||
#define GLFW_APIENTRY_DEFINED
|
|
||||||
#endif /* APIENTRY */
|
#endif /* APIENTRY */
|
||||||
|
|
||||||
|
|
||||||
@ -418,7 +407,7 @@ extern "C" {
|
|||||||
#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
|
#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
|
||||||
#define GLFW_AUX_BUFFERS 0x0002100B
|
#define GLFW_AUX_BUFFERS 0x0002100B
|
||||||
#define GLFW_STEREO 0x0002100C
|
#define GLFW_STEREO 0x0002100C
|
||||||
#define GLFW_WINDOW_NO_RESIZE 0x0002100D
|
#define GLFW_WINDOW_RESIZABLE 0x0002100D
|
||||||
#define GLFW_FSAA_SAMPLES 0x0002100E
|
#define GLFW_FSAA_SAMPLES 0x0002100E
|
||||||
#define GLFW_OPENGL_VERSION_MAJOR 0x0002100F
|
#define GLFW_OPENGL_VERSION_MAJOR 0x0002100F
|
||||||
#define GLFW_OPENGL_VERSION_MINOR 0x00021010
|
#define GLFW_OPENGL_VERSION_MINOR 0x00021010
|
||||||
@ -438,13 +427,14 @@ extern "C" {
|
|||||||
#define GLFW_OPENGL_COMPAT_PROFILE 0x00000002
|
#define GLFW_OPENGL_COMPAT_PROFILE 0x00000002
|
||||||
#define GLFW_OPENGL_ES2_PROFILE 0x00000004
|
#define GLFW_OPENGL_ES2_PROFILE 0x00000004
|
||||||
|
|
||||||
/* glfwEnable/glfwDisable tokens */
|
/* glfwGetInputMode/glfwSetInputMode tokens */
|
||||||
|
#define GLFW_CURSOR_MODE 0x00030001
|
||||||
#define GLFW_STICKY_KEYS 0x00030002
|
#define GLFW_STICKY_KEYS 0x00030002
|
||||||
#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
|
#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
|
||||||
#define GLFW_SYSTEM_KEYS 0x00030004
|
#define GLFW_SYSTEM_KEYS 0x00030004
|
||||||
#define GLFW_KEY_REPEAT 0x00030005
|
#define GLFW_KEY_REPEAT 0x00030005
|
||||||
|
|
||||||
/* glfwSetCursorMode tokens */
|
/* GLFW_CURSOR_MODE values */
|
||||||
#define GLFW_CURSOR_NORMAL 0x00040001
|
#define GLFW_CURSOR_NORMAL 0x00040001
|
||||||
#define GLFW_CURSOR_HIDDEN 0x00040002
|
#define GLFW_CURSOR_HIDDEN 0x00040002
|
||||||
#define GLFW_CURSOR_CAPTURED 0x00040003
|
#define GLFW_CURSOR_CAPTURED 0x00040003
|
||||||
@ -494,8 +484,6 @@ typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
|||||||
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
|
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
||||||
typedef void* (* GLFWmallocfun)(size_t);
|
|
||||||
typedef void (* GLFWfreefun)(void*);
|
|
||||||
|
|
||||||
/* The video mode structure used by glfwGetVideoModes */
|
/* The video mode structure used by glfwGetVideoModes */
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -515,19 +503,6 @@ typedef struct
|
|||||||
unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
|
unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
|
||||||
} GLFWgammaramp;
|
} GLFWgammaramp;
|
||||||
|
|
||||||
/* Custom memory allocator interface */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GLFWmallocfun malloc;
|
|
||||||
GLFWfreefun free;
|
|
||||||
} GLFWallocator;
|
|
||||||
|
|
||||||
/* Custom threading model interface */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int dummy;
|
|
||||||
} GLFWthreadmodel;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Prototypes
|
* Prototypes
|
||||||
@ -535,7 +510,6 @@ typedef struct
|
|||||||
|
|
||||||
/* Initialization, termination and version querying */
|
/* Initialization, termination and version querying */
|
||||||
GLFWAPI int glfwInit(void);
|
GLFWAPI int glfwInit(void);
|
||||||
GLFWAPI int glfwInitWithModels(GLFWthreadmodel* threading, GLFWallocator* allocator);
|
|
||||||
GLFWAPI void glfwTerminate(void);
|
GLFWAPI void glfwTerminate(void);
|
||||||
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
|
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
|
||||||
GLFWAPI const char* glfwGetVersionString(void);
|
GLFWAPI const char* glfwGetVersionString(void);
|
||||||
@ -580,11 +554,12 @@ GLFWAPI void glfwPollEvents(void);
|
|||||||
GLFWAPI void glfwWaitEvents(void);
|
GLFWAPI void glfwWaitEvents(void);
|
||||||
|
|
||||||
/* Input handling */
|
/* Input handling */
|
||||||
|
GLFWAPI int glfwGetInputMode(GLFWwindow window, int mode);
|
||||||
|
GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value);
|
||||||
GLFWAPI int glfwGetKey(GLFWwindow window, int key);
|
GLFWAPI int glfwGetKey(GLFWwindow window, int key);
|
||||||
GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button);
|
GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button);
|
||||||
GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos);
|
GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos);
|
||||||
GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos);
|
GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos);
|
||||||
GLFWAPI void glfwSetCursorMode(GLFWwindow window, int mode);
|
|
||||||
GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* xoffset, int* yoffset);
|
GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* xoffset, int* yoffset);
|
||||||
GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun);
|
GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun);
|
||||||
GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
|
GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
|
||||||
@ -614,10 +589,6 @@ GLFWAPI int glfwExtensionSupported(const char* extension);
|
|||||||
GLFWAPI void* glfwGetProcAddress(const char* procname);
|
GLFWAPI void* glfwGetProcAddress(const char* procname);
|
||||||
GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
|
GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
|
||||||
|
|
||||||
/* Enable/disable functions */
|
|
||||||
GLFWAPI void glfwEnable(GLFWwindow window, int token);
|
|
||||||
GLFWAPI void glfwDisable(GLFWwindow window, int token);
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Global definition cleanup
|
* Global definition cleanup
|
||||||
@ -625,11 +596,6 @@ GLFWAPI void glfwDisable(GLFWwindow window, int token);
|
|||||||
|
|
||||||
/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
|
/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
|
||||||
|
|
||||||
#ifdef GLFW_APIENTRY_DEFINED
|
|
||||||
#undef APIENTRY
|
|
||||||
#undef GLFW_APIENTRY_DEFINED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GLFW_WINGDIAPI_DEFINED
|
#ifdef GLFW_WINGDIAPI_DEFINED
|
||||||
#undef WINGDIAPI
|
#undef WINGDIAPI
|
||||||
#undef GLFW_WINGDIAPI_DEFINED
|
#undef GLFW_WINGDIAPI_DEFINED
|
||||||
|
20
readme.html
20
readme.html
@ -272,25 +272,27 @@ version of GLFW.</p>
|
|||||||
<li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
|
<li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
|
||||||
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
|
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
|
||||||
<li>Added <code>glfwGetCurrentContext</code> function for retrieving the window whose OpenGL context is current</li>
|
<li>Added <code>glfwGetCurrentContext</code> function for retrieving the window whose OpenGL context is current</li>
|
||||||
<li>Added <code>glfwInitWithModels</code> function and <code>GLFWallocator</code> and <code>GLFWthreadmodel</code> types for pluggable memory allocation and threading models</li>
|
|
||||||
<li>Added <code>glfwCopyContext</code> function for copying OpenGL state categories between contexts</li>
|
<li>Added <code>glfwCopyContext</code> function for copying OpenGL state categories between contexts</li>
|
||||||
<li>Added <code>glfwSetCursorMode</code> function for controlling per-window cursor mode, replacing <code>GLFW_MOUSE_CURSOR</code></li>
|
|
||||||
<li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li>
|
<li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li>
|
||||||
<li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li>
|
<li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li>
|
||||||
<li>Added <code>GLFW_OPENGL_REVISION</code> window parameter to make up for removal of <code>glfwGetGLVersion</code></li>
|
<li>Added <code>GLFW_OPENGL_REVISION</code> window parameter to make up for removal of <code>glfwGetGLVersion</code></li>
|
||||||
<li>Added <code>GLFW_INCLUDE_GL3</code> macro for telling the GLFW header to include <code>gl3.h</code> header instead of <code>gl.h</code></li>
|
<li>Added <code>GLFW_INCLUDE_GL3</code> macro for telling the GLFW header to include <code>gl3.h</code> header instead of <code>gl.h</code></li>
|
||||||
<li>Added <code>windows</code> simple multi-window test program</li>
|
<li>Added <code>windows</code> simple multi-window test program</li>
|
||||||
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
|
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
|
||||||
|
<li>Added <code>dynamic</code> simple dynamic linking test program</li>
|
||||||
<li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li>
|
<li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li>
|
||||||
<li>Added initial window title parameter to <code>glfwOpenWindow</code></li>
|
<li>Added initial window title parameter to <code>glfwOpenWindow</code></li>
|
||||||
<li>Added <code>glfwSetGamma</code>, <code>glfwSetGammaRamp</code> and <code>glfwGetGammaRamp</code> functions and <code>GLFWgammaramp</code> type for monitor gamma ramp control</li>
|
<li>Added <code>glfwSetGamma</code>, <code>glfwSetGammaRamp</code> and <code>glfwGetGammaRamp</code> functions and <code>GLFWgammaramp</code> type for monitor gamma ramp control</li>
|
||||||
<li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>
|
<li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>
|
||||||
|
<li>Changed <code>glfwOpenWindow</code> and <code>glfwSetWindowTitle</code> to use UTF-8 encoded strings</li>
|
||||||
<li>Renamed <code>glfw.h</code> to <code>glfw3.h</code> to avoid conflicts with 2.x series</li>
|
<li>Renamed <code>glfw.h</code> to <code>glfw3.h</code> to avoid conflicts with 2.x series</li>
|
||||||
<li>Renamed <code>GLFW_WINDOW</code> token to <code>GLFW_WINDOWED</code></li>
|
<li>Renamed <code>GLFW_WINDOW</code> token to <code>GLFW_WINDOWED</code></li>
|
||||||
|
<li>Renamed <code>GLFW_WINDOW_NO_RESIZE</code> to <code>GLFW_WINDOW_RESIZABLE</code></li>
|
||||||
<li>Renamed <code>version</code> test to <code>glfwinfo</code></li>
|
<li>Renamed <code>version</code> test to <code>glfwinfo</code></li>
|
||||||
<li>Replaced ad hoc build system with CMake</li>
|
<li>Replaced ad hoc build system with CMake</li>
|
||||||
<li>Replaced layout-dependent key codes with single, platform-independent set based on US layout</li>
|
<li>Replaced layout-dependent key codes with single, platform-independent set based on US layout</li>
|
||||||
<li>Replaced mouse wheel interface with two-dimensional scrolling interface</li>
|
<li>Replaced mouse wheel interface with two-dimensional scrolling interface</li>
|
||||||
|
<li>Replaced <code>glfwEnable</code> and <code>glfwDisable</code> with <code>glfwGetInputMode</code> and <code>glfwSetInputMode</code></li>
|
||||||
<li>Made Unicode character input unaffected by <code>GLFW_KEY_REPEAT</code></li>
|
<li>Made Unicode character input unaffected by <code>GLFW_KEY_REPEAT</code></li>
|
||||||
<li>Removed event auto-polling and the <code>GLFW_AUTO_POLL_EVENTS</code> window enable</li>
|
<li>Removed event auto-polling and the <code>GLFW_AUTO_POLL_EVENTS</code> window enable</li>
|
||||||
<li>Removed the Win32 port .def files</li>
|
<li>Removed the Win32 port .def files</li>
|
||||||
@ -307,15 +309,24 @@ version of GLFW.</p>
|
|||||||
<li>Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation</li>
|
<li>Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation</li>
|
||||||
<li>Bugfix: The FSAA test did not check for the availability of <code>GL_ARB_multisample</code></li>
|
<li>Bugfix: The FSAA test did not check for the availability of <code>GL_ARB_multisample</code></li>
|
||||||
<li>[Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above</li>
|
<li>[Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above</li>
|
||||||
|
<li>[Cocoa] Added support for joysticks</li>
|
||||||
|
<li>[Cocoa] Replaced <code>NSDate</code> time source with <code>mach_absolute_time</code></li>
|
||||||
<li>[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable</li>
|
<li>[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable</li>
|
||||||
<li>[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash</li>
|
<li>[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash</li>
|
||||||
|
<li>[Cocoa] Bugfix: <code>glfwInit</code> changed the current directory for unbundled executables</li>
|
||||||
<li>[X11] Added support for the <code>GLX_EXT_swap_control</code> extension as an alternative to <code>GLX_SGI_swap_control</code></li>
|
<li>[X11] Added support for the <code>GLX_EXT_swap_control</code> extension as an alternative to <code>GLX_SGI_swap_control</code></li>
|
||||||
<li>[X11] Added the POSIX <code>CLOCK_MONOTONIC</code> time source as the preferred method</li>
|
<li>[X11] Added the POSIX <code>CLOCK_MONOTONIC</code> time source as the preferred method</li>
|
||||||
|
<li>[X11] Added dependency on libm, where present</li>
|
||||||
|
<li>[X11] Added support for the <code>_NET_WM_NAME</code> and <code>_NET_WM_ICON_NAME</code> EWMH window properties</li>
|
||||||
|
<li>[X11] Bugfix: Some window properties required by the ICCCM were not set</li>
|
||||||
<li>[X11] Bugfix: Calling <code>glXCreateContextAttribsARB</code> with an unavailable OpenGL version caused the application to terminate with a <code>BadMatch</code> Xlib error</li>
|
<li>[X11] Bugfix: Calling <code>glXCreateContextAttribsARB</code> with an unavailable OpenGL version caused the application to terminate with a <code>BadMatch</code> Xlib error</li>
|
||||||
|
<li>[X11] Bugfix: A synchronization point necessary for jitter-free locked cursor mode was incorrectly removed</li>
|
||||||
|
<li>[Win32] Changed port to use Unicode mode only</li>
|
||||||
<li>[Win32] Removed explicit support for versions of Windows older than Windows XP</li>
|
<li>[Win32] Removed explicit support for versions of Windows older than Windows XP</li>
|
||||||
<li>[Win32] Bugfix: Window activation and iconification did not work as expected</li>
|
<li>[Win32] Bugfix: Window activation and iconification did not work as expected</li>
|
||||||
<li>[Win32] Bugfix: Software rasterizer pixel formats were not discarded by the WGL_ARB_pixel_format code path</li>
|
<li>[Win32] Bugfix: Software rasterizer pixel formats were not discarded by the WGL_ARB_pixel_format code path</li>
|
||||||
<li>[Win32] Bugfix: The array for WGL context attributes was too small and could overflow</li>
|
<li>[Win32] Bugfix: The array for WGL context attributes was too small and could overflow</li>
|
||||||
|
<li>[Win32] Bugfix: Alt+F4 hot key was not translated into <code>WM_CLOSE</code></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>v2.7</h3>
|
<h3>v2.7</h3>
|
||||||
@ -857,6 +868,8 @@ their skills. Special thanks go out to:</p>
|
|||||||
|
|
||||||
<li>Tristam MacDonald, for his bug reports and feedback on the Cocoa port</li>
|
<li>Tristam MacDonald, for his bug reports and feedback on the Cocoa port</li>
|
||||||
|
|
||||||
|
<li>Hans 'Hanmac' Mackowiak, for adding UTF-8 window title support on X11</li>
|
||||||
|
|
||||||
<li>David Medlock, for doing the initial Lua port</li>
|
<li>David Medlock, for doing the initial Lua port</li>
|
||||||
|
|
||||||
<li>Kenneth Miller, for his many and detailed bug reports on Win32</li>
|
<li>Kenneth Miller, for his many and detailed bug reports on Win32</li>
|
||||||
@ -886,6 +899,9 @@ their skills. Special thanks go out to:</p>
|
|||||||
|
|
||||||
<li>Johannes Stein, for maintaining the Pascal bindings</li>
|
<li>Johannes Stein, for maintaining the Pascal bindings</li>
|
||||||
|
|
||||||
|
<li>Sergey Tikhomirov, for the initial implementation of joystick support on
|
||||||
|
Mac OS X</li>
|
||||||
|
|
||||||
<li>Samuli Tuomola, for support, bug reports and testing</li>
|
<li>Samuli Tuomola, for support, bug reports and testing</li>
|
||||||
|
|
||||||
<li>Frank Wille, for helping with the AmigaOS port and making GLFW
|
<li>Frank Wille, for helping with the AmigaOS port and making GLFW
|
||||||
|
@ -1,16 +1,4 @@
|
|||||||
|
|
||||||
if(CYGWIN)
|
|
||||||
|
|
||||||
# These lines are intended to remove the --export-all-symbols
|
|
||||||
# flag added in the Modules/Platform/CYGWIN.cmake file of the
|
|
||||||
# CMake distribution.
|
|
||||||
# This is a HACK. If you have trouble _linking_ the GLFW
|
|
||||||
# _shared_ library on Cygwin, try disabling this.
|
|
||||||
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
|
|
||||||
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
|
|
||||||
|
|
||||||
endif(CYGWIN)
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
if(_GLFW_HAS_XRANDR)
|
if(_GLFW_HAS_XRANDR)
|
||||||
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
|
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
|
||||||
@ -27,27 +15,25 @@ include_directories(${GLFW_SOURCE_DIR}/src
|
|||||||
${GLFW_BINARY_DIR}/src
|
${GLFW_BINARY_DIR}/src
|
||||||
${GLFW_INCLUDE_DIR})
|
${GLFW_INCLUDE_DIR})
|
||||||
|
|
||||||
set(common_SOURCES clipboard.c enable.c error.c fullscreen.c gamma.c init.c input.c
|
set(common_SOURCES clipboard.c error.c fullscreen.c gamma.c init.c input.c
|
||||||
joystick.c opengl.c time.c window.c)
|
joystick.c opengl.c time.c window.c)
|
||||||
|
|
||||||
if(_GLFW_COCOA_NSGL)
|
if(_GLFW_COCOA_NSGL)
|
||||||
set(libglfw_SOURCES ${common_SOURCES} cocoa_clipboard.c
|
set(libglfw_SOURCES ${common_SOURCES} cocoa_clipboard.m
|
||||||
cocoa_enable.m cocoa_fullscreen.m
|
cocoa_fullscreen.m cocoa_gamma.m
|
||||||
cocoa_gamma.m cocoa_init.m cocoa_joystick.m
|
cocoa_init.m cocoa_input.m cocoa_joystick.m
|
||||||
cocoa_opengl.m cocoa_time.m cocoa_window.m)
|
cocoa_opengl.m cocoa_time.m cocoa_window.m)
|
||||||
|
|
||||||
# For some reason, CMake doesn't know about .m
|
# For some reason, CMake doesn't know about .m
|
||||||
set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C)
|
set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C)
|
||||||
elseif(_GLFW_WIN32_WGL)
|
elseif(_GLFW_WIN32_WGL)
|
||||||
set(libglfw_SOURCES ${common_SOURCES} win32_clipboard.c
|
set(libglfw_SOURCES ${common_SOURCES} win32_clipboard.c win32_fullscreen.c
|
||||||
win32_enable.c win32_fullscreen.c
|
win32_gamma.c win32_init.c win32_input.c win32_joystick.c
|
||||||
win32_gamma.c win32_init.c win32_joystick.c
|
|
||||||
win32_opengl.c win32_time.c win32_window.c
|
win32_opengl.c win32_time.c win32_window.c
|
||||||
win32_dllmain.c)
|
win32_dllmain.c)
|
||||||
elseif(_GLFW_X11_GLX)
|
elseif(_GLFW_X11_GLX)
|
||||||
set(libglfw_SOURCES ${common_SOURCES} x11_clipboard.c
|
set(libglfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_fullscreen.c
|
||||||
x11_enable.c x11_fullscreen.c
|
x11_gamma.c x11_init.c x11_input.c x11_joystick.c
|
||||||
x11_gamma.c x11_init.c x11_joystick.c
|
|
||||||
x11_keysym2unicode.c x11_opengl.c x11_time.c
|
x11_keysym2unicode.c x11_opengl.c x11_time.c
|
||||||
x11_window.c)
|
x11_window.c)
|
||||||
else()
|
else()
|
||||||
@ -70,13 +56,6 @@ if(WIN32)
|
|||||||
IMPORT_SUFFIX "dll.lib")
|
IMPORT_SUFFIX "dll.lib")
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
if(CYGWIN)
|
|
||||||
# Build for the regular Win32 environment (not Cygwin)
|
|
||||||
set_target_properties(libglfwStatic libglfwShared PROPERTIES
|
|
||||||
COMPILE_FLAGS "-mwin32 -mno-cygwin"
|
|
||||||
LINK_FLAGS "-mwin32 -mno-cygwin")
|
|
||||||
endif(CYGWIN)
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
|
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
|
||||||
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
|
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
|
||||||
|
@ -50,8 +50,6 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
|
|||||||
CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE];
|
CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE];
|
||||||
|
|
||||||
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
|
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
|
||||||
// i.e. 256. I don't think anyone would want to change the gamma on
|
|
||||||
// Mac anyway...
|
|
||||||
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
|
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -80,8 +78,6 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
|
|||||||
CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE];
|
CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE];
|
||||||
|
|
||||||
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
|
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
|
||||||
// i.e. 256. I don't think anyone would want to change the gamma on
|
|
||||||
// Mac anyway...
|
|
||||||
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
|
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -93,6 +89,7 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
|
|||||||
green[i] = ramp->green[i] / 65535.f;
|
green[i] = ramp->green[i] / 65535.f;
|
||||||
blue[i] = ramp->blue[i] / 65535.f;
|
blue[i] = ramp->blue[i] / 65535.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGSetDisplayTransferByTable(CGMainDisplayID(), GLFW_GAMMA_RAMP_SIZE, red, green, blue);
|
CGSetDisplayTransferByTable(CGMainDisplayID(), GLFW_GAMMA_RAMP_SIZE, red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,18 @@ NSString* GLFWNameKeys[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Change to our application bundle's resources directory, if present
|
||||||
|
//========================================================================
|
||||||
|
static void changeToResourcesDirectory(void)
|
||||||
|
{
|
||||||
|
char* resourcePath = [[[NSBundle mainBundle] resourcePath] UTF8String];
|
||||||
|
|
||||||
|
if (access(resourcePath, R_OK) == 0)
|
||||||
|
chdir(resourcePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Try to figure out what the calling application is called
|
// Try to figure out what the calling application is called
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -87,15 +99,12 @@ static NSString* findAppName(void)
|
|||||||
[name isKindOfClass:[NSString class]] &&
|
[name isKindOfClass:[NSString class]] &&
|
||||||
![@"" isEqualToString:name])
|
![@"" isEqualToString:name])
|
||||||
{
|
{
|
||||||
|
_glfwLibrary.NS.bundled = GL_TRUE;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, we're unbundled
|
// If we get here, we're unbundled
|
||||||
if (!_glfwLibrary.NS.unbundled)
|
|
||||||
{
|
|
||||||
// Could do this only if we discover we're unbundled, but it should
|
|
||||||
// do no harm...
|
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
|
|
||||||
@ -103,13 +112,10 @@ static NSString* findAppName(void)
|
|||||||
// handy. There is an NSApplication API to do this, but...
|
// handy. There is an NSApplication API to do this, but...
|
||||||
SetFrontProcess(&psn);
|
SetFrontProcess(&psn);
|
||||||
|
|
||||||
_glfwLibrary.NS.unbundled = GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char** progname = _NSGetProgname();
|
char** progname = _NSGetProgname();
|
||||||
if (progname && *progname)
|
if (progname && *progname)
|
||||||
{
|
{
|
||||||
// TODO: UTF8?
|
// TODO: UTF-8?
|
||||||
return [NSString stringWithUTF8String:*progname];
|
return [NSString stringWithUTF8String:*progname];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +208,7 @@ int _glfwPlatformInit(void)
|
|||||||
[GLFWApplication sharedApplication];
|
[GLFWApplication sharedApplication];
|
||||||
|
|
||||||
_glfwLibrary.NS.OpenGLFramework =
|
_glfwLibrary.NS.OpenGLFramework =
|
||||||
CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) );
|
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
||||||
if (_glfwLibrary.NS.OpenGLFramework == NULL)
|
if (_glfwLibrary.NS.OpenGLFramework == NULL)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
@ -210,16 +216,16 @@ int _glfwPlatformInit(void)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
|
// Setting up the menu bar must go between sharedApplication
|
||||||
|
// above and finishLaunching below, in order to properly emulate the
|
||||||
if (access([resourcePath cStringUsingEncoding:NSUTF8StringEncoding], R_OK) == 0)
|
// behavior of NSApplicationMain
|
||||||
chdir([resourcePath cStringUsingEncoding:NSUTF8StringEncoding]);
|
|
||||||
|
|
||||||
// Setting up menu bar must go exactly here else weirdness ensues
|
|
||||||
setUpMenuBar();
|
setUpMenuBar();
|
||||||
|
|
||||||
[NSApp finishLaunching];
|
[NSApp finishLaunching];
|
||||||
|
|
||||||
|
if (_glfwLibrary.NS.bundled)
|
||||||
|
changeToResourcesDirectory();
|
||||||
|
|
||||||
_glfwPlatformSetTime(0.0);
|
_glfwPlatformSetTime(0.0);
|
||||||
|
|
||||||
_glfwLibrary.NS.desktopMode =
|
_glfwLibrary.NS.desktopMode =
|
||||||
@ -230,6 +236,10 @@ int _glfwPlatformInit(void)
|
|||||||
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
||||||
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
|
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
|
||||||
|
|
||||||
|
_glfwInitTimer();
|
||||||
|
|
||||||
|
_glfwInitJoysticks();
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,6 +261,8 @@ int _glfwPlatformTerminate(void)
|
|||||||
[_glfwLibrary.NS.autoreleasePool release];
|
[_glfwLibrary.NS.autoreleasePool release];
|
||||||
_glfwLibrary.NS.autoreleasePool = nil;
|
_glfwLibrary.NS.autoreleasePool = nil;
|
||||||
|
|
||||||
|
_glfwTerminateJoysticks();
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +273,7 @@ int _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
const char* version = "GLFW " _GLFW_VERSION_FULL " Cocoa";
|
const char* version = _GLFW_VERSION_FULL " Cocoa";
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,440 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#include <mach/mach_error.h>
|
||||||
|
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <IOKit/IOKitLib.h>
|
||||||
|
#include <IOKit/IOCFPlugIn.h>
|
||||||
|
#include <IOKit/hid/IOHIDLib.h>
|
||||||
|
#include <IOKit/hid/IOHIDKeys.h>
|
||||||
|
#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Joystick element information
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
IOHIDElementCookie cookie;
|
||||||
|
|
||||||
|
long value;
|
||||||
|
|
||||||
|
long min;
|
||||||
|
long max;
|
||||||
|
|
||||||
|
long minReport;
|
||||||
|
long maxReport;
|
||||||
|
|
||||||
|
} _glfwJoystickElement;
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Joystick information & state
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int present;
|
||||||
|
char product[256];
|
||||||
|
|
||||||
|
IOHIDDeviceInterface** interface;
|
||||||
|
|
||||||
|
int numAxes;
|
||||||
|
int numButtons;
|
||||||
|
int numHats;
|
||||||
|
|
||||||
|
CFMutableArrayRef axes;
|
||||||
|
CFMutableArrayRef buttons;
|
||||||
|
CFMutableArrayRef hats;
|
||||||
|
|
||||||
|
} _glfwJoystick;
|
||||||
|
|
||||||
|
static _glfwJoystick _glfwJoysticks[GLFW_JOYSTICK_LAST + 1];
|
||||||
|
|
||||||
|
|
||||||
|
void GetElementsCFArrayHandler(const void* value, void* parameter);
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Adds an element to the specified joystick
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void addJoystickElement(_glfwJoystick* joystick, CFTypeRef refElement)
|
||||||
|
{
|
||||||
|
long elementType, usagePage, usage;
|
||||||
|
CFTypeRef refElementType, refUsagePage, refUsage;
|
||||||
|
|
||||||
|
refElementType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementTypeKey));
|
||||||
|
refUsagePage = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsagePageKey));
|
||||||
|
refUsage = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsageKey));
|
||||||
|
|
||||||
|
CFMutableArrayRef elementsArray = NULL;
|
||||||
|
|
||||||
|
CFNumberGetValue(refElementType, kCFNumberLongType, &elementType);
|
||||||
|
CFNumberGetValue(refUsagePage, kCFNumberLongType, &usagePage);
|
||||||
|
CFNumberGetValue(refUsage, kCFNumberLongType, &usage);
|
||||||
|
|
||||||
|
if ((elementType == kIOHIDElementTypeInput_Axis) ||
|
||||||
|
(elementType == kIOHIDElementTypeInput_Button) ||
|
||||||
|
(elementType == kIOHIDElementTypeInput_Misc))
|
||||||
|
{
|
||||||
|
switch (usagePage) /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */
|
||||||
|
{
|
||||||
|
case kHIDPage_GenericDesktop:
|
||||||
|
{
|
||||||
|
switch (usage)
|
||||||
|
{
|
||||||
|
case kHIDUsage_GD_X:
|
||||||
|
case kHIDUsage_GD_Y:
|
||||||
|
case kHIDUsage_GD_Z:
|
||||||
|
case kHIDUsage_GD_Rx:
|
||||||
|
case kHIDUsage_GD_Ry:
|
||||||
|
case kHIDUsage_GD_Rz:
|
||||||
|
case kHIDUsage_GD_Slider:
|
||||||
|
case kHIDUsage_GD_Dial:
|
||||||
|
case kHIDUsage_GD_Wheel:
|
||||||
|
joystick->numAxes++;
|
||||||
|
elementsArray = joystick->axes;
|
||||||
|
break;
|
||||||
|
case kHIDUsage_GD_Hatswitch:
|
||||||
|
joystick->numHats++;
|
||||||
|
elementsArray = joystick->hats;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kHIDPage_Button:
|
||||||
|
joystick->numButtons++;
|
||||||
|
elementsArray = joystick->buttons;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elementsArray)
|
||||||
|
{
|
||||||
|
long number;
|
||||||
|
CFTypeRef refType;
|
||||||
|
|
||||||
|
_glfwJoystickElement* element = (_glfwJoystickElement*) malloc(sizeof(_glfwJoystickElement));
|
||||||
|
|
||||||
|
CFArrayAppendValue(elementsArray, element);
|
||||||
|
|
||||||
|
refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementCookieKey));
|
||||||
|
if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number))
|
||||||
|
element->cookie = (IOHIDElementCookie) number;
|
||||||
|
|
||||||
|
refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMinKey));
|
||||||
|
if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number))
|
||||||
|
element->minReport = element->min = number;
|
||||||
|
|
||||||
|
refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMaxKey));
|
||||||
|
if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number))
|
||||||
|
element->maxReport = element->max = number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CFTypeRef refElementTop = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementKey));
|
||||||
|
if (refElementTop)
|
||||||
|
{
|
||||||
|
CFTypeID type = CFGetTypeID (refElementTop);
|
||||||
|
if (type == CFArrayGetTypeID()) /* if element is an array */
|
||||||
|
{
|
||||||
|
CFRange range = {0, CFArrayGetCount (refElementTop)};
|
||||||
|
CFArrayApplyFunction(refElementTop, range, GetElementsCFArrayHandler, joystick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Adds an element to the specified joystick
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void GetElementsCFArrayHandler(const void* value, void* parameter)
|
||||||
|
{
|
||||||
|
if (CFGetTypeID(value) == CFDictionaryGetTypeID())
|
||||||
|
addJoystickElement((_glfwJoystick*) parameter, (CFTypeRef) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Returns the value of the specified element of the specified joystick
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static long getElementValue(_glfwJoystick* joystick, _glfwJoystickElement* element)
|
||||||
|
{
|
||||||
|
IOReturn result = kIOReturnSuccess;
|
||||||
|
IOHIDEventStruct hidEvent;
|
||||||
|
hidEvent.value = 0;
|
||||||
|
|
||||||
|
if (joystick && element && joystick->interface)
|
||||||
|
{
|
||||||
|
result = (*(joystick->interface))->getElementValue(joystick->interface,
|
||||||
|
element->cookie,
|
||||||
|
&hidEvent);
|
||||||
|
if (kIOReturnSuccess == result)
|
||||||
|
{
|
||||||
|
/* record min and max for auto calibration */
|
||||||
|
if (hidEvent.value < element->minReport)
|
||||||
|
element->minReport = hidEvent.value;
|
||||||
|
if (hidEvent.value > element->maxReport)
|
||||||
|
element->maxReport = hidEvent.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* auto user scale */
|
||||||
|
return (long) hidEvent.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Removes the specified joystick
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void removeJoystick(_glfwJoystick* joystick)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (joystick->present)
|
||||||
|
{
|
||||||
|
joystick->present = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 0; i < joystick->numAxes; i++)
|
||||||
|
{
|
||||||
|
_glfwJoystickElement* axes =
|
||||||
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->axes, i);
|
||||||
|
free(axes);
|
||||||
|
}
|
||||||
|
CFArrayRemoveAllValues(joystick->axes);
|
||||||
|
joystick->numAxes = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < joystick->numButtons; i++)
|
||||||
|
{
|
||||||
|
_glfwJoystickElement* button =
|
||||||
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->buttons, i);
|
||||||
|
free(button);
|
||||||
|
}
|
||||||
|
CFArrayRemoveAllValues(joystick->buttons);
|
||||||
|
joystick->numButtons = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < joystick->numHats; i++)
|
||||||
|
{
|
||||||
|
_glfwJoystickElement* hat =
|
||||||
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->hats, i);
|
||||||
|
free(hat);
|
||||||
|
}
|
||||||
|
CFArrayRemoveAllValues(joystick->hats);
|
||||||
|
joystick->hats = 0;
|
||||||
|
|
||||||
|
(*(joystick->interface))->close(joystick->interface);
|
||||||
|
(*(joystick->interface))->Release(joystick->interface);
|
||||||
|
|
||||||
|
joystick->interface = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Callback for user-initiated joystick removal
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void removalCallback(void* target, IOReturn result, void* refcon, void* sender)
|
||||||
|
{
|
||||||
|
removeJoystick((_glfwJoystick*) refcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Polls for joystick events and updates GFLW state
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void pollJoystickEvents(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
CFIndex j;
|
||||||
|
|
||||||
|
for (i = 0; i < GLFW_JOYSTICK_LAST + 1; i++)
|
||||||
|
{
|
||||||
|
_glfwJoystick* joystick = &_glfwJoysticks[i];
|
||||||
|
|
||||||
|
if (joystick->present)
|
||||||
|
{
|
||||||
|
for (j = 0; j < joystick->numButtons; j++)
|
||||||
|
{
|
||||||
|
_glfwJoystickElement* button =
|
||||||
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->buttons, j);
|
||||||
|
button->value = getElementValue(joystick, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < joystick->numAxes; j++)
|
||||||
|
{
|
||||||
|
_glfwJoystickElement* axes =
|
||||||
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->axes, j);
|
||||||
|
axes->value = getElementValue(joystick, axes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Initialize joystick interface
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwInitJoysticks(void)
|
||||||
|
{
|
||||||
|
int deviceCounter = 0;
|
||||||
|
IOReturn result = kIOReturnSuccess;
|
||||||
|
mach_port_t masterPort = 0;
|
||||||
|
io_iterator_t objectIterator = 0;
|
||||||
|
CFMutableDictionaryRef hidMatchDictionary = NULL;
|
||||||
|
io_object_t ioHIDDeviceObject = 0;
|
||||||
|
|
||||||
|
result = IOMasterPort(bootstrap_port, &masterPort);
|
||||||
|
hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey);
|
||||||
|
if (kIOReturnSuccess != result || !hidMatchDictionary)
|
||||||
|
return;
|
||||||
|
|
||||||
|
result = IOServiceGetMatchingServices(masterPort,
|
||||||
|
hidMatchDictionary,
|
||||||
|
&objectIterator);
|
||||||
|
if (result != kIOReturnSuccess)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!objectIterator) /* there are no joysticks */
|
||||||
|
return;
|
||||||
|
|
||||||
|
while ((ioHIDDeviceObject = IOIteratorNext(objectIterator)))
|
||||||
|
{
|
||||||
|
CFMutableDictionaryRef hidProperties = 0;
|
||||||
|
kern_return_t result;
|
||||||
|
CFTypeRef refCF = 0;
|
||||||
|
|
||||||
|
IOCFPlugInInterface** ppPlugInInterface = NULL;
|
||||||
|
HRESULT plugInResult = S_OK;
|
||||||
|
SInt32 score = 0;
|
||||||
|
|
||||||
|
long usagePage, usage;
|
||||||
|
|
||||||
|
result = IORegistryEntryCreateCFProperties(ioHIDDeviceObject,
|
||||||
|
&hidProperties,
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
kNilOptions);
|
||||||
|
|
||||||
|
if (result != kIOReturnSuccess)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Check device type */
|
||||||
|
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey));
|
||||||
|
if (refCF)
|
||||||
|
CFNumberGetValue(refCF, kCFNumberLongType, &usagePage);
|
||||||
|
|
||||||
|
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsageKey));
|
||||||
|
if (refCF)
|
||||||
|
CFNumberGetValue(refCF, kCFNumberLongType, &usage);
|
||||||
|
|
||||||
|
if ((usagePage != kHIDPage_GenericDesktop) ||
|
||||||
|
(usage != kHIDUsage_GD_Joystick &&
|
||||||
|
usage != kHIDUsage_GD_GamePad &&
|
||||||
|
usage != kHIDUsage_GD_MultiAxisController))
|
||||||
|
{
|
||||||
|
/* We don't interested in this device */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfwJoystick* joystick = &_glfwJoysticks[deviceCounter];
|
||||||
|
|
||||||
|
joystick->present = GL_TRUE;
|
||||||
|
|
||||||
|
result = IOCreatePlugInInterfaceForService(ioHIDDeviceObject,
|
||||||
|
kIOHIDDeviceUserClientTypeID,
|
||||||
|
kIOCFPlugInInterfaceID,
|
||||||
|
&ppPlugInInterface,
|
||||||
|
&score);
|
||||||
|
|
||||||
|
if (kIOReturnSuccess != result)
|
||||||
|
return;
|
||||||
|
|
||||||
|
plugInResult = (*ppPlugInInterface)->QueryInterface(
|
||||||
|
ppPlugInInterface,
|
||||||
|
CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID),
|
||||||
|
(void *) &(joystick->interface));
|
||||||
|
|
||||||
|
if (plugInResult != S_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
(*ppPlugInInterface)->Release(ppPlugInInterface);
|
||||||
|
|
||||||
|
(*(joystick->interface))->open(joystick->interface, 0);
|
||||||
|
(*(joystick->interface))->setRemovalCallback(joystick->interface,
|
||||||
|
removalCallback,
|
||||||
|
joystick,
|
||||||
|
joystick);
|
||||||
|
|
||||||
|
/* Get product string */
|
||||||
|
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
|
||||||
|
if (refCF)
|
||||||
|
{
|
||||||
|
CFStringGetCString(refCF,
|
||||||
|
(char*) &(joystick->product),
|
||||||
|
256,
|
||||||
|
CFStringGetSystemEncoding());
|
||||||
|
}
|
||||||
|
|
||||||
|
joystick->numAxes = 0;
|
||||||
|
joystick->numButtons = 0;
|
||||||
|
joystick->numHats = 0;
|
||||||
|
joystick->axes = CFArrayCreateMutable(NULL, 0, NULL);
|
||||||
|
joystick->buttons = CFArrayCreateMutable(NULL, 0, NULL);
|
||||||
|
joystick->hats = CFArrayCreateMutable(NULL, 0, NULL);
|
||||||
|
|
||||||
|
CFTypeRef refTopElement = CFDictionaryGetValue(hidProperties,
|
||||||
|
CFSTR(kIOHIDElementKey));
|
||||||
|
CFTypeID type = CFGetTypeID(refTopElement);
|
||||||
|
if (type == CFArrayGetTypeID())
|
||||||
|
{
|
||||||
|
CFRange range = { 0, CFArrayGetCount(refTopElement) };
|
||||||
|
CFArrayApplyFunction(refTopElement,
|
||||||
|
range,
|
||||||
|
GetElementsCFArrayHandler,
|
||||||
|
(void*) joystick);
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceCounter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Close all opened joystick handles
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwTerminateJoysticks(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < GLFW_JOYSTICK_LAST + 1; i++)
|
||||||
|
{
|
||||||
|
_glfwJoystick* joystick = &_glfwJoysticks[i];
|
||||||
|
removeJoystick(joystick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
@ -38,29 +472,111 @@
|
|||||||
// Determine joystick capabilities
|
// Determine joystick capabilities
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwPlatformGetJoystickParam( int joy, int param )
|
int _glfwPlatformGetJoystickParam(int joy, int param)
|
||||||
{
|
{
|
||||||
// TODO: Implement this.
|
if (!_glfwJoysticks[joy].present)
|
||||||
return 0;
|
{
|
||||||
|
// TODO: Figure out if this is an error
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (param)
|
||||||
|
{
|
||||||
|
case GLFW_PRESENT:
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
case GLFW_AXES:
|
||||||
|
return (int) CFArrayGetCount(_glfwJoysticks[joy].axes);
|
||||||
|
|
||||||
|
case GLFW_BUTTONS:
|
||||||
|
return (int) CFArrayGetCount(_glfwJoysticks[joy].buttons);
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Get joystick axis positions
|
// Get joystick axis positions
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
|
int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes)
|
||||||
{
|
{
|
||||||
// TODO: Implement this.
|
int i;
|
||||||
|
|
||||||
|
if (joy < GLFW_JOYSTICK_1 || joy > GLFW_JOYSTICK_LAST)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
_glfwJoystick joystick = _glfwJoysticks[joy];
|
||||||
|
|
||||||
|
if (!joystick.present)
|
||||||
|
{
|
||||||
|
// TODO: Figure out if this is an error
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
numaxes = numaxes < joystick.numAxes ? numaxes : joystick.numAxes;
|
||||||
|
|
||||||
|
// Update joystick state
|
||||||
|
pollJoystickEvents();
|
||||||
|
|
||||||
|
for (i = 0; i < numaxes; i++)
|
||||||
|
{
|
||||||
|
_glfwJoystickElement* axes =
|
||||||
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick.axes, i);
|
||||||
|
|
||||||
|
long readScale = axes->maxReport - axes->minReport;
|
||||||
|
|
||||||
|
if (readScale == 0)
|
||||||
|
pos[i] = axes->value;
|
||||||
|
else
|
||||||
|
pos[i] = (2.0f * (axes->value - axes->minReport) / readScale) - 1.0f;
|
||||||
|
|
||||||
|
//printf("%ld, %ld, %ld\n", axes->value, axes->minReport, axes->maxReport);
|
||||||
|
|
||||||
|
if (i & 1)
|
||||||
|
pos[i] = -pos[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return numaxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Get joystick button states
|
// Get joystick button states
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons, int numbuttons )
|
int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons,
|
||||||
|
int numbuttons)
|
||||||
{
|
{
|
||||||
// TODO: Implement this.
|
int i;
|
||||||
|
|
||||||
|
if (joy < GLFW_JOYSTICK_1 || joy > GLFW_JOYSTICK_LAST)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
_glfwJoystick joystick = _glfwJoysticks[joy];
|
||||||
|
|
||||||
|
if (!joystick.present)
|
||||||
|
{
|
||||||
|
// TODO: Figure out if this is an error
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
numbuttons = numbuttons < joystick.numButtons ? numbuttons : joystick.numButtons;
|
||||||
|
|
||||||
|
// Update joystick state
|
||||||
|
pollJoystickEvents();
|
||||||
|
|
||||||
|
for (i = 0; i < numbuttons; i++)
|
||||||
|
{
|
||||||
|
_glfwJoystickElement* button = (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick.buttons, i);
|
||||||
|
buttons[i] = button->value ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numbuttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,16 +85,29 @@ typedef struct _GLFWwindowNS
|
|||||||
typedef struct _GLFWlibraryNS
|
typedef struct _GLFWlibraryNS
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
double t0;
|
double base;
|
||||||
|
double resolution;
|
||||||
} timer;
|
} timer;
|
||||||
|
|
||||||
// dlopen handle for dynamically loading OpenGL extension entry points
|
// dlopen handle for dynamically loading OpenGL extension entry points
|
||||||
void* OpenGLFramework;
|
void* OpenGLFramework;
|
||||||
GLboolean unbundled;
|
GLboolean bundled;
|
||||||
id desktopMode;
|
id desktopMode;
|
||||||
id delegate;
|
id delegate;
|
||||||
id autoreleasePool;
|
id autoreleasePool;
|
||||||
} _GLFWlibraryNS;
|
} _GLFWlibraryNS;
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Prototypes for platform specific internal functions
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
// Time
|
||||||
|
void _glfwInitTimer(void);
|
||||||
|
|
||||||
|
// Joystick input
|
||||||
|
void _glfwInitJoysticks(void);
|
||||||
|
void _glfwTerminateJoysticks(void);
|
||||||
|
|
||||||
|
|
||||||
#endif // _platform_h_
|
#endif // _platform_h_
|
||||||
|
@ -29,6 +29,36 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Return raw time
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static uint64_t getRawTime(void)
|
||||||
|
{
|
||||||
|
return mach_absolute_time();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Initialise timer
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwInitTimer(void)
|
||||||
|
{
|
||||||
|
mach_timebase_info_data_t info;
|
||||||
|
mach_timebase_info(&info);
|
||||||
|
|
||||||
|
_glfwLibrary.NS.timer.resolution = (double) info.numer / (info.denom * 1.0e9);
|
||||||
|
_glfwLibrary.NS.timer.base = getRawTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
@ -40,8 +70,8 @@
|
|||||||
|
|
||||||
double _glfwPlatformGetTime(void)
|
double _glfwPlatformGetTime(void)
|
||||||
{
|
{
|
||||||
return [NSDate timeIntervalSinceReferenceDate] -
|
return (double) (getRawTime() - _glfwLibrary.NS.timer.base) *
|
||||||
_glfwLibrary.NS.timer.t0;
|
_glfwLibrary.NS.timer.resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -50,7 +80,7 @@ double _glfwPlatformGetTime(void)
|
|||||||
|
|
||||||
void _glfwPlatformSetTime(double time)
|
void _glfwPlatformSetTime(double time)
|
||||||
{
|
{
|
||||||
_glfwLibrary.NS.timer.t0 =
|
_glfwLibrary.NS.timer.base = getRawTime() -
|
||||||
[NSDate timeIntervalSinceReferenceDate] - time;
|
(uint64_t) (time / _glfwLibrary.NS.timer.resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ static const unsigned int MAC_TO_GLFW_KEYCODE_MAPPING[128] =
|
|||||||
/* 07 */ GLFW_KEY_X,
|
/* 07 */ GLFW_KEY_X,
|
||||||
/* 08 */ GLFW_KEY_C,
|
/* 08 */ GLFW_KEY_C,
|
||||||
/* 09 */ GLFW_KEY_V,
|
/* 09 */ GLFW_KEY_V,
|
||||||
/* 0a */ -1,
|
/* 0a */ GLFW_KEY_GRAVE_ACCENT,
|
||||||
/* 0b */ GLFW_KEY_B,
|
/* 0b */ GLFW_KEY_B,
|
||||||
/* 0c */ GLFW_KEY_Q,
|
/* 0c */ GLFW_KEY_Q,
|
||||||
/* 0d */ GLFW_KEY_W,
|
/* 0d */ GLFW_KEY_W,
|
||||||
@ -187,7 +187,7 @@ static const unsigned int MAC_TO_GLFW_KEYCODE_MAPPING[128] =
|
|||||||
/* 2f */ GLFW_KEY_PERIOD,
|
/* 2f */ GLFW_KEY_PERIOD,
|
||||||
/* 30 */ GLFW_KEY_TAB,
|
/* 30 */ GLFW_KEY_TAB,
|
||||||
/* 31 */ GLFW_KEY_SPACE,
|
/* 31 */ GLFW_KEY_SPACE,
|
||||||
/* 32 */ GLFW_KEY_GRAVE_ACCENT,
|
/* 32 */ GLFW_KEY_WORLD_1,
|
||||||
/* 33 */ GLFW_KEY_BACKSPACE,
|
/* 33 */ GLFW_KEY_BACKSPACE,
|
||||||
/* 34 */ -1,
|
/* 34 */ -1,
|
||||||
/* 35 */ GLFW_KEY_ESCAPE,
|
/* 35 */ GLFW_KEY_ESCAPE,
|
||||||
@ -393,7 +393,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
|
|
||||||
if ([event modifierFlags] & NSCommandKeyMask)
|
if ([event modifierFlags] & NSCommandKeyMask)
|
||||||
{
|
{
|
||||||
if (!window->sysKeysDisabled)
|
if (window->systemKeys)
|
||||||
[super keyDown:event];
|
[super keyDown:event];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -443,20 +443,66 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW platform API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Here is where the window is created, and the OpenGL rendering context is
|
// Create the Cocoa window
|
||||||
// created
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
static GLboolean createWindow(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig *wndconfig,
|
const _GLFWwndconfig* wndconfig)
|
||||||
const _GLFWfbconfig *fbconfig)
|
|
||||||
{
|
{
|
||||||
|
unsigned int styleMask = 0;
|
||||||
|
|
||||||
|
if (wndconfig->mode == GLFW_WINDOWED)
|
||||||
|
{
|
||||||
|
styleMask = NSTitledWindowMask | NSClosableWindowMask |
|
||||||
|
NSMiniaturizableWindowMask;
|
||||||
|
|
||||||
|
if (wndconfig->resizable)
|
||||||
|
styleMask |= NSResizableWindowMask;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
styleMask = NSBorderlessWindowMask;
|
||||||
|
|
||||||
|
window->NS.window = [[NSWindow alloc]
|
||||||
|
initWithContentRect:NSMakeRect(0, 0, window->width, window->height)
|
||||||
|
styleMask:styleMask
|
||||||
|
backing:NSBackingStoreBuffered
|
||||||
|
defer:NO];
|
||||||
|
|
||||||
|
if (window->NS.window == nil)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa/NSOpenGL: Failed to create window");
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
[window->NS.window setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
||||||
|
[window->NS.window setContentView:[[GLFWContentView alloc]
|
||||||
|
initWithGlfwWindow:window]];
|
||||||
|
[window->NS.window setDelegate:window->NS.delegate];
|
||||||
|
[window->NS.window setAcceptsMouseMovedEvents:YES];
|
||||||
|
[window->NS.window center];
|
||||||
|
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Create the OpenGL context
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static GLboolean createContext(_GLFWwindow* window,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig)
|
||||||
|
{
|
||||||
|
unsigned int attributeCount = 0;
|
||||||
|
|
||||||
|
// Mac 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 MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
// Fail if any OpenGL version above 2.1 other than 3.2 was requested
|
// Fail if any OpenGL version above 2.1 other than 3.2 was requested
|
||||||
if (wndconfig->glMajor > 3 ||
|
if (wndconfig->glMajor > 3 ||
|
||||||
@ -499,104 +545,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can only have one application delegate, but we only allocate it the
|
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
|
||||||
// first time we create a window to keep all window code in this file
|
|
||||||
if (_glfwLibrary.NS.delegate == nil)
|
|
||||||
{
|
|
||||||
_glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init];
|
|
||||||
if (_glfwLibrary.NS.delegate == nil)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Cocoa/NSOpenGL: Failed to create application "
|
|
||||||
"delegate");
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
[NSApp setDelegate:_glfwLibrary.NS.delegate];
|
|
||||||
}
|
|
||||||
|
|
||||||
window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
|
|
||||||
if (window->NS.delegate == nil)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Cocoa/NSOpenGL: Failed to create window delegate");
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mac 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;
|
|
||||||
|
|
||||||
// Ignored hints:
|
|
||||||
// OpenGLMajor, OpenGLMinor, OpenGLForward:
|
|
||||||
// pending Mac OS X support for OpenGL 3.x
|
|
||||||
// OpenGLDebug
|
|
||||||
// pending it meaning anything on Mac OS X
|
|
||||||
|
|
||||||
// Don't use accumulation buffer support; it's not accelerated
|
|
||||||
// Aux buffers probably aren't accelerated either
|
|
||||||
|
|
||||||
CFDictionaryRef fullscreenMode = NULL;
|
|
||||||
if (wndconfig->mode == GLFW_FULLSCREEN)
|
|
||||||
{
|
|
||||||
// I think it's safe to pass 0 to the refresh rate for this function
|
|
||||||
// rather than conditionalizing the code to call the version which
|
|
||||||
// doesn't specify refresh...
|
|
||||||
fullscreenMode =
|
|
||||||
CGDisplayBestModeForParametersAndRefreshRateWithProperty(
|
|
||||||
CGMainDisplayID(),
|
|
||||||
colorBits + fbconfig->alphaBits,
|
|
||||||
window->width, window->height,
|
|
||||||
wndconfig->refreshRate,
|
|
||||||
// Controversial, see macosx_fullscreen.m for discussion
|
|
||||||
kCGDisplayModeIsSafeForHardware,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
window->width =
|
|
||||||
[[(id)fullscreenMode objectForKey:(id)kCGDisplayWidth] intValue];
|
|
||||||
window->height =
|
|
||||||
[[(id)fullscreenMode objectForKey:(id)kCGDisplayHeight] intValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int styleMask = 0;
|
|
||||||
|
|
||||||
if (wndconfig->mode == GLFW_WINDOWED)
|
|
||||||
{
|
|
||||||
styleMask = NSTitledWindowMask | NSClosableWindowMask |
|
|
||||||
NSMiniaturizableWindowMask;
|
|
||||||
|
|
||||||
if (!wndconfig->windowNoResize)
|
|
||||||
styleMask |= NSResizableWindowMask;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
styleMask = NSBorderlessWindowMask;
|
|
||||||
|
|
||||||
window->NS.window = [[NSWindow alloc]
|
|
||||||
initWithContentRect:NSMakeRect(0, 0, window->width, window->height)
|
|
||||||
styleMask:styleMask
|
|
||||||
backing:NSBackingStoreBuffered
|
|
||||||
defer:NO];
|
|
||||||
|
|
||||||
[window->NS.window setTitle:[NSString stringWithCString:wndconfig->title
|
|
||||||
encoding:NSISOLatin1StringEncoding]];
|
|
||||||
|
|
||||||
[window->NS.window setContentView:[[GLFWContentView alloc] initWithGlfwWindow:window]];
|
|
||||||
[window->NS.window setDelegate:window->NS.delegate];
|
|
||||||
[window->NS.window setAcceptsMouseMovedEvents:YES];
|
|
||||||
[window->NS.window center];
|
|
||||||
|
|
||||||
if (wndconfig->mode == GLFW_FULLSCREEN)
|
|
||||||
{
|
|
||||||
CGCaptureAllDisplays();
|
|
||||||
CGDisplaySwitchToMode(CGMainDisplayID(), fullscreenMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int attribute_count = 0;
|
|
||||||
|
|
||||||
#define ADD_ATTR(x) { attributes[attribute_count++] = x; }
|
|
||||||
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
|
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
|
||||||
|
|
||||||
// Arbitrary array size here
|
// Arbitrary array size here
|
||||||
@ -638,7 +587,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
ADD_ATTR2(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
ADD_ATTR2(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
||||||
|
|
||||||
if (fbconfig->stereo)
|
if (fbconfig->stereo)
|
||||||
ADD_ATTR(NSOpenGLPFAStereo );
|
ADD_ATTR(NSOpenGLPFAStereo);
|
||||||
|
|
||||||
if (fbconfig->samples > 0)
|
if (fbconfig->samples > 0)
|
||||||
{
|
{
|
||||||
@ -656,7 +605,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
if (window->NSGL.pixelFormat == nil)
|
if (window->NSGL.pixelFormat == nil)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
"Cocoa/NSOpenGL: Failed to create pixel format");
|
"Cocoa/NSOpenGL: Failed to create OpenGL pixel format");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,12 +624,93 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW platform API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Here is where the window is created, and the OpenGL rendering context is
|
||||||
|
// created
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig)
|
||||||
|
{
|
||||||
|
// We can only have one application delegate, but we only allocate it the
|
||||||
|
// first time we create a window to keep all window code in this file
|
||||||
|
if (_glfwLibrary.NS.delegate == nil)
|
||||||
|
{
|
||||||
|
_glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init];
|
||||||
|
if (_glfwLibrary.NS.delegate == nil)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa/NSOpenGL: Failed to create application "
|
||||||
|
"delegate");
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NSApp setDelegate:_glfwLibrary.NS.delegate];
|
||||||
|
}
|
||||||
|
|
||||||
|
window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
|
||||||
|
if (window->NS.delegate == nil)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa/NSOpenGL: Failed to create window delegate");
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mac 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;
|
||||||
|
|
||||||
|
// Don't use accumulation buffer support; it's not accelerated
|
||||||
|
// Aux buffers probably aren't accelerated either
|
||||||
|
|
||||||
|
CFDictionaryRef fullscreenMode = NULL;
|
||||||
|
if (wndconfig->mode == GLFW_FULLSCREEN)
|
||||||
|
{
|
||||||
|
// I think it's safe to pass 0 to the refresh rate for this function
|
||||||
|
// rather than conditionalizing the code to call the version which
|
||||||
|
// doesn't specify refresh...
|
||||||
|
fullscreenMode =
|
||||||
|
CGDisplayBestModeForParametersAndRefreshRateWithProperty(
|
||||||
|
CGMainDisplayID(),
|
||||||
|
colorBits + fbconfig->alphaBits,
|
||||||
|
window->width, window->height,
|
||||||
|
wndconfig->refreshRate,
|
||||||
|
// Controversial, see macosx_fullscreen.m for discussion
|
||||||
|
kCGDisplayModeIsSafeForHardware,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
window->width =
|
||||||
|
[[(id)fullscreenMode objectForKey:(id)kCGDisplayWidth] intValue];
|
||||||
|
window->height =
|
||||||
|
[[(id)fullscreenMode objectForKey:(id)kCGDisplayHeight] intValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!createWindow(window, wndconfig))
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
|
if (!createContext(window, wndconfig, fbconfig))
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
[window->NS.window makeKeyAndOrderFront:nil];
|
[window->NS.window makeKeyAndOrderFront:nil];
|
||||||
[window->NSGL.context setView:[window->NS.window contentView]];
|
[window->NSGL.context setView:[window->NS.window contentView]];
|
||||||
|
|
||||||
if (wndconfig->mode == GLFW_FULLSCREEN)
|
if (wndconfig->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
// TODO: Make this work on pre-Leopard systems
|
CGCaptureAllDisplays();
|
||||||
|
CGDisplaySwitchToMode(CGMainDisplayID(), fullscreenMode);
|
||||||
|
|
||||||
[[window->NS.window contentView] enterFullScreenMode:[NSScreen mainScreen]
|
[[window->NS.window contentView] enterFullScreenMode:[NSScreen mainScreen]
|
||||||
withOptions:nil];
|
withOptions:nil];
|
||||||
}
|
}
|
||||||
@ -691,7 +721,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
window->cursorPosX = point.x;
|
window->cursorPosX = point.x;
|
||||||
window->cursorPosY = point.y;
|
window->cursorPosY = point.y;
|
||||||
|
|
||||||
window->windowNoResize = wndconfig->windowNoResize;
|
window->resizable = wndconfig->resizable;
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
@ -737,8 +767,7 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
|
||||||
{
|
{
|
||||||
[window->NS.window setTitle:[NSString stringWithCString:title
|
[window->NS.window setTitle:[NSString stringWithUTF8String:title]];
|
||||||
encoding:NSISOLatin1StringEncoding]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
192
src/enable.c
192
src/enable.c
@ -1,192 +0,0 @@
|
|||||||
//========================================================================
|
|
||||||
// GLFW - An OpenGL library
|
|
||||||
// Platform: Any
|
|
||||||
// API version: 3.0
|
|
||||||
// WWW: http://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"
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Enable and disable sticky keys mode
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void enableStickyKeys(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
window->stickyKeys = GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void disableStickyKeys(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
window->stickyKeys = GL_FALSE;
|
|
||||||
|
|
||||||
// Release all sticky keys
|
|
||||||
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
|
||||||
{
|
|
||||||
if (window->key[i] == GLFW_STICK)
|
|
||||||
window->key[i] = GLFW_RELEASE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Enable and disable sticky mouse buttons mode
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void enableStickyMouseButtons(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
window->stickyMouseButtons = GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void disableStickyMouseButtons(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
window->stickyMouseButtons = GL_FALSE;
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Enable and disable system keys
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void enableSystemKeys(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
if (!window->sysKeysDisabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_glfwPlatformEnableSystemKeys(window);
|
|
||||||
|
|
||||||
// Indicate that system keys are no longer disabled
|
|
||||||
window->sysKeysDisabled = GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void disableSystemKeys(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
if (window->sysKeysDisabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_glfwPlatformDisableSystemKeys(window);
|
|
||||||
|
|
||||||
// Indicate that system keys are now disabled
|
|
||||||
window->sysKeysDisabled = GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Enable and disable key repeat
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void enableKeyRepeat(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
window->keyRepeat = GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void disableKeyRepeat(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
window->keyRepeat = GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW public API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Enable certain GLFW/window/system functions
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI void glfwEnable(GLFWwindow window, int token)
|
|
||||||
{
|
|
||||||
if (!_glfwInitialized)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (token)
|
|
||||||
{
|
|
||||||
case GLFW_STICKY_KEYS:
|
|
||||||
enableStickyKeys(window);
|
|
||||||
break;
|
|
||||||
case GLFW_STICKY_MOUSE_BUTTONS:
|
|
||||||
enableStickyMouseButtons(window);
|
|
||||||
break;
|
|
||||||
case GLFW_SYSTEM_KEYS:
|
|
||||||
enableSystemKeys(window);
|
|
||||||
break;
|
|
||||||
case GLFW_KEY_REPEAT:
|
|
||||||
enableKeyRepeat(window);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Disable certain GLFW/window/system functions
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI void glfwDisable(GLFWwindow window, int token)
|
|
||||||
{
|
|
||||||
if (!_glfwInitialized)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (token)
|
|
||||||
{
|
|
||||||
case GLFW_STICKY_KEYS:
|
|
||||||
disableStickyKeys(window);
|
|
||||||
break;
|
|
||||||
case GLFW_STICKY_MOUSE_BUTTONS:
|
|
||||||
disableStickyMouseButtons(window);
|
|
||||||
break;
|
|
||||||
case GLFW_SYSTEM_KEYS:
|
|
||||||
disableSystemKeys(window);
|
|
||||||
break;
|
|
||||||
case GLFW_KEY_REPEAT:
|
|
||||||
disableKeyRepeat(window);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -117,6 +117,7 @@ GLFWAPI const char* glfwErrorString(int error)
|
|||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Sets the callback function for GLFW errors
|
// Sets the callback function for GLFW errors
|
||||||
|
// This function may be called without GLFW having been initialized
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun)
|
GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun)
|
||||||
|
55
src/init.c
55
src/init.c
@ -35,30 +35,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Allocate memory using the allocator
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void* _glfwMalloc(size_t size)
|
|
||||||
{
|
|
||||||
return _glfwLibrary.allocator.malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Free memory using the allocator
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwFree(void* ptr)
|
|
||||||
{
|
|
||||||
_glfwLibrary.allocator.free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -68,43 +44,12 @@ void _glfwFree(void* ptr)
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwInit(void)
|
GLFWAPI int glfwInit(void)
|
||||||
{
|
|
||||||
return glfwInitWithModels(NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Initialize various GLFW state using custom model interfaces
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI int glfwInitWithModels(GLFWthreadmodel* threading, GLFWallocator* allocator)
|
|
||||||
{
|
{
|
||||||
if (_glfwInitialized)
|
if (_glfwInitialized)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
memset(&_glfwLibrary, 0, sizeof(_glfwLibrary));
|
memset(&_glfwLibrary, 0, sizeof(_glfwLibrary));
|
||||||
|
|
||||||
if (threading)
|
|
||||||
_glfwLibrary.threading = *threading;
|
|
||||||
|
|
||||||
if (allocator)
|
|
||||||
{
|
|
||||||
// Verify that the specified model is complete
|
|
||||||
if (!allocator->malloc || !allocator->free)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_INVALID_VALUE, NULL);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwLibrary.allocator = *allocator;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use the libc malloc and free
|
|
||||||
_glfwLibrary.allocator.malloc = malloc;
|
|
||||||
_glfwLibrary.allocator.free = free;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not all window hints have zero as their default value, so this
|
// Not all window hints have zero as their default value, so this
|
||||||
// needs to be here despite the memset above
|
// needs to be here despite the memset above
|
||||||
_glfwSetDefaultWindowHints();
|
_glfwSetDefaultWindowHints();
|
||||||
|
246
src/input.c
246
src/input.c
@ -31,6 +31,122 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Sets the cursor mode for the specified window
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void setCursorMode(_GLFWwindow* window, int mode)
|
||||||
|
{
|
||||||
|
int centerPosX, centerPosY;
|
||||||
|
|
||||||
|
if (mode != GLFW_CURSOR_NORMAL &&
|
||||||
|
mode != GLFW_CURSOR_HIDDEN &&
|
||||||
|
mode != GLFW_CURSOR_CAPTURED)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->cursorMode == mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
centerPosX = window->width / 2;
|
||||||
|
centerPosY = window->height / 2;
|
||||||
|
|
||||||
|
if (mode == GLFW_CURSOR_CAPTURED)
|
||||||
|
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
{
|
||||||
|
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
|
||||||
|
_glfwInputCursorMotion(window,
|
||||||
|
centerPosX - window->cursorPosX,
|
||||||
|
centerPosY - window->cursorPosY);
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfwPlatformSetCursorMode(window, mode);
|
||||||
|
|
||||||
|
window->cursorMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set sticky keys mode for the specified window
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void setStickyKeys(_GLFWwindow* window, int enabled)
|
||||||
|
{
|
||||||
|
if (window->stickyKeys == enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// Release all sticky keys
|
||||||
|
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||||
|
{
|
||||||
|
if (window->key[i] == GLFW_STICK)
|
||||||
|
window->key[i] = GLFW_RELEASE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window->stickyKeys = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set sticky mouse buttons mode for the specified window
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void setStickyMouseButtons(_GLFWwindow* window, int enabled)
|
||||||
|
{
|
||||||
|
if (window->stickyMouseButtons == enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window->stickyMouseButtons = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set system keys for the specified window
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void setSystemKeys(_GLFWwindow* window, int enabled)
|
||||||
|
{
|
||||||
|
if (window->systemKeys == enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
_glfwPlatformEnableSystemKeys(window);
|
||||||
|
else
|
||||||
|
_glfwPlatformDisableSystemKeys(window);
|
||||||
|
|
||||||
|
window->systemKeys = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set key repeat for the specified window
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void setKeyRepeat(_GLFWwindow* window, int enabled)
|
||||||
|
{
|
||||||
|
window->keyRepeat = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -41,7 +157,7 @@
|
|||||||
|
|
||||||
void _glfwInputKey(_GLFWwindow* window, int key, int action)
|
void _glfwInputKey(_GLFWwindow* window, int key, int action)
|
||||||
{
|
{
|
||||||
GLboolean keyrepeat = GL_FALSE;
|
GLboolean repeated = GL_FALSE;
|
||||||
|
|
||||||
if (key < 0 || key > GLFW_KEY_LAST)
|
if (key < 0 || key > GLFW_KEY_LAST)
|
||||||
return;
|
return;
|
||||||
@ -55,12 +171,12 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
|
|||||||
window->key[key] = GLFW_STICK;
|
window->key[key] = GLFW_STICK;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
keyrepeat = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS);
|
repeated = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS);
|
||||||
window->key[key] = (char) action;
|
window->key[key] = (char) action;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call user callback function
|
// Call user callback function
|
||||||
if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat))
|
if (_glfwLibrary.keyCallback && (window->keyRepeat || !repeated))
|
||||||
_glfwLibrary.keyCallback(window, key, action);
|
_glfwLibrary.keyCallback(window, key, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,9 +254,11 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_glfwLibrary.mousePosCallback)
|
if (_glfwLibrary.mousePosCallback)
|
||||||
|
{
|
||||||
_glfwLibrary.mousePosCallback(window,
|
_glfwLibrary.mousePosCallback(window,
|
||||||
window->cursorPosX,
|
window->cursorPosX,
|
||||||
window->cursorPosY);
|
window->cursorPosY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,6 +266,77 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
|
|||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Returns the specified input mode of the specified window
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
GLFWAPI int glfwGetInputMode(GLFWwindow handle, int mode)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
|
||||||
|
if (!_glfwInitialized)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case GLFW_CURSOR_MODE:
|
||||||
|
return window->cursorMode;
|
||||||
|
case GLFW_STICKY_KEYS:
|
||||||
|
return window->stickyKeys;
|
||||||
|
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||||
|
return window->stickyMouseButtons;
|
||||||
|
case GLFW_SYSTEM_KEYS:
|
||||||
|
return window->systemKeys;
|
||||||
|
case GLFW_KEY_REPEAT:
|
||||||
|
return window->keyRepeat;
|
||||||
|
default:
|
||||||
|
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Sets the specified input mode of the specified window
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
GLFWAPI void glfwSetInputMode(GLFWwindow handle, int mode, int value)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
|
||||||
|
if (!_glfwInitialized)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case GLFW_CURSOR_MODE:
|
||||||
|
setCursorMode(window, value);
|
||||||
|
break;
|
||||||
|
case GLFW_STICKY_KEYS:
|
||||||
|
setStickyKeys(window, value ? GL_TRUE : GL_FALSE);
|
||||||
|
break;
|
||||||
|
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||||
|
setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE);
|
||||||
|
break;
|
||||||
|
case GLFW_SYSTEM_KEYS:
|
||||||
|
setSystemKeys(window, value ? GL_TRUE : GL_FALSE);
|
||||||
|
break;
|
||||||
|
case GLFW_KEY_REPEAT:
|
||||||
|
setKeyRepeat(window, value ? GL_TRUE : GL_FALSE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Returns the state of the specified key for the specified window
|
// Returns the state of the specified key for the specified window
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -162,10 +351,8 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
|
|||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it a valid key?
|
|
||||||
if (key < 0 || key > GLFW_KEY_LAST)
|
if (key < 0 || key > GLFW_KEY_LAST)
|
||||||
{
|
{
|
||||||
// TODO: Decide whether key is a value or enum
|
|
||||||
_glfwSetError(GLFW_INVALID_ENUM,
|
_glfwSetError(GLFW_INVALID_ENUM,
|
||||||
"glfwGetKey: The specified key is invalid");
|
"glfwGetKey: The specified key is invalid");
|
||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
@ -196,7 +383,6 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
|
|||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it a valid mouse button?
|
|
||||||
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_INVALID_ENUM,
|
_glfwSetError(GLFW_INVALID_ENUM,
|
||||||
@ -229,7 +415,6 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return mouse position
|
|
||||||
if (xpos != NULL)
|
if (xpos != NULL)
|
||||||
*xpos = window->cursorPosX;
|
*xpos = window->cursorPosX;
|
||||||
|
|
||||||
@ -298,51 +483,6 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Sets the cursor mode for the specified window
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode)
|
|
||||||
{
|
|
||||||
int centerPosX, centerPosY;
|
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode != GLFW_CURSOR_NORMAL &&
|
|
||||||
mode != GLFW_CURSOR_HIDDEN &&
|
|
||||||
mode != GLFW_CURSOR_CAPTURED)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window->cursorMode == mode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
centerPosX = window->width / 2;
|
|
||||||
centerPosY = window->height / 2;
|
|
||||||
|
|
||||||
if (mode == GLFW_CURSOR_CAPTURED)
|
|
||||||
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
|
|
||||||
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
|
||||||
{
|
|
||||||
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
|
|
||||||
_glfwInputCursorMotion(window,
|
|
||||||
centerPosX - window->cursorPosX,
|
|
||||||
centerPosY - window->cursorPosY);
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwPlatformSetCursorMode(window, mode);
|
|
||||||
|
|
||||||
window->cursorMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Set callback function for keyboard input
|
// Set callback function for keyboard input
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -403,7 +543,6 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set callback function
|
|
||||||
_glfwLibrary.mousePosCallback = cbfun;
|
_glfwLibrary.mousePosCallback = cbfun;
|
||||||
|
|
||||||
// Call the callback function to let the application know the current
|
// Call the callback function to let the application know the current
|
||||||
@ -430,7 +569,6 @@ GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set callback function
|
|
||||||
_glfwLibrary.scrollCallback = cbfun;
|
_glfwLibrary.scrollCallback = cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#if defined(_init_c_)
|
#if defined(_init_c_)
|
||||||
#define GLFWGLOBAL
|
#define GLFWGLOBAL
|
||||||
#else
|
#else
|
||||||
#define GLFWGLOBAL extern
|
#define GLFWGLOBAL extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -66,13 +66,13 @@
|
|||||||
#include "../support/GL/glext.h"
|
#include "../support/GL/glext.h"
|
||||||
|
|
||||||
#if defined(_GLFW_COCOA_NSGL)
|
#if defined(_GLFW_COCOA_NSGL)
|
||||||
#include "cocoa_platform.h"
|
#include "cocoa_platform.h"
|
||||||
#elif defined(_GLFW_WIN32_WGL)
|
#elif defined(_GLFW_WIN32_WGL)
|
||||||
#include "win32_platform.h"
|
#include "win32_platform.h"
|
||||||
#elif defined(_GLFW_X11_GLX)
|
#elif defined(_GLFW_X11_GLX)
|
||||||
#include "x11_platform.h"
|
#include "x11_platform.h"
|
||||||
#else
|
#else
|
||||||
#error "No supported platform selected"
|
#error "No supported platform selected"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct _GLFWhints _GLFWhints;
|
typedef struct _GLFWhints _GLFWhints;
|
||||||
@ -103,7 +103,7 @@ struct _GLFWhints
|
|||||||
int accumAlphaBits;
|
int accumAlphaBits;
|
||||||
int auxBuffers;
|
int auxBuffers;
|
||||||
GLboolean stereo;
|
GLboolean stereo;
|
||||||
GLboolean windowNoResize;
|
GLboolean resizable;
|
||||||
int samples;
|
int samples;
|
||||||
int glMajor;
|
int glMajor;
|
||||||
int glMinor;
|
int glMinor;
|
||||||
@ -125,7 +125,7 @@ struct _GLFWwndconfig
|
|||||||
int mode;
|
int mode;
|
||||||
const char* title;
|
const char* title;
|
||||||
int refreshRate;
|
int refreshRate;
|
||||||
GLboolean windowNoResize;
|
GLboolean resizable;
|
||||||
int glMajor;
|
int glMajor;
|
||||||
int glMinor;
|
int glMinor;
|
||||||
GLboolean glForward;
|
GLboolean glForward;
|
||||||
@ -175,7 +175,7 @@ struct _GLFWwindow
|
|||||||
int width, height;
|
int width, height;
|
||||||
int positionX, positionY;
|
int positionX, positionY;
|
||||||
int mode; // GLFW_WINDOW or GLFW_FULLSCREEN
|
int mode; // GLFW_WINDOW or GLFW_FULLSCREEN
|
||||||
GLboolean windowNoResize; // resize- and maximize gadgets disabled flag
|
GLboolean resizable; // GL_TRUE if user may resize this window
|
||||||
int refreshRate; // monitor refresh rate
|
int refreshRate; // monitor refresh rate
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ struct _GLFWwindow
|
|||||||
GLboolean stickyKeys;
|
GLboolean stickyKeys;
|
||||||
GLboolean stickyMouseButtons;
|
GLboolean stickyMouseButtons;
|
||||||
GLboolean keyRepeat;
|
GLboolean keyRepeat;
|
||||||
GLboolean sysKeysDisabled; // system keys disabled flag
|
GLboolean systemKeys; // system keys enabled flag
|
||||||
int cursorPosX, cursorPosY;
|
int cursorPosX, cursorPosY;
|
||||||
int cursorMode;
|
int cursorMode;
|
||||||
int scrollX, scrollY;
|
int scrollX, scrollY;
|
||||||
@ -241,9 +241,6 @@ struct _GLFWlibrary
|
|||||||
GLFWkeyfun keyCallback;
|
GLFWkeyfun keyCallback;
|
||||||
GLFWcharfun charCallback;
|
GLFWcharfun charCallback;
|
||||||
|
|
||||||
GLFWthreadmodel threading;
|
|
||||||
GLFWallocator allocator;
|
|
||||||
|
|
||||||
GLFWgammaramp currentRamp;
|
GLFWgammaramp currentRamp;
|
||||||
GLFWgammaramp originalRamp;
|
GLFWgammaramp originalRamp;
|
||||||
int originalRampSize;
|
int originalRampSize;
|
||||||
@ -276,7 +273,7 @@ int _glfwPlatformInit(void);
|
|||||||
int _glfwPlatformTerminate(void);
|
int _glfwPlatformTerminate(void);
|
||||||
const char* _glfwPlatformGetVersionString(void);
|
const char* _glfwPlatformGetVersionString(void);
|
||||||
|
|
||||||
// Enable/Disable
|
// Input
|
||||||
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window);
|
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window);
|
||||||
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window);
|
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window);
|
||||||
|
|
||||||
@ -330,10 +327,6 @@ void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long
|
|||||||
// Prototypes for platform independent internal functions
|
// Prototypes for platform independent internal functions
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
// Memory management (init.c)
|
|
||||||
void* _glfwMalloc(size_t size);
|
|
||||||
void _glfwFree(void* ptr);
|
|
||||||
|
|
||||||
// Fullscren management (fullscreen.c)
|
// Fullscren management (fullscreen.c)
|
||||||
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
||||||
|
|
||||||
@ -343,14 +336,14 @@ void _glfwSetError(int error, const char* description);
|
|||||||
// Window management (window.c)
|
// Window management (window.c)
|
||||||
void _glfwSetDefaultWindowHints(void);
|
void _glfwSetDefaultWindowHints(void);
|
||||||
|
|
||||||
// WIndow event notification
|
// Window event notification (window.c)
|
||||||
void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated);
|
void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated);
|
||||||
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
|
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
|
||||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
||||||
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
||||||
void _glfwInputWindowDamage(_GLFWwindow* window);
|
void _glfwInputWindowDamage(_GLFWwindow* window);
|
||||||
|
|
||||||
// Input event notification
|
// Input event notification (input.c)
|
||||||
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
||||||
void _glfwInputChar(_GLFWwindow* window, int character);
|
void _glfwInputChar(_GLFWwindow* window, int character);
|
||||||
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
|
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
|
||||||
|
@ -47,7 +47,7 @@ static GLboolean initLibraries(void)
|
|||||||
#ifndef _GLFW_NO_DLOAD_GDI32
|
#ifndef _GLFW_NO_DLOAD_GDI32
|
||||||
// gdi32.dll (OpenGL pixel format functions & SwapBuffers)
|
// gdi32.dll (OpenGL pixel format functions & SwapBuffers)
|
||||||
|
|
||||||
_glfwLibrary.Win32.gdi.instance = LoadLibrary("gdi32.dll");
|
_glfwLibrary.Win32.gdi.instance = LoadLibrary(L"gdi32.dll");
|
||||||
if (!_glfwLibrary.Win32.gdi.instance)
|
if (!_glfwLibrary.Win32.gdi.instance)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
@ -81,12 +81,12 @@ static GLboolean initLibraries(void)
|
|||||||
#ifndef _GLFW_NO_DLOAD_WINMM
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
||||||
// winmm.dll (for joystick and timer support)
|
// winmm.dll (for joystick and timer support)
|
||||||
|
|
||||||
_glfwLibrary.Win32.winmm.instance = LoadLibrary("winmm.dll");
|
_glfwLibrary.Win32.winmm.instance = LoadLibrary(L"winmm.dll");
|
||||||
if (!_glfwLibrary.Win32.winmm.instance)
|
if (!_glfwLibrary.Win32.winmm.instance)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
_glfwLibrary.Win32.winmm.joyGetDevCapsA = (JOYGETDEVCAPSA_T)
|
_glfwLibrary.Win32.winmm.joyGetDevCaps = (JOYGETDEVCAPS_T)
|
||||||
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetDevCapsA");
|
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetDevCapsW");
|
||||||
_glfwLibrary.Win32.winmm.joyGetPos = (JOYGETPOS_T)
|
_glfwLibrary.Win32.winmm.joyGetPos = (JOYGETPOS_T)
|
||||||
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetPos");
|
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetPos");
|
||||||
_glfwLibrary.Win32.winmm.joyGetPosEx = (JOYGETPOSEX_T)
|
_glfwLibrary.Win32.winmm.joyGetPosEx = (JOYGETPOSEX_T)
|
||||||
@ -94,7 +94,7 @@ static GLboolean initLibraries(void)
|
|||||||
_glfwLibrary.Win32.winmm.timeGetTime = (TIMEGETTIME_T)
|
_glfwLibrary.Win32.winmm.timeGetTime = (TIMEGETTIME_T)
|
||||||
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "timeGetTime");
|
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "timeGetTime");
|
||||||
|
|
||||||
if (!_glfwLibrary.Win32.winmm.joyGetDevCapsA ||
|
if (!_glfwLibrary.Win32.winmm.joyGetDevCaps ||
|
||||||
!_glfwLibrary.Win32.winmm.joyGetPos ||
|
!_glfwLibrary.Win32.winmm.joyGetPos ||
|
||||||
!_glfwLibrary.Win32.winmm.joyGetPosEx ||
|
!_glfwLibrary.Win32.winmm.joyGetPosEx ||
|
||||||
!_glfwLibrary.Win32.winmm.timeGetTime)
|
!_glfwLibrary.Win32.winmm.timeGetTime)
|
||||||
@ -131,6 +131,60 @@ static void freeLibraries(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Returns a wide string version of the specified UTF-8 string
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
WCHAR* _glfwCreateWideStringFromUTF8(const char* source)
|
||||||
|
{
|
||||||
|
WCHAR* target;
|
||||||
|
int length;
|
||||||
|
|
||||||
|
length = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);
|
||||||
|
if (!length)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
target = (WCHAR*) malloc(sizeof(WCHAR) * (length + 1));
|
||||||
|
|
||||||
|
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1))
|
||||||
|
{
|
||||||
|
free(target);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Returns a UTF-8 string version of the specified wide string
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
char* _glfwCreateUTF8FromWideString(const WCHAR* source)
|
||||||
|
{
|
||||||
|
char* target;
|
||||||
|
int length;
|
||||||
|
|
||||||
|
length = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);
|
||||||
|
if (!length)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
target = (char*) malloc(length + 1);
|
||||||
|
|
||||||
|
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length + 1, NULL, NULL))
|
||||||
|
{
|
||||||
|
free(target);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -205,7 +259,7 @@ int _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
const char* version = "GLFW " _GLFW_VERSION_FULL
|
const char* version = _GLFW_VERSION_FULL
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
" MinGW"
|
" MinGW"
|
||||||
#elif defined(__CYGWIN__)
|
#elif defined(__CYGWIN__)
|
||||||
|
@ -40,6 +40,19 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (to
|
||||||
|
// correctly declare a GL_ARB_debug_output callback, for example) but windows.h
|
||||||
|
// thinks it is the only one that gets to do so
|
||||||
|
#undef APIENTRY
|
||||||
|
|
||||||
|
// GLFW on Windows is Unicode only and does not work in MBCS mode
|
||||||
|
#ifndef UNICODE
|
||||||
|
#define UNICODE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// GLFW requires Windows XP
|
||||||
|
#define WINVER 0x0501
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
|
|
||||||
@ -56,10 +69,10 @@
|
|||||||
// Some old versions of w32api (used by MinGW and Cygwin) define
|
// Some old versions of w32api (used by MinGW and Cygwin) define
|
||||||
// WH_KEYBOARD_LL without typedef:ing KBDLLHOOKSTRUCT (!)
|
// WH_KEYBOARD_LL without typedef:ing KBDLLHOOKSTRUCT (!)
|
||||||
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||||
#include <w32api.h>
|
#include <w32api.h>
|
||||||
#if defined(WH_KEYBOARD_LL) && (__W32API_MAJOR_VERSION == 1) && (__W32API_MINOR_VERSION <= 2)
|
#if defined(WH_KEYBOARD_LL) && (__W32API_MAJOR_VERSION == 1) && (__W32API_MINOR_VERSION <= 2)
|
||||||
#undef WH_KEYBOARD_LL
|
#undef WH_KEYBOARD_LL
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -79,64 +92,64 @@ typedef struct tagKBDLLHOOKSTRUCT {
|
|||||||
#endif // WH_KEYBOARD_LL
|
#endif // WH_KEYBOARD_LL
|
||||||
|
|
||||||
#ifndef LLKHF_ALTDOWN
|
#ifndef LLKHF_ALTDOWN
|
||||||
#define LLKHF_ALTDOWN 0x00000020
|
#define LLKHF_ALTDOWN 0x00000020
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SPI_SETSCREENSAVERRUNNING
|
#ifndef SPI_SETSCREENSAVERRUNNING
|
||||||
#define SPI_SETSCREENSAVERRUNNING 97
|
#define SPI_SETSCREENSAVERRUNNING 97
|
||||||
#endif
|
#endif
|
||||||
#ifndef SPI_GETANIMATION
|
#ifndef SPI_GETANIMATION
|
||||||
#define SPI_GETANIMATION 72
|
#define SPI_GETANIMATION 72
|
||||||
#endif
|
#endif
|
||||||
#ifndef SPI_SETANIMATION
|
#ifndef SPI_SETANIMATION
|
||||||
#define SPI_SETANIMATION 73
|
#define SPI_SETANIMATION 73
|
||||||
#endif
|
#endif
|
||||||
#ifndef SPI_GETFOREGROUNDLOCKTIMEOUT
|
#ifndef SPI_GETFOREGROUNDLOCKTIMEOUT
|
||||||
#define SPI_GETFOREGROUNDLOCKTIMEOUT 0x2000
|
#define SPI_GETFOREGROUNDLOCKTIMEOUT 0x2000
|
||||||
#endif
|
#endif
|
||||||
#ifndef SPI_SETFOREGROUNDLOCKTIMEOUT
|
#ifndef SPI_SETFOREGROUNDLOCKTIMEOUT
|
||||||
#define SPI_SETFOREGROUNDLOCKTIMEOUT 0x2001
|
#define SPI_SETFOREGROUNDLOCKTIMEOUT 0x2001
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CDS_FULLSCREEN
|
#ifndef CDS_FULLSCREEN
|
||||||
#define CDS_FULLSCREEN 4
|
#define CDS_FULLSCREEN 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PFD_GENERIC_ACCELERATED
|
#ifndef PFD_GENERIC_ACCELERATED
|
||||||
#define PFD_GENERIC_ACCELERATED 0x00001000
|
#define PFD_GENERIC_ACCELERATED 0x00001000
|
||||||
#endif
|
#endif
|
||||||
#ifndef PFD_DEPTH_DONTCARE
|
#ifndef PFD_DEPTH_DONTCARE
|
||||||
#define PFD_DEPTH_DONTCARE 0x20000000
|
#define PFD_DEPTH_DONTCARE 0x20000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENUM_CURRENT_SETTINGS
|
#ifndef ENUM_CURRENT_SETTINGS
|
||||||
#define ENUM_CURRENT_SETTINGS -1
|
#define ENUM_CURRENT_SETTINGS -1
|
||||||
#endif
|
#endif
|
||||||
#ifndef ENUM_REGISTRY_SETTINGS
|
#ifndef ENUM_REGISTRY_SETTINGS
|
||||||
#define ENUM_REGISTRY_SETTINGS -2
|
#define ENUM_REGISTRY_SETTINGS -2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WM_MOUSEWHEEL
|
#ifndef WM_MOUSEWHEEL
|
||||||
#define WM_MOUSEWHEEL 0x020A
|
#define WM_MOUSEWHEEL 0x020A
|
||||||
#endif
|
#endif
|
||||||
#ifndef WHEEL_DELTA
|
#ifndef WHEEL_DELTA
|
||||||
#define WHEEL_DELTA 120
|
#define WHEEL_DELTA 120
|
||||||
#endif
|
#endif
|
||||||
#ifndef WM_MOUSEHWHEEL
|
#ifndef WM_MOUSEHWHEEL
|
||||||
#define WM_MOUSEHWHEEL 0x020E
|
#define WM_MOUSEHWHEEL 0x020E
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WM_XBUTTONDOWN
|
#ifndef WM_XBUTTONDOWN
|
||||||
#define WM_XBUTTONDOWN 0x020B
|
#define WM_XBUTTONDOWN 0x020B
|
||||||
#endif
|
#endif
|
||||||
#ifndef WM_XBUTTONUP
|
#ifndef WM_XBUTTONUP
|
||||||
#define WM_XBUTTONUP 0x020C
|
#define WM_XBUTTONUP 0x020C
|
||||||
#endif
|
#endif
|
||||||
#ifndef XBUTTON1
|
#ifndef XBUTTON1
|
||||||
#define XBUTTON1 1
|
#define XBUTTON1 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef XBUTTON2
|
#ifndef XBUTTON2
|
||||||
#define XBUTTON2 2
|
#define XBUTTON2 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -157,7 +170,7 @@ typedef BOOL (WINAPI * SETDEVICEGAMMARAMP_T) (HDC,PVOID);
|
|||||||
|
|
||||||
// winmm.dll function pointer typedefs
|
// winmm.dll function pointer typedefs
|
||||||
#ifndef _GLFW_NO_DLOAD_WINMM
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
||||||
typedef MMRESULT (WINAPI * JOYGETDEVCAPSA_T) (UINT,LPJOYCAPSA,UINT);
|
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T) (UINT,LPJOYCAPS,UINT);
|
||||||
typedef MMRESULT (WINAPI * JOYGETPOS_T) (UINT,LPJOYINFO);
|
typedef MMRESULT (WINAPI * JOYGETPOS_T) (UINT,LPJOYINFO);
|
||||||
typedef MMRESULT (WINAPI * JOYGETPOSEX_T) (UINT,LPJOYINFOEX);
|
typedef MMRESULT (WINAPI * JOYGETPOSEX_T) (UINT,LPJOYINFOEX);
|
||||||
typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
|
typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
|
||||||
@ -166,40 +179,40 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
|
|||||||
|
|
||||||
// gdi32.dll shortcuts
|
// gdi32.dll shortcuts
|
||||||
#ifndef _GLFW_NO_DLOAD_GDI32
|
#ifndef _GLFW_NO_DLOAD_GDI32
|
||||||
#define _glfw_ChoosePixelFormat _glfwLibrary.Win32.gdi.ChoosePixelFormat
|
#define _glfw_ChoosePixelFormat _glfwLibrary.Win32.gdi.ChoosePixelFormat
|
||||||
#define _glfw_DescribePixelFormat _glfwLibrary.Win32.gdi.DescribePixelFormat
|
#define _glfw_DescribePixelFormat _glfwLibrary.Win32.gdi.DescribePixelFormat
|
||||||
#define _glfw_GetPixelFormat _glfwLibrary.Win32.gdi.GetPixelFormat
|
#define _glfw_GetPixelFormat _glfwLibrary.Win32.gdi.GetPixelFormat
|
||||||
#define _glfw_SetPixelFormat _glfwLibrary.Win32.gdi.SetPixelFormat
|
#define _glfw_SetPixelFormat _glfwLibrary.Win32.gdi.SetPixelFormat
|
||||||
#define _glfw_SwapBuffers _glfwLibrary.Win32.gdi.SwapBuffers
|
#define _glfw_SwapBuffers _glfwLibrary.Win32.gdi.SwapBuffers
|
||||||
#define _glfw_GetDeviceGammaRamp _glfwLibrary.Win32.gdi.GetDeviceGammaRamp
|
#define _glfw_GetDeviceGammaRamp _glfwLibrary.Win32.gdi.GetDeviceGammaRamp
|
||||||
#define _glfw_SetDeviceGammaRamp _glfwLibrary.Win32.gdi.SetDeviceGammaRamp
|
#define _glfw_SetDeviceGammaRamp _glfwLibrary.Win32.gdi.SetDeviceGammaRamp
|
||||||
#else
|
#else
|
||||||
#define _glfw_ChoosePixelFormat ChoosePixelFormat
|
#define _glfw_ChoosePixelFormat ChoosePixelFormat
|
||||||
#define _glfw_DescribePixelFormat DescribePixelFormat
|
#define _glfw_DescribePixelFormat DescribePixelFormat
|
||||||
#define _glfw_GetPixelFormat GetPixelFormat
|
#define _glfw_GetPixelFormat GetPixelFormat
|
||||||
#define _glfw_SetPixelFormat SetPixelFormat
|
#define _glfw_SetPixelFormat SetPixelFormat
|
||||||
#define _glfw_SwapBuffers SwapBuffers
|
#define _glfw_SwapBuffers SwapBuffers
|
||||||
#define _glfw_GetDeviceGammaRamp GetDeviceGammaRamp
|
#define _glfw_GetDeviceGammaRamp GetDeviceGammaRamp
|
||||||
#define _glfw_SetDeviceGammaRamp SetDeviceGammaRamp
|
#define _glfw_SetDeviceGammaRamp SetDeviceGammaRamp
|
||||||
#endif // _GLFW_NO_DLOAD_GDI32
|
#endif // _GLFW_NO_DLOAD_GDI32
|
||||||
|
|
||||||
// winmm.dll shortcuts
|
// winmm.dll shortcuts
|
||||||
#ifndef _GLFW_NO_DLOAD_WINMM
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
||||||
#define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCapsA
|
#define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCaps
|
||||||
#define _glfw_joyGetPos _glfwLibrary.Win32.winmm.joyGetPos
|
#define _glfw_joyGetPos _glfwLibrary.Win32.winmm.joyGetPos
|
||||||
#define _glfw_joyGetPosEx _glfwLibrary.Win32.winmm.joyGetPosEx
|
#define _glfw_joyGetPosEx _glfwLibrary.Win32.winmm.joyGetPosEx
|
||||||
#define _glfw_timeGetTime _glfwLibrary.Win32.winmm.timeGetTime
|
#define _glfw_timeGetTime _glfwLibrary.Win32.winmm.timeGetTime
|
||||||
#else
|
#else
|
||||||
#define _glfw_joyGetDevCaps joyGetDevCapsA
|
#define _glfw_joyGetDevCaps joyGetDevCaps
|
||||||
#define _glfw_joyGetPos joyGetPos
|
#define _glfw_joyGetPos joyGetPos
|
||||||
#define _glfw_joyGetPosEx joyGetPosEx
|
#define _glfw_joyGetPosEx joyGetPosEx
|
||||||
#define _glfw_timeGetTime timeGetTime
|
#define _glfw_timeGetTime timeGetTime
|
||||||
#endif // _GLFW_NO_DLOAD_WINMM
|
#endif // _GLFW_NO_DLOAD_WINMM
|
||||||
|
|
||||||
|
|
||||||
// We use versioned window class names in order not to cause conflicts
|
// We use versioned window class names in order not to cause conflicts
|
||||||
// between applications using different versions of GLFW
|
// between applications using different versions of GLFW
|
||||||
#define _GLFW_WNDCLASSNAME "GLFW30"
|
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
||||||
|
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
|
||||||
@ -304,7 +317,7 @@ typedef struct _GLFWlibraryWin32
|
|||||||
// winmm.dll
|
// winmm.dll
|
||||||
struct {
|
struct {
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
JOYGETDEVCAPSA_T joyGetDevCapsA;
|
JOYGETDEVCAPS_T joyGetDevCaps;
|
||||||
JOYGETPOS_T joyGetPos;
|
JOYGETPOS_T joyGetPos;
|
||||||
JOYGETPOSEX_T joyGetPosEx;
|
JOYGETPOSEX_T joyGetPosEx;
|
||||||
TIMEGETTIME_T timeGetTime;
|
TIMEGETTIME_T timeGetTime;
|
||||||
@ -318,6 +331,10 @@ typedef struct _GLFWlibraryWin32
|
|||||||
// Prototypes for platform specific internal functions
|
// Prototypes for platform specific internal functions
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
// Wide strings
|
||||||
|
WCHAR* _glfwCreateWideStringFromUTF8(const char* source);
|
||||||
|
char* _glfwCreateUTF8FromWideString(const WCHAR* source);
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
void _glfwInitTimer(void);
|
void _glfwInitTimer(void);
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
|
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||||
@ -895,7 +895,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
if (_glfwLibrary.charCallback)
|
if (_glfwLibrary.charCallback)
|
||||||
translateChar(window, (DWORD) wParam, (DWORD) lParam);
|
translateChar(window, (DWORD) wParam, (DWORD) lParam);
|
||||||
|
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
@ -910,7 +910,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
else
|
else
|
||||||
_glfwInputKey(window, translateKey(wParam, lParam), GLFW_RELEASE);
|
_glfwInputKey(window, translateKey(wParam, lParam), GLFW_RELEASE);
|
||||||
|
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
@ -1220,7 +1220,7 @@ static ATOM registerWindowClass(void)
|
|||||||
wc.lpszClassName = _GLFW_WNDCLASSNAME; // Set class name
|
wc.lpszClassName = _GLFW_WNDCLASSNAME; // Set class name
|
||||||
|
|
||||||
// Load user-provided icon if available
|
// Load user-provided icon if available
|
||||||
wc.hIcon = LoadIcon(_glfwLibrary.Win32.instance, "GLFW_ICON");
|
wc.hIcon = LoadIcon(_glfwLibrary.Win32.instance, L"GLFW_ICON");
|
||||||
if (!wc.hIcon)
|
if (!wc.hIcon)
|
||||||
{
|
{
|
||||||
// Load default icon
|
// Load default icon
|
||||||
@ -1257,13 +1257,13 @@ static int choosePixelFormat(_GLFWwindow* window, const _GLFWfbconfig* fbconfig)
|
|||||||
closest = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
closest = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
||||||
if (!closest)
|
if (!closest)
|
||||||
{
|
{
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelFormat = (int) closest->platformID;
|
pixelFormat = (int) closest->platformID;
|
||||||
|
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
fbconfigs = NULL;
|
fbconfigs = NULL;
|
||||||
closest = NULL;
|
closest = NULL;
|
||||||
|
|
||||||
@ -1283,6 +1283,7 @@ static int createWindow(_GLFWwindow* window,
|
|||||||
int pixelFormat, fullWidth, fullHeight;
|
int pixelFormat, fullWidth, fullHeight;
|
||||||
RECT wa;
|
RECT wa;
|
||||||
POINT pos;
|
POINT pos;
|
||||||
|
WCHAR* wideTitle;
|
||||||
|
|
||||||
// Set common window styles
|
// Set common window styles
|
||||||
dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
|
dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
|
||||||
@ -1309,7 +1310,7 @@ static int createWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
||||||
|
|
||||||
if (!wndconfig->windowNoResize)
|
if (wndconfig->resizable)
|
||||||
{
|
{
|
||||||
dwStyle |= (WS_MAXIMIZEBOX | WS_SIZEBOX);
|
dwStyle |= (WS_MAXIMIZEBOX | WS_SIZEBOX);
|
||||||
dwExStyle |= WS_EX_WINDOWEDGE;
|
dwExStyle |= WS_EX_WINDOWEDGE;
|
||||||
@ -1331,9 +1332,17 @@ static int createWindow(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0);
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0);
|
||||||
|
|
||||||
|
wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
|
||||||
|
if (!wideTitle)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
|
"glfwOpenWindow: Failed to convert title to wide string");
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
window->Win32.handle = CreateWindowEx(window->Win32.dwExStyle,
|
window->Win32.handle = CreateWindowEx(window->Win32.dwExStyle,
|
||||||
_GLFW_WNDCLASSNAME,
|
_GLFW_WNDCLASSNAME,
|
||||||
wndconfig->title,
|
wideTitle,
|
||||||
window->Win32.dwStyle,
|
window->Win32.dwStyle,
|
||||||
wa.left, wa.top, // Window position
|
wa.left, wa.top, // Window position
|
||||||
fullWidth, // Decorated window width
|
fullWidth, // Decorated window width
|
||||||
@ -1349,6 +1358,8 @@ static int createWindow(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(wideTitle);
|
||||||
|
|
||||||
window->WGL.DC = GetDC(window->Win32.handle);
|
window->WGL.DC = GetDC(window->Win32.handle);
|
||||||
if (!window->WGL.DC)
|
if (!window->WGL.DC)
|
||||||
{
|
{
|
||||||
@ -1568,7 +1579,17 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
{
|
{
|
||||||
SetWindowText(window->Win32.handle, title);
|
WCHAR* wideTitle = _glfwCreateWideStringFromUTF8(title);
|
||||||
|
if (!wideTitle)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
|
"glfwSetWindowTitle: Failed to convert title to wide string");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWindowText(window->Win32.handle, wideTitle);
|
||||||
|
|
||||||
|
free(wideTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
21
src/window.c
21
src/window.c
@ -100,6 +100,9 @@ void _glfwSetDefaultWindowHints(void)
|
|||||||
// The default minimum OpenGL version is 1.0
|
// The default minimum OpenGL version is 1.0
|
||||||
_glfwLibrary.hints.glMajor = 1;
|
_glfwLibrary.hints.glMajor = 1;
|
||||||
_glfwLibrary.hints.glMinor = 0;
|
_glfwLibrary.hints.glMinor = 0;
|
||||||
|
|
||||||
|
// The default is to allow window resizing
|
||||||
|
_glfwLibrary.hints.resizable = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -247,7 +250,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
|||||||
wndconfig.mode = mode;
|
wndconfig.mode = mode;
|
||||||
wndconfig.title = title;
|
wndconfig.title = title;
|
||||||
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
|
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
|
||||||
wndconfig.windowNoResize = _glfwLibrary.hints.windowNoResize ? GL_TRUE : GL_FALSE;
|
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
|
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
|
||||||
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
|
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
|
||||||
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
|
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
|
||||||
@ -288,7 +291,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
|||||||
height = 480;
|
height = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow));
|
window = (_GLFWwindow*) malloc(sizeof(_GLFWwindow));
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||||
@ -306,6 +309,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
|||||||
window->height = height;
|
window->height = height;
|
||||||
window->mode = mode;
|
window->mode = mode;
|
||||||
window->cursorMode = GLFW_CURSOR_NORMAL;
|
window->cursorMode = GLFW_CURSOR_NORMAL;
|
||||||
|
window->systemKeys = GL_TRUE;
|
||||||
|
|
||||||
// Open the actual window and create its context
|
// Open the actual window and create its context
|
||||||
if (!_glfwPlatformOpenWindow(window, &wndconfig, &fbconfig))
|
if (!_glfwPlatformOpenWindow(window, &wndconfig, &fbconfig))
|
||||||
@ -327,7 +331,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
|||||||
// The GLFW specification states that fullscreen windows have the cursor
|
// The GLFW specification states that fullscreen windows have the cursor
|
||||||
// captured by default
|
// captured by default
|
||||||
if (mode == GLFW_FULLSCREEN)
|
if (mode == GLFW_FULLSCREEN)
|
||||||
glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
|
||||||
|
|
||||||
// Clearing the front buffer to black to avoid garbage pixels left over
|
// Clearing the front buffer to black to avoid garbage pixels left over
|
||||||
// from previous uses of our bit of VRAM
|
// from previous uses of our bit of VRAM
|
||||||
@ -419,8 +423,8 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
|
|||||||
case GLFW_STEREO:
|
case GLFW_STEREO:
|
||||||
_glfwLibrary.hints.stereo = hint;
|
_glfwLibrary.hints.stereo = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_WINDOW_NO_RESIZE:
|
case GLFW_WINDOW_RESIZABLE:
|
||||||
_glfwLibrary.hints.windowNoResize = hint;
|
_glfwLibrary.hints.resizable = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_FSAA_SAMPLES:
|
case GLFW_FSAA_SAMPLES:
|
||||||
_glfwLibrary.hints.samples = hint;
|
_glfwLibrary.hints.samples = hint;
|
||||||
@ -488,7 +492,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
|
|||||||
*prev = window->next;
|
*prev = window->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwFree(window);
|
free(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -651,7 +655,6 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
|
|||||||
if (!window->iconified)
|
if (!window->iconified)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Restore iconified window
|
|
||||||
_glfwPlatformRestoreWindow(window);
|
_glfwPlatformRestoreWindow(window);
|
||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
@ -707,8 +710,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
|||||||
return window->stereo;
|
return window->stereo;
|
||||||
case GLFW_REFRESH_RATE:
|
case GLFW_REFRESH_RATE:
|
||||||
return window->refreshRate;
|
return window->refreshRate;
|
||||||
case GLFW_WINDOW_NO_RESIZE:
|
case GLFW_WINDOW_RESIZABLE:
|
||||||
return window->windowNoResize;
|
return window->resizable;
|
||||||
case GLFW_FSAA_SAMPLES:
|
case GLFW_FSAA_SAMPLES:
|
||||||
return window->samples;
|
return window->samples;
|
||||||
case GLFW_OPENGL_VERSION_MAJOR:
|
case GLFW_OPENGL_VERSION_MAJOR:
|
||||||
|
@ -339,7 +339,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rgbarray = (int*) _glfwMalloc(sizeof(int) * viscount);
|
rgbarray = (int*) malloc(sizeof(int) * viscount);
|
||||||
rgbcount = 0;
|
rgbcount = 0;
|
||||||
|
|
||||||
// Build RGB array
|
// Build RGB array
|
||||||
@ -387,7 +387,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
|||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
||||||
sizelist = XRRConfigSizes(sc, &sizecount);
|
sizelist = XRRConfigSizes(sc, &sizecount);
|
||||||
|
|
||||||
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * sizecount);
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * sizecount);
|
||||||
|
|
||||||
for (k = 0; k < sizecount; k++)
|
for (k = 0; k < sizecount; k++)
|
||||||
{
|
{
|
||||||
@ -407,7 +407,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
|||||||
|
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
||||||
|
|
||||||
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * modecount);
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * modecount);
|
||||||
|
|
||||||
for (k = 0; k < modecount; k++)
|
for (k = 0; k < modecount; k++)
|
||||||
{
|
{
|
||||||
@ -436,7 +436,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
|||||||
if (!resarray)
|
if (!resarray)
|
||||||
{
|
{
|
||||||
rescount = 1;
|
rescount = 1;
|
||||||
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * rescount);
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * rescount);
|
||||||
|
|
||||||
resarray[0].width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
resarray[0].width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
||||||
resarray[0].height = DisplayHeight(_glfwLibrary.X11.display, screen);
|
resarray[0].height = DisplayHeight(_glfwLibrary.X11.display, screen);
|
||||||
@ -459,8 +459,8 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
|||||||
|
|
||||||
XFree(vislist);
|
XFree(vislist);
|
||||||
|
|
||||||
_glfwFree(resarray);
|
free(resarray);
|
||||||
_glfwFree(rgbarray);
|
free(rgbarray);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ static void updateKeyCodeLUT(void)
|
|||||||
|
|
||||||
static GLboolean initDisplay(void)
|
static GLboolean initDisplay(void)
|
||||||
{
|
{
|
||||||
_glfwLibrary.X11.display = XOpenDisplay(0);
|
_glfwLibrary.X11.display = XOpenDisplay(NULL);
|
||||||
if (!_glfwLibrary.X11.display)
|
if (!_glfwLibrary.X11.display)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: Failed to open X display");
|
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: Failed to open X display");
|
||||||
@ -639,7 +639,7 @@ int _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
const char* version = "GLFW " _GLFW_VERSION_FULL
|
const char* version = _GLFW_VERSION_FULL
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
" XRandR"
|
" XRandR"
|
||||||
#endif
|
#endif
|
||||||
@ -649,6 +649,9 @@ const char* _glfwPlatformGetVersionString(void)
|
|||||||
#if !defined(_GLFW_HAS_XRANDR) && !defined(_GLFW_HAS_XF86VIDMODE)
|
#if !defined(_GLFW_HAS_XRANDR) && !defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
" no-mode-switching-support"
|
" no-mode-switching-support"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_GLFW_HAS_XKB)
|
||||||
|
" Xkb"
|
||||||
|
#endif
|
||||||
#if defined(_GLFW_HAS_GLXGETPROCADDRESS)
|
#if defined(_GLFW_HAS_GLXGETPROCADDRESS)
|
||||||
" glXGetProcAddress"
|
" glXGetProcAddress"
|
||||||
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB)
|
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
||||||
void (*glXGetProcAddress(const GLubyte* procName))();
|
// This is the only glXGetProcAddress variant not declared by glxext.h
|
||||||
void (*glXGetProcAddressARB(const GLubyte* procName))();
|
|
||||||
void (*glXGetProcAddressEXT(const GLubyte* procName))();
|
void (*glXGetProcAddressEXT(const GLubyte* procName))();
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,13 +46,6 @@
|
|||||||
// extensions and not all operating systems come with an up-to-date version
|
// extensions and not all operating systems come with an up-to-date version
|
||||||
#include "../support/GL/glxext.h"
|
#include "../support/GL/glxext.h"
|
||||||
|
|
||||||
|
|
||||||
// We need declarations for GLX version 1.3 or above even if the server doesn't
|
|
||||||
// support version 1.3
|
|
||||||
#ifndef GLX_VERSION_1_3
|
|
||||||
#error "GLX header version 1.3 or above is required"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// With XFree86, we can use the XF86VidMode extension
|
// With XFree86, we can use the XF86VidMode extension
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
#include <X11/extensions/xf86vmode.h>
|
#include <X11/extensions/xf86vmode.h>
|
||||||
@ -152,6 +145,8 @@ typedef struct _GLFWwindowX11
|
|||||||
Colormap colormap; // Window colormap
|
Colormap colormap; // Window colormap
|
||||||
Window handle; // Window handle
|
Window handle; // Window handle
|
||||||
Atom wmDeleteWindow; // WM_DELETE_WINDOW atom
|
Atom wmDeleteWindow; // WM_DELETE_WINDOW atom
|
||||||
|
Atom wmName; // _NET_WM_NAME atom
|
||||||
|
Atom wmIconName; // _NET_WM_ICON_NAME atom
|
||||||
Atom wmPing; // _NET_WM_PING atom
|
Atom wmPing; // _NET_WM_PING atom
|
||||||
Atom wmState; // _NET_WM_STATE atom
|
Atom wmState; // _NET_WM_STATE atom
|
||||||
Atom wmStateFullscreen; // _NET_WM_STATE_FULLSCREEN atom
|
Atom wmStateFullscreen; // _NET_WM_STATE_FULLSCREEN atom
|
||||||
|
@ -195,6 +195,12 @@ static GLboolean hasEWMH(_GLFWwindow* window)
|
|||||||
window->X11.wmStateFullscreen =
|
window->X11.wmStateFullscreen =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
|
||||||
|
|
||||||
|
window->X11.wmName =
|
||||||
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_NAME");
|
||||||
|
|
||||||
|
window->X11.wmIconName =
|
||||||
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_ICON_NAME");
|
||||||
|
|
||||||
window->X11.wmPing =
|
window->X11.wmPing =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING");
|
||||||
|
|
||||||
@ -310,7 +316,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
|
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||||
@ -794,7 +800,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
hints->flags = 0;
|
hints->flags = 0;
|
||||||
|
|
||||||
if (wndconfig->windowNoResize)
|
if (!wndconfig->resizable)
|
||||||
{
|
{
|
||||||
hints->flags |= (PMinSize | PMaxSize);
|
hints->flags |= (PMinSize | PMaxSize);
|
||||||
hints->min_width = hints->max_width = window->width;
|
hints->min_width = hints->max_width = window->width;
|
||||||
@ -1427,7 +1433,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
_GLFWfbconfig closest;
|
_GLFWfbconfig closest;
|
||||||
|
|
||||||
window->refreshRate = wndconfig->refreshRate;
|
window->refreshRate = wndconfig->refreshRate;
|
||||||
window->windowNoResize = wndconfig->windowNoResize;
|
window->resizable = wndconfig->resizable;
|
||||||
|
|
||||||
initGLXExtensions(window);
|
initGLXExtensions(window);
|
||||||
|
|
||||||
@ -1444,12 +1450,12 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
result = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
result = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
closest = *result;
|
closest = *result;
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!createContext(window, wndconfig, (GLXFBConfigID) closest.platformID))
|
if (!createContext(window, wndconfig, (GLXFBConfigID) closest.platformID))
|
||||||
@ -1544,9 +1550,39 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
{
|
{
|
||||||
// Set window & icon title
|
Atom type = XInternAtom(_glfwLibrary.X11.display, "UTF8_STRING", False);
|
||||||
XStoreName(_glfwLibrary.X11.display, window->X11.handle, title);
|
|
||||||
XSetIconName(_glfwLibrary.X11.display, window->X11.handle, title);
|
#if defined(X_HAVE_UTF8_STRING)
|
||||||
|
Xutf8SetWMProperties(_glfwLibrary.X11.display,
|
||||||
|
window->X11.handle,
|
||||||
|
title, title,
|
||||||
|
NULL, 0,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
#else
|
||||||
|
// This may be a slightly better fallback than using XStoreName and
|
||||||
|
// XSetIconName, which always store their arguments using STRING
|
||||||
|
XmbSetWMProperties(_glfwLibrary.X11.display,
|
||||||
|
window->X11.handle,
|
||||||
|
title, title,
|
||||||
|
NULL, 0,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (window->X11.wmName != None)
|
||||||
|
{
|
||||||
|
XChangeProperty(_glfwLibrary.X11.display, window->X11.handle,
|
||||||
|
window->X11.wmName, type, 8,
|
||||||
|
PropModeReplace,
|
||||||
|
(unsigned char*) title, strlen(title));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->X11.wmIconName != None)
|
||||||
|
{
|
||||||
|
XChangeProperty(_glfwLibrary.X11.display, window->X11.handle,
|
||||||
|
window->X11.wmIconName, type, 8,
|
||||||
|
PropModeReplace,
|
||||||
|
(unsigned char*) title, strlen(title));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1568,7 +1604,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
&width, &height, &rate);
|
&width, &height, &rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->windowNoResize)
|
if (!window->resizable)
|
||||||
{
|
{
|
||||||
// Update window size restrictions to match new window size
|
// Update window size restrictions to match new window size
|
||||||
|
|
||||||
@ -1735,7 +1771,7 @@ void _glfwPlatformRefreshWindowParams(void)
|
|||||||
&dotclock, &modeline);
|
&dotclock, &modeline);
|
||||||
pixels_per_second = 1000.0f * (float) dotclock;
|
pixels_per_second = 1000.0f * (float) dotclock;
|
||||||
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
|
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
|
||||||
window->refreshRate = (int)(pixels_per_second/pixels_per_frame+0.5);
|
window->refreshRate = (int) (pixels_per_second / pixels_per_frame + 0.5);
|
||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1771,6 +1807,11 @@ void _glfwPlatformPollEvents(void)
|
|||||||
window->width / 2,
|
window->width / 2,
|
||||||
window->height / 2);
|
window->height / 2);
|
||||||
window->X11.cursorCentered = GL_TRUE;
|
window->X11.cursorCentered = GL_TRUE;
|
||||||
|
|
||||||
|
// NOTE: This is a temporary fix. It works as long as you use
|
||||||
|
// offsets accumulated over the course of a frame, instead of
|
||||||
|
// performing the necessary actions per callback call.
|
||||||
|
XFlush( _glfwLibrary.X11.display );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,66 @@
|
|||||||
|
|
||||||
link_libraries(libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
set(STATIC_DEPS libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
||||||
|
set(SHARED_DEPS libglfwShared ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
||||||
|
|
||||||
include_directories(${GLFW_SOURCE_DIR}/include
|
include_directories(${GLFW_SOURCE_DIR}/include
|
||||||
${GLFW_SOURCE_DIR}/support
|
${GLFW_SOURCE_DIR}/support
|
||||||
${OPENGL_INCLUDE_DIR})
|
${OPENGL_INCLUDE_DIR})
|
||||||
|
|
||||||
add_executable(clipboard clipboard.c)
|
add_executable(clipboard clipboard.c)
|
||||||
|
target_link_libraries(clipboard ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(defaults defaults.c)
|
add_executable(defaults defaults.c)
|
||||||
|
target_link_libraries(defaults ${STATIC_DEPS})
|
||||||
|
|
||||||
|
add_executable(dynamic dynamic.c)
|
||||||
|
target_link_libraries(dynamic ${SHARED_DEPS})
|
||||||
|
|
||||||
add_executable(events events.c)
|
add_executable(events events.c)
|
||||||
|
target_link_libraries(events ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(fsaa fsaa.c getopt.c)
|
add_executable(fsaa fsaa.c getopt.c)
|
||||||
|
target_link_libraries(fsaa ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(fsfocus fsfocus.c)
|
add_executable(fsfocus fsfocus.c)
|
||||||
|
target_link_libraries(fsfocus ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(gamma gamma.c getopt.c)
|
add_executable(gamma gamma.c getopt.c)
|
||||||
|
target_link_libraries(gamma ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(glfwinfo glfwinfo.c getopt.c)
|
add_executable(glfwinfo glfwinfo.c getopt.c)
|
||||||
|
target_link_libraries(glfwinfo ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(iconify iconify.c getopt.c)
|
add_executable(iconify iconify.c getopt.c)
|
||||||
|
target_link_libraries(iconify ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(joysticks joysticks.c)
|
add_executable(joysticks joysticks.c)
|
||||||
|
target_link_libraries(joysticks ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(listmodes listmodes.c)
|
add_executable(listmodes listmodes.c)
|
||||||
|
target_link_libraries(listmodes ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(peter peter.c)
|
add_executable(peter peter.c)
|
||||||
|
target_link_libraries(peter ${STATIC_DEPS})
|
||||||
|
|
||||||
add_executable(reopen reopen.c)
|
add_executable(reopen reopen.c)
|
||||||
|
target_link_libraries(reopen ${STATIC_DEPS})
|
||||||
|
|
||||||
if(APPLE)
|
add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c)
|
||||||
# Set fancy names for bundles
|
target_link_libraries(accuracy ${STATIC_DEPS})
|
||||||
add_executable(Accuracy MACOSX_BUNDLE accuracy.c)
|
|
||||||
add_executable(Sharing MACOSX_BUNDLE sharing.c)
|
|
||||||
add_executable(Tearing MACOSX_BUNDLE tearing.c)
|
|
||||||
add_executable(Windows MACOSX_BUNDLE windows.c)
|
|
||||||
else()
|
|
||||||
# Set boring names for executables
|
|
||||||
add_executable(accuracy WIN32 accuracy.c)
|
|
||||||
add_executable(sharing WIN32 sharing.c)
|
|
||||||
add_executable(tearing WIN32 tearing.c)
|
|
||||||
add_executable(windows WIN32 windows.c)
|
|
||||||
endif(APPLE)
|
|
||||||
|
|
||||||
set(WINDOWS_BINARIES accuracy sharing tearing windows)
|
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
|
||||||
set(CONSOLE_BINARIES clipboard defaults events fsaa fsfocus gamma glfwinfo iconify
|
target_link_libraries(sharing ${STATIC_DEPS})
|
||||||
|
|
||||||
|
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
|
||||||
|
target_link_libraries(tearing ${STATIC_DEPS})
|
||||||
|
|
||||||
|
add_executable(title WIN32 MACOSX_BUNDLE title.c)
|
||||||
|
target_link_libraries(title ${STATIC_DEPS})
|
||||||
|
|
||||||
|
add_executable(windows WIN32 MACOSX_BUNDLE windows.c)
|
||||||
|
target_link_libraries(windows ${STATIC_DEPS})
|
||||||
|
|
||||||
|
set(WINDOWS_BINARIES accuracy sharing tearing title windows)
|
||||||
|
set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
|
||||||
joysticks listmodes peter reopen)
|
joysticks listmodes peter reopen)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@ -42,13 +69,3 @@ if(MSVC)
|
|||||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
if(CYGWIN)
|
|
||||||
# Set cross-compile and subsystem compile and link flags
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
|
||||||
COMPILE_FLAGS "-mno-cygwin")
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
|
||||||
LINK_FLAGS "-mno-cygwin -mwindows")
|
|
||||||
set_target_properties(${CONSOLE_BINARIES} PROPERTIES
|
|
||||||
LINK_FLAGS "-mno-cygwin -mconsole")
|
|
||||||
endif(CYGWIN)
|
|
||||||
|
|
||||||
|
91
tests/dynamic.c
Normal file
91
tests/dynamic.c
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
//========================================================================
|
||||||
|
// Dynamic linking test
|
||||||
|
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// This test came about as the result of bug #3060461
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLFW_DLL
|
||||||
|
#include <GL/glfw3.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||||
|
{
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
GLFWwindow window;
|
||||||
|
int major, minor, rev;
|
||||||
|
glfwGetVersion(&major, &minor, &rev);
|
||||||
|
|
||||||
|
printf("GLFW header version: %i.%i.%i\n",
|
||||||
|
GLFW_VERSION_MAJOR,
|
||||||
|
GLFW_VERSION_MINOR,
|
||||||
|
GLFW_VERSION_REVISION);
|
||||||
|
printf("GLFW library version: %i.%i.%i\n", major, minor, rev);
|
||||||
|
printf("GLFW library version string: %s\n", glfwGetVersionString());
|
||||||
|
|
||||||
|
if (major != GLFW_VERSION_MAJOR ||
|
||||||
|
minor != GLFW_VERSION_MINOR ||
|
||||||
|
rev != GLFW_VERSION_REVISION)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GLFW library version mismatch\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to initialize GLFW\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Dynamic Linking Test", NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
|
||||||
|
fprintf(stderr, "Failed to open GLFW window\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwSetWindowSizeCallback(window_size_callback);
|
||||||
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
|
while (glfwIsWindow(window))
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glfwSwapBuffers();
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
@ -40,8 +40,9 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
static GLboolean keyrepeat = 0;
|
static GLboolean keyrepeat = GL_FALSE;
|
||||||
static GLboolean systemkeys = 1;
|
static GLboolean systemkeys = GL_TRUE;
|
||||||
|
static GLboolean closeable = GL_TRUE;
|
||||||
static unsigned int counter = 0;
|
static unsigned int counter = 0;
|
||||||
|
|
||||||
static const char* get_key_name(int key)
|
static const char* get_key_name(int key)
|
||||||
@ -230,7 +231,7 @@ static void window_size_callback(GLFWwindow window, int width, int height)
|
|||||||
static int window_close_callback(GLFWwindow window)
|
static int window_close_callback(GLFWwindow window)
|
||||||
{
|
{
|
||||||
printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime());
|
printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime());
|
||||||
return 1;
|
return closeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_refresh_callback(GLFWwindow window)
|
static void window_refresh_callback(GLFWwindow window)
|
||||||
@ -298,10 +299,7 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
case GLFW_KEY_R:
|
case GLFW_KEY_R:
|
||||||
{
|
{
|
||||||
keyrepeat = !keyrepeat;
|
keyrepeat = !keyrepeat;
|
||||||
if (keyrepeat)
|
glfwSetInputMode(window, GLFW_KEY_REPEAT, keyrepeat);
|
||||||
glfwEnable(window, GLFW_KEY_REPEAT);
|
|
||||||
else
|
|
||||||
glfwDisable(window, GLFW_KEY_REPEAT);
|
|
||||||
|
|
||||||
printf("(( key repeat %s ))\n", keyrepeat ? "enabled" : "disabled");
|
printf("(( key repeat %s ))\n", keyrepeat ? "enabled" : "disabled");
|
||||||
break;
|
break;
|
||||||
@ -310,14 +308,19 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
case GLFW_KEY_S:
|
case GLFW_KEY_S:
|
||||||
{
|
{
|
||||||
systemkeys = !systemkeys;
|
systemkeys = !systemkeys;
|
||||||
if (systemkeys)
|
glfwSetInputMode(window, GLFW_SYSTEM_KEYS, systemkeys);
|
||||||
glfwEnable(window, GLFW_SYSTEM_KEYS);
|
|
||||||
else
|
|
||||||
glfwDisable(window, GLFW_SYSTEM_KEYS);
|
|
||||||
|
|
||||||
printf("(( system keys %s ))\n", systemkeys ? "enabled" : "disabled");
|
printf("(( system keys %s ))\n", systemkeys ? "enabled" : "disabled");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GLFW_KEY_C:
|
||||||
|
{
|
||||||
|
closeable = !closeable;
|
||||||
|
|
||||||
|
printf("(( closing %s ))\n", closeable ? "enabled" : "disabled");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||||
|
|
||||||
glfwSetWindowFocusCallback(window_focus_callback);
|
glfwSetWindowFocusCallback(window_focus_callback);
|
||||||
glfwSetKeyCallback(window_key_callback);
|
glfwSetKeyCallback(window_key_callback);
|
||||||
|
@ -35,11 +35,20 @@
|
|||||||
|
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
|
|
||||||
|
#define STEP_SIZE 0.1f
|
||||||
|
|
||||||
static GLfloat gamma = 1.0f;
|
static GLfloat gamma = 1.0f;
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: gammatest [-h] [-f]\n");
|
printf("Usage: gamma [-h] [-f]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_gamma(float value)
|
||||||
|
{
|
||||||
|
gamma = value;
|
||||||
|
printf("Gamma: %f\n", gamma);
|
||||||
|
glfwSetGamma(gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void key_callback(GLFWwindow window, int key, int action)
|
static void key_callback(GLFWwindow window, int key, int action)
|
||||||
@ -50,21 +59,27 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_ESCAPE:
|
case GLFW_KEY_ESCAPE:
|
||||||
|
{
|
||||||
glfwCloseWindow(window);
|
glfwCloseWindow(window);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GLFW_KEY_KP_ADD:
|
case GLFW_KEY_KP_ADD:
|
||||||
case GLFW_KEY_Q:
|
case GLFW_KEY_Q:
|
||||||
gamma += 0.1f;
|
{
|
||||||
printf("Gamma: %f\n", gamma);
|
set_gamma(gamma + STEP_SIZE);
|
||||||
glfwSetGamma(gamma);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GLFW_KEY_KP_SUBTRACT:
|
case GLFW_KEY_KP_SUBTRACT:
|
||||||
case GLFW_KEY_W:
|
case GLFW_KEY_W:
|
||||||
gamma -= 0.1f;
|
{
|
||||||
printf("Gamma: %f\n", gamma);
|
if (gamma - STEP_SIZE > 0.f)
|
||||||
glfwSetGamma(gamma);
|
set_gamma(gamma - STEP_SIZE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void size_callback(GLFWwindow window, int width, int height)
|
static void size_callback(GLFWwindow window, int width, int height)
|
||||||
@ -124,7 +139,7 @@ int main(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Gamma: %f\n", gamma);
|
set_gamma(1.f);
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
glfwSetKeyCallback(key_callback);
|
glfwSetKeyCallback(key_callback);
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: version [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
printf("Usage: glfwinfo [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
||||||
printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT " " PROFILE_NAME_ES2 "\n");
|
printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT " " PROFILE_NAME_ES2 "\n");
|
||||||
printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
|
printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
|
|
||||||
static void size_callback(GLFWwindow window, int width, int height)
|
static void size_callback(GLFWwindow window, int width, int height)
|
||||||
{
|
{
|
||||||
|
printf("%0.2f Size %ix%i\n", glfwGetTime(), width, height);
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static GLboolean cursor_captured = GL_FALSE;
|
|
||||||
static GLFWwindow window_handle = NULL;
|
static GLFWwindow window_handle = NULL;
|
||||||
static int cursor_x;
|
static int cursor_x;
|
||||||
static int cursor_y;
|
static int cursor_y;
|
||||||
@ -44,18 +43,16 @@ static GLboolean open_window(void);
|
|||||||
|
|
||||||
static void toggle_mouse_cursor(GLFWwindow window)
|
static void toggle_mouse_cursor(GLFWwindow window)
|
||||||
{
|
{
|
||||||
if (cursor_captured)
|
if (glfwGetInputMode(window, GLFW_CURSOR_MODE) == GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
printf("Released cursor\n");
|
printf("Released cursor\n");
|
||||||
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Captured cursor\n");
|
printf("Captured cursor\n");
|
||||||
glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor_captured = !cursor_captured;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mouse_position_callback(GLFWwindow window, int x, int y)
|
static void mouse_position_callback(GLFWwindow window, int x, int y)
|
||||||
|
@ -92,8 +92,6 @@ static void draw_quad(GLuint texture)
|
|||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
glColor3f(0.6f, 0.f, 0.6f);
|
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glTexCoord2f(0.f, 0.f);
|
glTexCoord2f(0.f, 0.f);
|
||||||
@ -142,6 +140,11 @@ int main(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set drawing color for the first context and copy it to the second
|
||||||
|
glfwMakeContextCurrent(windows[0]);
|
||||||
|
glColor3f(0.6f, 0.f, 0.6f);
|
||||||
|
glfwCopyContext(windows[0], windows[1], GL_CURRENT_BIT);
|
||||||
|
|
||||||
// Put the second window to the right of the first one
|
// Put the second window to the right of the first one
|
||||||
glfwGetWindowPos(windows[0], &x, &y);
|
glfwGetWindowPos(windows[0], &x, &y);
|
||||||
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
|
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
|
||||||
|
@ -34,11 +34,30 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
static int swap_interval;
|
||||||
|
|
||||||
|
static void set_swap_interval(int value)
|
||||||
|
{
|
||||||
|
char title[256];
|
||||||
|
|
||||||
|
swap_interval = value;
|
||||||
|
glfwSwapInterval(swap_interval);
|
||||||
|
|
||||||
|
sprintf(title, "Tearing detector (interval %i)", swap_interval);
|
||||||
|
glfwSetWindowTitle(glfwGetCurrentContext(), title);
|
||||||
|
}
|
||||||
|
|
||||||
static void window_size_callback(GLFWwindow window, int width, int height)
|
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void key_callback(GLFWwindow window, int key, int action)
|
||||||
|
{
|
||||||
|
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
|
||||||
|
set_swap_interval(!swap_interval);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
float position;
|
float position;
|
||||||
@ -50,7 +69,7 @@ int main(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Tearing Detector", NULL);
|
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "", NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
@ -59,8 +78,10 @@ int main(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_swap_interval(1);
|
||||||
|
|
||||||
glfwSetWindowSizeCallback(window_size_callback);
|
glfwSetWindowSizeCallback(window_size_callback);
|
||||||
glfwSwapInterval(1);
|
glfwSetKeyCallback(key_callback);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
||||||
|
70
tests/title.c
Normal file
70
tests/title.c
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
//========================================================================
|
||||||
|
// UTF-8 window title test
|
||||||
|
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// This test sets a UTF-8 window title
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#include <GL/glfw3.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||||
|
{
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
GLFWwindow window;
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
|
glfwSetWindowSizeCallback(window_size_callback);
|
||||||
|
|
||||||
|
while (glfwIsWindow(window) == GL_TRUE)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glfwSwapBuffers();
|
||||||
|
glfwWaitEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user