1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

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

This commit is contained in:
Camilla Berglund 2011-07-27 18:30:52 +02:00
commit 95cddf85e1
26 changed files with 378 additions and 155 deletions

View File

@ -155,11 +155,14 @@ install(FILES COPYING.txt readme.html
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Uninstall operation # Uninstall operation
# Don't generate this target if a higher-level project already has
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if(NOT TARGET uninstall)
configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY) ${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
add_custom_target(uninstall add_custom_target(uninstall
${CMAKE_COMMAND} -P ${CMAKE_COMMAND} -P
${GLFW_BINARY_DIR}/cmake_uninstall.cmake) ${GLFW_BINARY_DIR}/cmake_uninstall.cmake)
endif()

View File

@ -34,12 +34,18 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE. * DAMAGE.
*/ */
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "getopt.h" #include "getopt.h"
/* 2011-07-27 Camilla Berglund <elmindreda@elmindreda.org>
*
* Added _CRT_SECURE_NO_WARNINGS macro.
*/
/* 2009-10-12 Camilla Berglund <elmindreda@elmindreda.org> /* 2009-10-12 Camilla Berglund <elmindreda@elmindreda.org>
* *
* Removed unused global static variable 'ID'. * Removed unused global static variable 'ID'.

View File

@ -23,6 +23,8 @@
// //
//======================================================================== //========================================================================
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
@ -422,7 +424,7 @@ static void update_map(int num_iter)
if (fabs(pd) <= 1.0f) if (fabs(pd) <= 1.0f)
{ {
/* tx,tz is within the circle */ /* tx,tz is within the circle */
GLfloat new_height = disp + (cos(pd*3.14f)*disp); GLfloat new_height = disp + (float) (cos(pd*3.14f)*disp);
map_vertices[1][ii] += new_height; map_vertices[1][ii] += new_height;
} }
} }

40
include/GL/glfw3.h Normal file → Executable file
View File

@ -75,7 +75,7 @@ extern "C" {
#else #else
#define APIENTRY #define APIENTRY
#endif #endif
#define GL_APIENTRY_DEFINED #define GLFW_APIENTRY_DEFINED
#endif /* APIENTRY */ #endif /* APIENTRY */
@ -96,7 +96,7 @@ extern "C" {
/* Others (e.g. MinGW, Cygwin) */ /* Others (e.g. MinGW, Cygwin) */
#define WINGDIAPI extern #define WINGDIAPI extern
#endif #endif
#define GL_WINGDIAPI_DEFINED #define GLFW_WINGDIAPI_DEFINED
#endif /* WINGDIAPI */ #endif /* WINGDIAPI */
/* Some <GL/glu.h> files also need CALLBACK defined */ /* Some <GL/glu.h> files also need CALLBACK defined */
@ -112,7 +112,7 @@ extern "C" {
/* Other Windows compilers */ /* Other Windows compilers */
#define CALLBACK __stdcall #define CALLBACK __stdcall
#endif #endif
#define GLU_CALLBACK_DEFINED #define GLFW_CALLBACK_DEFINED
#endif /* CALLBACK */ #endif /* CALLBACK */
/* Microsoft Visual C++, Borland C++ and Pelles C <GL*glu.h> needs wchar_t */ /* Microsoft Visual C++, Borland C++ and Pelles C <GL*glu.h> needs wchar_t */
@ -147,6 +147,10 @@ extern "C" {
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ /* -------------------- 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 /* 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 * 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 * solves the problem with Windows <GL/gl.h> and <GL/glu.h> needing some
@ -533,9 +537,7 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
/* Window handling */ /* Window handling */
GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share); GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share);
GLFWAPI void glfwOpenWindowHint(int target, int hint); GLFWAPI void glfwOpenWindowHint(int target, int hint);
GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window);
GLFWAPI int glfwIsWindow(GLFWwindow window); GLFWAPI int glfwIsWindow(GLFWwindow window);
GLFWAPI GLFWwindow glfwGetCurrentWindow(void);
GLFWAPI void glfwCloseWindow(GLFWwindow window); GLFWAPI void glfwCloseWindow(GLFWwindow window);
GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title); GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title);
GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height); GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height);
@ -579,17 +581,43 @@ GLFWAPI double glfwGetTime(void);
GLFWAPI void glfwSetTime(double time); GLFWAPI void glfwSetTime(double time);
/* OpenGL support */ /* OpenGL support */
GLFWAPI void glfwMakeContextCurrent(GLFWwindow window);
GLFWAPI GLFWwindow glfwGetCurrentContext(void);
GLFWAPI void glfwSwapBuffers(void); GLFWAPI void glfwSwapBuffers(void);
GLFWAPI void glfwSwapInterval(int interval); GLFWAPI void glfwSwapInterval(int interval);
GLFWAPI int glfwExtensionSupported(const char* extension); GLFWAPI int glfwExtensionSupported(const char* extension);
GLFWAPI void* glfwGetProcAddress(const char* procname); GLFWAPI void* glfwGetProcAddress(const char* procname);
GLFWAPI void glfwCopyGLState(GLFWwindow src, GLFWwindow dst, unsigned long mask); GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
/* Enable/disable functions */ /* Enable/disable functions */
GLFWAPI void glfwEnable(GLFWwindow window, int token); GLFWAPI void glfwEnable(GLFWwindow window, int token);
GLFWAPI void glfwDisable(GLFWwindow window, int token); GLFWAPI void glfwDisable(GLFWwindow window, int token);
/*************************************************************************
* Global definition cleanup
*************************************************************************/
/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
#ifdef GLFW_APIENTRY_DEFINED
#undef APIENTRY
#undef GLFW_APIENTRY_DEFINED
#endif
#ifdef GLFW_WINGDIAPI_DEFINED
#undef WINGDIAPI
#undef GLFW_WINGDIAPI_DEFINED
#endif
#ifdef GLFW_CALLBACK_DEFINED
#undef CALLBACK
#undef GLFW_CALLBACK_DEFINED
#endif
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -263,7 +263,7 @@ version of GLFW.</p>
<ul> <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>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>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>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>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> <li>Added <code>glfwSetWindowUserPointer</code> and <code>glfwGetWindowUserPointer</code> functions for per-window user pointers</li>
@ -271,9 +271,9 @@ version of GLFW.</p>
<li>Added <code>glfwGetWindowPos</code> function for querying the position of the specified window</li> <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>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li> <li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
<li>Added <code>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>glfwInitWithModels</code> function and <code>GLFWallocator</code> and <code>GLFWthreadmodel</code> types for pluggable memory allocation and threading models</li>
<li>Added <code>glfwCopyGLState</code> function for copying OpenGL state categories between contexts</li> <li>Added <code>glfwCopyContext</code> function for copying OpenGL state categories between contexts</li>
<li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li> <li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li>
<li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li> <li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li>
<li>Added <code>GLFW_OPENGL_REVISION</code> window parameter to make up for removal of <code>glfwGetGLVersion</code></li> <li>Added <code>GLFW_OPENGL_REVISION</code> window parameter to make up for removal of <code>glfwGetGLVersion</code></li>
@ -303,6 +303,7 @@ version of GLFW.</p>
<li>Bugfix: The default OpenGL version in the <code>version</code> test was set to 1.1</li> <li>Bugfix: The default OpenGL version in the <code>version</code> test was set to 1.1</li>
<li>Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation</li> <li>Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation</li>
<li>Bugfix: The FSAA test did not check for the availability of <code>GL_ARB_multisample</code></li> <li>Bugfix: The FSAA test did not check for the availability of <code>GL_ARB_multisample</code></li>
<li>[Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above</li>
<li>[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable</li> <li>[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable</li>
<li>[X11] Added support for the <code>GLX_EXT_swap_control</code> extension as an alternative to <code>GLX_SGI_swap_control</code></li> <li>[X11] Added support for the <code>GLX_EXT_swap_control</code> extension as an alternative to <code>GLX_SGI_swap_control</code></li>
<li>[X11] Bugfix: Calling <code>glXCreateContextAttribsARB</code> with an unavailable OpenGL version caused the application to terminate with a <code>BadMatch</code> Xlib error</li> <li>[X11] Bugfix: Calling <code>glXCreateContextAttribsARB</code> with an unavailable OpenGL version caused the application to terminate with a <code>BadMatch</code> Xlib error</li>

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

@ -34,6 +34,19 @@
////// GLFW platform API ////// ////// 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 // Swap buffers
//======================================================================== //========================================================================
@ -90,7 +103,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst // Copies the specified OpenGL state categories from src to dst
//======================================================================== //========================================================================
void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask) void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{ {
[dst->NSGL.context copyAttributesFromContext:src->NSGL.context withMask:mask]; [dst->NSGL.context copyAttributesFromContext:src->NSGL.context withMask:mask];
} }

View File

@ -476,14 +476,37 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
const _GLFWwndconfig *wndconfig, const _GLFWwndconfig *wndconfig,
const _GLFWfbconfig *fbconfig) const _GLFWfbconfig *fbconfig)
{ {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
// Fail if OpenGL 3.3 or above was requested
if( wndconfig->glMajor > 3 || wndconfig->glMajor == 3 && wndconfig->glMinor > 2 )
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Cocoa/NSOpenGL: The targeted version of Mac OS X does "
"not support OpenGL version 3.3 or above");
return GL_FALSE;
}
if( wndconfig->glProfile )
{
// Fail if a profile other than core was explicitly selected
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");
return GL_FALSE;
}
}
#else
// Fail if OpenGL 3.0 or above was requested // Fail if OpenGL 3.0 or above was requested
if( wndconfig->glMajor > 2 ) if( wndconfig->glMajor > 2 )
{ {
_glfwSetError(GLFW_VERSION_UNAVAILABLE, _glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Cocoa/NSOpenGL: Mac OS X does not support OpenGL " "Cocoa/NSOpenGL: The targeted version of Mac OS X does "
"version 3.0 or above"); "not support OpenGL version 3.0 or above");
return GL_FALSE; return GL_FALSE;
} }
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
// Fail if a robustness strategy was requested // Fail if a robustness strategy was requested
if (wndconfig->glRobustness) if (wndconfig->glRobustness)
@ -591,7 +614,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
unsigned int attribute_count = 0; unsigned int attribute_count = 0;
#define ADD_ATTR(x) attributes[attribute_count++] = x #define ADD_ATTR(x) { attributes[attribute_count++] = x; }
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); } #define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
// Arbitrary array size here // Arbitrary array size here
@ -607,6 +630,11 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID())); CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()));
} }
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if( wndconfig->glMajor > 2 )
ADD_ATTR2( NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core );
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits); ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
if (fbconfig->alphaBits > 0) if (fbconfig->alphaBits > 0)
@ -675,7 +703,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
withOptions:nil]; withOptions:nil];
} }
glfwMakeWindowCurrent(window); glfwMakeContextCurrent(window);
NSPoint point = [[NSCursor currentCursor] hotSpot]; NSPoint point = [[NSCursor currentCursor] hotSpot];
window->mousePosX = point.x; window->mousePosX = point.x;
@ -686,18 +714,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
return GL_TRUE; 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 // Properly kill the window / video display
@ -859,10 +875,9 @@ void _glfwPlatformRefreshWindowParams(void)
forVirtualScreen:0]; forVirtualScreen:0];
window->samples = value; window->samples = value;
// These are forced to false as long as Mac OS X lacks support for OpenGL 3.0+ // These this is forced to false as long as Mac OS X lacks support for
window->glForward = GL_FALSE; // requesting debug contexts
window->glDebug = GL_FALSE; window->glDebug = GL_FALSE;
window->glProfile = 0;
} }
//======================================================================== //========================================================================

View File

@ -138,7 +138,8 @@ GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode)
if (mode == NULL) if (mode == NULL)
{ {
_glfwSetError(GLFW_INVALID_VALUE, "glfwGetDesktopMode: Parameter 'mode' cannot be NULL"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwGetDesktopMode: Parameter 'mode' cannot be NULL");
return; return;
} }

View File

@ -57,7 +57,7 @@ GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain)
float value = (float) i / ((float) (size - 1)); float value = (float) i / ((float) (size - 1));
// Apply gamma // Apply gamma
value = pow(value, 1.f / gamma) * 65535.f + 0.5f; value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f;
// Apply gain // Apply gain
value = gain * (value - 32767.5f) + 32767.5f; value = gain * (value - 32767.5f) + 32767.5f;

View File

@ -53,7 +53,8 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
if (key < 0 || key > GLFW_KEY_LAST) if (key < 0 || key > GLFW_KEY_LAST)
{ {
// TODO: Decide whether key is a value or enum // TODO: Decide whether key is a value or enum
_glfwSetError(GLFW_INVALID_VALUE, "glfwGetKey: The specified key is invalid"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwGetKey: The specified key is invalid");
return GLFW_RELEASE; return GLFW_RELEASE;
} }
@ -85,7 +86,8 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
// Is it a valid mouse button? // Is it a valid mouse button?
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
{ {
_glfwSetError(GLFW_INVALID_ENUM, "glfwGetMouseButton: The specified mouse button is invalid"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwGetMouseButton: The specified mouse button is invalid");
return GLFW_RELEASE; return GLFW_RELEASE;
} }

View File

@ -296,7 +296,6 @@ void _glfwPlatformSetTime(double time);
// Window management // Window management
int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig); int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig);
void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window);
void _glfwPlatformCloseWindow(_GLFWwindow* window); void _glfwPlatformCloseWindow(_GLFWwindow* window);
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title); void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height); void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
@ -312,12 +311,13 @@ void _glfwPlatformPollEvents(void);
void _glfwPlatformWaitEvents(void); void _glfwPlatformWaitEvents(void);
// OpenGL context management // OpenGL context management
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
void _glfwPlatformSwapBuffers(void); void _glfwPlatformSwapBuffers(void);
void _glfwPlatformSwapInterval(int interval); void _glfwPlatformSwapInterval(int interval);
void _glfwPlatformRefreshWindowParams(void); void _glfwPlatformRefreshWindowParams(void);
int _glfwPlatformExtensionSupported(const char* extension); int _glfwPlatformExtensionSupported(const char* extension);
void* _glfwPlatformGetProcAddress(const char* procname); void* _glfwPlatformGetProcAddress(const char* procname);
void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask); void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
//======================================================================== //========================================================================

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

View File

@ -255,25 +255,29 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0) if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
{ {
// OpenGL 1.0 is the smallest valid version // OpenGL 1.0 is the smallest valid version
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5) if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5)
{ {
// OpenGL 1.x series ended with version 1.5 // OpenGL 1.x series ended with version 1.5
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 1) else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 1)
{ {
// OpenGL 2.x series ended with version 2.1 // OpenGL 2.x series ended with version 2.1
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 3) else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 3)
{ {
// OpenGL 3.x series ended with version 3.3 // OpenGL 3.x series ended with version 3.3
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
else else
@ -290,7 +294,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
// compatibility with future updates to OpenGL ES, we allow // compatibility with future updates to OpenGL ES, we allow
// everything 2.x and let the driver report invalid 2.x versions // everything 2.x and let the driver report invalid 2.x versions
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL ES 2.x version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL ES 2.x version requested");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -299,16 +304,20 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE && if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE &&
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE) wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
{ {
_glfwSetError(GLFW_INVALID_ENUM, "glfwOpenWindow: Invalid OpenGL profile requested"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwOpenWindow: Invalid OpenGL profile requested");
return GL_FALSE; return GL_FALSE;
} }
if (wndconfig->glMajor < 3 || (wndconfig->glMajor == 3 && wndconfig->glMinor < 2)) if (wndconfig->glMajor < 3 ||
(wndconfig->glMajor == 3 && wndconfig->glMinor < 2))
{ {
// Desktop OpenGL context profiles are only defined for version 3.2 // Desktop OpenGL context profiles are only defined for version 3.2
// and above // and above
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Context profiles only exist for OpenGL version 3.2 and above"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Context profiles only exist for "
"OpenGL version 3.2 and above");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -316,7 +325,9 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glForward && wndconfig->glMajor < 3) if (wndconfig->glForward && wndconfig->glMajor < 3)
{ {
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Forward compatibility only exist for OpenGL version 3.0 and above"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Forward compatibility only exist for "
"OpenGL version 3.0 and above");
return GL_FALSE; return GL_FALSE;
} }
@ -325,7 +336,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glRobustness != GLFW_OPENGL_NO_RESET_NOTIFICATION && if (wndconfig->glRobustness != GLFW_OPENGL_NO_RESET_NOTIFICATION &&
wndconfig->glRobustness != GLFW_OPENGL_LOSE_CONTEXT_ON_RESET) wndconfig->glRobustness != GLFW_OPENGL_LOSE_CONTEXT_ON_RESET)
{ {
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL robustness mode requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL robustness mode requested");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -342,9 +354,36 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
{ {
parseGLVersion(&window->glMajor, &window->glMinor, &window->glRevision); parseGLVersion(&window->glMajor, &window->glMinor, &window->glRevision);
// As these are hard constraints when non-zero, we can simply copy them // Read back forward-compatibility flag
window->glProfile = wndconfig->glProfile; {
window->glForward = wndconfig->glForward; window->glForward = GL_FALSE;
if (window->glMajor >= 3)
{
GLint flags;
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
window->glForward = GL_TRUE;
}
}
// Read back OpenGL context profile
{
window->glProfile = 0;
if (window->glMajor > 3 || (window->glMajor == 3 && window->glMinor >= 2))
{
GLint mask;
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
window->glProfile = GLFW_OPENGL_CORE_PROFILE;
}
}
window->glRobustness = wndconfig->glRobustness; window->glRobustness = wndconfig->glRobustness;
if (window->glMajor < wndconfig->glMajor || if (window->glMajor < wndconfig->glMajor ||
@ -358,7 +397,8 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
// For API consistency, we emulate the behavior of the // For API consistency, we emulate the behavior of the
// {GLX|WGL}_ARB_create_context extension and fail here // {GLX|WGL}_ARB_create_context extension and fail here
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "glfwOpenWindow: The requested OpenGL version is not available"); _glfwSetError(GLFW_VERSION_UNAVAILABLE,
"glfwOpenWindow: The requested OpenGL version is not available");
return GL_FALSE; return GL_FALSE;
} }
@ -375,7 +415,9 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
// on X11/GLX using custom build systems, as it needs explicit // on X11/GLX using custom build systems, as it needs explicit
// configuration in order to work // configuration in order to work
_glfwSetError(GLFW_PLATFORM_ERROR, "glfwOpenWindow: Entry point retrieval is broken; see the build documentation for your platform"); _glfwSetError(GLFW_PLATFORM_ERROR,
"glfwOpenWindow: Entry point retrieval is broken; see "
"the build documentation for your platform");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -423,6 +465,44 @@ int _glfwStringInExtensionString(const char* string,
////// GLFW public API ////// ////// 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) // Swap buffers (double-buffering)
//======================================================================== //========================================================================
@ -560,7 +640,7 @@ GLFWAPI void* glfwGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst // Copies the specified OpenGL state categories from src to dst
//======================================================================== //========================================================================
GLFWAPI void glfwCopyGLState(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mask) GLFWAPI void glfwCopyContext(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mask)
{ {
_GLFWwindow* src; _GLFWwindow* src;
_GLFWwindow* dst; _GLFWwindow* dst;
@ -576,10 +656,11 @@ GLFWAPI void glfwCopyGLState(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mas
if (_glfwLibrary.currentWindow == dst) if (_glfwLibrary.currentWindow == dst)
{ {
_glfwSetError(GLFW_INVALID_VALUE, "Cannot copy OpenGL state to a current context"); _glfwSetError(GLFW_INVALID_VALUE,
"Cannot copy OpenGL state to a current context");
return; return;
} }
_glfwPlatformCopyGLState(src, dst, mask); _glfwPlatformCopyContext(src, dst, mask);
} }

View File

@ -265,6 +265,9 @@ void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
// Return desktop mode parameters // Return desktop mode parameters
mode->width = dm.dmPelsWidth; mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight; mode->height = dm.dmPelsHeight;
_glfwSplitBPP(dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits); _glfwSplitBPP(dm.dmBitsPerPel,
&mode->redBits,
&mode->greenBits,
&mode->blueBits);
} }

View File

@ -35,6 +35,19 @@
////// GLFW platform API ////// ////// 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) // Swap buffers (double-buffering)
//======================================================================== //========================================================================
@ -108,9 +121,12 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst // Copies the specified OpenGL state categories from src to dst
//======================================================================== //========================================================================
void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask) void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{ {
if (!wglCopyContext(src->WGL.context, dst->WGL.context, mask)) if (!wglCopyContext(src->WGL.context, dst->WGL.context, mask))
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to copy OpenGL context attributes"); {
_glfwSetError(GLFW_PLATFORM_ERROR,
"Win32/WGL: Failed to copy OpenGL context attributes");
}
} }

View File

@ -34,13 +34,16 @@
// We don't need all the fancy stuff // We don't need all the fancy stuff
#define NOMINMAX #define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN #define VC_EXTRALEAN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include "../../include/GL/wglext.h" #include "../include/GL/wglext.h"
//======================================================================== //========================================================================

View File

@ -1342,7 +1342,7 @@ static int createWindow(_GLFWwindow* window,
if (!createContext(window, wndconfig, pixelFormat)) if (!createContext(window, wndconfig, pixelFormat))
return GL_FALSE; return GL_FALSE;
glfwMakeWindowCurrent(window); glfwMakeContextCurrent(window);
initWGLExtensions(window); initWGLExtensions(window);
@ -1365,7 +1365,7 @@ static void destroyWindow(_GLFWwindow* window)
// This is duplicated from glfwCloseWindow // This is duplicated from glfwCloseWindow
// TODO: Stop duplicating code // TODO: Stop duplicating code
if (window == _glfwLibrary.currentWindow) if (window == _glfwLibrary.currentWindow)
glfwMakeWindowCurrent(NULL); glfwMakeContextCurrent(NULL);
// This is duplicated from glfwCloseWindow // This is duplicated from glfwCloseWindow
// TODO: Stop duplicating code // TODO: Stop duplicating code
@ -1521,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 // Properly kill the window / video display
//======================================================================== //========================================================================
@ -1569,7 +1556,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{ {
int bpp, newMode = 0, refresh; //int bpp, refresh;
int newMode = 0;
GLboolean sizeChanged = GL_FALSE; GLboolean sizeChanged = GL_FALSE;
if (window->mode == GLFW_FULLSCREEN) if (window->mode == GLFW_FULLSCREEN)
@ -1660,7 +1648,7 @@ void _glfwPlatformRefreshWindowParams(void)
{ {
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
DEVMODE dm; DEVMODE dm;
int pixelFormat, mode; int pixelFormat;
_GLFWwindow* window = _glfwLibrary.currentWindow; _GLFWwindow* window = _glfwLibrary.currentWindow;

View File

@ -289,7 +289,8 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN) if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN)
{ {
_glfwSetError(GLFW_INVALID_ENUM, "glfwOpenWindow: Invalid enum for 'mode' parameter"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwOpenWindow: Invalid enum for 'mode' parameter");
return GL_FALSE; return GL_FALSE;
} }
@ -314,7 +315,8 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow)); window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow));
if (!window) if (!window)
{ {
_glfwSetError(GLFW_OUT_OF_MEMORY, "glfwOpenWindow: Failed to allocate window structure"); _glfwSetError(GLFW_OUT_OF_MEMORY,
"glfwOpenWindow: Failed to allocate window structure");
return NULL; return NULL;
} }
@ -336,7 +338,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
} }
// Cache the actual (as opposed to desired) window parameters // Cache the actual (as opposed to desired) window parameters
glfwMakeWindowCurrent(window); glfwMakeContextCurrent(window);
_glfwPlatformRefreshWindowParams(); _glfwPlatformRefreshWindowParams();
if (!_glfwIsValidContext(window, &wndconfig)) if (!_glfwIsValidContext(window, &wndconfig))
@ -359,28 +361,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 // Returns GL_TRUE if the specified window handle is an actual window
//======================================================================== //========================================================================
@ -409,22 +389,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 // Set hints for opening the window
//======================================================================== //========================================================================
@ -532,7 +496,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
// Clear the current context if this window's context is current // Clear the current context if this window's context is current
if (window == _glfwLibrary.currentWindow) if (window == _glfwLibrary.currentWindow)
glfwMakeWindowCurrent(NULL); glfwMakeContextCurrent(NULL);
// Clear the active window pointer if this is the active window // Clear the active window pointer if this is the active window
if (window == _glfwLibrary.activeWindow) if (window == _glfwLibrary.activeWindow)
@ -788,7 +752,9 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
case GLFW_OPENGL_ROBUSTNESS: case GLFW_OPENGL_ROBUSTNESS:
return window->glRobustness; return window->glRobustness;
default: default:
_glfwSetError(GLFW_INVALID_ENUM, "glfwGetWindowParam: Invalid enum value for 'param' parameter"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwGetWindowParam: Invalid enum value for 'param' "
"parameter");
return 0; return 0;
} }
} }

View File

@ -401,7 +401,8 @@ static GLboolean initDisplay(void)
&_glfwLibrary.X11.RandR.majorVersion, &_glfwLibrary.X11.RandR.majorVersion,
&_glfwLibrary.X11.RandR.minorVersion)) &_glfwLibrary.X11.RandR.minorVersion))
{ {
_glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to query RandR version"); _glfwSetError(GLFW_PLATFORM_ERROR,
"X11/GLX: Failed to query RandR version");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -420,7 +421,8 @@ static GLboolean initDisplay(void)
&_glfwLibrary.X11.glxMajor, &_glfwLibrary.X11.glxMajor,
&_glfwLibrary.X11.glxMinor)) &_glfwLibrary.X11.glxMinor))
{ {
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: Failed to query GLX version"); _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"X11/GLX: Failed to query GLX version");
return GL_FALSE; return GL_FALSE;
} }
@ -475,7 +477,8 @@ static void initGammaRamp(void)
// This is probably Nvidia RandR with broken gamma support // This is probably Nvidia RandR with broken gamma support
// Flag it as useless and try Xf86VidMode below, if available // Flag it as useless and try Xf86VidMode below, if available
_glfwLibrary.X11.RandR.gammaBroken = GL_TRUE; _glfwLibrary.X11.RandR.gammaBroken = GL_TRUE;
fprintf(stderr, "Ignoring broken nVidia implementation of RandR 1.2+ gamma\n"); fprintf(stderr,
"Ignoring broken nVidia implementation of RandR 1.2+ gamma\n");
} }
XRRFreeScreenResources(rr); XRRFreeScreenResources(rr);
@ -515,14 +518,17 @@ static Cursor createNULLCursor(void)
// TODO: Add error checks // TODO: Add error checks
cursormask = XCreatePixmap(_glfwLibrary.X11.display, _glfwLibrary.X11.root, 1, 1, 1); cursormask = XCreatePixmap(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
1, 1, 1);
xgc.function = GXclear; xgc.function = GXclear;
gc = XCreateGC(_glfwLibrary.X11.display, cursormask, GCFunction, &xgc); gc = XCreateGC(_glfwLibrary.X11.display, cursormask, GCFunction, &xgc);
XFillRectangle(_glfwLibrary.X11.display, cursormask, gc, 0, 0, 1, 1); XFillRectangle(_glfwLibrary.X11.display, cursormask, gc, 0, 0, 1, 1);
col.pixel = 0; col.pixel = 0;
col.red = 0; col.red = 0;
col.flags = 4; col.flags = 4;
cursor = XCreatePixmapCursor(_glfwLibrary.X11.display, cursormask, cursormask, cursor = XCreatePixmapCursor(_glfwLibrary.X11.display,
cursormask, cursormask,
&col, &col, 0, 0); &col, &col, 0, 0);
XFreePixmap(_glfwLibrary.X11.display, cursormask); XFreePixmap(_glfwLibrary.X11.display, cursormask);
XFreeGC(_glfwLibrary.X11.display, gc); XFreeGC(_glfwLibrary.X11.display, gc);

View File

@ -56,6 +56,23 @@ void (*glXGetProcAddressEXT(const GLubyte* procName))();
////// GLFW internal API ////// ////// 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 // Swap OpenGL buffers
//======================================================================== //========================================================================
@ -121,7 +138,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst // Copies the specified OpenGL state categories from src to dst
//======================================================================== //========================================================================
void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask) void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{ {
glXCopyContext(_glfwLibrary.X11.display, glXCopyContext(_glfwLibrary.X11.display,
src->GLX.context, src->GLX.context,

View File

@ -1448,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 // Properly kill the window/video display
//======================================================================== //========================================================================

View File

@ -31,6 +31,8 @@
// //
//======================================================================== //========================================================================
#define _CRT_SECURE_NO_WARNINGS
#include <GL/glfw3.h> #include <GL/glfw3.h>
#include <stdio.h> #include <stdio.h>

View File

@ -34,18 +34,23 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE. * DAMAGE.
*/ */
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "getopt.h" #include "getopt.h"
/* 2011-07-27 Camilla Berglund <elmindreda@elmindreda.org>
*
* Added _CRT_SECURE_NO_WARNINGS macro.
*/
/* 2009-10-12 Camilla Berglund <elmindreda@elmindreda.org> /* 2009-10-12 Camilla Berglund <elmindreda@elmindreda.org>
* *
* Removed unused global static variable 'ID'. * Removed unused global static variable 'ID'.
*/ */
char* optarg = NULL; char* optarg = NULL;
int optind = 0; int optind = 0;
int opterr = 1; int opterr = 1;

View File

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

View File

@ -66,14 +66,14 @@ int main(void)
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300); glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
glClearColor(i & 1, i >> 1, 0.0, 0.0); glClearColor((GLclampf) (i & 1), (GLclampf) (i >> 1), 0.0, 0.0);
} }
while (running) while (running)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
glfwMakeWindowCurrent(windows[i]); glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers();
} }