1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-10-08 07:07:25 -04:00

Merge branch 'master' of ssh://glfw.git.sourceforge.net/gitroot/glfw/glfw

This commit is contained in:
Camilla Berglund 2011-07-27 16:23:04 +02:00
commit dc345d7914
46 changed files with 378 additions and 350 deletions

View File

@ -15,19 +15,6 @@ include(CheckSymbolExists)
find_package(OpenGL REQUIRED)
set(common_SOURCES
${GLFW_SOURCE_DIR}/src/enable.c
${GLFW_SOURCE_DIR}/src/error.c
${GLFW_SOURCE_DIR}/src/fullscreen.c
${GLFW_SOURCE_DIR}/src/gamma.c
${GLFW_SOURCE_DIR}/src/init.c
${GLFW_SOURCE_DIR}/src/input.c
${GLFW_SOURCE_DIR}/src/joystick.c
${GLFW_SOURCE_DIR}/src/opengl.c
${GLFW_SOURCE_DIR}/src/time.c
${GLFW_SOURCE_DIR}/src/window.c
)
#--------------------------------------------------------------------
# Set up GLFW for Win32 and WGL on Windows
#--------------------------------------------------------------------
@ -41,9 +28,6 @@ if (WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
# Select platform specific code
add_subdirectory(src/win32)
endif (WIN32)
#--------------------------------------------------------------------
@ -105,9 +89,6 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(_GLFW_USE_LINUX_JOYSTICKS 1)
endif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# Select platform specific code
add_subdirectory(src/x11)
endif(UNIX AND NOT APPLE AND NOT CYGWIN)
#--------------------------------------------------------------------
@ -135,14 +116,12 @@ if (UNIX AND APPLE)
find_library(COCOA_FRAMEWORK Cocoa)
list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK})
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
# Select platform specific code
add_subdirectory(src/cocoa)
endif(UNIX AND APPLE)
#--------------------------------------------------------------------
# Add example and test programs
# Add subdirectories
#--------------------------------------------------------------------
add_subdirectory(src)
add_subdirectory(examples)
add_subdirectory(tests)
@ -176,11 +155,14 @@ install(FILES COPYING.txt readme.html
#--------------------------------------------------------------------
# Uninstall operation
# Don't generate this target if a higher-level project already has
#--------------------------------------------------------------------
configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
if(NOT TARGET uninstall)
configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
add_custom_target(uninstall
${CMAKE_COMMAND} -P
${GLFW_BINARY_DIR}/cmake_uninstall.cmake)
add_custom_target(uninstall
${CMAKE_COMMAND} -P
${GLFW_BINARY_DIR}/cmake_uninstall.cmake)
endif()

View File

@ -147,6 +147,10 @@ extern "C" {
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
/* Include the declaration of the size_t type used below.
*/
#include <stddef.h>
/* Include standard OpenGL headers: GLFW uses GL_FALSE/GL_TRUE, and it is
* convenient for the user to only have to include <GL/glfw.h>. This also
* solves the problem with Windows <GL/gl.h> and <GL/glu.h> needing some
@ -409,10 +413,11 @@ extern "C" {
#define GLFW_FSAA_SAMPLES 0x00020012
#define GLFW_OPENGL_VERSION_MAJOR 0x00020013
#define GLFW_OPENGL_VERSION_MINOR 0x00020014
#define GLFW_OPENGL_FORWARD_COMPAT 0x00020015
#define GLFW_OPENGL_DEBUG_CONTEXT 0x00020016
#define GLFW_OPENGL_PROFILE 0x00020017
#define GLFW_OPENGL_ROBUSTNESS 0x00020018
#define GLFW_OPENGL_REVISION 0x00020015
#define GLFW_OPENGL_FORWARD_COMPAT 0x00020016
#define GLFW_OPENGL_DEBUG_CONTEXT 0x00020017
#define GLFW_OPENGL_PROFILE 0x00020018
#define GLFW_OPENGL_ROBUSTNESS 0x00020019
/* GLFW_OPENGL_ROBUSTNESS mode tokens */
#define GLFW_OPENGL_NO_ROBUSTNESS 0x00000000
@ -532,9 +537,7 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
/* Window handling */
GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share);
GLFWAPI void glfwOpenWindowHint(int target, int hint);
GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window);
GLFWAPI int glfwIsWindow(GLFWwindow window);
GLFWAPI GLFWwindow glfwGetCurrentWindow(void);
GLFWAPI void glfwCloseWindow(GLFWwindow window);
GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title);
GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height);
@ -578,11 +581,13 @@ GLFWAPI double glfwGetTime(void);
GLFWAPI void glfwSetTime(double time);
/* OpenGL support */
GLFWAPI void glfwMakeContextCurrent(GLFWwindow window);
GLFWAPI GLFWwindow glfwGetCurrentContext(void);
GLFWAPI void glfwSwapBuffers(void);
GLFWAPI void glfwSwapInterval(int interval);
GLFWAPI int glfwExtensionSupported(const char* extension);
GLFWAPI void* glfwGetProcAddress(const char* procname);
GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev);
GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
/* Enable/disable functions */
GLFWAPI void glfwEnable(GLFWwindow window, int token);

View File

@ -263,7 +263,7 @@ version of GLFW.</p>
<ul>
<li>Added <code>GLFWwindow</code> window handle type and updated window-related functions and callbacks to take a window handle</li>
<li>Added <code>glfwIsWindow</code> function for verifying that a given window handle is (still) valid</li>
<li>Added <code>glfwMakeWindowCurrent</code> function for making the context of the specified window current</li>
<li>Added <code>glfwMakeContextCurrent</code> function for making the context of the specified window current</li>
<li>Added <code>glfwGetError</code> and <code>glfwErrorString</code> error reporting functions and a number of error tokens</li>
<li>Added <code>glfwSetErrorCallback</code> function and <code>GLFWerrorfun</code> type for receiving more specific and/or nested errors</li>
<li>Added <code>glfwSetWindowUserPointer</code> and <code>glfwGetWindowUserPointer</code> functions for per-window user pointers</li>
@ -271,10 +271,12 @@ version of GLFW.</p>
<li>Added <code>glfwGetWindowPos</code> function for querying the position of the specified window</li>
<li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
<li>Added <code>glfwGetCurrentWindow</code> function for retrieving the window whose OpenGL context is current</li>
<li>Added <code>glfwGetCurrentContext</code> function for retrieving the window whose OpenGL context is current</li>
<li>Added <code>glfwInitWithModels</code> function and <code>GLFWallocator</code> and <code>GLFWthreadmodel</code> types for pluggable memory allocation and threading models</li>
<li>Added <code>glfwCopyContext</code> function for copying OpenGL state categories between contexts</li>
<li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li>
<li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li>
<li>Added <code>GLFW_OPENGL_REVISION</code> window parameter to make up for removal of <code>glfwGetGLVersion</code></li>
<li>Added <code>windows</code> simple multi-window test program</li>
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
<li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li>
@ -294,6 +296,7 @@ version of GLFW.</p>
<li>Removed deprecated Carbon port</li>
<li>Removed <code>glfwSleep</code> function</li>
<li>Removed <code>glfwGetNumberOfProcessors</code> function</li>
<li>Removed <code>glfwGetGLVersion</code> function</li>
<li>Removed <code>GLFW_OPENED</code> window parameter</li>
<li>Removed nonsensical key actions for Unicode character input</li>
<li>Removed <code>GLFWCALL</code> and <code>GLFWAPIENTRY</code> macros for stdcall calling convention</li>

82
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,82 @@
if(CYGWIN)
# These lines are intended to remove the --export-all-symbols
# flag added in the Modules/Platform/CYGWIN.cmake file of the
# CMake distribution.
# This is a HACK. If you have trouble _linking_ the GLFW
# _shared_ library on Cygwin, try disabling this.
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
endif(CYGWIN)
if(UNIX)
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)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src
${GLFW_INCLUDE_DIR})
set(common_SOURCES enable.c 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_enable.m cocoa_fullscreen.m
cocoa_gamma.m cocoa_init.m cocoa_joystick.m
cocoa_opengl.m cocoa_time.m 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_enable.c win32_fullscreen.c
win32_gamma.c win32_init.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_enable.c x11_fullscreen.c
x11_gamma.c x11_init.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(_GLFW_COCOA_NSGL)
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)
if(WIN32)
# The GLFW DLL needs a special compile-time macro and import library name
set_target_properties(libglfwShared PROPERTIES
DEFINE_SYMBOL GLFW_BUILD_DLL
PREFIX ""
IMPORT_PREFIX ""
IMPORT_SUFFIX "dll.lib")
endif(WIN32)
if(CYGWIN)
# Build for the regular Win32 environment (not Cygwin)
set_target_properties(libglfwStatic libglfwShared PROPERTIES
COMPILE_FLAGS "-mwin32 -mno-cygwin"
LINK_FLAGS "-mwin32 -mno-cygwin")
endif(CYGWIN)
if(APPLE)
# 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 "")
endif(NOT CFLAGS)
set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
endif(APPLE)
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)

View File

@ -1,40 +0,0 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src
${GLFW_INCLUDE_DIR})
set(cocoa_SOURCES cocoa_enable.m
cocoa_fullscreen.m
cocoa_gamma.m
cocoa_init.m
cocoa_joystick.m
cocoa_opengl.m
cocoa_time.m
cocoa_window.m)
# For some reason, CMake doesn't know about .m
set_source_files_properties(${cocoa_SOURCES} PROPERTIES LANGUAGE C)
set(libglfw_SOURCES ${common_SOURCES} ${cocoa_SOURCES})
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)
# 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 "")
endif(NOT CFLAGS)
set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)

View File

@ -1,11 +0,0 @@
prefix=@PREFIX@
exec_prefix=@PREFIX@
libdir=@PREFIX@/lib
includedir=@PREFIX@/include
Name: GLFW
Description: A portable library for OpenGL development
Version: 3.0
URL: http://www.glfw.org/
Libs: -L${libdir} -lglfw -framework AGL -framework OpenGL -framework Carbon
Cflags: -I${includedir}

View File

@ -34,6 +34,19 @@
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{
if (window)
[window->NSGL.context makeCurrentContext];
else
[NSOpenGLContext clearCurrentContext];
}
//========================================================================
// Swap buffers
//========================================================================
@ -86,3 +99,12 @@ void* _glfwPlatformGetProcAddress(const char* procname)
return symbol;
}
//========================================================================
// Copies the specified OpenGL state categories from src to dst
//========================================================================
void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{
[dst->NSGL.context copyAttributesFromContext:src->NSGL.context withMask:mask];
}

View File

@ -363,7 +363,11 @@ static int convertMacKeyCode(unsigned int macKeyCode)
}
if (_glfwLibrary.mousePosCallback)
_glfwLibrary.mousePosCallback(window, window->mousePosX, window->mousePosY);
{
_glfwLibrary.mousePosCallback(window,
window->mousePosX,
window->mousePosY);
}
}
- (void)rightMouseDown:(NSEvent *)event
@ -475,14 +479,18 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
// Fail if OpenGL 3.0 or above was requested
if (wndconfig->glMajor > 2)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Cocoa/NSOpenGL: Mac OS X does not support OpenGL version 3.0 or above");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Cocoa/NSOpenGL: Mac OS X does not support OpenGL "
"version 3.0 or above");
return GL_FALSE;
}
// Fail if a robustness strategy was requested
if (wndconfig->glRobustness)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Cocoa/NSOpenGL: Mac OS X does not support OpenGL robustness strategies");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Cocoa/NSOpenGL: Mac OS X does not support OpenGL "
"robustness strategies");
return GL_FALSE;
}
@ -493,7 +501,9 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
_glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init];
if (_glfwLibrary.NS.delegate == nil)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create application delegate");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Cocoa/NSOpenGL: Failed to create application "
"delegate");
return GL_FALSE;
}
@ -503,7 +513,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
if (window->NS.delegate == nil)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create window delegate");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Cocoa/NSOpenGL: Failed to create window delegate");
return GL_FALSE;
}
@ -634,7 +645,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
if (window->NSGL.pixelFormat == nil)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create pixel format");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Cocoa/NSOpenGL: Failed to create pixel format");
return GL_FALSE;
}
@ -648,7 +660,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
shareContext:share];
if (window->NSGL.context == nil)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create OpenGL context");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Cocoa/NSOpenGL: Failed to create OpenGL context");
return GL_FALSE;
}
@ -662,7 +675,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
withOptions:nil];
}
glfwMakeWindowCurrent(window);
glfwMakeContextCurrent(window);
NSPoint point = [[NSCursor currentCursor] hotSpot];
window->mousePosX = point.x;
@ -673,18 +686,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
return GL_TRUE;
}
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window)
{
if (window)
[window->NSGL.context makeCurrentContext];
else
[NSOpenGLContext clearCurrentContext];
}
//========================================================================
// Properly kill the window / video display

View File

@ -58,11 +58,18 @@
#include "config.h"
#include "../../include/GL/glfw3.h"
#include "../../include/GL/glext.h"
#include "platform.h"
#include "../include/GL/glfw3.h"
#include "../include/GL/glext.h"
#if defined(_GLFW_COCOA_NSGL)
#include "cocoa_platform.h"
#elif defined(_GLFW_WIN32_WGL)
#include "win32_platform.h"
#elif defined(_GLFW_X11_GLX)
#include "x11_platform.h"
#else
#error "No supported platform selected"
#endif
typedef struct _GLFWhints _GLFWhints;
typedef struct _GLFWwndconfig _GLFWwndconfig;
@ -289,7 +296,6 @@ void _glfwPlatformSetTime(double time);
// Window management
int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig);
void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window);
void _glfwPlatformCloseWindow(_GLFWwindow* window);
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
@ -305,11 +311,13 @@ void _glfwPlatformPollEvents(void);
void _glfwPlatformWaitEvents(void);
// OpenGL context management
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
void _glfwPlatformSwapBuffers(void);
void _glfwPlatformSwapInterval(int interval);
void _glfwPlatformRefreshWindowParams(void);
int _glfwPlatformExtensionSupported(const char* extension);
void* _glfwPlatformGetProcAddress(const char* procname);
void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
//========================================================================

0
src/libglfw.pc.cmake Normal file
View File

View File

@ -423,6 +423,44 @@ int _glfwStringInExtensionString(const char* string,
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
GLFWAPI void glfwMakeContextCurrent(GLFWwindow handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
if (_glfwLibrary.currentWindow == window)
return;
_glfwPlatformMakeContextCurrent(window);
_glfwLibrary.currentWindow = window;
}
//========================================================================
// Returns the window whose OpenGL context is current
//========================================================================
GLFWAPI GLFWwindow glfwGetCurrentContext(void)
{
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return GL_FALSE;
}
return _glfwLibrary.currentWindow;
}
//========================================================================
// Swap buffers (double-buffering)
//========================================================================
@ -557,12 +595,13 @@ GLFWAPI void* glfwGetProcAddress(const char* procname)
//========================================================================
// Returns the OpenGL version
// Copies the specified OpenGL state categories from src to dst
//========================================================================
GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev)
GLFWAPI void glfwCopyContext(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mask)
{
_GLFWwindow* window;
_GLFWwindow* src;
_GLFWwindow* dst;
if (!_glfwInitialized)
{
@ -570,20 +609,15 @@ GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev)
return;
}
window = _glfwLibrary.currentWindow;
if (!window)
src = (_GLFWwindow*) hsrc;
dst = (_GLFWwindow*) hdst;
if (_glfwLibrary.currentWindow == dst)
{
_glfwSetError(GLFW_NO_CURRENT_WINDOW, NULL);
_glfwSetError(GLFW_INVALID_VALUE, "Cannot copy OpenGL state to a current context");
return;
}
if (major != NULL)
*major = window->glMajor;
if (minor != NULL)
*minor = window->glMinor;
if (rev != NULL)
*rev = window->glRevision;
_glfwPlatformCopyContext(src, dst, mask);
}

View File

@ -1,59 +0,0 @@
if(CYGWIN)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
# These lines are intended to remove the --export-all-symbols
# flag added in the Modules/Platform/CYGWIN.cmake file of the
# CMake distribution.
# This is a HACK. If you have trouble _linking_ the GLFW
# _shared_ library on Cygwin, try disabling this.
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
endif(CYGWIN)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src
${GLFW_INCLUDE_DIR})
set(libglfw_SOURCES ${common_SOURCES}
win32_enable.c
win32_fullscreen.c
win32_gamma.c
win32_init.c
win32_joystick.c
win32_opengl.c
win32_time.c
win32_window.c
win32_dllmain.c)
add_library(libglfwStatic STATIC ${libglfw_SOURCES})
add_library(libglfwShared SHARED ${libglfw_SOURCES})
target_link_libraries(libglfwShared ${OPENGL_gl_LIBRARY})
set_target_properties(libglfwShared PROPERTIES
DEFINE_SYMBOL GLFW_BUILD_DLL
PREFIX ""
IMPORT_PREFIX ""
IMPORT_SUFFIX "dll.lib")
set_target_properties(libglfwStatic libglfwShared PROPERTIES
CLEAN_DIRECT_OUTPUT 1
OUTPUT_NAME glfw)
if(CYGWIN)
# Build for the regular Win32 environment (not Cygwin)
set_target_properties(libglfwStatic libglfwShared PROPERTIES
COMPILE_FLAGS "-mwin32 -mno-cygwin"
LINK_FLAGS "-mwin32 -mno-cygwin")
endif(CYGWIN)
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
if(CYGWIN)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
endif(CYGWIN)

View File

@ -1,11 +0,0 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: GLFW
Description: A portable library for OpenGL development
Version: 3.0
URL: http://www.glfw.org/
Libs: -L${libdir} -lglfw @GLFW_LIBRARIES@
Cflags: -I${includedir} -mwin32

View File

@ -35,6 +35,19 @@
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{
if (window)
wglMakeCurrent(window->WGL.DC, window->WGL.context);
else
wglMakeCurrent(NULL, NULL);
}
//========================================================================
// Swap buffers (double-buffering)
//========================================================================
@ -103,3 +116,14 @@ void* _glfwPlatformGetProcAddress(const char* procname)
return (void*) wglGetProcAddress(procname);
}
//========================================================================
// Copies the specified OpenGL state categories from src to dst
//========================================================================
void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{
if (!wglCopyContext(src->WGL.context, dst->WGL.context, mask))
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to copy OpenGL context attributes");
}

View File

@ -155,7 +155,9 @@ static int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib
{
int value = 0;
if (!window->WGL.GetPixelFormatAttribivARB(window->WGL.DC, pixelFormat, 0, 1, &attrib, &value))
if (!window->WGL.GetPixelFormatAttribivARB(window->WGL.DC,
pixelFormat,
0, 1, &attrib, &value))
{
// NOTE: We should probably handle this error somehow
return 0;
@ -180,7 +182,12 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
if (window->WGL.has_WGL_ARB_pixel_format)
count = getPixelFormatAttrib(window, 1, WGL_NUMBER_PIXEL_FORMATS_ARB);
else
count = _glfw_DescribePixelFormat(window->WGL.DC, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
{
count = _glfw_DescribePixelFormat(window->WGL.DC,
1,
sizeof(PIXELFORMATDESCRIPTOR),
NULL);
}
if (!count)
{
@ -191,7 +198,8 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
if (!result)
{
_glfwSetError(GLFW_OUT_OF_MEMORY, "Win32/WGL: Failed to allocate _GLFWfbconfig array");
_glfwSetError(GLFW_OUT_OF_MEMORY,
"Win32/WGL: Failed to allocate _GLFWfbconfig array");
return NULL;
}
@ -259,8 +267,13 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{
// Get pixel format attributes through old-fashioned PFDs
if (!_glfw_DescribePixelFormat(window->WGL.DC, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
if (!_glfw_DescribePixelFormat(window->WGL.DC,
i,
sizeof(PIXELFORMATDESCRIPTOR),
&pfd))
{
continue;
}
if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
@ -324,13 +337,15 @@ static GLboolean createContext(_GLFWwindow* window,
if (!_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
{
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "Win32/WGL: Failed to retrieve PFD for selected pixel format");
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"Win32/WGL: Failed to retrieve PFD for selected pixel format");
return GL_FALSE;
}
if (!_glfw_SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
{
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "Win32/WGL: Failed to set selected pixel format");
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"Win32/WGL: Failed to set selected pixel format");
return GL_FALSE;
}
@ -371,14 +386,18 @@ static GLboolean createContext(_GLFWwindow* window,
if (!window->WGL.has_WGL_ARB_create_context_profile)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Win32/WGL: OpenGL profile requested but "
"WGL_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
!window->WGL.has_WGL_EXT_create_context_es2_profile)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: OpenGL ES 2.x profile requested but WGL_EXT_create_context_es2_profile is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Win32/WGL: OpenGL ES 2.x profile requested but "
"WGL_EXT_create_context_es2_profile is unavailable");
return GL_FALSE;
}
@ -399,7 +418,10 @@ static GLboolean createContext(_GLFWwindow* window,
if (!window->WGL.has_WGL_ARB_create_context_robustness)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: An OpenGL robustness strategy was requested but WGL_ARB_create_context_robustness is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Win32/WGL: An OpenGL robustness strategy was "
"requested but WGL_ARB_create_context_robustness "
"is unavailable");
return GL_FALSE;
}
@ -419,7 +441,8 @@ static GLboolean createContext(_GLFWwindow* window,
attribs);
if (!window->WGL.context)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: Failed to create OpenGL context");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Win32/WGL: Failed to create OpenGL context");
return GL_FALSE;
}
}
@ -428,7 +451,8 @@ static GLboolean createContext(_GLFWwindow* window,
window->WGL.context = wglCreateContext(window->WGL.DC);
if (!window->WGL.context)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to create OpenGL context");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Win32/WGL: Failed to create OpenGL context");
return GL_FALSE;
}
@ -436,7 +460,9 @@ static GLboolean createContext(_GLFWwindow* window,
{
if (!wglShareLists(share, window->WGL.context))
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to enable sharing with specified OpenGL context");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Win32/WGL: Failed to enable sharing with "
"specified OpenGL context");
return GL_FALSE;
}
}
@ -992,7 +1018,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
}
if (_glfwLibrary.windowSizeCallback)
_glfwLibrary.windowSizeCallback(window, window->width, window->height);
{
_glfwLibrary.windowSizeCallback(window,
window->width,
window->height);
}
return 0;
}
@ -1178,7 +1208,8 @@ static ATOM registerWindowClass(void)
classAtom = RegisterClass(&wc);
if (!classAtom)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to register window class");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Win32/WGL: Failed to register window class");
return 0;
}
@ -1299,7 +1330,8 @@ static int createWindow(_GLFWwindow* window,
window->WGL.DC = GetDC(window->Win32.handle);
if (!window->WGL.DC)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to retrieve DC for window");
_glfwSetError(GLFW_PLATFORM_ERROR,
"Win32/WGL: Failed to retrieve DC for window");
return GL_FALSE;
}
@ -1310,7 +1342,7 @@ static int createWindow(_GLFWwindow* window,
if (!createContext(window, wndconfig, pixelFormat))
return GL_FALSE;
glfwMakeWindowCurrent(window);
glfwMakeContextCurrent(window);
initWGLExtensions(window);
@ -1333,7 +1365,7 @@ static void destroyWindow(_GLFWwindow* window)
// This is duplicated from glfwCloseWindow
// TODO: Stop duplicating code
if (window == _glfwLibrary.currentWindow)
glfwMakeWindowCurrent(NULL);
glfwMakeContextCurrent(NULL);
// This is duplicated from glfwCloseWindow
// TODO: Stop duplicating code
@ -1417,7 +1449,10 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
{
if (!window->WGL.has_WGL_ARB_create_context)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: A forward compatible or debug OpenGL context requested but WGL_ARB_create_context is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Win32/WGL: A forward compatible or debug OpenGL "
"context requested but WGL_ARB_create_context is "
"unavailable");
return GL_FALSE;
}
@ -1428,7 +1463,9 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
{
if (!window->WGL.has_WGL_ARB_create_context_profile)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Win32/WGL: OpenGL profile requested but "
"WGL_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
@ -1484,19 +1521,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
}
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window)
{
if (window)
wglMakeCurrent(window->WGL.DC, window->WGL.context);
else
wglMakeCurrent(NULL, NULL);
}
//========================================================================
// Properly kill the window / video display
//========================================================================

View File

@ -336,7 +336,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
}
// Cache the actual (as opposed to desired) window parameters
glfwMakeWindowCurrent(window);
glfwMakeContextCurrent(window);
_glfwPlatformRefreshWindowParams();
if (!_glfwIsValidContext(window, &wndconfig))
@ -359,28 +359,6 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
}
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
if (_glfwLibrary.currentWindow == window)
return;
_glfwPlatformMakeWindowCurrent(window);
_glfwLibrary.currentWindow = window;
}
//========================================================================
// Returns GL_TRUE if the specified window handle is an actual window
//========================================================================
@ -409,22 +387,6 @@ GLFWAPI int glfwIsWindow(GLFWwindow handle)
}
//========================================================================
// Returns GL_TRUE if the specified window handle is an actual window
//========================================================================
GLFWAPI GLFWwindow glfwGetCurrentWindow(void)
{
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return GL_FALSE;
}
return _glfwLibrary.currentWindow;
}
//========================================================================
// Set hints for opening the window
//========================================================================
@ -532,7 +494,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
// Clear the current context if this window's context is current
if (window == _glfwLibrary.currentWindow)
glfwMakeWindowCurrent(NULL);
glfwMakeContextCurrent(NULL);
// Clear the active window pointer if this is the active window
if (window == _glfwLibrary.activeWindow)
@ -777,6 +739,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
return window->glMajor;
case GLFW_OPENGL_VERSION_MINOR:
return window->glMinor;
case GLFW_OPENGL_REVISION:
return window->glRevision;
case GLFW_OPENGL_FORWARD_COMPAT:
return window->glForward;
case GLFW_OPENGL_DEBUG_CONTEXT:

View File

@ -1,30 +0,0 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src
${GLFW_INCLUDE_DIR})
set(libglfw_SOURCES ${common_SOURCES}
x11_enable.c
x11_fullscreen.c
x11_gamma.c
x11_init.c
x11_joystick.c
x11_keysym2unicode.c
x11_opengl.c
x11_time.c
x11_window.c)
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)
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)

View File

@ -1,11 +0,0 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: GLFW
Description: A portable library for OpenGL development
Version: 3.0
URL: http://www.glfw.org/
Libs: -L${libdir} -lglfw @GLFW_LIBRARIES@
Cflags: -I${includedir}

View File

@ -56,6 +56,23 @@ void (*glXGetProcAddressEXT(const GLubyte* procName))();
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{
if (window)
{
glXMakeCurrent(_glfwLibrary.X11.display,
window->X11.handle,
window->GLX.context);
}
else
glXMakeCurrent(_glfwLibrary.X11.display, None, NULL);
}
//========================================================================
// Swap OpenGL buffers
//========================================================================
@ -116,3 +133,16 @@ void* _glfwPlatformGetProcAddress(const char* procname)
return (void*) _glfw_glXGetProcAddress((const GLubyte*) procname);
}
//========================================================================
// Copies the specified OpenGL state categories from src to dst
//========================================================================
void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{
glXCopyContext(_glfwLibrary.X11.display,
src->GLX.context,
dst->GLX.context,
mask);
}

View File

@ -277,7 +277,8 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{
if (!window->GLX.has_GLX_SGIX_fbconfig)
{
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: GLXFBConfig support not found");
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"X11/GLX: GLXFBConfig support not found");
return NULL;
}
}
@ -290,16 +291,20 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
&count);
if (!count)
{
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: No GLXFBConfigs returned");
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"X11/GLX: No GLXFBConfigs returned");
return NULL;
}
}
else
{
fbconfigs = glXGetFBConfigs(_glfwLibrary.X11.display, _glfwLibrary.X11.screen, &count);
fbconfigs = glXGetFBConfigs(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
&count);
if (!count)
{
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: No GLXFBConfigs returned");
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"X11/GLX: No GLXFBConfigs returned");
return NULL;
}
}
@ -307,7 +312,8 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
if (!result)
{
_glfwSetError(GLFW_OUT_OF_MEMORY, "X11/GLX: Failed to allocate _GLFWfbconfig array");
_glfwSetError(GLFW_OUT_OF_MEMORY,
"X11/GLX: Failed to allocate _GLFWfbconfig array");
return NULL;
}
@ -320,7 +326,9 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
continue;
}
if (!(getFBConfigAttrib(window, fbconfigs[i], GLX_RENDER_TYPE) & GLX_RGBA_BIT))
if (!(getFBConfigAttrib(window,
fbconfigs[i],
GLX_RENDER_TYPE) & GLX_RGBA_BIT))
{
// Only consider RGBA GLXFBConfigs
continue;
@ -408,7 +416,8 @@ static int createContext(_GLFWwindow* window,
if (fbconfig == NULL)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to retrieve the selected GLXFBConfig");
_glfwSetError(GLFW_PLATFORM_ERROR,
"X11/GLX: Failed to retrieve the selected GLXFBConfig");
return GL_FALSE;
}
}
@ -429,7 +438,8 @@ static int createContext(_GLFWwindow* window,
{
XFree(fbconfig);
_glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to retrieve visual for GLXFBConfig");
_glfwSetError(GLFW_PLATFORM_ERROR,
"X11/GLX: Failed to retrieve visual for GLXFBConfig");
return GL_FALSE;
}
@ -467,14 +477,18 @@ static int createContext(_GLFWwindow* window,
if (!window->GLX.has_GLX_ARB_create_context_profile)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "X11/GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"X11/GLX: An OpenGL profile requested but "
"GLX_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
!window->GLX.has_GLX_EXT_create_context_es2_profile)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "X11/GLX: OpenGL ES 2.x profile requested but GLX_EXT_create_context_es2_profile is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"X11/GLX: OpenGL ES 2.x profile requested but "
"GLX_EXT_create_context_es2_profile is unavailable");
return GL_FALSE;
}
@ -494,7 +508,10 @@ static int createContext(_GLFWwindow* window,
if (!window->GLX.has_GLX_ARB_create_context_robustness)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "X11/GLX: An OpenGL robustness strategy was requested but GLX_ARB_create_context_robustness is unavailable");
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"X11/GLX: An OpenGL robustness strategy was "
"requested but GLX_ARB_create_context_robustness "
"is unavailable");
return GL_FALSE;
}
@ -503,7 +520,10 @@ static int createContext(_GLFWwindow* window,
else if (wndconfig->glRobustness == GLFW_OPENGL_LOSE_CONTEXT_ON_RESET)
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
setGLXattrib(attribs, index, GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy);
setGLXattrib(attribs,
index,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
strategy);
}
setGLXattrib(attribs, index, None, None);
@ -551,7 +571,8 @@ static int createContext(_GLFWwindow* window,
{
// TODO: Handle all the various error codes here
_glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to create OpenGL context");
_glfwSetError(GLFW_PLATFORM_ERROR,
"X11/GLX: Failed to create OpenGL context");
return GL_FALSE;
}
@ -699,7 +720,8 @@ static GLboolean createWindow(_GLFWwindow* window,
{
// TODO: Handle all the various error codes here
_glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to create window");
_glfwSetError(GLFW_PLATFORM_ERROR,
"X11/GLX: Failed to create window");
return GL_FALSE;
}
}
@ -760,7 +782,8 @@ static GLboolean createWindow(_GLFWwindow* window,
XWMHints* hints = XAllocWMHints();
if (!hints)
{
_glfwSetError(GLFW_OUT_OF_MEMORY, "X11/GLX: Failed to allocate WM hints");
_glfwSetError(GLFW_OUT_OF_MEMORY,
"X11/GLX: Failed to allocate WM hints");
return GL_FALSE;
}
@ -776,7 +799,8 @@ static GLboolean createWindow(_GLFWwindow* window,
XSizeHints* hints = XAllocSizeHints();
if (!hints)
{
_glfwSetError(GLFW_OUT_OF_MEMORY, "X11/GLX: Failed to allocate size hints");
_glfwSetError(GLFW_OUT_OF_MEMORY,
"X11/GLX: Failed to allocate size hints");
return GL_FALSE;
}
@ -1424,23 +1448,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
}
//========================================================================
// Make the OpenGL context associated with the specified window current
//========================================================================
void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window)
{
if (window)
{
glXMakeCurrent(_glfwLibrary.X11.display,
window->X11.handle,
window->GLX.context);
}
else
glXMakeCurrent(_glfwLibrary.X11.display, None, NULL);
}
//========================================================================
// Properly kill the window/video display
//========================================================================
@ -1505,7 +1512,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
if (window->mode == GLFW_FULLSCREEN)
{
// Get the closest matching video mode for the specified window size
mode = _glfwGetClosestVideoMode(_glfwLibrary.X11.screen, &width, &height, &rate);
mode = _glfwGetClosestVideoMode(_glfwLibrary.X11.screen,
&width, &height, &rate);
}
if (window->windowNoResize)
@ -1670,7 +1678,8 @@ void _glfwPlatformRefreshWindowParams(void)
{
#if defined(_GLFW_HAS_XF86VIDMODE)
// Use the XF86VidMode extension to get current video mode
XF86VidModeGetModeLine(_glfwLibrary.X11.display, _glfwLibrary.X11.screen,
XF86VidModeGetModeLine(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
&dotclock, &modeline);
pixels_per_second = 1000.0f * (float) dotclock;
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;

View File

@ -80,7 +80,7 @@ static GLuint create_texture(void)
static void draw_quad(GLuint texture)
{
int width, height;
glfwGetWindowSize(glfwGetCurrentWindow(), &width, &height);
glfwGetWindowSize(glfwGetCurrentContext(), &width, &height);
glViewport(0, 0, width, height);
@ -148,11 +148,11 @@ int main(int argc, char** argv)
while (glfwIsWindow(windows[0]) && glfwIsWindow(windows[1]))
{
glfwMakeWindowCurrent(windows[0]);
glfwMakeContextCurrent(windows[0]);
draw_quad(texture);
glfwSwapBuffers();
glfwMakeWindowCurrent(windows[1]);
glfwMakeContextCurrent(windows[1]);
draw_quad(texture);
glfwSwapBuffers();

View File

@ -229,7 +229,9 @@ int main(int argc, char** argv)
printf("OpenGL context version string: \"%s\"\n", glGetString(GL_VERSION));
glfwGetGLVersion(&major, &minor, &revision);
major = glfwGetWindowParam(window, GLFW_OPENGL_VERSION_MAJOR);
minor = glfwGetWindowParam(window, GLFW_OPENGL_VERSION_MINOR);
revision = glfwGetWindowParam(window, GLFW_OPENGL_REVISION);
printf("OpenGL context version parsed by GLFW: %u.%u.%u\n", major, minor, revision);

View File

@ -73,7 +73,7 @@ int main(void)
{
for (i = 0; i < 4; i++)
{
glfwMakeWindowCurrent(windows[i]);
glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers();
}