diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0c2eeef..06acbef0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,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()
diff --git a/examples/getopt.c b/examples/getopt.c
index b891b0a5..9d79b9a7 100644
--- a/examples/getopt.c
+++ b/examples/getopt.c
@@ -34,12 +34,18 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
+#define _CRT_SECURE_NO_WARNINGS
+
#include
#include
#include
#include "getopt.h"
+/* 2011-07-27 Camilla Berglund
+ *
+ * Added _CRT_SECURE_NO_WARNINGS macro.
+ */
/* 2009-10-12 Camilla Berglund
*
* Removed unused global static variable 'ID'.
diff --git a/examples/heightmap.c b/examples/heightmap.c
index f37c732f..1d3dd72e 100644
--- a/examples/heightmap.c
+++ b/examples/heightmap.c
@@ -23,6 +23,8 @@
//
//========================================================================
+#define _CRT_SECURE_NO_WARNINGS
+
#include
#include
#include
@@ -422,7 +424,7 @@ static void update_map(int num_iter)
if (fabs(pd) <= 1.0f)
{
/* 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;
}
}
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
old mode 100644
new mode 100755
index 63e5f17f..ab9629f1
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -75,7 +75,7 @@ extern "C" {
#else
#define APIENTRY
#endif
- #define GL_APIENTRY_DEFINED
+ #define GLFW_APIENTRY_DEFINED
#endif /* APIENTRY */
@@ -96,7 +96,7 @@ extern "C" {
/* Others (e.g. MinGW, Cygwin) */
#define WINGDIAPI extern
#endif
- #define GL_WINGDIAPI_DEFINED
+ #define GLFW_WINGDIAPI_DEFINED
#endif /* WINGDIAPI */
/* Some files also need CALLBACK defined */
@@ -112,7 +112,7 @@ extern "C" {
/* Other Windows compilers */
#define CALLBACK __stdcall
#endif
- #define GLU_CALLBACK_DEFINED
+ #define GLFW_CALLBACK_DEFINED
#endif /* CALLBACK */
/* Microsoft Visual C++, Borland C++ and Pelles C needs wchar_t */
@@ -147,6 +147,10 @@ extern "C" {
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
+/* Include the declaration of the size_t type used below.
+ */
+#include
+
/* Include standard OpenGL headers: GLFW uses GL_FALSE/GL_TRUE, and it is
* convenient for the user to only have to include . This also
* solves the problem with Windows and needing some
@@ -533,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);
@@ -579,17 +581,43 @@ 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 glfwCopyGLState(GLFWwindow src, GLFWwindow dst, unsigned long mask);
+GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
/* Enable/disable functions */
GLFWAPI void glfwEnable(GLFWwindow window, int token);
GLFWAPI void glfwDisable(GLFWwindow window, int token);
+/*************************************************************************
+ * Global definition cleanup
+ *************************************************************************/
+
+/* ------------------- 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
}
#endif
diff --git a/readme.html b/readme.html
index d1d4b031..96a892a2 100644
--- a/readme.html
+++ b/readme.html
@@ -263,7 +263,7 @@ version of GLFW.
- Added
GLFWwindow
window handle type and updated window-related functions and callbacks to take a window handle
- Added
glfwIsWindow
function for verifying that a given window handle is (still) valid
- - Added
glfwMakeWindowCurrent
function for making the context of the specified window current
+ - Added
glfwMakeContextCurrent
function for making the context of the specified window current
- Added
glfwGetError
and glfwErrorString
error reporting functions and a number of error tokens
- Added
glfwSetErrorCallback
function and GLFWerrorfun
type for receiving more specific and/or nested errors
- Added
glfwSetWindowUserPointer
and glfwGetWindowUserPointer
functions for per-window user pointers
@@ -271,9 +271,9 @@ version of GLFW.
- Added
glfwGetWindowPos
function for querying the position of the specified window
- Added
glfwSetWindowFocusCallback
function and GLFWwindowfocusfun
type for receiving window focus events
- Added
glfwSetWindowIconifyCallback
function and GLFWwindowiconifyfun
type for receiving window iconification events
- - Added
glfwGetCurrentWindow
function for retrieving the window whose OpenGL context is current
+ - Added
glfwGetCurrentContext
function for retrieving the window whose OpenGL context is current
- Added
glfwInitWithModels
function and GLFWallocator
and GLFWthreadmodel
types for pluggable memory allocation and threading models
- - Added
glfwCopyGLState
function for copying OpenGL state categories between contexts
+ - Added
glfwCopyContext
function for copying OpenGL state categories between contexts
- Added
GLFW_OPENGL_ES2_PROFILE
profile for creating OpenGL ES 2.0 contexts using the GLX_EXT_create_context_es2_profile
and WGL_EXT_create_context_es2_profile
extensions
- Added
GLFW_OPENGL_ROBUSTNESS
window hint and associated strategy tokens for GL_ARB_robustness
support
- Added
GLFW_OPENGL_REVISION
window parameter to make up for removal of glfwGetGLVersion
@@ -303,6 +303,7 @@ version of GLFW.
- Bugfix: The default OpenGL version in the
version
test was set to 1.1
- Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation
- Bugfix: The FSAA test did not check for the availability of
GL_ARB_multisample
+ - [Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above
- [Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
- [X11] Added support for the
GLX_EXT_swap_control
extension as an alternative to GLX_SGI_swap_control
- [X11] Bugfix: Calling
glXCreateContextAttribsARB
with an unavailable OpenGL version caused the application to terminate with a BadMatch
Xlib error
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 00000000..dd844fc1
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -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)
+
diff --git a/src/cocoa_opengl.m b/src/cocoa_opengl.m
index 6d93ed9f..bd3827fc 100644
--- a/src/cocoa_opengl.m
+++ b/src/cocoa_opengl.m
@@ -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
//========================================================================
@@ -90,7 +103,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// 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];
}
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 283eae32..c0832805 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -476,15 +476,38 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
const _GLFWwndconfig *wndconfig,
const _GLFWfbconfig *fbconfig)
{
- // Fail if OpenGL 3.0 or above was requested
- if (wndconfig->glMajor > 2)
+#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: Mac OS X does not support OpenGL "
- "version 3.0 or above");
+ "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
+ if( wndconfig->glMajor > 2 )
+ {
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Cocoa/NSOpenGL: The targeted version of Mac OS X does "
+ "not support OpenGL version 3.0 or above");
+ return GL_FALSE;
+ }
+#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
+
// Fail if a robustness strategy was requested
if (wndconfig->glRobustness)
{
@@ -591,7 +614,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
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); }
// Arbitrary array size here
@@ -607,6 +630,11 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
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);
if (fbconfig->alphaBits > 0)
@@ -675,7 +703,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
withOptions:nil];
}
- glfwMakeWindowCurrent(window);
+ glfwMakeContextCurrent(window);
NSPoint point = [[NSCursor currentCursor] hotSpot];
window->mousePosX = point.x;
@@ -686,18 +714,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
@@ -859,10 +875,9 @@ void _glfwPlatformRefreshWindowParams(void)
forVirtualScreen:0];
window->samples = value;
- // These are forced to false as long as Mac OS X lacks support for OpenGL 3.0+
- window->glForward = GL_FALSE;
+ // These this is forced to false as long as Mac OS X lacks support for
+ // requesting debug contexts
window->glDebug = GL_FALSE;
- window->glProfile = 0;
}
//========================================================================
diff --git a/src/fullscreen.c b/src/fullscreen.c
index 7a5c97da..7cc96bb7 100644
--- a/src/fullscreen.c
+++ b/src/fullscreen.c
@@ -138,7 +138,8 @@ GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode)
if (mode == NULL)
{
- _glfwSetError(GLFW_INVALID_VALUE, "glfwGetDesktopMode: Parameter 'mode' cannot be NULL");
+ _glfwSetError(GLFW_INVALID_VALUE,
+ "glfwGetDesktopMode: Parameter 'mode' cannot be NULL");
return;
}
diff --git a/src/gamma.c b/src/gamma.c
index 83847e10..d0c45d01 100644
--- a/src/gamma.c
+++ b/src/gamma.c
@@ -57,7 +57,7 @@ GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain)
float value = (float) i / ((float) (size - 1));
// 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
value = gain * (value - 32767.5f) + 32767.5f;
diff --git a/src/input.c b/src/input.c
index 3e0c1c5c..0f5cfaa3 100644
--- a/src/input.c
+++ b/src/input.c
@@ -53,7 +53,8 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
if (key < 0 || key > GLFW_KEY_LAST)
{
// 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;
}
@@ -85,7 +86,8 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
// Is it a valid mouse button?
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;
}
diff --git a/src/internal.h b/src/internal.h
index 2c49aa2b..19bf299a 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -296,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);
@@ -312,12 +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 _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
+void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
//========================================================================
diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.cmake
new file mode 100644
index 00000000..e69de29b
diff --git a/src/opengl.c b/src/opengl.c
index 5e465f4a..6d6f24fb 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -255,25 +255,29 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
{
// 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;
}
if (wndconfig->glMajor == 1 && wndconfig->glMinor > 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;
}
else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 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;
}
else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 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;
}
else
@@ -290,7 +294,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
// compatibility with future updates to OpenGL ES, we allow
// 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;
}
}
@@ -299,16 +304,20 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glProfile != GLFW_OPENGL_CORE_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;
}
- 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
// 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;
}
}
@@ -316,7 +325,9 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glForward && wndconfig->glMajor < 3)
{
// 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;
}
@@ -325,7 +336,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glRobustness != GLFW_OPENGL_NO_RESET_NOTIFICATION &&
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;
}
}
@@ -342,9 +354,36 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
{
parseGLVersion(&window->glMajor, &window->glMinor, &window->glRevision);
- // As these are hard constraints when non-zero, we can simply copy them
- window->glProfile = wndconfig->glProfile;
- window->glForward = wndconfig->glForward;
+ // Read back forward-compatibility flag
+ {
+ 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;
if (window->glMajor < wndconfig->glMajor ||
@@ -358,7 +397,8 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
// For API consistency, we emulate the behavior of the
// {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;
}
@@ -375,7 +415,9 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
// on X11/GLX using custom build systems, as it needs explicit
// 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;
}
}
@@ -423,6 +465,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)
//========================================================================
@@ -560,7 +640,7 @@ GLFWAPI void* glfwGetProcAddress(const char* procname)
// 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* dst;
@@ -576,10 +656,11 @@ GLFWAPI void glfwCopyGLState(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mas
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;
}
- _glfwPlatformCopyGLState(src, dst, mask);
+ _glfwPlatformCopyContext(src, dst, mask);
}
diff --git a/src/win32_fullscreen.c b/src/win32_fullscreen.c
index 24db644f..de3d898b 100644
--- a/src/win32_fullscreen.c
+++ b/src/win32_fullscreen.c
@@ -265,6 +265,9 @@ void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
// Return desktop mode parameters
mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight;
- _glfwSplitBPP(dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits);
+ _glfwSplitBPP(dm.dmBitsPerPel,
+ &mode->redBits,
+ &mode->greenBits,
+ &mode->blueBits);
}
diff --git a/src/win32_opengl.c b/src/win32_opengl.c
index d729fb51..1a7faa05 100644
--- a/src/win32_opengl.c
+++ b/src/win32_opengl.c
@@ -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)
//========================================================================
@@ -108,9 +121,12 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// 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))
- _glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to copy OpenGL context attributes");
+ {
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Win32/WGL: Failed to copy OpenGL context attributes");
+ }
}
diff --git a/src/win32_platform.h b/src/win32_platform.h
index d6a5787d..2ff73116 100644
--- a/src/win32_platform.h
+++ b/src/win32_platform.h
@@ -34,13 +34,16 @@
// We don't need all the fancy stuff
#define NOMINMAX
-#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
+#ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+#endif
+
#include
#include
-#include "../../include/GL/wglext.h"
+#include "../include/GL/wglext.h"
//========================================================================
diff --git a/src/win32_window.c b/src/win32_window.c
index 23633105..8e72c417 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -1342,7 +1342,7 @@ static int createWindow(_GLFWwindow* window,
if (!createContext(window, wndconfig, pixelFormat))
return GL_FALSE;
- glfwMakeWindowCurrent(window);
+ glfwMakeContextCurrent(window);
initWGLExtensions(window);
@@ -1365,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
@@ -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
//========================================================================
@@ -1569,7 +1556,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
- int bpp, newMode = 0, refresh;
+ //int bpp, refresh;
+ int newMode = 0;
GLboolean sizeChanged = GL_FALSE;
if (window->mode == GLFW_FULLSCREEN)
@@ -1660,7 +1648,7 @@ void _glfwPlatformRefreshWindowParams(void)
{
PIXELFORMATDESCRIPTOR pfd;
DEVMODE dm;
- int pixelFormat, mode;
+ int pixelFormat;
_GLFWwindow* window = _glfwLibrary.currentWindow;
diff --git a/src/window.c b/src/window.c
index 156460d0..82d84b87 100644
--- a/src/window.c
+++ b/src/window.c
@@ -289,7 +289,8 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
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;
}
@@ -314,7 +315,8 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow));
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;
}
@@ -336,7 +338,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 +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
//========================================================================
@@ -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
//========================================================================
@@ -532,7 +496,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)
@@ -788,7 +752,9 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
case GLFW_OPENGL_ROBUSTNESS:
return window->glRobustness;
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;
}
}
diff --git a/src/x11_init.c b/src/x11_init.c
index c2480ada..03cc617f 100644
--- a/src/x11_init.c
+++ b/src/x11_init.c
@@ -401,7 +401,8 @@ static GLboolean initDisplay(void)
&_glfwLibrary.X11.RandR.majorVersion,
&_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;
}
}
@@ -420,7 +421,8 @@ static GLboolean initDisplay(void)
&_glfwLibrary.X11.glxMajor,
&_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;
}
@@ -475,7 +477,8 @@ static void initGammaRamp(void)
// This is probably Nvidia RandR with broken gamma support
// Flag it as useless and try Xf86VidMode below, if available
_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);
@@ -515,14 +518,17 @@ static Cursor createNULLCursor(void)
// 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;
gc = XCreateGC(_glfwLibrary.X11.display, cursormask, GCFunction, &xgc);
XFillRectangle(_glfwLibrary.X11.display, cursormask, gc, 0, 0, 1, 1);
col.pixel = 0;
col.red = 0;
col.flags = 4;
- cursor = XCreatePixmapCursor(_glfwLibrary.X11.display, cursormask, cursormask,
+ cursor = XCreatePixmapCursor(_glfwLibrary.X11.display,
+ cursormask, cursormask,
&col, &col, 0, 0);
XFreePixmap(_glfwLibrary.X11.display, cursormask);
XFreeGC(_glfwLibrary.X11.display, gc);
diff --git a/src/x11_opengl.c b/src/x11_opengl.c
index 0442209b..a261d616 100644
--- a/src/x11_opengl.c
+++ b/src/x11_opengl.c
@@ -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
//========================================================================
@@ -121,7 +138,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// 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,
src->GLX.context,
diff --git a/src/x11_window.c b/src/x11_window.c
index e3e291ff..5a54f389 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -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
//========================================================================
diff --git a/tests/events.c b/tests/events.c
index ca114e33..6ae6718a 100644
--- a/tests/events.c
+++ b/tests/events.c
@@ -31,6 +31,8 @@
//
//========================================================================
+#define _CRT_SECURE_NO_WARNINGS
+
#include
#include
diff --git a/tests/getopt.c b/tests/getopt.c
index b891b0a5..712cf28a 100644
--- a/tests/getopt.c
+++ b/tests/getopt.c
@@ -34,18 +34,23 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
+#define _CRT_SECURE_NO_WARNINGS
+
#include
#include
#include
#include "getopt.h"
+/* 2011-07-27 Camilla Berglund
+ *
+ * Added _CRT_SECURE_NO_WARNINGS macro.
+ */
/* 2009-10-12 Camilla Berglund
*
* Removed unused global static variable 'ID'.
*/
-
char* optarg = NULL;
int optind = 0;
int opterr = 1;
diff --git a/tests/sharing.c b/tests/sharing.c
index 16e6eaf4..942ec2c6 100644
--- a/tests/sharing.c
+++ b/tests/sharing.c
@@ -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();
diff --git a/tests/windows.c b/tests/windows.c
index 13c76cbe..ddb8a224 100644
--- a/tests/windows.c
+++ b/tests/windows.c
@@ -66,14 +66,14 @@ int main(void)
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)
{
for (i = 0; i < 4; i++)
{
- glfwMakeWindowCurrent(windows[i]);
+ glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers();
}