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 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/CMakeLists.txt b/CMakeLists.txt index f27cf7cd..57f4d16b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,73 +11,109 @@ 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) #-------------------------------------------------------------------- -# Set up GLFW for Win32 and WGL on Windows +# Enable all warnings on GCC, regardless of OS +#-------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCC) + add_definitions(-Wall) +endif() + +#-------------------------------------------------------------------- +# 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 Cocoa and NSOpenGL on Mac OS X") +elseif (UNIX AND NOT APPLE) + set(_GLFW_X11_GLX 1) + message(STATUS "Building GLFW for X11 and GLX on a Unix-like system") +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_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) + endif() 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) # 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}) - 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_PKG_DEPS "gl x11") + set(GLFW_PKG_LIBS "") include(CheckFunctionExists) - include(CheckSymbolExists) - 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_PKG_DEPS "${GLFW_PKG_DEPS} 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}) + else() + list(APPEND glfw_LIBRARIES Xxf86vm) + endif() + + set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xxf86vm") endif() # 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() - # Check for glXGetProcAddress + find_library(RT_LIBRARY rt) + mark_as_advanced(RT_LIBRARY) + if (RT_LIBRARY) + list(APPEND glfw_LIBRARIES ${RT_LIBRARY}) + set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lrt") + endif() + + find_library(MATH_LIBRARY m) + mark_as_advanced(MATH_LIBRARY) + if (MATH_LIBRARY) + list(APPEND glfw_LIBRARIES ${MATH_LIBRARY}) + set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lm") + endif() + + set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY}) + check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS) if (NOT _GLFW_HAS_GLXGETPROCADDRESS) @@ -92,6 +128,27 @@ if (UNIX AND NOT APPLE) 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) + mark_as_advanced(DL_LIBRARY) + if (DL_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY}) + else() + set(CMAKE_REQUIRED_LIBRARIES "") + endif() + + check_function_exists(dlopen _GLFW_HAS_DLOPEN) + + 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_PKG_LIBS "${GLFW_PKG_LIBS} -ldl") + endif() endif() if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") @@ -102,13 +159,9 @@ 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 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) @@ -124,12 +177,20 @@ 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}) + + set(GLFW_PKG_DEPS "") + set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation") endif() +#-------------------------------------------------------------------- +# Export GLFW library dependencies +#-------------------------------------------------------------------- +set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW") + #-------------------------------------------------------------------- # Add subdirectories #-------------------------------------------------------------------- @@ -144,29 +205,34 @@ if (GLFW_BUILD_TESTS) endif() #-------------------------------------------------------------------- -# Create shared configuration header +# Create generated files #-------------------------------------------------------------------- +configure_file(${GLFW_SOURCE_DIR}/docs/Doxyfile.in + ${GLFW_BINARY_DIR}/docs/Doxyfile @ONLY) + configure_file(${GLFW_SOURCE_DIR}/src/config.h.in ${GLFW_BINARY_DIR}/src/config.h @ONLY) #-------------------------------------------------------------------- -# Install standard files +# Install header and documentation +# The src directory's CMakeLists.txt file installs the library #-------------------------------------------------------------------- - install(DIRECTORY include/GL DESTINATION include FILES_MATCHING PATTERN glfw3.h) install(FILES COPYING.txt readme.html - DESTINATION share/doc/glfw-${GLFW_VERSION_FULL}/) - -# The src directory's CMakeLists.txt file installs the library + DESTINATION share/doc/glfw-${GLFW_VERSION_FULL}) #-------------------------------------------------------------------- -# -- Documentation generation +# Create and install pkg-config file on supported platforms #-------------------------------------------------------------------- -configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in" - "${GLFW_BINARY_DIR}/docs/Doxyfile" - @ONLY) +if (_GLFW_X11_GLX OR _GLFW_COCOA_NSGL) + configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in + ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY) + + install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc + DESTINATION lib/pkgconfig) +endif() #-------------------------------------------------------------------- # Uninstall operation diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a644b987..76135a92 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,12 @@ -# 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) + link_libraries(${OPENGL_gl_LIBRARY}) +else() + link_libraries(${glfw_LIBRARIES}) +endif() include_directories(${GLFW_SOURCE_DIR}/include ${GLFW_SOURCE_DIR}/support diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 7271e628..4a2c5145 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 @@ -113,7 +119,11 @@ extern "C" { /* ---------------- GLFW related system specific defines ----------------- */ -#if defined(_WIN32) && defined(GLFW_BUILD_DLL) +#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL) + #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined" +#endif + +#if defined(_WIN32) && defined(_GLFW_BUILD_DLL) /* We are building a Win32 DLL */ #define GLFWAPI __declspec(dllexport) diff --git a/readme.html b/readme.html index fd788bae..6e098a05 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
  • @@ -289,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 bdc4d5fe..26471f93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,69 +1,54 @@ -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) -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) +if (_GLFW_COCOA_NSGL) + 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) -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) - 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) -else() - message(FATAL_ERROR "No supported platform was selected") + set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) +elseif (_GLFW_WIN32_WGL) + 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(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) 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 ${glfw_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 (_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") + 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) + set(glfw_CFLAGS "") + endif() + set_target_properties(glfw PROPERTIES + COMPILE_FLAGS "${glfw_CFLAGS} -fno-common") endif() - set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common") + + 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/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); diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.in similarity index 66% rename from src/libglfw.pc.cmake rename to src/libglfw.pc.in index 47cfb4f5..be6275aa 100644 --- a/src/libglfw.pc.cmake +++ b/src/libglfw.pc.in @@ -5,8 +5,9 @@ libdir=${exec_prefix}/lib Name: GLFW Description: A portable library for OpenGL, window and input -Version: 3.0.0 +Version: @GLFW_VERSION_FULL@ URL: http://www.glfw.org/ -Requires.private: gl x11 @GLFW_PKGLIBS@ -Libs: -L${libdir} -lglfw +Requires.private: @GLFW_PKG_DEPS@ +Libs: -L${libdir} -lglfw +Libs.private: @GLFW_PKG_LIBS@ Cflags: -I${includedir} 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 4e1b7863..55232fd7 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; @@ -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) diff --git a/src/win32_platform.h b/src/win32_platform.h index aa551a09..63a372d7 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 diff --git a/src/win32_window.c b/src/win32_window.c index 66326278..d73e73c3 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 //======================================================================== @@ -1620,29 +1596,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 @@ -1654,8 +1611,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) sizeChanged = GL_TRUE; } - //if (newMode != window->Win32.modeID) - //_glfwSetVideoModeMODE(newMode); + // TODO: Change video mode } else { 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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7a166881..d016fb0e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,68 +1,43 @@ -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) + link_libraries(${OPENGL_gl_LIBRARY}) +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); -} - 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); } }