From 7e0ca6705b0a687a15acde6a90b908f5b6f138d6 Mon Sep 17 00:00:00 2001
From: Hanmac
Date: Tue, 31 Jan 2012 10:00:52 +0100
Subject: [PATCH 01/62] Added use of XkbKeycodeToKeysym when Xkb is available.
---
src/x11_init.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/x11_init.c b/src/x11_init.c
index 4d3c0f74..3ed9ab13 100644
--- a/src/x11_init.c
+++ b/src/x11_init.c
@@ -79,7 +79,11 @@ static int keyCodeToGLFWKeyCode(int keyCode)
// Note: This way we always force "NumLock = ON", which is intentional
// since the returned key code should correspond to a physical
// location.
+#if defined(_GLFW_HAS_XKB)
+ keySym = XkbKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 1, 0);
+#else
keySym = XKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 1);
+#endif
switch (keySym)
{
case XK_KP_0: return GLFW_KEY_KP_0;
@@ -102,7 +106,12 @@ static int keyCodeToGLFWKeyCode(int keyCode)
// Now try pimary keysym for function keys (non-printable keys). These
// should not be layout dependent (i.e. US layout and international
// layouts should give the same result).
+#if defined(_GLFW_HAS_XKB)
+ keySym = XkbKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 0, 0);
+#else
keySym = XKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 0);
+#endif
+
switch (keySym)
{
case XK_Escape: return GLFW_KEY_ESCAPE;
From a202799f4577ef8ec5941709c9f4d05c08b19940 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 26 Feb 2012 03:24:42 +0100
Subject: [PATCH 02/62] Renamed AppKit init function.
---
src/cocoa_window.m | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 221dcc5e..578d1c41 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -595,7 +595,7 @@ static void setUpMenuBar(void)
//========================================================================
// Initialize the Cocoa Application Kit
//========================================================================
-static GLboolean initializeCocoa(void)
+static GLboolean initializeAppKit(void)
{
if (NSApp)
return GL_TRUE;
@@ -813,7 +813,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig)
{
- if (!initializeCocoa())
+ if (!initializeAppKit())
return GL_FALSE;
// We can only have one application delegate, but we only allocate it the
From f47f5d9f59623e9a46f095c0840413ac3cc631af Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 26 Feb 2012 18:41:33 +0100
Subject: [PATCH 03/62] Updated changelog.
---
readme.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/readme.html b/readme.html
index 5ab86c64..19c438f5 100644
--- a/readme.html
+++ b/readme.html
@@ -869,7 +869,8 @@ their skills. Special thanks go out to:
Tristam MacDonald, for his bug reports and feedback on the Cocoa port
- Hans 'Hanmac' Mackowiak, for adding UTF-8 window title support on X11
+ Hans 'Hanmac' Mackowiak, for adding UTF-8 window title support on X11 and
+ a fix for the Xkb support
David Medlock, for doing the initial Lua port
From 98fbc07aa4d73e61b514f90f7678fa542799f0a6 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 27 Feb 2012 02:21:26 +0100
Subject: [PATCH 04/62] Fixed GLFW_WINDOW_NO_RESIZE state not being saved.
---
readme.html | 2 ++
src/cocoa_window.m | 2 ++
src/win32_window.c | 1 +
3 files changed, 5 insertions(+)
diff --git a/readme.html b/readme.html
index 19c438f5..d23f982a 100644
--- a/readme.html
+++ b/readme.html
@@ -315,6 +315,7 @@ version of GLFW.
[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash
[Cocoa] Bugfix: glfwInit
changed the current directory for unbundled executables
+ [Cocoa] Bugfix: The GLFW_WINDOW_NO_RESIZE
window parameter was always zero
[X11] Added support for the GLX_EXT_swap_control
extension as an alternative to GLX_SGI_swap_control
[X11] Added the POSIX CLOCK_MONOTONIC
time source as the preferred method
[X11] Added dependency on libm, where present
@@ -328,6 +329,7 @@ version of GLFW.
[Win32] Bugfix: Software rasterizer pixel formats were not discarded by the WGL_ARB_pixel_format code path
[Win32] Bugfix: The array for WGL context attributes was too small and could overflow
[Win32] Bugfix: Alt+F4 hot key was not translated into WM_CLOSE
+ [Win32] Bugfix: The GLFW_WINDOW_NO_RESIZE
window parameter was always zero
v2.7
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 221dcc5e..bf3b0fbc 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -816,6 +816,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
if (!initializeCocoa())
return GL_FALSE;
+ window->resizable = wndconfig->resizable;
+
// 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)
diff --git a/src/win32_window.c b/src/win32_window.c
index 24788a33..0f3c67d0 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -1441,6 +1441,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
GLboolean recreateContext = GL_FALSE;
window->Win32.desiredRefreshRate = wndconfig->refreshRate;
+ window->resizable = wndconfig->resizable;
if (!_glfwLibrary.Win32.classAtom)
{
From a82598ea24d08b82c9e28f3943a70e5bd7ae1f5f Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 29 Feb 2012 19:52:34 +0100
Subject: [PATCH 05/62] Disable dynamic loading for Win32 DLL.
---
src/CMakeLists.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b5569c40..79a5c314 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,9 +47,10 @@ set_target_properties(libglfwStatic libglfwShared PROPERTIES
OUTPUT_NAME glfw)
if(WIN32)
+ target_link_libraries(libglfwShared winmm)
# The GLFW DLL needs a special compile-time macro and import library name
set_target_properties(libglfwShared PROPERTIES
- DEFINE_SYMBOL GLFW_BUILD_DLL
+ COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
PREFIX ""
IMPORT_PREFIX ""
IMPORT_SUFFIX "dll.lib")
From cd7b9b1568a8145bb22393fed1be27223a6f0d3b Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 29 Feb 2012 20:15:39 +0100
Subject: [PATCH 06/62] CMake file formatting.
---
CMakeLists.txt | 28 +++++++++++++---------------
examples/CMakeLists.txt | 10 +++++-----
src/CMakeLists.txt | 20 ++++++++++----------
tests/CMakeLists.txt | 4 ++--
4 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e6554c5..a4454365 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ if (WIN32)
# Set up library and include paths
list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
-endif (WIN32)
+endif()
#--------------------------------------------------------------------
# Set up GLFW for Xlib and GLX on Unix-like systems with X Windows
@@ -47,12 +47,12 @@ if (UNIX AND NOT APPLE)
find_library(MATH_LIBRARY m)
if (MATH_LIBRARY)
list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY})
- endif(MATH_LIBRARY)
+ endif()
find_library(RT_LIBRARY rt)
if (RT_LIBRARY)
list(APPEND GLFW_LIBRARIES ${RT_LIBRARY})
- endif(RT_LIBRARY)
+ endif()
include(CheckFunctionExists)
include(CheckSymbolExists)
@@ -83,24 +83,22 @@ if (UNIX AND NOT APPLE)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
check_function_exists(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB)
- endif (NOT _GLFW_HAS_GLXGETPROCADDRESS)
+ endif()
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
check_function_exists(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT)
- endif (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
+ endif()
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND
NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND
NOT _GLFW_HAS_GLXGETPROCADDRESSEXT)
message(WARNING "No glXGetProcAddressXXX variant found")
- endif (NOT _GLFW_HAS_GLXGETPROCADDRESS AND
- NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND
- NOT _GLFW_HAS_GLXGETPROCADDRESSEXT)
+ endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(_GLFW_USE_LINUX_JOYSTICKS 1)
- endif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-endif(UNIX AND NOT APPLE)
+ endif()
+endif()
#--------------------------------------------------------------------
# Set up GLFW for Cocoa and NSOpenGL on Mac OS X
@@ -121,7 +119,7 @@ if (UNIX AND APPLE)
set(CMAKE_C_FLAGS "-mmacosx-version-min=10.5")
else(GLFW_BUILD_UNIVERSAL)
message(STATUS "Building GLFW only for the native architecture")
- endif(GLFW_BUILD_UNIVERSAL)
+ endif()
# Set up library and include paths
find_library(COCOA_FRAMEWORK Cocoa)
@@ -131,7 +129,7 @@ if (UNIX AND APPLE)
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()
#--------------------------------------------------------------------
# Add subdirectories
@@ -140,11 +138,11 @@ add_subdirectory(src)
if (GLFW_BUILD_EXAMPLES)
add_subdirectory(examples)
-endif(GLFW_BUILD_EXAMPLES)
+endif()
if (GLFW_BUILD_TESTS)
add_subdirectory(tests)
-endif(GLFW_BUILD_TESTS)
+endif()
#--------------------------------------------------------------------
# Create shared configuration header
@@ -175,7 +173,7 @@ configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in"
# Uninstall operation
# Don't generate this target if a higher-level project already has
#--------------------------------------------------------------------
-if(NOT TARGET uninstall)
+if (NOT TARGET uninstall)
configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index d511b22d..37b7f754 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -7,14 +7,14 @@ include_directories(${GLFW_SOURCE_DIR}/include
${GLFW_SOURCE_DIR}/support
${OPENGL_INCLUDE_DIR})
-if(APPLE)
+if (APPLE)
# Set fancy names for bundles
add_executable(Boing MACOSX_BUNDLE boing.c)
add_executable(Gears MACOSX_BUNDLE gears.c)
add_executable("Split View" MACOSX_BUNDLE splitview.c)
add_executable(Triangle MACOSX_BUNDLE triangle.c)
add_executable(Wave MACOSX_BUNDLE wave.c)
-else(APPLE)
+else()
# Set boring names for executables
add_executable(boing WIN32 boing.c)
add_executable(gears WIN32 gears.c)
@@ -22,13 +22,13 @@ else(APPLE)
add_executable(splitview WIN32 splitview.c)
add_executable(triangle WIN32 triangle.c)
add_executable(wave WIN32 wave.c)
-endif(APPLE)
+endif()
set(WINDOWS_BINARIES boing gears heightmap splitview triangle wave)
-if(MSVC)
+if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup")
-endif(MSVC)
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 79a5c314..bdc4d5fe 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,15 +1,15 @@
if(UNIX)
- if(_GLFW_HAS_XRANDR)
+ if (_GLFW_HAS_XRANDR)
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
- endif(_GLFW_HAS_XRANDR)
- if(_GLFW_HAS_XF86VIDMODE)
+ endif()
+ if (_GLFW_HAS_XF86VIDMODE)
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm")
- endif(_GLFW_HAS_XF86VIDMODE)
+ endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
-endif(UNIX)
+endif()
include_directories(${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src
@@ -37,7 +37,7 @@ elseif(_GLFW_X11_GLX)
x11_window.c)
else()
message(FATAL_ERROR "No supported platform was selected")
-endif(_GLFW_COCOA_NSGL)
+endif()
add_library(libglfwStatic STATIC ${libglfw_SOURCES})
add_library(libglfwShared SHARED ${libglfw_SOURCES})
@@ -54,16 +54,16 @@ if(WIN32)
PREFIX ""
IMPORT_PREFIX ""
IMPORT_SUFFIX "dll.lib")
-endif(WIN32)
+endif()
if(APPLE)
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
- if(NOT CFLAGS)
+ if (NOT CFLAGS)
set(CFLAGS "")
- endif(NOT CFLAGS)
+ endif()
set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
-endif(APPLE)
+endif()
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index d7ac0954..58631603 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -61,9 +61,9 @@ set(WINDOWS_BINARIES accuracy sharing tearing title windows)
set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
joysticks listmodes peter reopen)
-if(MSVC)
+if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup")
-endif(MSVC)
+endif()
From 537754aab84f7edbca100c7c70682f0331c05a20 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 29 Feb 2012 20:17:09 +0100
Subject: [PATCH 07/62] Require CMake 2.8.
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4454365..25f83279 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
project(GLFW C)
-cmake_minimum_required(VERSION 2.4)
+cmake_minimum_required(VERSION 2.8)
cmake_policy(VERSION 2.4)
set(GLFW_VERSION_MAJOR "3")
From a27c444af41434eb270df8dd7a48954585aa4ec3 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 29 Feb 2012 20:19:05 +0100
Subject: [PATCH 08/62] Updated comment.
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25f83279..03870594 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -160,7 +160,7 @@ install(DIRECTORY include/GL DESTINATION include
install(FILES COPYING.txt readme.html
DESTINATION share/doc/glfw-${GLFW_VERSION_FULL}/)
-# The respective port's CMakeLists.txt file installs the library
+# The src directory's CMakeLists.txt file installs the library
#--------------------------------------------------------------------
# -- Documentation generation
From e7fb35a5d8075cd2d2cb28181213b75356d26769 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 1 Mar 2012 03:41:36 +0100
Subject: [PATCH 09/62] Removed legacy CMake policy.
---
CMakeLists.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 03870594..f27cf7cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,6 @@
project(GLFW C)
cmake_minimum_required(VERSION 2.8)
-cmake_policy(VERSION 2.4)
set(GLFW_VERSION_MAJOR "3")
set(GLFW_VERSION_MINOR "0")
From f49119107f6b214a179affc6aba798c2dca70eec Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 1 Mar 2012 03:45:06 +0100
Subject: [PATCH 10/62] Removed misplaced Win32 configuration macros.
---
src/config.h.in | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/config.h.in b/src/config.h.in
index f966356c..46a6e2aa 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -60,11 +60,6 @@
// Define this to 1 if the Linux joystick API is available
#cmakedefine _GLFW_USE_LINUX_JOYSTICKS 1
-// Define this to 1 to not load gdi32.dll dynamically
-#cmakedefine _GLFW_NO_DLOAD_GDI32 1
-// Define this to 1 to not load winmm.dll dynamically
-#cmakedefine _GLFW_NO_DLOAD_WINMM 1
-
// The GLFW version as used by glfwGetVersionString
#define _GLFW_VERSION_FULL "@GLFW_VERSION_FULL@"
From b5a3249f2e8a28d1a1324449e80f3b610cc7d40f Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 1 Mar 2012 03:51:35 +0100
Subject: [PATCH 11/62] Removed unused header.
---
include/GL/glfw3.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index e84bdbba..cc817521 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -136,10 +136,6 @@ extern "C" {
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
-/* Include the declaration of the size_t type used below.
- */
-#include
-
/* Include standard OpenGL headers: GLFW uses GL_FALSE/GL_TRUE, and it is
* convenient for the user to only have to include . This also
* solves the problem with Windows and needing some
From 6f3f68bad1c3aef37c7299cdcdb30b8b28e8e85c Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 1 Mar 2012 17:03:42 +0100
Subject: [PATCH 12/62] Gave CMake toolchain file clearer name.
---
CMake/{linux-mingw32msvc.cmake => linux-i586-mingw32msvc.cmake} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename CMake/{linux-mingw32msvc.cmake => linux-i586-mingw32msvc.cmake} (100%)
diff --git a/CMake/linux-mingw32msvc.cmake b/CMake/linux-i586-mingw32msvc.cmake
similarity index 100%
rename from CMake/linux-mingw32msvc.cmake
rename to CMake/linux-i586-mingw32msvc.cmake
From 4ac5ea331bdd6e117e5ef36431f051058b30be1b Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 1 Mar 2012 17:15:37 +0100
Subject: [PATCH 13/62] Updated toolchain file README.
---
CMake/README.txt | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/CMake/README.txt b/CMake/README.txt
index d24854ed..9581f832 100644
--- a/CMake/README.txt
+++ b/CMake/README.txt
@@ -1,10 +1,19 @@
-This folder contains a collection of toolchains definition in order to
-support cross compilation. The naming scheme is the following:
+This directory contains a collection of toolchain definitions for cross
+compilation, currently limited to compiling Win32 binaries on Linux.
+
+The toolchain file naming scheme is as follows:
+
host-system-compiler.cmake
-to use this at the time you run the initial cmake command use the
-following parameter
- -DCMAKE_TOOLCHAIN_FILE=./toolchains/XXX-XXX-XXX.cmake
- which maps to file in this folder.
+To use these files you add a special parameter when configuring the source tree:
+
+ cmake -DCMAKE_TOOLCHAIN_FILE= .
+
+For example, to use the Debian GNU/Linux MinGW package, run CMake like this:
+
+ cmake -DCMAKE_TOOLCHAIN_FILE=CMake/linux-i586-mingw32msvc.cmake .
+
+For more details see this article:
+
+ http://www.paraview.org/Wiki/CMake_Cross_Compiling
-For more details see: http://www.paraview.org/Wiki/CMake_Cross_Compiling
From c0db61bd6e07e78ff9a47c8e9ebb26e5859da744 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 16:26:15 +0100
Subject: [PATCH 14/62] Moved autorelease pool back to glfwInit.
---
src/cocoa_init.m | 2 ++
src/cocoa_window.m | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index 16ea6e68..3251115f 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -78,6 +78,8 @@ static void changeToResourcesDirectory(void)
int _glfwPlatformInit(void)
{
+ _glfwLibrary.NS.autoreleasePool = [[NSAutoreleasePool alloc] init];
+
_glfwLibrary.NS.OpenGLFramework =
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfwLibrary.NS.OpenGLFramework == NULL)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 578d1c41..c74138b3 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -600,8 +600,6 @@ static GLboolean initializeAppKit(void)
if (NSApp)
return GL_TRUE;
- _glfwLibrary.NS.autoreleasePool = [[NSAutoreleasePool alloc] init];
-
// Implicitly create shared NSApplication instance
[GLFWApplication sharedApplication];
From 7af82fdade34454deaabe5aed09f04d766fe3a9d Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 16:27:53 +0100
Subject: [PATCH 15/62] Replaced deprecated CoreGraphics calls in video mode
enumeration.
---
readme.html | 1 +
src/cocoa_fullscreen.m | 85 ++++++++++++++++++++++++++++--------------
src/cocoa_init.m | 9 ++++-
src/cocoa_platform.h | 9 +++--
4 files changed, 69 insertions(+), 35 deletions(-)
diff --git a/readme.html b/readme.html
index 5ab86c64..12f726bf 100644
--- a/readme.html
+++ b/readme.html
@@ -312,6 +312,7 @@ version of GLFW.
[Cocoa] Added support for joysticks
[Cocoa] Postponed menu creation to first window creation
[Cocoa] Replaced NSDate
time source with mach_absolute_time
+ [Cocoa] Replaced deprecated CoreGraphics calls in video mode enumeration
[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash
[Cocoa] Bugfix: glfwInit
changed the current directory for unbundled executables
diff --git a/src/cocoa_fullscreen.m b/src/cocoa_fullscreen.m
index 370296b8..cc5df538 100644
--- a/src/cocoa_fullscreen.m
+++ b/src/cocoa_fullscreen.m
@@ -34,38 +34,59 @@
// Check whether the display mode should be included in enumeration
//========================================================================
-static BOOL modeIsGood(NSDictionary* mode)
+static GLboolean modeIsGood(CGDisplayModeRef mode)
{
- // This is a bit controversial, if you've got something other than an
- // LCD computer monitor as an output device you might not want these
- // checks. You might also want to reject modes which are interlaced,
- // or TV out. There is no one-size-fits-all policy that can work here.
- // This seems like a decent compromise, but certain applications may
- // wish to patch this...
- return [[mode objectForKey:(id)kCGDisplayBitsPerPixel] intValue] >= 15 &&
- [mode objectForKey:(id)kCGDisplayModeIsSafeForHardware] != nil &&
- [mode objectForKey:(id)kCGDisplayModeIsStretched] == nil;
+ uint32_t flags = CGDisplayModeGetIOFlags(mode);
+ if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
+ return GL_FALSE;
+
+ if (flags & kDisplayModeInterlacedFlag)
+ return GL_FALSE;
+
+ if (flags & kDisplayModeTelevisionFlag)
+ return GL_FALSE;
+
+ if (flags & kDisplayModeStretchedFlag)
+ return GL_FALSE;
+
+ CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
+ if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
+ CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
+ {
+ CFRelease(format);
+ return GL_FALSE;
+ }
+
+ CFRelease(format);
+ return GL_TRUE;
}
//========================================================================
// Convert Core Graphics display mode to GLFW video mode
//========================================================================
-static GLFWvidmode vidmodeFromCGDisplayMode(NSDictionary* mode)
+static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode)
{
- unsigned int width =
- [[mode objectForKey:(id)kCGDisplayWidth] unsignedIntValue];
- unsigned int height =
- [[mode objectForKey:(id)kCGDisplayHeight] unsignedIntValue];
- unsigned int bps =
- [[mode objectForKey:(id)kCGDisplayBitsPerSample] unsignedIntValue];
-
GLFWvidmode result;
- result.width = width;
- result.height = height;
- result.redBits = bps;
- result.greenBits = bps;
- result.blueBits = bps;
+ result.width = CGDisplayModeGetWidth(mode);
+ result.height = CGDisplayModeGetHeight(mode);
+
+ CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
+
+ if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
+ {
+ result.redBits = 5;
+ result.greenBits = 5;
+ result.blueBits = 5;
+ }
+ else
+ {
+ result.redBits = 8;
+ result.greenBits = 8;
+ result.blueBits = 8;
+ }
+
+ CFRelease(format);
return result;
}
@@ -80,17 +101,23 @@ static GLFWvidmode vidmodeFromCGDisplayMode(NSDictionary* mode)
int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
{
- NSArray* modes = (NSArray*) CGDisplayAvailableModes(CGMainDisplayID());
- unsigned int i, j = 0, n = [modes count];
+ CGDisplayModeRef mode;
+ CFArrayRef modes;
+ CFIndex count, i;
+ int stored = 0;
- for (i = 0; i < n && j < (unsigned)maxcount; i++)
+ modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
+ count = CFArrayGetCount(modes);
+
+ for (i = 0; i < count && stored < maxcount; i++)
{
- NSDictionary *mode = [modes objectAtIndex:i];
+ mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (modeIsGood(mode))
- list[j++] = vidmodeFromCGDisplayMode(mode);
+ list[stored++] = vidmodeFromCGDisplayMode(mode);
}
- return j;
+ CFRelease(modes);
+ return stored;
}
//========================================================================
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index 3251115f..067d4dde 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -91,8 +91,7 @@ int _glfwPlatformInit(void)
changeToResourcesDirectory();
- _glfwLibrary.NS.desktopMode =
- (NSDictionary*) CGDisplayCurrentMode(CGMainDisplayID());
+ _glfwLibrary.NS.desktopMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
// Save the original gamma ramp
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
@@ -117,6 +116,12 @@ int _glfwPlatformTerminate(void)
// Restore the original gamma ramp
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
+ if (_glfwLibrary.NS.desktopMode)
+ {
+ CFRelease(_glfwLibrary.NS.desktopMode);
+ _glfwLibrary.NS.desktopMode = NULL;
+ }
+
[NSApp setDelegate:nil];
[_glfwLibrary.NS.delegate release];
_glfwLibrary.NS.delegate = nil;
diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h
index 1a90af01..5a753707 100644
--- a/src/cocoa_platform.h
+++ b/src/cocoa_platform.h
@@ -37,6 +37,7 @@
#if defined(__OBJC__)
#import
#else
+#include
typedef void* id;
#endif
@@ -90,10 +91,10 @@ typedef struct _GLFWlibraryNS
} timer;
// dlopen handle for dynamically loading OpenGL extension entry points
- void* OpenGLFramework;
- id desktopMode;
- id delegate;
- id autoreleasePool;
+ void* OpenGLFramework;
+ CGDisplayModeRef desktopMode;
+ id delegate;
+ id autoreleasePool;
} _GLFWlibraryNS;
From e55396d75432a3386af70c3737054f5ff3d7db01 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 20:09:06 +0100
Subject: [PATCH 16/62] Shortened call to setAppleMenu:.
---
src/cocoa_window.m | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 239e883a..defe8fce 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -469,13 +469,6 @@ static int convertMacKeyCode(unsigned int macKeyCode)
@end
-// Prior to Snow Leopard, we need to use this oddly-named semi-private API
-// to get the application menu working properly. Need to be careful in
-// case it goes away in a future OS update.
-@interface NSApplication (NSAppleMenu)
-- (void)setAppleMenu:(NSMenu*)m;
-@end
-
//========================================================================
// Try to figure out what the calling application is called
//========================================================================
@@ -584,11 +577,9 @@ static void setUpMenuBar(void)
action:@selector(arrangeInFront:)
keyEquivalent:@""];
- // At least guard the call to private API to avoid an exception if it
- // goes away. Hopefully that means the worst we'll break in future is to
- // look ugly...
- if ([NSApp respondsToSelector:@selector(setAppleMenu:)])
- [NSApp setAppleMenu:appMenu];
+ // Prior to Snow Leopard, we need to use this oddly-named semi-private API
+ // to get the application menu working properly.
+ [NSApp performSelector:NSSelectorFromString(@"setAppleMenu:") withObject:appMenu];
}
From 4b21ccbe19706dc8bc59c80c814d298e8c56e49d Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 20:22:23 +0100
Subject: [PATCH 17/62] Output fix.
---
tests/glfwinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c
index 369e6a96..45cb8616 100644
--- a/tests/glfwinfo.c
+++ b/tests/glfwinfo.c
@@ -263,7 +263,7 @@ int main(int argc, char** argv)
if (major > 3 || (major == 3 && minor >= 2))
{
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
- printf("OpenGL profile mask: 0x%08x (%s)\n", mask, get_profile_name(mask));
+ printf("OpenGL profile mask: %s (0x%08x)\n", get_profile_name(mask), mask);
printf("OpenGL profile parsed by GLFW: %s\n",
get_glfw_profile_name(glfwGetWindowParam(window, GLFW_OPENGL_PROFILE)));
From cb9bae5c71382a517e8a22a2773cb6521b6b1d6c Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 20:27:47 +0100
Subject: [PATCH 18/62] Made glfwOpenWindow enforce the forward-compat and
profile hints.
---
readme.html | 1 +
src/cocoa_window.m | 15 ++++++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/readme.html b/readme.html
index 5943be58..5762b023 100644
--- a/readme.html
+++ b/readme.html
@@ -313,6 +313,7 @@ version of GLFW.
[Cocoa] Postponed menu creation to first window creation
[Cocoa] Replaced NSDate
time source with mach_absolute_time
[Cocoa] Replaced deprecated CoreGraphics calls in video mode enumeration
+ [Cocoa] Bugfix: glfwOpenWindow
did not properly enforce the forward-compatible and context profile hints
[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash
[Cocoa] Bugfix: glfwInit
changed the current directory for unbundled executables
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index defe8fce..46532778 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -675,14 +675,23 @@ static GLboolean createContext(_GLFWwindow* window,
return GL_FALSE;
}
- if (wndconfig->glProfile)
+ if (wndconfig->glMajor > 2)
{
- // Fail if a profile other than core was explicitly selected
+ if (!wndconfig->glForward)
+ {
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Cocoa/NSOpenGL: The targeted version of Mac OS X "
+ "only supports OpenGL 3.2 contexts if they are "
+ "forward-compatible");
+ return GL_FALSE;
+ }
+
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Cocoa/NSOpenGL: The targeted version of Mac OS X "
- "only supports the OpenGL core profile");
+ "only supports OpenGL 3.2 contexts if they use the "
+ "core profile");
return GL_FALSE;
}
}
From 3383e59a73b18eb3a49288339ed06b7c677278db Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 20:30:59 +0100
Subject: [PATCH 19/62] Renamed function.
---
src/cocoa_window.m | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 46532778..2907e941 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -523,7 +523,7 @@ static NSString* findAppName(void)
// localize(d|able), etc. Loading a nib would save us this horror, but that
// doesn't seem like a good thing to require of GLFW's clients.
//========================================================================
-static void setUpMenuBar(void)
+static void createMenuBar(void)
{
NSString* appName = findAppName();
@@ -597,7 +597,7 @@ static GLboolean initializeAppKit(void)
// Setting up the menu bar must go between sharedApplication
// above and finishLaunching below, in order to properly emulate the
// behavior of NSApplicationMain
- setUpMenuBar();
+ createMenuBar();
[NSApp finishLaunching];
From a90675c526445495fd6e1fc0d8b4a94338f82a4a Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 22:05:40 +0100
Subject: [PATCH 20/62] Shortened the shortening.
---
src/cocoa_window.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 2907e941..94a11118 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -579,7 +579,7 @@ static void createMenuBar(void)
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
// to get the application menu working properly.
- [NSApp performSelector:NSSelectorFromString(@"setAppleMenu:") withObject:appMenu];
+ [NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu];
}
From adf4899f4c94cba654f777632c245d7382c11de4 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 22:37:48 +0100
Subject: [PATCH 21/62] Added name and version to test and example bundles.
---
examples/CMakeLists.txt | 18 ++++++++++++++++--
tests/CMakeLists.txt | 11 +++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 37b7f754..39cad943 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -14,6 +14,12 @@ if (APPLE)
add_executable("Split View" MACOSX_BUNDLE splitview.c)
add_executable(Triangle MACOSX_BUNDLE triangle.c)
add_executable(Wave MACOSX_BUNDLE wave.c)
+
+ set_target_properties(Boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing")
+ set_target_properties(Gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears")
+ set_target_properties("Split View" PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Split View")
+ set_target_properties(Triangle PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Triangle")
+ set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
else()
# Set boring names for executables
add_executable(boing WIN32 boing.c)
@@ -24,11 +30,19 @@ else()
add_executable(wave WIN32 wave.c)
endif()
-set(WINDOWS_BINARIES boing gears heightmap splitview triangle wave)
-
if (MSVC)
+ set(WINDOWS_BINARIES boing gears heightmap splitview triangle wave)
+
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
+if (APPLE)
+ set(BUNDLE_BINARIES Boing Gears "Split View" Triangle Wave)
+
+ set_target_properties(${BUNDLE_BINARIES} PROPERTIES
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
+endif()
+
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 58631603..44a79972 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -44,18 +44,23 @@ target_link_libraries(reopen ${STATIC_DEPS})
add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c)
target_link_libraries(accuracy ${STATIC_DEPS})
+set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy")
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
target_link_libraries(sharing ${STATIC_DEPS})
+set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
target_link_libraries(tearing ${STATIC_DEPS})
+set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing")
add_executable(title WIN32 MACOSX_BUNDLE title.c)
target_link_libraries(title ${STATIC_DEPS})
+set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
add_executable(windows WIN32 MACOSX_BUNDLE windows.c)
target_link_libraries(windows ${STATIC_DEPS})
+set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
set(WINDOWS_BINARIES accuracy sharing tearing title windows)
set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
@@ -67,3 +72,9 @@ if (MSVC)
LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
+if (APPLE)
+ set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
+endif()
+
From c286c716cde8681e0c503024c95f10f05fbac59e Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 5 Mar 2012 23:41:05 +0100
Subject: [PATCH 22/62] Formatting.
---
examples/CMakeLists.txt | 52 ++++++++++++++++++++---------------------
tests/CMakeLists.txt | 12 +++++-----
2 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 39cad943..a644b987 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -8,41 +8,41 @@ include_directories(${GLFW_SOURCE_DIR}/include
${OPENGL_INCLUDE_DIR})
if (APPLE)
- # Set fancy names for bundles
- add_executable(Boing MACOSX_BUNDLE boing.c)
- add_executable(Gears MACOSX_BUNDLE gears.c)
- add_executable("Split View" MACOSX_BUNDLE splitview.c)
- add_executable(Triangle MACOSX_BUNDLE triangle.c)
- add_executable(Wave MACOSX_BUNDLE wave.c)
+ # Set fancy names for bundles
+ add_executable(Boing MACOSX_BUNDLE boing.c)
+ add_executable(Gears MACOSX_BUNDLE gears.c)
+ add_executable("Split View" MACOSX_BUNDLE splitview.c)
+ add_executable(Triangle MACOSX_BUNDLE triangle.c)
+ add_executable(Wave MACOSX_BUNDLE wave.c)
- set_target_properties(Boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing")
- set_target_properties(Gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears")
- set_target_properties("Split View" PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Split View")
- set_target_properties(Triangle PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Triangle")
- set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
+ set_target_properties(Boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing")
+ set_target_properties(Gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears")
+ set_target_properties("Split View" PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Split View")
+ set_target_properties(Triangle PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Triangle")
+ set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
else()
- # Set boring names for executables
- add_executable(boing WIN32 boing.c)
- add_executable(gears WIN32 gears.c)
- add_executable(heightmap WIN32 heightmap.c getopt.c)
- add_executable(splitview WIN32 splitview.c)
- add_executable(triangle WIN32 triangle.c)
- add_executable(wave WIN32 wave.c)
+ # Set boring names for executables
+ add_executable(boing WIN32 boing.c)
+ add_executable(gears WIN32 gears.c)
+ add_executable(heightmap WIN32 heightmap.c getopt.c)
+ add_executable(splitview WIN32 splitview.c)
+ add_executable(triangle WIN32 triangle.c)
+ add_executable(wave WIN32 wave.c)
endif()
if (MSVC)
- set(WINDOWS_BINARIES boing gears heightmap splitview triangle wave)
+ set(WINDOWS_BINARIES boing gears heightmap splitview triangle wave)
- # Tell MSVC to use main instead of WinMain for Windows subsystem executables
- set_target_properties(${WINDOWS_BINARIES} PROPERTIES
- LINK_FLAGS "/ENTRY:mainCRTStartup")
+ # Tell MSVC to use main instead of WinMain for Windows subsystem executables
+ set_target_properties(${WINDOWS_BINARIES} PROPERTIES
+ LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
if (APPLE)
- set(BUNDLE_BINARIES Boing Gears "Split View" Triangle Wave)
+ set(BUNDLE_BINARIES Boing Gears "Split View" Triangle Wave)
- set_target_properties(${BUNDLE_BINARIES} PROPERTIES
- MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
- MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
+ set_target_properties(${BUNDLE_BINARIES} PROPERTIES
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
endif()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 44a79972..663f9a11 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -67,14 +67,14 @@ set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
joysticks listmodes peter reopen)
if (MSVC)
- # Tell MSVC to use main instead of WinMain for Windows subsystem executables
- set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
- LINK_FLAGS "/ENTRY:mainCRTStartup")
+ # Tell MSVC to use main instead of WinMain for Windows subsystem executables
+ set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
+ LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
if (APPLE)
- set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
- MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
- MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
+ set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
endif()
From 5f854b2bbf2ea9b6129a990271119f462ef4520e Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 6 Mar 2012 00:58:04 +0100
Subject: [PATCH 23/62] Replaced CFRelease with CGDisplayModeRelease.
---
src/cocoa_init.m | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index 067d4dde..89260c56 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -116,11 +116,7 @@ int _glfwPlatformTerminate(void)
// Restore the original gamma ramp
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
- if (_glfwLibrary.NS.desktopMode)
- {
- CFRelease(_glfwLibrary.NS.desktopMode);
- _glfwLibrary.NS.desktopMode = NULL;
- }
+ CGDisplayModeRelease(_glfwLibrary.NS.desktopMode);
[NSApp setDelegate:nil];
[_glfwLibrary.NS.delegate release];
From be547da9d2ead0ee17371111a06b85d088ba47a8 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 6 Mar 2012 02:21:01 +0100
Subject: [PATCH 24/62] Replaced more deprecated CoreGraphics calls.
---
readme.html | 2 +-
src/cocoa_fullscreen.m | 97 ++++++++++++++++++++++++++++++++++++++++++
src/cocoa_platform.h | 3 ++
src/cocoa_window.m | 37 +++++-----------
4 files changed, 111 insertions(+), 28 deletions(-)
diff --git a/readme.html b/readme.html
index 5762b023..5f3af632 100644
--- a/readme.html
+++ b/readme.html
@@ -312,7 +312,7 @@ version of GLFW.
[Cocoa] Added support for joysticks
[Cocoa] Postponed menu creation to first window creation
[Cocoa] Replaced NSDate
time source with mach_absolute_time
- [Cocoa] Replaced deprecated CoreGraphics calls in video mode enumeration
+ [Cocoa] Replaced deprecated CoreGraphics calls in video mode enumeration and setting
[Cocoa] Bugfix: glfwOpenWindow
did not properly enforce the forward-compatible and context profile hints
[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash
diff --git a/src/cocoa_fullscreen.m b/src/cocoa_fullscreen.m
index cc5df538..d3a715ba 100644
--- a/src/cocoa_fullscreen.m
+++ b/src/cocoa_fullscreen.m
@@ -29,6 +29,9 @@
#include "internal.h"
+#include
+#include
+
//========================================================================
// Check whether the display mode should be included in enumeration
@@ -91,6 +94,100 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode)
}
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+//========================================================================
+// Change the current video mode
+//========================================================================
+
+GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp, int* refreshRate)
+{
+ CGDisplayModeRef bestMode = NULL;
+ CFArrayRef modes;
+ CFIndex count, i;
+ unsigned int leastSizeDiff = UINT_MAX;
+ double leastRateDiff = DBL_MAX;
+
+ modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
+ count = CFArrayGetCount(modes);
+
+ for (i = 0; i < count; i++)
+ {
+ CGDisplayModeRef mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
+ if (!modeIsGood(mode))
+ continue;
+
+ int modeBPP;
+
+ // Identify display mode pixel encoding
+ {
+ CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
+
+ if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
+ modeBPP = 16;
+ else
+ modeBPP = 32;
+
+ CFRelease(format);
+ }
+
+ int modeWidth = (int) CGDisplayModeGetWidth(mode);
+ int modeHeight = (int) CGDisplayModeGetHeight(mode);
+
+ unsigned int sizeDiff = (abs(modeBPP - *bpp) << 25) |
+ ((modeWidth - *width) * (modeWidth - *width) +
+ (modeHeight - *height) * (modeHeight - *height));
+
+ double rateDiff;
+
+ if (*refreshRate > 0)
+ rateDiff = fabs(CGDisplayModeGetRefreshRate(mode) - *refreshRate);
+ else
+ {
+ // If no refresh rate was specified, then they're all the same
+ rateDiff = 0;
+ }
+
+ if ((sizeDiff < leastSizeDiff) ||
+ (sizeDiff == leastSizeDiff && (rateDiff < leastRateDiff)))
+ {
+ bestMode = mode;
+
+ leastSizeDiff = sizeDiff;
+ leastRateDiff = rateDiff;
+ }
+ }
+
+ if (!bestMode)
+ {
+ CFRelease(modes);
+ return GL_FALSE;
+ }
+
+ CGDisplayCapture(CGMainDisplayID());
+ CGDisplaySetDisplayMode(CGMainDisplayID(), bestMode, NULL);
+
+ CFRelease(modes);
+ return GL_TRUE;
+}
+
+
+//========================================================================
+// Restore the previously saved (original) video mode
+//========================================================================
+
+void _glfwRestoreVideoMode(void)
+{
+ CGDisplaySetDisplayMode(CGMainDisplayID(),
+ _glfwLibrary.NS.desktopMode,
+ NULL);
+
+ CGDisplayRelease(CGMainDisplayID());
+}
+
+
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h
index 5a753707..a06c13a0 100644
--- a/src/cocoa_platform.h
+++ b/src/cocoa_platform.h
@@ -109,5 +109,8 @@ void _glfwInitTimer(void);
void _glfwInitJoysticks(void);
void _glfwTerminateJoysticks(void);
+// Fullscreen
+GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp, int* refreshRate);
+void _glfwRestoreVideoMode(void);
#endif // _platform_h_
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 94a11118..c1d710c0 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -850,28 +850,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
// 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;
@@ -883,8 +861,15 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
if (wndconfig->mode == GLFW_FULLSCREEN)
{
- CGCaptureAllDisplays();
- CGDisplaySwitchToMode(CGMainDisplayID(), fullscreenMode);
+ int bpp = colorBits + fbconfig->alphaBits;
+
+ if (!_glfwSetVideoMode(&window->width,
+ &window->height,
+ &bpp,
+ &window->refreshRate))
+ {
+ return GL_FALSE;
+ }
[[window->NS.window contentView] enterFullScreenMode:[NSScreen mainScreen]
withOptions:nil];
@@ -914,9 +899,7 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
{
[[window->NS.window contentView] exitFullScreenModeWithOptions:nil];
- CGDisplaySwitchToMode(CGMainDisplayID(),
- (CFDictionaryRef) _glfwLibrary.NS.desktopMode);
- CGReleaseAllDisplays();
+ _glfwRestoreVideoMode();
}
[window->NSGL.pixelFormat release];
From 8155f90bf33c07724d9f6e7e69fcddebc6fde0c4 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 7 Mar 2012 15:04:14 +0100
Subject: [PATCH 25/62] Formatting.
---
src/cocoa_fullscreen.m | 2 ++
src/cocoa_init.m | 2 ++
src/cocoa_joystick.m | 1 -
src/cocoa_opengl.m | 4 ++++
src/cocoa_time.c | 1 +
src/cocoa_window.m | 20 ++++++++++++++++++++
6 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/cocoa_fullscreen.m b/src/cocoa_fullscreen.m
index d3a715ba..147913fb 100644
--- a/src/cocoa_fullscreen.m
+++ b/src/cocoa_fullscreen.m
@@ -64,6 +64,7 @@ static GLboolean modeIsGood(CGDisplayModeRef mode)
return GL_TRUE;
}
+
//========================================================================
// Convert Core Graphics display mode to GLFW video mode
//========================================================================
@@ -217,6 +218,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
return stored;
}
+
//========================================================================
// Get the desktop video mode
//========================================================================
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index 89260c56..d9530f62 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -33,6 +33,7 @@
//========================================================================
// Change to our application bundle's resources directory, if present
//========================================================================
+
static void changeToResourcesDirectory(void)
{
char resourcesPath[MAXPATHLEN];
@@ -105,6 +106,7 @@ int _glfwPlatformInit(void)
return GL_TRUE;
}
+
//========================================================================
// Close window, if open, and shut down GLFW
//========================================================================
diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m
index a167692f..45b3be0f 100644
--- a/src/cocoa_joystick.m
+++ b/src/cocoa_joystick.m
@@ -579,4 +579,3 @@ int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons,
return numbuttons;
}
-
diff --git a/src/cocoa_opengl.m b/src/cocoa_opengl.m
index bd3827fc..0ea39076 100644
--- a/src/cocoa_opengl.m
+++ b/src/cocoa_opengl.m
@@ -59,6 +59,7 @@ void _glfwPlatformSwapBuffers(void)
[window->NSGL.context flushBuffer];
}
+
//========================================================================
// Set double buffering swap interval
//========================================================================
@@ -71,6 +72,7 @@ void _glfwPlatformSwapInterval(int interval)
[window->NSGL.context setValues:&sync forParameter:NSOpenGLCPSwapInterval];
}
+
//========================================================================
// Check if an OpenGL extension is available at runtime
//========================================================================
@@ -81,6 +83,7 @@ int _glfwPlatformExtensionSupported(const char* extension)
return GL_FALSE;
}
+
//========================================================================
// Get the function pointer to an OpenGL function
//========================================================================
@@ -99,6 +102,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
return symbol;
}
+
//========================================================================
// Copies the specified OpenGL state categories from src to dst
//========================================================================
diff --git a/src/cocoa_time.c b/src/cocoa_time.c
index 4facbffb..745b4239 100644
--- a/src/cocoa_time.c
+++ b/src/cocoa_time.c
@@ -74,6 +74,7 @@ double _glfwPlatformGetTime(void)
_glfwLibrary.NS.timer.resolution;
}
+
//========================================================================
// Set timer value in seconds
//========================================================================
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index c1d710c0..d2bcbb3d 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -112,6 +112,7 @@
@end
+
//========================================================================
// Delegate for application related notifications
//========================================================================
@@ -133,6 +134,7 @@
@end
+
//========================================================================
// Keyboard symbol translation table
//========================================================================
@@ -270,6 +272,7 @@ static const unsigned int MAC_TO_GLFW_KEYCODE_MAPPING[128] =
/* 7f */ -1,
};
+
//========================================================================
// Converts a Mac OS X keycode to a GLFW keycode
//========================================================================
@@ -285,6 +288,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
return MAC_TO_GLFW_KEYCODE_MAPPING[macKeyCode];
}
+
//========================================================================
// Content view class for the GLFW window
//========================================================================
@@ -446,6 +450,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
@end
+
//========================================================================
// GLFW application class
//========================================================================
@@ -516,6 +521,7 @@ static NSString* findAppName(void)
return @"GLFW Application";
}
+
//========================================================================
// Set up the menu bar (manually)
// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
@@ -523,6 +529,7 @@ static NSString* findAppName(void)
// localize(d|able), etc. Loading a nib would save us this horror, but that
// doesn't seem like a good thing to require of GLFW's clients.
//========================================================================
+
static void createMenuBar(void)
{
NSString* appName = findAppName();
@@ -586,6 +593,7 @@ static void createMenuBar(void)
//========================================================================
// Initialize the Cocoa Application Kit
//========================================================================
+
static GLboolean initializeAppKit(void)
{
if (NSApp)
@@ -604,6 +612,7 @@ static GLboolean initializeAppKit(void)
return GL_TRUE;
}
+
//========================================================================
// Create the Cocoa window
//========================================================================
@@ -647,6 +656,7 @@ static GLboolean createWindow(_GLFWwindow* window,
return GL_TRUE;
}
+
//========================================================================
// Create the OpenGL context
//========================================================================
@@ -919,6 +929,7 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
// TODO: Probably more cleanup
}
+
//========================================================================
// Set the window title
//========================================================================
@@ -928,6 +939,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
[window->NS.window setTitle:[NSString stringWithUTF8String:title]];
}
+
//========================================================================
// Set the window size
//========================================================================
@@ -937,6 +949,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
[window->NS.window setContentSize:NSMakeSize(width, height)];
}
+
//========================================================================
// Set the window position
//========================================================================
@@ -957,6 +970,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
display:YES];
}
+
//========================================================================
// Iconify the window
//========================================================================
@@ -966,6 +980,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
[window->NS.window miniaturize:nil];
}
+
//========================================================================
// Restore (un-iconify) the window
//========================================================================
@@ -975,6 +990,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
[window->NS.window deminiaturize:nil];
}
+
//========================================================================
// Write back window parameters into GLFW window structure
//========================================================================
@@ -1049,6 +1065,7 @@ void _glfwPlatformRefreshWindowParams(void)
window->glDebug = GL_FALSE;
}
+
//========================================================================
// Poll for new window and input events
//========================================================================
@@ -1073,6 +1090,7 @@ void _glfwPlatformPollEvents(void)
_glfwLibrary.NS.autoreleasePool = [[NSAutoreleasePool alloc] init];
}
+
//========================================================================
// Wait for new window and input events
//========================================================================
@@ -1091,6 +1109,7 @@ void _glfwPlatformWaitEvents( void )
_glfwPlatformPollEvents();
}
+
//========================================================================
// Set physical mouse cursor position
//========================================================================
@@ -1123,6 +1142,7 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
CGDisplayMoveCursorToPoint(CGMainDisplayID(), targetPoint);
}
+
//========================================================================
// Set physical mouse cursor mode
//========================================================================
From 89eec8af09c82a9193cc7c7ae6d5436375f91fa8 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 7 Mar 2012 15:10:53 +0100
Subject: [PATCH 26/62] Made more consistent use of key code conversion.
---
src/cocoa_window.m | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index d2bcbb3d..411e600d 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -392,11 +392,11 @@ static int convertMacKeyCode(unsigned int macKeyCode)
{
NSUInteger i, length;
NSString* characters;
- int code = convertMacKeyCode([event keyCode]);
+ int key = convertMacKeyCode([event keyCode]);
- if (code != -1)
+ if (key != -1)
{
- _glfwInputKey(window, code, GLFW_PRESS);
+ _glfwInputKey(window, key, GLFW_PRESS);
if ([event modifierFlags] & NSCommandKeyMask)
{
@@ -416,7 +416,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
- (void)flagsChanged:(NSEvent *)event
{
- int mode;
+ int mode, key;
unsigned int newModifierFlags =
[event modifierFlags] | NSDeviceIndependentModifierFlagsMask;
@@ -426,14 +426,17 @@ static int convertMacKeyCode(unsigned int macKeyCode)
mode = GLFW_RELEASE;
window->NS.modifierFlags = newModifierFlags;
- _glfwInputKey(window, MAC_TO_GLFW_KEYCODE_MAPPING[[event keyCode]], mode);
+
+ key = convertMacKeyCode([event keyCode]);
+ if (key != -1)
+ _glfwInputKey(window, key, mode);
}
- (void)keyUp:(NSEvent *)event
{
- int code = convertMacKeyCode([event keyCode]);
- if (code != -1)
- _glfwInputKey(window, code, GLFW_RELEASE);
+ int key = convertMacKeyCode([event keyCode]);
+ if (key != -1)
+ _glfwInputKey(window, key, GLFW_RELEASE);
}
- (void)scrollWheel:(NSEvent *)event
From 339fb7d246af11248d42d5d2131f85dba8e0dc56 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 7 Mar 2012 15:13:41 +0100
Subject: [PATCH 27/62] Made key code translation table private to function.
---
src/cocoa_window.m | 274 ++++++++++++++++++++++-----------------------
1 file changed, 135 insertions(+), 139 deletions(-)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 411e600d..b8ccdea6 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -135,157 +135,153 @@
@end
-//========================================================================
-// Keyboard symbol translation table
-//========================================================================
-
-// TODO: Need to find mappings for F13-F15, volume down/up/mute, and eject.
-static const unsigned int MAC_TO_GLFW_KEYCODE_MAPPING[128] =
-{
- /* 00 */ GLFW_KEY_A,
- /* 01 */ GLFW_KEY_S,
- /* 02 */ GLFW_KEY_D,
- /* 03 */ GLFW_KEY_F,
- /* 04 */ GLFW_KEY_H,
- /* 05 */ GLFW_KEY_G,
- /* 06 */ GLFW_KEY_Z,
- /* 07 */ GLFW_KEY_X,
- /* 08 */ GLFW_KEY_C,
- /* 09 */ GLFW_KEY_V,
- /* 0a */ GLFW_KEY_GRAVE_ACCENT,
- /* 0b */ GLFW_KEY_B,
- /* 0c */ GLFW_KEY_Q,
- /* 0d */ GLFW_KEY_W,
- /* 0e */ GLFW_KEY_E,
- /* 0f */ GLFW_KEY_R,
- /* 10 */ GLFW_KEY_Y,
- /* 11 */ GLFW_KEY_T,
- /* 12 */ GLFW_KEY_1,
- /* 13 */ GLFW_KEY_2,
- /* 14 */ GLFW_KEY_3,
- /* 15 */ GLFW_KEY_4,
- /* 16 */ GLFW_KEY_6,
- /* 17 */ GLFW_KEY_5,
- /* 18 */ GLFW_KEY_EQUAL,
- /* 19 */ GLFW_KEY_9,
- /* 1a */ GLFW_KEY_7,
- /* 1b */ GLFW_KEY_MINUS,
- /* 1c */ GLFW_KEY_8,
- /* 1d */ GLFW_KEY_0,
- /* 1e */ GLFW_KEY_RIGHT_BRACKET,
- /* 1f */ GLFW_KEY_O,
- /* 20 */ GLFW_KEY_U,
- /* 21 */ GLFW_KEY_LEFT_BRACKET,
- /* 22 */ GLFW_KEY_I,
- /* 23 */ GLFW_KEY_P,
- /* 24 */ GLFW_KEY_ENTER,
- /* 25 */ GLFW_KEY_L,
- /* 26 */ GLFW_KEY_J,
- /* 27 */ GLFW_KEY_APOSTROPHE,
- /* 28 */ GLFW_KEY_K,
- /* 29 */ GLFW_KEY_SEMICOLON,
- /* 2a */ GLFW_KEY_BACKSLASH,
- /* 2b */ GLFW_KEY_COMMA,
- /* 2c */ GLFW_KEY_SLASH,
- /* 2d */ GLFW_KEY_N,
- /* 2e */ GLFW_KEY_M,
- /* 2f */ GLFW_KEY_PERIOD,
- /* 30 */ GLFW_KEY_TAB,
- /* 31 */ GLFW_KEY_SPACE,
- /* 32 */ GLFW_KEY_WORLD_1,
- /* 33 */ GLFW_KEY_BACKSPACE,
- /* 34 */ -1,
- /* 35 */ GLFW_KEY_ESCAPE,
- /* 36 */ GLFW_KEY_RIGHT_SUPER,
- /* 37 */ GLFW_KEY_LEFT_SUPER,
- /* 38 */ GLFW_KEY_LEFT_SHIFT,
- /* 39 */ GLFW_KEY_CAPS_LOCK,
- /* 3a */ GLFW_KEY_LEFT_ALT,
- /* 3b */ GLFW_KEY_LEFT_CONTROL,
- /* 3c */ GLFW_KEY_RIGHT_SHIFT,
- /* 3d */ GLFW_KEY_RIGHT_ALT,
- /* 3e */ GLFW_KEY_RIGHT_CONTROL,
- /* 3f */ -1, /* Function */
- /* 40 */ GLFW_KEY_F17,
- /* 41 */ GLFW_KEY_KP_DECIMAL,
- /* 42 */ -1,
- /* 43 */ GLFW_KEY_KP_MULTIPLY,
- /* 44 */ -1,
- /* 45 */ GLFW_KEY_KP_ADD,
- /* 46 */ -1,
- /* 47 */ GLFW_KEY_NUM_LOCK, /* Really KeypadClear... */
- /* 48 */ -1, /* VolumeUp */
- /* 49 */ -1, /* VolumeDown */
- /* 4a */ -1, /* Mute */
- /* 4b */ GLFW_KEY_KP_DIVIDE,
- /* 4c */ GLFW_KEY_KP_ENTER,
- /* 4d */ -1,
- /* 4e */ GLFW_KEY_KP_SUBTRACT,
- /* 4f */ GLFW_KEY_F18,
- /* 50 */ GLFW_KEY_F19,
- /* 51 */ GLFW_KEY_KP_EQUAL,
- /* 52 */ GLFW_KEY_KP_0,
- /* 53 */ GLFW_KEY_KP_1,
- /* 54 */ GLFW_KEY_KP_2,
- /* 55 */ GLFW_KEY_KP_3,
- /* 56 */ GLFW_KEY_KP_4,
- /* 57 */ GLFW_KEY_KP_5,
- /* 58 */ GLFW_KEY_KP_6,
- /* 59 */ GLFW_KEY_KP_7,
- /* 5a */ GLFW_KEY_F20,
- /* 5b */ GLFW_KEY_KP_8,
- /* 5c */ GLFW_KEY_KP_9,
- /* 5d */ -1,
- /* 5e */ -1,
- /* 5f */ -1,
- /* 60 */ GLFW_KEY_F5,
- /* 61 */ GLFW_KEY_F6,
- /* 62 */ GLFW_KEY_F7,
- /* 63 */ GLFW_KEY_F3,
- /* 64 */ GLFW_KEY_F8,
- /* 65 */ GLFW_KEY_F9,
- /* 66 */ -1,
- /* 67 */ GLFW_KEY_F11,
- /* 68 */ -1,
- /* 69 */ GLFW_KEY_F13,
- /* 6a */ GLFW_KEY_F16,
- /* 6b */ GLFW_KEY_F14,
- /* 6c */ -1,
- /* 6d */ GLFW_KEY_F10,
- /* 6e */ -1,
- /* 6f */ GLFW_KEY_F12,
- /* 70 */ -1,
- /* 71 */ GLFW_KEY_F15,
- /* 72 */ GLFW_KEY_INSERT, /* Really Help... */
- /* 73 */ GLFW_KEY_HOME,
- /* 74 */ GLFW_KEY_PAGE_UP,
- /* 75 */ GLFW_KEY_DELETE,
- /* 76 */ GLFW_KEY_F4,
- /* 77 */ GLFW_KEY_END,
- /* 78 */ GLFW_KEY_F2,
- /* 79 */ GLFW_KEY_PAGE_DOWN,
- /* 7a */ GLFW_KEY_F1,
- /* 7b */ GLFW_KEY_LEFT,
- /* 7c */ GLFW_KEY_RIGHT,
- /* 7d */ GLFW_KEY_DOWN,
- /* 7e */ GLFW_KEY_UP,
- /* 7f */ -1,
-};
-
-
//========================================================================
// Converts a Mac OS X keycode to a GLFW keycode
//========================================================================
static int convertMacKeyCode(unsigned int macKeyCode)
{
+ // Keyboard symbol translation table
+ // TODO: Need to find mappings for F13-F15, volume down/up/mute, and eject.
+ static const unsigned int table[128] =
+ {
+ /* 00 */ GLFW_KEY_A,
+ /* 01 */ GLFW_KEY_S,
+ /* 02 */ GLFW_KEY_D,
+ /* 03 */ GLFW_KEY_F,
+ /* 04 */ GLFW_KEY_H,
+ /* 05 */ GLFW_KEY_G,
+ /* 06 */ GLFW_KEY_Z,
+ /* 07 */ GLFW_KEY_X,
+ /* 08 */ GLFW_KEY_C,
+ /* 09 */ GLFW_KEY_V,
+ /* 0a */ GLFW_KEY_GRAVE_ACCENT,
+ /* 0b */ GLFW_KEY_B,
+ /* 0c */ GLFW_KEY_Q,
+ /* 0d */ GLFW_KEY_W,
+ /* 0e */ GLFW_KEY_E,
+ /* 0f */ GLFW_KEY_R,
+ /* 10 */ GLFW_KEY_Y,
+ /* 11 */ GLFW_KEY_T,
+ /* 12 */ GLFW_KEY_1,
+ /* 13 */ GLFW_KEY_2,
+ /* 14 */ GLFW_KEY_3,
+ /* 15 */ GLFW_KEY_4,
+ /* 16 */ GLFW_KEY_6,
+ /* 17 */ GLFW_KEY_5,
+ /* 18 */ GLFW_KEY_EQUAL,
+ /* 19 */ GLFW_KEY_9,
+ /* 1a */ GLFW_KEY_7,
+ /* 1b */ GLFW_KEY_MINUS,
+ /* 1c */ GLFW_KEY_8,
+ /* 1d */ GLFW_KEY_0,
+ /* 1e */ GLFW_KEY_RIGHT_BRACKET,
+ /* 1f */ GLFW_KEY_O,
+ /* 20 */ GLFW_KEY_U,
+ /* 21 */ GLFW_KEY_LEFT_BRACKET,
+ /* 22 */ GLFW_KEY_I,
+ /* 23 */ GLFW_KEY_P,
+ /* 24 */ GLFW_KEY_ENTER,
+ /* 25 */ GLFW_KEY_L,
+ /* 26 */ GLFW_KEY_J,
+ /* 27 */ GLFW_KEY_APOSTROPHE,
+ /* 28 */ GLFW_KEY_K,
+ /* 29 */ GLFW_KEY_SEMICOLON,
+ /* 2a */ GLFW_KEY_BACKSLASH,
+ /* 2b */ GLFW_KEY_COMMA,
+ /* 2c */ GLFW_KEY_SLASH,
+ /* 2d */ GLFW_KEY_N,
+ /* 2e */ GLFW_KEY_M,
+ /* 2f */ GLFW_KEY_PERIOD,
+ /* 30 */ GLFW_KEY_TAB,
+ /* 31 */ GLFW_KEY_SPACE,
+ /* 32 */ GLFW_KEY_WORLD_1,
+ /* 33 */ GLFW_KEY_BACKSPACE,
+ /* 34 */ -1,
+ /* 35 */ GLFW_KEY_ESCAPE,
+ /* 36 */ GLFW_KEY_RIGHT_SUPER,
+ /* 37 */ GLFW_KEY_LEFT_SUPER,
+ /* 38 */ GLFW_KEY_LEFT_SHIFT,
+ /* 39 */ GLFW_KEY_CAPS_LOCK,
+ /* 3a */ GLFW_KEY_LEFT_ALT,
+ /* 3b */ GLFW_KEY_LEFT_CONTROL,
+ /* 3c */ GLFW_KEY_RIGHT_SHIFT,
+ /* 3d */ GLFW_KEY_RIGHT_ALT,
+ /* 3e */ GLFW_KEY_RIGHT_CONTROL,
+ /* 3f */ -1, /* Function */
+ /* 40 */ GLFW_KEY_F17,
+ /* 41 */ GLFW_KEY_KP_DECIMAL,
+ /* 42 */ -1,
+ /* 43 */ GLFW_KEY_KP_MULTIPLY,
+ /* 44 */ -1,
+ /* 45 */ GLFW_KEY_KP_ADD,
+ /* 46 */ -1,
+ /* 47 */ GLFW_KEY_NUM_LOCK, /* Really KeypadClear... */
+ /* 48 */ -1, /* VolumeUp */
+ /* 49 */ -1, /* VolumeDown */
+ /* 4a */ -1, /* Mute */
+ /* 4b */ GLFW_KEY_KP_DIVIDE,
+ /* 4c */ GLFW_KEY_KP_ENTER,
+ /* 4d */ -1,
+ /* 4e */ GLFW_KEY_KP_SUBTRACT,
+ /* 4f */ GLFW_KEY_F18,
+ /* 50 */ GLFW_KEY_F19,
+ /* 51 */ GLFW_KEY_KP_EQUAL,
+ /* 52 */ GLFW_KEY_KP_0,
+ /* 53 */ GLFW_KEY_KP_1,
+ /* 54 */ GLFW_KEY_KP_2,
+ /* 55 */ GLFW_KEY_KP_3,
+ /* 56 */ GLFW_KEY_KP_4,
+ /* 57 */ GLFW_KEY_KP_5,
+ /* 58 */ GLFW_KEY_KP_6,
+ /* 59 */ GLFW_KEY_KP_7,
+ /* 5a */ GLFW_KEY_F20,
+ /* 5b */ GLFW_KEY_KP_8,
+ /* 5c */ GLFW_KEY_KP_9,
+ /* 5d */ -1,
+ /* 5e */ -1,
+ /* 5f */ -1,
+ /* 60 */ GLFW_KEY_F5,
+ /* 61 */ GLFW_KEY_F6,
+ /* 62 */ GLFW_KEY_F7,
+ /* 63 */ GLFW_KEY_F3,
+ /* 64 */ GLFW_KEY_F8,
+ /* 65 */ GLFW_KEY_F9,
+ /* 66 */ -1,
+ /* 67 */ GLFW_KEY_F11,
+ /* 68 */ -1,
+ /* 69 */ GLFW_KEY_F13,
+ /* 6a */ GLFW_KEY_F16,
+ /* 6b */ GLFW_KEY_F14,
+ /* 6c */ -1,
+ /* 6d */ GLFW_KEY_F10,
+ /* 6e */ -1,
+ /* 6f */ GLFW_KEY_F12,
+ /* 70 */ -1,
+ /* 71 */ GLFW_KEY_F15,
+ /* 72 */ GLFW_KEY_INSERT, /* Really Help... */
+ /* 73 */ GLFW_KEY_HOME,
+ /* 74 */ GLFW_KEY_PAGE_UP,
+ /* 75 */ GLFW_KEY_DELETE,
+ /* 76 */ GLFW_KEY_F4,
+ /* 77 */ GLFW_KEY_END,
+ /* 78 */ GLFW_KEY_F2,
+ /* 79 */ GLFW_KEY_PAGE_DOWN,
+ /* 7a */ GLFW_KEY_F1,
+ /* 7b */ GLFW_KEY_LEFT,
+ /* 7c */ GLFW_KEY_RIGHT,
+ /* 7d */ GLFW_KEY_DOWN,
+ /* 7e */ GLFW_KEY_UP,
+ /* 7f */ -1,
+ };
+
if (macKeyCode >= 128)
return -1;
// This treats keycodes as *positional*; that is, we'll return 'a'
// for the key left of 's', even on an AZERTY keyboard. The charInput
// function should still get 'q' though.
- return MAC_TO_GLFW_KEYCODE_MAPPING[macKeyCode];
+ return table[macKeyCode];
}
From 5fd66f7d3067e6504e9e18335688c226ce78c045 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 7 Mar 2012 18:38:08 +0100
Subject: [PATCH 28/62] Free visual list earlier.
---
src/x11_fullscreen.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/x11_fullscreen.c b/src/x11_fullscreen.c
index e71c2a2b..f7855c4b 100644
--- a/src/x11_fullscreen.c
+++ b/src/x11_fullscreen.c
@@ -372,6 +372,8 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
}
}
+ XFree(vislist);
+
rescount = 0;
resarray = NULL;
@@ -457,8 +459,6 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
}
}
- XFree(vislist);
-
free(resarray);
free(rgbarray);
From 18efa516a2ce62ea6f5131691ac66013f8d64442 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 8 Mar 2012 01:01:42 +0100
Subject: [PATCH 29/62] Added modes test.
---
readme.html | 1 +
tests/CMakeLists.txt | 5 +-
tests/modes.c | 225 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 230 insertions(+), 1 deletion(-)
create mode 100644 tests/modes.c
diff --git a/readme.html b/readme.html
index 5f3af632..8af1c2e4 100644
--- a/readme.html
+++ b/readme.html
@@ -280,6 +280,7 @@ version of GLFW.
Added windows
simple multi-window test program
Added sharing
simple OpenGL object sharing test program
Added dynamic
simple dynamic linking test program
+ Added modes
video mode enumeration and setting test program
Added a parameter to glfwOpenWindow
for specifying a context the new window's context will share objects with
Added initial window title parameter to glfwOpenWindow
Added glfwSetGamma
, glfwSetGammaRamp
and glfwGetGammaRamp
functions and GLFWgammaramp
type for monitor gamma ramp control
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 663f9a11..7a166881 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -36,6 +36,9 @@ target_link_libraries(joysticks ${STATIC_DEPS})
add_executable(listmodes listmodes.c)
target_link_libraries(listmodes ${STATIC_DEPS})
+add_executable(modes modes.c getopt.c)
+target_link_libraries(modes ${STATIC_DEPS})
+
add_executable(peter peter.c)
target_link_libraries(peter ${STATIC_DEPS})
@@ -64,7 +67,7 @@ set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
set(WINDOWS_BINARIES accuracy sharing tearing title windows)
set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
- joysticks listmodes peter reopen)
+ joysticks listmodes modes peter reopen)
if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
diff --git a/tests/modes.c b/tests/modes.c
new file mode 100644
index 00000000..de3aec8a
--- /dev/null
+++ b/tests/modes.c
@@ -0,0 +1,225 @@
+//========================================================================
+// Video mode test
+// Copyright (c) Camilla Berglund
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+//
+// This test enumerates or verifies video modes
+//
+//========================================================================
+
+#include
+
+#include
+#include
+
+#include "getopt.h"
+
+static GLFWwindow window = NULL;
+
+enum Mode
+{
+ NO_MODE,
+ LIST_MODE,
+ TEST_MODE
+};
+
+static void usage(void)
+{
+ printf("Usage: modes -l\n");
+ printf(" modes -t\n");
+ printf(" modes -h\n");
+}
+
+static void print_mode(GLFWvidmode* mode)
+{
+ printf("%i x %i x %i (%i %i %i)",
+ mode->width, mode->height,
+ mode->redBits + mode->greenBits + mode->blueBits,
+ mode->redBits, mode->greenBits, mode->blueBits);
+}
+
+static void error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Error: %s\n", description);
+}
+
+static void window_size_callback(GLFWwindow window, int width, int height)
+{
+ printf("Window resized to %ix%i\n", width, height);
+
+ glViewport(0, 0, width, height);
+}
+
+static int window_close_callback(GLFWwindow dummy)
+{
+ window = NULL;
+ return GL_TRUE;
+}
+
+static void list_modes(GLFWvidmode* modes, int count)
+{
+ int i;
+ GLFWvidmode mode;
+
+ glfwGetDesktopMode(&mode);
+ printf("Desktop mode: ");
+ print_mode(&mode);
+ putchar('\n');
+
+ for (i = 0; i < count; i++)
+ {
+ printf("%3i: ", i);
+ print_mode(modes + i);
+ putchar('\n');
+ }
+}
+
+static void test_modes(GLFWvidmode* modes, int count)
+{
+ int i, width, height;
+
+ glfwSetWindowSizeCallback(window_size_callback);
+ glfwSetWindowCloseCallback(window_close_callback);
+
+ for (i = 0; i < count; i++)
+ {
+ glfwOpenWindowHint(GLFW_RED_BITS, modes[i].redBits);
+ glfwOpenWindowHint(GLFW_GREEN_BITS, modes[i].greenBits);
+ glfwOpenWindowHint(GLFW_BLUE_BITS, modes[i].blueBits);
+
+ printf("Opening ");
+ print_mode(modes + i);
+ printf(" window\n");
+
+ window = glfwOpenWindow(modes[i].width, modes[i].height,
+ GLFW_FULLSCREEN, "Video Mode Test",
+ NULL);
+ if (!window)
+ {
+ printf("Failed to enter mode %i: ", i);
+ print_mode(modes + i);
+ putchar('\n');
+ continue;
+ }
+
+ glfwSetTime(0.0);
+ glfwSwapInterval(1);
+
+ while (glfwGetTime() < 5.0)
+ {
+ glClear(GL_COLOR_BUFFER_BIT);
+ glfwSwapBuffers();
+ glfwPollEvents();
+
+ if (!window)
+ {
+ printf("User terminated program\n");
+ exit(EXIT_SUCCESS);
+ }
+ }
+
+ if (glfwGetWindowParam(window, GLFW_RED_BITS) != modes[i].redBits ||
+ glfwGetWindowParam(window, GLFW_GREEN_BITS) != modes[i].greenBits ||
+ glfwGetWindowParam(window, GLFW_BLUE_BITS) != modes[i].blueBits)
+ {
+ printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
+ glfwGetWindowParam(window, GLFW_RED_BITS),
+ glfwGetWindowParam(window, GLFW_GREEN_BITS),
+ glfwGetWindowParam(window, GLFW_BLUE_BITS),
+ modes[i].redBits,
+ modes[i].greenBits,
+ modes[i].blueBits);
+ }
+
+ glfwGetWindowSize(window, &width, &height);
+
+ if (width != modes[i].width || height != height)
+ {
+ printf("*** Size mismatch: %ix%i instead of %ix%i\n",
+ width, height,
+ modes[i].width, modes[i].height);
+ }
+
+ printf("Closing window\n");
+
+ glfwCloseWindow(window);
+ glfwPollEvents();
+ window = NULL;
+
+ sleep(5);
+ }
+}
+
+int main(int argc, char** argv)
+{
+ int ch, found, count = 0, mode = NO_MODE;
+ GLFWvidmode* modes = NULL;
+
+ while ((ch = getopt(argc, argv, "lth")) != -1)
+ {
+ switch (ch)
+ {
+ case 'h':
+ usage();
+ exit(EXIT_SUCCESS);
+ case 'l':
+ mode = LIST_MODE;
+ break;
+ case 't':
+ mode = TEST_MODE;
+ break;
+ default:
+ usage();
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ glfwSetErrorCallback(error_callback);
+
+ if (!glfwInit())
+ exit(EXIT_FAILURE);
+
+ for (;;)
+ {
+ count += 256;
+ modes = realloc(modes, sizeof(GLFWvidmode) * count);
+
+ found = glfwGetVideoModes(modes, count);
+ if (found < count)
+ break;
+ }
+
+ if (mode == LIST_MODE)
+ list_modes(modes, found);
+ else if (mode == TEST_MODE)
+ test_modes(modes, found);
+
+ free(modes);
+ modes = NULL;
+
+ exit(EXIT_SUCCESS);
+}
+
From 21f2327e563f1b3c996bbb535d14daa417434edb Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sat, 10 Mar 2012 16:23:09 +0100
Subject: [PATCH 30/62] Formatting.
---
src/input.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/input.c b/src/input.c
index ec894a27..ded88712 100644
--- a/src/input.c
+++ b/src/input.c
@@ -167,7 +167,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
return;
// Register key action
- if(action == GLFW_RELEASE && window->stickyKeys)
+ if (action == GLFW_RELEASE && window->stickyKeys)
window->key[key] = GLFW_STICK;
else
{
From eb83a3e8f9ba5aa68e0a17a2c935be93cb6c5aeb Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 20 Mar 2012 15:23:35 +0100
Subject: [PATCH 31/62] Replaced final deprecated Core Graphics call.
---
readme.html | 2 +-
src/cocoa_init.m | 13 +++++++++++++
src/cocoa_platform.h | 1 +
src/cocoa_window.m | 5 -----
4 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/readme.html b/readme.html
index 5f3af632..bde16bcf 100644
--- a/readme.html
+++ b/readme.html
@@ -312,7 +312,7 @@ version of GLFW.
[Cocoa] Added support for joysticks
[Cocoa] Postponed menu creation to first window creation
[Cocoa] Replaced NSDate
time source with mach_absolute_time
- [Cocoa] Replaced deprecated CoreGraphics calls in video mode enumeration and setting
+ [Cocoa] Replaced all deprecated CoreGraphics calls with non-deprecated counterparts
[Cocoa] Bugfix: glfwOpenWindow
did not properly enforce the forward-compatible and context profile hints
[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index 89260c56..00898778 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -102,6 +102,13 @@ int _glfwPlatformInit(void)
_glfwInitJoysticks();
+ _glfwLibrary.NS.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
+ if (!_glfwLibrary.NS.eventSource)
+ return GL_FALSE;
+
+ CGEventSourceSetLocalEventsSuppressionInterval(_glfwLibrary.NS.eventSource,
+ 0.0);
+
return GL_TRUE;
}
@@ -113,6 +120,12 @@ int _glfwPlatformTerminate(void)
{
// TODO: Probably other cleanup
+ if (_glfwLibrary.NS.eventSource)
+ {
+ CFRelease(_glfwLibrary.NS.eventSource);
+ _glfwLibrary.NS.eventSource = NULL;
+ }
+
// Restore the original gamma ramp
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h
index a06c13a0..b70fb184 100644
--- a/src/cocoa_platform.h
+++ b/src/cocoa_platform.h
@@ -93,6 +93,7 @@ typedef struct _GLFWlibraryNS
// dlopen handle for dynamically loading OpenGL extension entry points
void* OpenGLFramework;
CGDisplayModeRef desktopMode;
+ CGEventSourceRef eventSource;
id delegate;
id autoreleasePool;
} _GLFWlibraryNS;
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index c1d710c0..9d5ee5ec 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -1108,11 +1108,6 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
// calculating the maximum y coordinate of all screens, since Cocoa's
// "global coordinates" are upside down from CG's...
- // Without this (once per app run, but it's convenient to do it here)
- // events will be suppressed for a default of 0.25 seconds after we
- // move the cursor.
- CGSetLocalEventsSuppressionInterval(0.0);
-
NSPoint localPoint = NSMakePoint(x, y);
NSPoint globalPoint = [window->NS.window convertBaseToScreen:localPoint];
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
From c58750ef927579a60a8a58d9fc5253094e49424e Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 20 Mar 2012 15:30:46 +0100
Subject: [PATCH 32/62] Applied fix for pixel format creation failure.
---
readme.html | 1 +
src/cocoa_window.m | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/readme.html b/readme.html
index 33832689..0f0838de 100644
--- a/readme.html
+++ b/readme.html
@@ -314,6 +314,7 @@ version of GLFW.
[Cocoa] Postponed menu creation to first window creation
[Cocoa] Replaced NSDate
time source with mach_absolute_time
[Cocoa] Replaced all deprecated CoreGraphics calls with non-deprecated counterparts
+ [Cocoa] Bugfix: The NSOpenGLPFAFullScreen
pixel format attribute caused creation to fail on some machines
[Cocoa] Bugfix: glfwOpenWindow
did not properly enforce the forward-compatible and context profile hints
[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index dd548361..5bb33097 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -734,7 +734,6 @@ static GLboolean createContext(_GLFWwindow* window,
if (wndconfig->mode == GLFW_FULLSCREEN)
{
- ADD_ATTR(NSOpenGLPFAFullScreen);
ADD_ATTR(NSOpenGLPFANoRecovery);
ADD_ATTR2(NSOpenGLPFAScreenMask,
CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()));
From 3a8b4b3a843d34a3a8d458b0ff59b4061dbdcc56 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 20 Mar 2012 15:44:25 +0100
Subject: [PATCH 33/62] Added credit.
---
readme.html | 2 ++
1 file changed, 2 insertions(+)
diff --git a/readme.html b/readme.html
index 0f0838de..d7442d3b 100644
--- a/readme.html
+++ b/readme.html
@@ -823,6 +823,8 @@ their skills. Special thanks go out to:
+ - artblanc, for a patch replacing a deprecated Core Graphics call
+
- Bobyshev Alexander and Martins Mozeiko, for the original proposal of
an FSAA hint and their work on the Win32 implementation of FSAA
From df1af5ca7597899b3e254fe8cb58b42ea64a5368 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 20 Mar 2012 20:00:04 +0100
Subject: [PATCH 34/62] I am POSIXed.
---
src/x11_time.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/x11_time.c b/src/x11_time.c
index e2203941..4184d326 100644
--- a/src/x11_time.c
+++ b/src/x11_time.c
@@ -39,7 +39,7 @@
static uint64_t getRawTime(void)
{
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
+#if defined(CLOCK_MONOTONIC)
if (_glfwLibrary.X11.timer.monotonic)
{
struct timespec ts;
@@ -64,7 +64,7 @@ static uint64_t getRawTime(void)
void _glfwInitTimer(void)
{
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
+#if defined(CLOCK_MONOTONIC)
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
From d976a7a86df4de24e20ba14ba99e5c5290b5705e Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 22 Mar 2012 14:27:19 +0100
Subject: [PATCH 35/62] Added Win32 library binaries.
---
.gitignore | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.gitignore b/.gitignore
index fad26de1..0496a03c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,9 @@ src/libglfw.pc
src/libglfw.so
src/libglfw.a
src/libglfw.dylib
+src/glfw.lib
+src/glfw.dll
+src/glfwdll.lib
examples/boing
examples/gears
examples/heightmap
From 812ad163ebefa787437ecb6e5d58426b9e23f7d8 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 22 Mar 2012 14:29:23 +0100
Subject: [PATCH 36/62] Formatting.
---
src/CMakeLists.txt | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bdc4d5fe..7c66ba97 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,5 @@
-if(UNIX)
+if (UNIX)
if (_GLFW_HAS_XRANDR)
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
endif()
@@ -18,19 +18,19 @@ include_directories(${GLFW_SOURCE_DIR}/src
set(common_SOURCES error.c fullscreen.c gamma.c init.c input.c
joystick.c opengl.c time.c window.c)
-if(_GLFW_COCOA_NSGL)
+if (_GLFW_COCOA_NSGL)
set(libglfw_SOURCES ${common_SOURCES} cocoa_fullscreen.m cocoa_gamma.c
cocoa_init.m cocoa_input.m cocoa_joystick.m
cocoa_opengl.m cocoa_time.c cocoa_window.m)
# For some reason, CMake doesn't know about .m
set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C)
-elseif(_GLFW_WIN32_WGL)
+elseif (_GLFW_WIN32_WGL)
set(libglfw_SOURCES ${common_SOURCES} win32_fullscreen.c win32_gamma.c
win32_init.c win32_input.c win32_joystick.c
win32_opengl.c win32_time.c win32_window.c
win32_dllmain.c)
-elseif(_GLFW_X11_GLX)
+elseif (_GLFW_X11_GLX)
set(libglfw_SOURCES ${common_SOURCES} x11_fullscreen.c x11_gamma.c
x11_init.c x11_input.c x11_joystick.c
x11_keysym2unicode.c x11_opengl.c x11_time.c
@@ -46,7 +46,7 @@ set_target_properties(libglfwStatic libglfwShared PROPERTIES
CLEAN_DIRECT_OUTPUT 1
OUTPUT_NAME glfw)
-if(WIN32)
+if (WIN32)
target_link_libraries(libglfwShared winmm)
# The GLFW DLL needs a special compile-time macro and import library name
set_target_properties(libglfwShared PROPERTIES
@@ -56,7 +56,7 @@ if(WIN32)
IMPORT_SUFFIX "dll.lib")
endif()
-if(APPLE)
+if (APPLE)
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
if (NOT CFLAGS)
From 8d2c2791c2566109d91ff3033f7e81d10fdd4346 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 22 Mar 2012 14:58:14 +0100
Subject: [PATCH 37/62] Added initial Linux MinGW-w64 support.
---
CMake/linux-amd64-mingw32msvc.cmake | 15 +++++++++++++++
include/GL/glfw3.h | 6 ++++++
src/win32_init.c | 4 ++--
src/win32_platform.h | 2 ++
4 files changed, 25 insertions(+), 2 deletions(-)
create mode 100644 CMake/linux-amd64-mingw32msvc.cmake
diff --git a/CMake/linux-amd64-mingw32msvc.cmake b/CMake/linux-amd64-mingw32msvc.cmake
new file mode 100644
index 00000000..5b68540e
--- /dev/null
+++ b/CMake/linux-amd64-mingw32msvc.cmake
@@ -0,0 +1,15 @@
+# Define the cross compilation environment for cross compiling from linux
+# to Win64 it is to be used when Debian cross compilation toolchain is
+# available.
+SET(CMAKE_SYSTEM_NAME Windows) # Target system name
+SET(CMAKE_SYSTEM_VERSION 1) # Not really used.
+SET(CMAKE_C_COMPILER "amd64-mingw32msvc-gcc")
+SET(CMAKE_CXX_COMPILER "amd64-mingw32msvc-g++")
+SET(CMAKE_RANLIB "amd64-mingw32msvc-ranlib")
+
+
+#Configure the behaviour of the find commands
+SET(CMAKE_FIND_ROOT_PATH "/usr/amd64-mingw32msvc")
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index cc817521..44e26b62 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -67,6 +67,12 @@ extern "C" {
#endif
#endif /* APIENTRY */
+/* TEMPORARY MinGW-w64 hacks.
+ */
+#if __MINGW64__
+ #define WINAPI
+#include
+#endif
/* The following three defines are here solely to make some Windows-based
* files happy. Theoretically we could include , but
diff --git a/src/win32_init.c b/src/win32_init.c
index 4e1b7863..4fab9b74 100644
--- a/src/win32_init.c
+++ b/src/win32_init.c
@@ -200,7 +200,7 @@ int _glfwPlatformInit(void)
// as possible in the hope of still being the foreground process)
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
&_glfwLibrary.Win32.foregroundLockTimeout, 0);
- SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID) 0,
+ SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
SPIF_SENDCHANGE);
if (!initLibraries())
@@ -246,7 +246,7 @@ int _glfwPlatformTerminate(void)
// Restore previous FOREGROUNDLOCKTIMEOUT system setting
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
- (LPVOID) _glfwLibrary.Win32.foregroundLockTimeout,
+ UIntToPtr(_glfwLibrary.Win32.foregroundLockTimeout),
SPIF_SENDCHANGE);
return GL_TRUE;
diff --git a/src/win32_platform.h b/src/win32_platform.h
index 82b8c9ca..0f6362c1 100644
--- a/src/win32_platform.h
+++ b/src/win32_platform.h
@@ -51,7 +51,9 @@
#endif
// GLFW requires Windows XP
+#ifndef WINVER
#define WINVER 0x0501
+#endif
#include
#include
From d204d5a434f51b0ddaab6537bd7acff0e288c55b Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 22 Mar 2012 23:25:39 +0100
Subject: [PATCH 38/62] Enabled all warnings on GNU C and compatibles.
---
CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f27cf7cd..57b8755f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,10 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
find_package(OpenGL REQUIRED)
+if (CMAKE_COMPILER_IS_GNUCC)
+ add_definitions(-Wall)
+endif()
+
#--------------------------------------------------------------------
# Set up GLFW for Win32 and WGL on Windows
#--------------------------------------------------------------------
From 08942fcabe4474310a0d57176ae10b7842451276 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 22 Mar 2012 23:28:43 +0100
Subject: [PATCH 39/62] Removed call to non-portable function.
---
tests/modes.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tests/modes.c b/tests/modes.c
index de3aec8a..9c558d47 100644
--- a/tests/modes.c
+++ b/tests/modes.c
@@ -165,8 +165,6 @@ static void test_modes(GLFWvidmode* modes, int count)
glfwCloseWindow(window);
glfwPollEvents();
window = NULL;
-
- sleep(5);
}
}
From c2a2114590ed289a14e64fcce614b852237f7b0f Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Thu, 22 Mar 2012 23:30:00 +0100
Subject: [PATCH 40/62] Fixed GCC warnings.
---
src/x11_fullscreen.c | 2 +-
src/x11_init.c | 4 ++--
src/x11_time.c | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/x11_fullscreen.c b/src/x11_fullscreen.c
index f7855c4b..37a3ae98 100644
--- a/src/x11_fullscreen.c
+++ b/src/x11_fullscreen.c
@@ -323,7 +323,7 @@ struct _glfwResolution
int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
{
int count, k, l, r, g, b, rgba, gl;
- int depth, screen;
+ int depth, screen = DefaultScreen(_glfwLibrary.X11.display);
XVisualInfo* vislist;
XVisualInfo dummy;
int viscount, rgbcount, rescount;
diff --git a/src/x11_init.c b/src/x11_init.c
index 3ed9ab13..d57af27e 100644
--- a/src/x11_init.c
+++ b/src/x11_init.c
@@ -470,8 +470,8 @@ static void initGammaRamp(void)
// RandR gamma support is only available with version 1.2 and above
if (_glfwLibrary.X11.RandR.available &&
(_glfwLibrary.X11.RandR.majorVersion > 1 ||
- _glfwLibrary.X11.RandR.majorVersion == 1 &&
- _glfwLibrary.X11.RandR.minorVersion >= 2))
+ (_glfwLibrary.X11.RandR.majorVersion == 1 &&
+ _glfwLibrary.X11.RandR.minorVersion >= 2)))
{
// FIXME: Assumes that all monitors have the same size gamma tables
// This is reasonable as I suspect the that if they did differ, it
diff --git a/src/x11_time.c b/src/x11_time.c
index 4184d326..f1445233 100644
--- a/src/x11_time.c
+++ b/src/x11_time.c
@@ -30,6 +30,7 @@
#include "internal.h"
+#include
#include
From 29d38c3b649cbe5fecd315bab47c263852e24d2e Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Fri, 23 Mar 2012 15:27:50 +0100
Subject: [PATCH 41/62] Increased Cocoa pixel format attribute array size.
---
src/cocoa_window.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 5bb33097..98c220ed 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -728,7 +728,7 @@ static GLboolean createContext(_GLFWwindow* window,
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
// Arbitrary array size here
- NSOpenGLPixelFormatAttribute attributes[24];
+ NSOpenGLPixelFormatAttribute attributes[40];
ADD_ATTR(NSOpenGLPFADoubleBuffer);
From c175084e1310abdd98e5560416bf6e484cc113a1 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 13:47:13 +0200
Subject: [PATCH 42/62] Added workaround for CMake bug 0006976.
---
CMakeLists.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57b8755f..d30b1ee0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,6 +73,14 @@ if (UNIX AND NOT APPLE)
if (X11_xf86vmode_FOUND)
set(_GLFW_HAS_XF86VIDMODE 1)
list(APPEND GLFW_INCLUDE_DIR ${X11_xf86vmode_INCLUDE_PATH})
+
+ # NOTE: This is a workaround for CMake bug 0006976 (missing
+ # X11_xf86vmode_LIB variable)
+ if (X11_xf86vmode_LIB)
+ list(APPEND GLFW_LIBRARIES ${X11_xf86vmode_LIB})
+ else()
+ list(APPEND GLFW_LIBRARIES Xxf86vm)
+ endif()
endif()
# Check for Xkb (X keyboard extension)
From 7f1d91e67b9904a6c64f3aab1f9df1da3603b8be Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 13:49:35 +0200
Subject: [PATCH 43/62] Formatting.
---
CMakeLists.txt | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d30b1ee0..d09ba186 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -120,7 +120,7 @@ if (UNIX AND APPLE)
# Define the platform identifier
set(_GLFW_COCOA_NSGL 1)
- option(GLFW_BUILD_UNIVERSAL "Build the GLFW library and examples as Universal Binaries" FALSE)
+ option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
# Universal build
if (GLFW_BUILD_UNIVERSAL)
@@ -136,10 +136,10 @@ if (UNIX AND APPLE)
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 ${OPENGL_gl_LIBRARY})
- list(APPEND GLFW_LIBRARIES ${IOKIT_FRAMEWORK})
- list(APPEND GLFW_LIBRARIES ${CORE_FOUNDATION_FRAMEWORK})
+ list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK}
+ ${OPENGL_gl_LIBRARY}
+ ${IOKIT_FRAMEWORK}
+ ${CORE_FOUNDATION_FRAMEWORK})
endif()
#--------------------------------------------------------------------
From f21f196036234077083ac9d70d536b773cde0307 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 13:52:35 +0200
Subject: [PATCH 44/62] Added comment.
---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d09ba186..fc9fa103 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,9 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
find_package(OpenGL REQUIRED)
+#--------------------------------------------------------------------
+# Enable all warnings on GCC, regardless of OS
+#--------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCC)
add_definitions(-Wall)
endif()
From 7b46a184cb0d1637ebb416b9ed578cbf2142046e Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 13:53:53 +0200
Subject: [PATCH 45/62] Added standard option to switch between static and
dynamic library, dropped dynamic test.
---
CMakeLists.txt | 5 +++
examples/CMakeLists.txt | 12 ++++--
readme.html | 1 -
src/CMakeLists.txt | 45 ++++++++++----------
tests/CMakeLists.txt | 40 ++++--------------
tests/dynamic.c | 91 -----------------------------------------
6 files changed, 43 insertions(+), 151 deletions(-)
delete mode 100644 tests/dynamic.c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc9fa103..509ce57f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@ 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_TESTS "Build the GLFW test programs" ON)
+option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
find_package(OpenGL REQUIRED)
@@ -33,6 +34,10 @@ if (WIN32)
# Set up library and include paths
list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
+
+ if (BUILD_SHARED_LIBS)
+ list(APPEND GLFW_LIBRARIES winmm)
+ endif()
endif()
#--------------------------------------------------------------------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index a644b987..b677addd 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,7 +1,11 @@
-# This line is used to link with static libraries
-# Note that the library list should be updated to be obtained from
-# the main CMakeLists.txt
-link_libraries(libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
+
+link_libraries(glfw ${OPENGL_glu_LIBRARY})
+
+if (BUILD_SHARED_LIBS)
+ add_definitions(-DGLFW_DLL)
+else()
+ link_libraries(${GLFW_LIBRARIES})
+endif()
include_directories(${GLFW_SOURCE_DIR}/include
${GLFW_SOURCE_DIR}/support
diff --git a/readme.html b/readme.html
index d7442d3b..84cc2a66 100644
--- a/readme.html
+++ b/readme.html
@@ -279,7 +279,6 @@ version of GLFW.
- Added
GLFW_INCLUDE_GL3
macro for telling the GLFW header to include gl3.h
header instead of gl.h
- Added
windows
simple multi-window test program
- Added
sharing
simple OpenGL object sharing test program
- - Added
dynamic
simple dynamic linking test program
- Added
modes
video mode enumeration and setting test program
- Added a parameter to
glfwOpenWindow
for specifying a context the new window's context will share objects with
- Added initial window title parameter to
glfwOpenWindow
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7c66ba97..e508f259 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,31 +39,32 @@ else()
message(FATAL_ERROR "No supported platform was selected")
endif()
-add_library(libglfwStatic STATIC ${libglfw_SOURCES})
-add_library(libglfwShared SHARED ${libglfw_SOURCES})
-target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
-set_target_properties(libglfwStatic libglfwShared PROPERTIES
- CLEAN_DIRECT_OUTPUT 1
- OUTPUT_NAME glfw)
+add_library(glfw ${libglfw_SOURCES})
-if (WIN32)
- target_link_libraries(libglfwShared winmm)
- # The GLFW DLL needs a special compile-time macro and import library name
- set_target_properties(libglfwShared PROPERTIES
- COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
- PREFIX ""
- IMPORT_PREFIX ""
- IMPORT_SUFFIX "dll.lib")
-endif()
+if (BUILD_SHARED_LIBS)
-if (APPLE)
- # Append -fno-common to the compile flags to work around a bug in the Apple GCC
- get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
- if (NOT CFLAGS)
- set(CFLAGS "")
+ if (WIN32)
+ # The GLFW DLL needs a special compile-time macro and import library name
+ set_target_properties(glfw PROPERTIES
+ COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
+ PREFIX ""
+ IMPORT_PREFIX ""
+ IMPORT_SUFFIX "dll.lib")
endif()
- set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
+
+ if (APPLE)
+ # Append -fno-common to the compile flags to work around a bug in the Apple GCC
+ get_target_property(CFLAGS glfw COMPILE_FLAGS)
+ if (NOT CFLAGS)
+ set(CFLAGS "")
+ endif()
+ set_target_properties(glfw PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
+ endif()
+
+ target_link_libraries(glfw ${GLFW_LIBRARIES})
+ target_link_libraries(glfw LINK_INTERFACE_LIBRARIES)
+
endif()
-install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
+install(TARGETS glfw DESTINATION lib)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7a166881..43db9d22 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,68 +1,42 @@
-set(STATIC_DEPS libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
-set(SHARED_DEPS libglfwShared ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
+link_libraries(glfw ${OPENGL_glu_LIBRARY})
+
+if (BUILD_SHARED_LIBS)
+ add_definitions(-DGLFW_DLL)
+else()
+ link_libraries(${GLFW_LIBRARIES})
+endif()
include_directories(${GLFW_SOURCE_DIR}/include
${GLFW_SOURCE_DIR}/support
${OPENGL_INCLUDE_DIR})
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)
-target_link_libraries(events ${STATIC_DEPS})
-
add_executable(fsaa fsaa.c getopt.c)
-target_link_libraries(fsaa ${STATIC_DEPS})
-
add_executable(fsfocus fsfocus.c)
-target_link_libraries(fsfocus ${STATIC_DEPS})
-
add_executable(gamma gamma.c getopt.c)
-target_link_libraries(gamma ${STATIC_DEPS})
-
add_executable(glfwinfo glfwinfo.c getopt.c)
-target_link_libraries(glfwinfo ${STATIC_DEPS})
-
add_executable(iconify iconify.c getopt.c)
-target_link_libraries(iconify ${STATIC_DEPS})
-
add_executable(joysticks joysticks.c)
-target_link_libraries(joysticks ${STATIC_DEPS})
-
add_executable(listmodes listmodes.c)
-target_link_libraries(listmodes ${STATIC_DEPS})
-
add_executable(modes modes.c getopt.c)
-target_link_libraries(modes ${STATIC_DEPS})
-
add_executable(peter peter.c)
-target_link_libraries(peter ${STATIC_DEPS})
-
add_executable(reopen reopen.c)
-target_link_libraries(reopen ${STATIC_DEPS})
add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c)
-target_link_libraries(accuracy ${STATIC_DEPS})
set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy")
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
-target_link_libraries(sharing ${STATIC_DEPS})
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
-target_link_libraries(tearing ${STATIC_DEPS})
set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing")
add_executable(title WIN32 MACOSX_BUNDLE title.c)
-target_link_libraries(title ${STATIC_DEPS})
set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
add_executable(windows WIN32 MACOSX_BUNDLE windows.c)
-target_link_libraries(windows ${STATIC_DEPS})
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
set(WINDOWS_BINARIES accuracy sharing tearing title windows)
diff --git a/tests/dynamic.c b/tests/dynamic.c
deleted file mode 100644
index 8bc5568b..00000000
--- a/tests/dynamic.c
+++ /dev/null
@@ -1,91 +0,0 @@
-//========================================================================
-// Dynamic linking test
-// Copyright (c) Camilla Berglund
-//
-// 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
-
-#include
-#include
-
-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);
-}
-
From 23776f67e3708883dad557d1e0ed748f0bf3a7ac Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 13:58:07 +0200
Subject: [PATCH 46/62] Formatting.
---
CMakeLists.txt | 2 +-
examples/CMakeLists.txt | 4 ++--
tests/CMakeLists.txt | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 509ce57f..2cd65cb3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@ find_package(OpenGL REQUIRED)
# Enable all warnings on GCC, regardless of OS
#--------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCC)
- add_definitions(-Wall)
+ add_definitions(-Wall)
endif()
#--------------------------------------------------------------------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index b677addd..2bdd95e9 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -2,9 +2,9 @@
link_libraries(glfw ${OPENGL_glu_LIBRARY})
if (BUILD_SHARED_LIBS)
- add_definitions(-DGLFW_DLL)
+ add_definitions(-DGLFW_DLL)
else()
- link_libraries(${GLFW_LIBRARIES})
+ link_libraries(${GLFW_LIBRARIES})
endif()
include_directories(${GLFW_SOURCE_DIR}/include
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 43db9d22..f6749e54 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -2,9 +2,9 @@
link_libraries(glfw ${OPENGL_glu_LIBRARY})
if (BUILD_SHARED_LIBS)
- add_definitions(-DGLFW_DLL)
+ add_definitions(-DGLFW_DLL)
else()
- link_libraries(${GLFW_LIBRARIES})
+ link_libraries(${GLFW_LIBRARIES})
endif()
include_directories(${GLFW_SOURCE_DIR}/include
From 9e8f5477748814f87ddc362df264b2dc01448bdd Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 13:59:34 +0200
Subject: [PATCH 47/62] Formatting.
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cd65cb3..85311188 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -177,7 +177,7 @@ install(DIRECTORY include/GL DESTINATION include
FILES_MATCHING PATTERN glfw3.h)
install(FILES COPYING.txt readme.html
- DESTINATION share/doc/glfw-${GLFW_VERSION_FULL}/)
+ DESTINATION share/doc/glfw-${GLFW_VERSION_FULL})
# The src directory's CMakeLists.txt file installs the library
From 4a905d2e28144d6deeb962e4d073386b798a328b Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 14:43:23 +0200
Subject: [PATCH 48/62] Comment update.
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 85311188..f5b08c1e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,7 @@ if (UNIX AND NOT APPLE)
include(CheckFunctionExists)
include(CheckSymbolExists)
+ # This is needed by the GLX function checks below
set(CMAKE_REQUIRED_LIBRARIES ${GLFW_LIBRARIES})
# Check for XRandR (modern resolution switching extension)
@@ -97,7 +98,6 @@ if (UNIX AND NOT APPLE)
list(APPEND GLFW_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
endif()
- # Check for glXGetProcAddress
check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
From d743793e71ad3b0089a39f443c75391b832c3ee4 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 14:51:56 +0200
Subject: [PATCH 49/62] Pkg-config dependency generation fixes.
---
CMakeLists.txt | 25 ++++++++++++++++---------
src/CMakeLists.txt | 9 ++-------
src/libglfw.pc.cmake | 2 +-
3 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5b08c1e..5aa640b7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,15 +55,7 @@ if (UNIX AND NOT APPLE)
list(APPEND GLFW_INCLUDE_DIR ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR})
list(APPEND GLFW_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY})
- find_library(MATH_LIBRARY m)
- if (MATH_LIBRARY)
- list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY})
- endif()
-
- find_library(RT_LIBRARY rt)
- if (RT_LIBRARY)
- list(APPEND GLFW_LIBRARIES ${RT_LIBRARY})
- endif()
+ set(GLFW_PKGLIBS "gl x11")
include(CheckFunctionExists)
include(CheckSymbolExists)
@@ -76,6 +68,7 @@ if (UNIX AND NOT APPLE)
set(_GLFW_HAS_XRANDR 1)
list(APPEND GLFW_INCLUDE_DIR ${X11_Xrandr_INCLUDE_PATH})
list(APPEND GLFW_LIBRARIES ${X11_Xrandr_LIB})
+ set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
endif()
# Check for Xf86VidMode (fallback legacy resolution switching extension)
@@ -90,6 +83,8 @@ if (UNIX AND NOT APPLE)
else()
list(APPEND GLFW_LIBRARIES Xxf86vm)
endif()
+
+ set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm")
endif()
# Check for Xkb (X keyboard extension)
@@ -98,6 +93,18 @@ if (UNIX AND NOT APPLE)
list(APPEND GLFW_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
endif()
+ find_library(RT_LIBRARY rt)
+ if (RT_LIBRARY)
+ list(APPEND GLFW_LIBRARIES ${RT_LIBRARY})
+ set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt")
+ endif()
+
+ find_library(MATH_LIBRARY m)
+ if (MATH_LIBRARY)
+ list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY})
+ set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m")
+ endif()
+
check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e508f259..aa7fbf30 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,14 +1,9 @@
if (UNIX)
- if (_GLFW_HAS_XRANDR)
- set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
- endif()
- if (_GLFW_HAS_XF86VIDMODE)
- set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm")
- endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc
+ DESTINATION lib/pkgconfig)
endif()
include_directories(${GLFW_SOURCE_DIR}/src
diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.cmake
index 47cfb4f5..164fdc26 100644
--- a/src/libglfw.pc.cmake
+++ b/src/libglfw.pc.cmake
@@ -7,6 +7,6 @@ Name: GLFW
Description: A portable library for OpenGL, window and input
Version: 3.0.0
URL: http://www.glfw.org/
-Requires.private: gl x11 @GLFW_PKGLIBS@
+Requires.private: @GLFW_PKGLIBS@
Libs: -L${libdir} -lglfw
Cflags: -I${includedir}
From 441452467a7127affa5957cdb24e184963b001c6 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 15:05:48 +0200
Subject: [PATCH 50/62] Marked library variables as advanced.
---
CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5aa640b7..d1034aad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,12 +94,14 @@ if (UNIX AND NOT APPLE)
endif()
find_library(RT_LIBRARY rt)
+ mark_as_advanced(RT_LIBRARY)
if (RT_LIBRARY)
list(APPEND GLFW_LIBRARIES ${RT_LIBRARY})
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt")
endif()
find_library(MATH_LIBRARY m)
+ mark_as_advanced(MATH_LIBRARY)
if (MATH_LIBRARY)
list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY})
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m")
From 20e685d37bbfc5c377b085148fb2d66c8cd92abe Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 16:34:36 +0200
Subject: [PATCH 51/62] Formatted variables not used outside of the local CMake
project.
---
CMakeLists.txt | 30 +++++++++++++++---------------
src/CMakeLists.txt | 39 ++++++++++++++++++++-------------------
2 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1034aad..e7149dd6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,11 +32,11 @@ if (WIN32)
set(_GLFW_WIN32_WGL 1)
# Set up library and include paths
- list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
- list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
+ list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
+ list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
if (BUILD_SHARED_LIBS)
- list(APPEND GLFW_LIBRARIES winmm)
+ list(APPEND glfw_LIBRARIES winmm)
endif()
endif()
@@ -52,8 +52,8 @@ if (UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
# Set up library and include paths
- list(APPEND GLFW_INCLUDE_DIR ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR})
- list(APPEND GLFW_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY})
+ list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR})
+ list(APPEND glfw_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY})
set(GLFW_PKGLIBS "gl x11")
@@ -61,27 +61,27 @@ if (UNIX AND NOT APPLE)
include(CheckSymbolExists)
# This is needed by the GLX function checks below
- set(CMAKE_REQUIRED_LIBRARIES ${GLFW_LIBRARIES})
+ set(CMAKE_REQUIRED_LIBRARIES ${glfw_LIBRARIES})
# Check for XRandR (modern resolution switching extension)
if (X11_Xrandr_FOUND)
set(_GLFW_HAS_XRANDR 1)
- list(APPEND GLFW_INCLUDE_DIR ${X11_Xrandr_INCLUDE_PATH})
- list(APPEND GLFW_LIBRARIES ${X11_Xrandr_LIB})
+ list(APPEND glfw_INCLUDE_DIRS ${X11_Xrandr_INCLUDE_PATH})
+ list(APPEND glfw_LIBRARIES ${X11_Xrandr_LIB})
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
endif()
# Check for Xf86VidMode (fallback legacy resolution switching extension)
if (X11_xf86vmode_FOUND)
set(_GLFW_HAS_XF86VIDMODE 1)
- list(APPEND GLFW_INCLUDE_DIR ${X11_xf86vmode_INCLUDE_PATH})
+ list(APPEND glfw_INCLUDE_DIRS ${X11_xf86vmode_INCLUDE_PATH})
# NOTE: This is a workaround for CMake bug 0006976 (missing
# X11_xf86vmode_LIB variable)
if (X11_xf86vmode_LIB)
- list(APPEND GLFW_LIBRARIES ${X11_xf86vmode_LIB})
+ list(APPEND glfw_LIBRARIES ${X11_xf86vmode_LIB})
else()
- list(APPEND GLFW_LIBRARIES Xxf86vm)
+ list(APPEND glfw_LIBRARIES Xxf86vm)
endif()
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm")
@@ -90,20 +90,20 @@ if (UNIX AND NOT APPLE)
# Check for Xkb (X keyboard extension)
if (X11_Xkb_FOUND)
set(_GLFW_HAS_XKB 1)
- list(APPEND GLFW_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
+ list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
endif()
find_library(RT_LIBRARY rt)
mark_as_advanced(RT_LIBRARY)
if (RT_LIBRARY)
- list(APPEND GLFW_LIBRARIES ${RT_LIBRARY})
+ list(APPEND glfw_LIBRARIES ${RT_LIBRARY})
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt")
endif()
find_library(MATH_LIBRARY m)
mark_as_advanced(MATH_LIBRARY)
if (MATH_LIBRARY)
- list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY})
+ list(APPEND glfw_LIBRARIES ${MATH_LIBRARY})
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m")
endif()
@@ -153,7 +153,7 @@ if (UNIX AND APPLE)
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}
${OPENGL_gl_LIBRARY}
${IOKIT_FRAMEWORK}
${CORE_FOUNDATION_FRAMEWORK})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index aa7fbf30..3f692cf8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,33 +8,33 @@ endif()
include_directories(${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src
- ${GLFW_INCLUDE_DIR})
+ ${glfw_INCLUDE_DIRS})
set(common_SOURCES error.c fullscreen.c gamma.c init.c input.c
joystick.c opengl.c time.c window.c)
if (_GLFW_COCOA_NSGL)
- set(libglfw_SOURCES ${common_SOURCES} cocoa_fullscreen.m cocoa_gamma.c
- cocoa_init.m cocoa_input.m cocoa_joystick.m
- cocoa_opengl.m cocoa_time.c cocoa_window.m)
+ set(glfw_SOURCES ${common_SOURCES} cocoa_fullscreen.m cocoa_gamma.c
+ cocoa_init.m cocoa_input.m cocoa_joystick.m
+ cocoa_opengl.m cocoa_time.c cocoa_window.m)
# For some reason, CMake doesn't know about .m
- set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C)
+ set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
elseif (_GLFW_WIN32_WGL)
- set(libglfw_SOURCES ${common_SOURCES} win32_fullscreen.c win32_gamma.c
- win32_init.c win32_input.c win32_joystick.c
- win32_opengl.c win32_time.c win32_window.c
- win32_dllmain.c)
+ set(glfw_SOURCES ${common_SOURCES} win32_fullscreen.c win32_gamma.c
+ win32_init.c win32_input.c win32_joystick.c
+ win32_opengl.c win32_time.c win32_window.c
+ win32_dllmain.c)
elseif (_GLFW_X11_GLX)
- set(libglfw_SOURCES ${common_SOURCES} x11_fullscreen.c x11_gamma.c
- x11_init.c x11_input.c x11_joystick.c
- x11_keysym2unicode.c x11_opengl.c x11_time.c
- x11_window.c)
+ set(glfw_SOURCES ${common_SOURCES} x11_fullscreen.c x11_gamma.c
+ x11_init.c x11_input.c x11_joystick.c
+ x11_keysym2unicode.c x11_opengl.c x11_time.c
+ x11_window.c)
else()
message(FATAL_ERROR "No supported platform was selected")
endif()
-add_library(glfw ${libglfw_SOURCES})
+add_library(glfw ${glfw_SOURCES})
if (BUILD_SHARED_LIBS)
@@ -49,14 +49,15 @@ if (BUILD_SHARED_LIBS)
if (APPLE)
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
- get_target_property(CFLAGS glfw COMPILE_FLAGS)
- if (NOT CFLAGS)
- set(CFLAGS "")
+ get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS)
+ if (NOT glfw_CFLAGS)
+ set(glfw_CFLAGS "")
endif()
- set_target_properties(glfw PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
+ set_target_properties(glfw PROPERTIES
+ COMPILE_FLAGS "${glfw_CFLAGS} -fno-common")
endif()
- target_link_libraries(glfw ${GLFW_LIBRARIES})
+ target_link_libraries(glfw ${glfw_LIBRARIES})
target_link_libraries(glfw LINK_INTERFACE_LIBRARIES)
endif()
From bd8eb1399a051ce09b07ce34f76f2e12889849bc Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 16:51:24 +0200
Subject: [PATCH 52/62] Put platform detection in a single place.
---
CMakeLists.txt | 32 ++++++++++++++++++--------------
src/CMakeLists.txt | 11 +++--------
2 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e7149dd6..ef6ded3d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,13 +23,25 @@ if (CMAKE_COMPILER_IS_GNUCC)
endif()
#--------------------------------------------------------------------
-# Set up GLFW for Win32 and WGL on Windows
+# Detect and select target platform
#--------------------------------------------------------------------
if (WIN32)
- message(STATUS "Building GLFW for WGL on a Win32 system")
-
- # Define the platform identifier
set(_GLFW_WIN32_WGL 1)
+ message(STATUS "Building GLFW for WGL on a Win32 system")
+elseif (UNIX AND APPLE)
+ set(_GLFW_COCOA_NSGL 1)
+ message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
+elseif (UNIX AND NOT APPLE)
+ set(_GLFW_X11_GLX 1)
+ message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X")
+else()
+ message(FATAL_ERROR "No supported platform was detected")
+endif()
+
+#--------------------------------------------------------------------
+# Set up GLFW for Win32 and WGL on Windows
+#--------------------------------------------------------------------
+if (_GLFW_WIN32_WGL)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
@@ -43,11 +55,7 @@ endif()
#--------------------------------------------------------------------
# Set up GLFW for Xlib and GLX on Unix-like systems with X Windows
#--------------------------------------------------------------------
-if (UNIX AND NOT APPLE)
- message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
-
- # Define the platform identifier
- set(_GLFW_X11_GLX 1)
+if (_GLFW_X11_GLX)
find_package(X11 REQUIRED)
@@ -131,12 +139,8 @@ endif()
#--------------------------------------------------------------------
# Set up GLFW for Cocoa and NSOpenGL on Mac OS X
#--------------------------------------------------------------------
-if (UNIX AND APPLE)
- message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X")
+if (_GLFW_COCOA_NSGL)
- # Define the platform identifier
- set(_GLFW_COCOA_NSGL 1)
-
option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
# Universal build
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3f692cf8..b8c0fd7d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,5 @@
-if (UNIX)
+if (_GLFW_X11_GLX)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc
@@ -30,24 +30,20 @@ elseif (_GLFW_X11_GLX)
x11_init.c x11_input.c x11_joystick.c
x11_keysym2unicode.c x11_opengl.c x11_time.c
x11_window.c)
-else()
- message(FATAL_ERROR "No supported platform was selected")
endif()
add_library(glfw ${glfw_SOURCES})
if (BUILD_SHARED_LIBS)
- if (WIN32)
+ if (_GLFW_WIN32_WGL)
# The GLFW DLL needs a special compile-time macro and import library name
set_target_properties(glfw PROPERTIES
COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
PREFIX ""
IMPORT_PREFIX ""
IMPORT_SUFFIX "dll.lib")
- endif()
-
- if (APPLE)
+ elseif (_GLFW_COCOA_NSGL)
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS)
if (NOT glfw_CFLAGS)
@@ -59,7 +55,6 @@ if (BUILD_SHARED_LIBS)
target_link_libraries(glfw ${glfw_LIBRARIES})
target_link_libraries(glfw LINK_INTERFACE_LIBRARIES)
-
endif()
install(TARGETS glfw DESTINATION lib)
From 1eb24ff261c815d2db102b78c74706defb892799 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:05:00 +0200
Subject: [PATCH 53/62] Executable dependency list fixes.
---
examples/CMakeLists.txt | 3 ++-
tests/CMakeLists.txt | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 2bdd95e9..76135a92 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -3,8 +3,9 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY})
if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL)
+ link_libraries(${OPENGL_gl_LIBRARY})
else()
- link_libraries(${GLFW_LIBRARIES})
+ link_libraries(${glfw_LIBRARIES})
endif()
include_directories(${GLFW_SOURCE_DIR}/include
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f6749e54..d016fb0e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -3,8 +3,9 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY})
if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL)
+ link_libraries(${OPENGL_gl_LIBRARY})
else()
- link_libraries(${GLFW_LIBRARIES})
+ link_libraries(${glfw_LIBRARIES})
endif()
include_directories(${GLFW_SOURCE_DIR}/include
From 862efe78e3535d8a1cad2084828ca91e410c60ac Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:22:35 +0200
Subject: [PATCH 54/62] Added fallback check for dlopen, clearer use of
required libraries.
---
CMakeLists.txt | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ef6ded3d..d17f72ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,9 +68,6 @@ if (_GLFW_X11_GLX)
include(CheckFunctionExists)
include(CheckSymbolExists)
- # This is needed by the GLX function checks below
- set(CMAKE_REQUIRED_LIBRARIES ${glfw_LIBRARIES})
-
# Check for XRandR (modern resolution switching extension)
if (X11_Xrandr_FOUND)
set(_GLFW_HAS_XRANDR 1)
@@ -115,6 +112,8 @@ if (_GLFW_X11_GLX)
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m")
endif()
+ set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
+
check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
@@ -129,6 +128,26 @@ if (_GLFW_X11_GLX)
NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND
NOT _GLFW_HAS_GLXGETPROCADDRESSEXT)
message(WARNING "No glXGetProcAddressXXX variant found")
+
+ # Check for dlopen support as a fallback
+
+ find_library(DL_LIBRARY dl)
+ if (DL_LIBRARY)
+ set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY})
+ else()
+ set(CMAKE_REQUIRED_LIBRARIES "")
+ endif()
+
+ check_function_exists(dlopen _GLFW_HAS_DLOPEN)
+
+ if (NOT _GLFW_HAS_DLOPEN)
+ message(FATAL_ERROR "No entry point retrieval mechanism found")
+ endif()
+
+ if (DL_LIBRARY)
+ list(APPEND glfw_LIBRARIES ${DL_LIBRARY})
+ set(GLFW_PKGLIBS "${GLFW_PKGLIBS} dl")
+ endif()
endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
From cfa798451e71b61504208de22434d1c51961961e Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:23:24 +0200
Subject: [PATCH 55/62] Fixed platform messages being mixed up.
---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d17f72ed..8101242b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,10 +30,10 @@ if (WIN32)
message(STATUS "Building GLFW for WGL on a Win32 system")
elseif (UNIX AND APPLE)
set(_GLFW_COCOA_NSGL 1)
- message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
+ message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X")
elseif (UNIX AND NOT APPLE)
set(_GLFW_X11_GLX 1)
- message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X")
+ message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
else()
message(FATAL_ERROR "No supported platform was detected")
endif()
From 730e2e55c9a10b90c7728f44a9744873fd1ab36f Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:24:33 +0200
Subject: [PATCH 56/62] Removed unused module.
---
CMakeLists.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8101242b..4ea202ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,7 +66,6 @@ if (_GLFW_X11_GLX)
set(GLFW_PKGLIBS "gl x11")
include(CheckFunctionExists)
- include(CheckSymbolExists)
# Check for XRandR (modern resolution switching extension)
if (X11_Xrandr_FOUND)
From 8dc139183543040e87e0ac73ace61702ff4789ba Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:25:03 +0200
Subject: [PATCH 57/62] Marked library variable as advanced.
---
CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ea202ea..c3e41168 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -131,6 +131,7 @@ if (_GLFW_X11_GLX)
# Check for dlopen support as a fallback
find_library(DL_LIBRARY dl)
+ mark_as_advanced(DL_LIBRARY)
if (DL_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY})
else()
From c097246312820cb64c44d3742f4647b14c94b404 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:31:22 +0200
Subject: [PATCH 58/62] Fixed listing of non-pkg-config libraries.
---
CMakeLists.txt | 13 +++++++------
src/libglfw.pc.cmake | 5 +++--
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3e41168..07790a12 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,7 +63,8 @@ if (_GLFW_X11_GLX)
list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY})
- set(GLFW_PKGLIBS "gl x11")
+ set(GLFW_PKG_DEPS "gl x11")
+ set(GLFW_PKG_LIBS "")
include(CheckFunctionExists)
@@ -72,7 +73,7 @@ if (_GLFW_X11_GLX)
set(_GLFW_HAS_XRANDR 1)
list(APPEND glfw_INCLUDE_DIRS ${X11_Xrandr_INCLUDE_PATH})
list(APPEND glfw_LIBRARIES ${X11_Xrandr_LIB})
- set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
+ set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xrandr")
endif()
# Check for Xf86VidMode (fallback legacy resolution switching extension)
@@ -88,7 +89,7 @@ if (_GLFW_X11_GLX)
list(APPEND glfw_LIBRARIES Xxf86vm)
endif()
- set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm")
+ set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xxf86vm")
endif()
# Check for Xkb (X keyboard extension)
@@ -101,14 +102,14 @@ if (_GLFW_X11_GLX)
mark_as_advanced(RT_LIBRARY)
if (RT_LIBRARY)
list(APPEND glfw_LIBRARIES ${RT_LIBRARY})
- set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt")
+ set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lrt")
endif()
find_library(MATH_LIBRARY m)
mark_as_advanced(MATH_LIBRARY)
if (MATH_LIBRARY)
list(APPEND glfw_LIBRARIES ${MATH_LIBRARY})
- set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m")
+ set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lm")
endif()
set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
@@ -146,7 +147,7 @@ if (_GLFW_X11_GLX)
if (DL_LIBRARY)
list(APPEND glfw_LIBRARIES ${DL_LIBRARY})
- set(GLFW_PKGLIBS "${GLFW_PKGLIBS} dl")
+ set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -ldl")
endif()
endif()
diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.cmake
index 164fdc26..f83ad126 100644
--- a/src/libglfw.pc.cmake
+++ b/src/libglfw.pc.cmake
@@ -7,6 +7,7 @@ Name: GLFW
Description: A portable library for OpenGL, window and input
Version: 3.0.0
URL: http://www.glfw.org/
-Requires.private: @GLFW_PKGLIBS@
-Libs: -L${libdir} -lglfw
+Requires.private: @GLFW_PKG_DEPS@
+Libs: -L${libdir} -lglfw
+Libs.private: @GLFW_PKG_LIBS@
Cflags: -I${includedir}
From 2588c9be1739d62d7b27bf11e278d1a6063d40e3 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:40:30 +0200
Subject: [PATCH 59/62] Renamed GLFW_BUILD_DLL to _GLFW_BUILD_DLL.
---
include/GL/glfw3.h | 2 +-
readme.html | 1 +
src/CMakeLists.txt | 2 +-
src/win32_dllmain.c | 4 ++--
src/win32_init.c | 2 +-
5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 44e26b62..180fca80 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -119,7 +119,7 @@ extern "C" {
/* ---------------- GLFW related system specific defines ----------------- */
-#if defined(_WIN32) && defined(GLFW_BUILD_DLL)
+#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
/* We are building a Win32 DLL */
#define GLFWAPI __declspec(dllexport)
diff --git a/readme.html b/readme.html
index 84cc2a66..f631acd7 100644
--- a/readme.html
+++ b/readme.html
@@ -288,6 +288,7 @@ version of GLFW.
- Renamed
glfw.h
to glfw3.h
to avoid conflicts with 2.x series
- Renamed
GLFW_WINDOW
token to GLFW_WINDOWED
- Renamed
GLFW_WINDOW_NO_RESIZE
to GLFW_WINDOW_RESIZABLE
+ - Renamed
GLFW_BUILD_DLL
to _GLFW_BUILD_DLL
- Renamed
version
test to glfwinfo
- Replaced ad hoc build system with CMake
- Replaced layout-dependent key codes with single, platform-independent set based on US layout
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b8c0fd7d..b87ac3b1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,7 +39,7 @@ if (BUILD_SHARED_LIBS)
if (_GLFW_WIN32_WGL)
# The GLFW DLL needs a special compile-time macro and import library name
set_target_properties(glfw PROPERTIES
- COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
+ COMPILE_DEFINITIONS "_GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
PREFIX ""
IMPORT_PREFIX ""
IMPORT_SUFFIX "dll.lib")
diff --git a/src/win32_dllmain.c b/src/win32_dllmain.c
index a999af0e..95258ccc 100644
--- a/src/win32_dllmain.c
+++ b/src/win32_dllmain.c
@@ -31,7 +31,7 @@
#include "internal.h"
-#if defined(GLFW_BUILD_DLL)
+#if defined(_GLFW_BUILD_DLL)
//========================================================================
// GLFW DLL entry point
@@ -45,5 +45,5 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
return TRUE;
}
-#endif // GLFW_BUILD_DLL
+#endif // _GLFW_BUILD_DLL
diff --git a/src/win32_init.c b/src/win32_init.c
index 4fab9b74..55232fd7 100644
--- a/src/win32_init.c
+++ b/src/win32_init.c
@@ -271,7 +271,7 @@ const char* _glfwPlatformGetVersionString(void)
#else
" (unknown compiler)"
#endif
-#if defined(GLFW_BUILD_DLL)
+#if defined(_GLFW_BUILD_DLL)
" DLL"
#endif
#if !defined(_GLFW_NO_DLOAD_GDI32)
From cc5d7cda64643b900c93502927837d09b35c13b3 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 17:43:02 +0200
Subject: [PATCH 60/62] Added configuration error check.
---
include/GL/glfw3.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 180fca80..b29d0005 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -119,6 +119,10 @@ extern "C" {
/* ---------------- GLFW related system specific defines ----------------- */
+#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
+ #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
+#endif
+
#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
/* We are building a Win32 DLL */
From 415ebbb97cfb9487b8682cf704cd7a07481a2420 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 20:15:27 +0200
Subject: [PATCH 61/62] Added cache variable for dependencies of GLFW.
---
CMakeLists.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07790a12..522aaf76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -183,6 +183,11 @@ if (_GLFW_COCOA_NSGL)
${CORE_FOUNDATION_FRAMEWORK})
endif()
+#--------------------------------------------------------------------
+# Export GLFW library dependencies
+#--------------------------------------------------------------------
+set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW")
+
#--------------------------------------------------------------------
# Add subdirectories
#--------------------------------------------------------------------
From 7fb702a22be00f26de75483185d39a01aa44abc6 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 25 Mar 2012 20:45:06 +0200
Subject: [PATCH 62/62] Removed unused code.
---
src/win32_window.c | 46 +---------------------------------------------
1 file changed, 1 insertion(+), 45 deletions(-)
diff --git a/src/win32_window.c b/src/win32_window.c
index 0f3c67d0..dd25c3ce 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -34,30 +34,6 @@
#include
-//========================================================================
-// Convert BPP to RGB bits based on "best guess"
-//========================================================================
-
-static void bpp2rgb(int bpp, int* r, int* g, int* b)
-{
- int delta;
-
- // We assume that by 32 they really meant 24
- if (bpp == 32)
- bpp = 24;
-
- // Convert "bits per pixel" to red, green & blue sizes
-
- *r = *g = *b = bpp / 3;
- delta = bpp - (*r * 3);
- if (delta >= 1)
- *g = *g + 1;
-
- if (delta == 2)
- *r = *r + 1;
-}
-
-
//========================================================================
// Enable/disable minimize/restore animations
//========================================================================
@@ -1600,29 +1576,10 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
- //int bpp, refresh;
- int newMode = 0;
GLboolean sizeChanged = GL_FALSE;
if (window->mode == GLFW_FULLSCREEN)
{
- // Get some info about the current mode
-
- DEVMODE dm;
-
- dm.dmSize = sizeof(DEVMODE);
- //if (EnumDisplaySettings(NULL, window->Win32.modeID, &dm))
- //{
- // We need to keep BPP the same for the OpenGL context to keep working
- //bpp = dm.dmBitsPerPel;
-
- // Get closest match for target video mode
- //refresh = window->Win32.desiredRefreshRate;
- //newMode = _glfwGetClosestVideoModeBPP(&width, &height, &bpp, &refresh);
- //}
- //else
- //newMode = window->Win32.modeID;
-
if (width > window->width || height > window->height)
{
// The new video mode is larger than the current one, so we resize
@@ -1634,8 +1591,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
sizeChanged = GL_TRUE;
}
- //if (newMode != window->Win32.modeID)
- //_glfwSetVideoModeMODE(newMode);
+ // TODO: Change video mode
}
else
{