mirror of
https://github.com/glfw/glfw.git
synced 2026-11-18 04:44:54 +00:00
Merge branch 'master' into multi-monitor
Conflicts: include/GL/glfw3.h src/window.c tests/glfwinfo.c
This commit is contained in:
+1
-2
@@ -85,8 +85,7 @@ int _glfwPlatformInit(void)
|
||||
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
||||
if (_glfwLibrary.NSGL.framework == NULL)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"glfwInit: Failed to locate OpenGL framework");
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR, "Failed to locate OpenGL framework");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -731,7 +731,7 @@ static GLboolean createContext(_GLFWwindow* window,
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"Cocoa/NSOpenGL: NSOpenGL does not support OpenGL ES");
|
||||
"NSOpenGL: This API does not support OpenGL ES");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
+83
-69
@@ -255,7 +255,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
|
||||
//========================================================================
|
||||
// Checks whether the client API part of the window config is sane
|
||||
// It blames glfwOpenWindow because that's the only caller
|
||||
//========================================================================
|
||||
|
||||
GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
@@ -263,39 +262,25 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
if (wndconfig->clientAPI != GLFW_OPENGL_API &&
|
||||
wndconfig->clientAPI != GLFW_OPENGL_ES_API)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_ENUM,
|
||||
"glfwCreateWindow: Invalid client API requested");
|
||||
_glfwSetError(GLFW_INVALID_ENUM, "Invalid client API requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
{
|
||||
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
|
||||
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0 ||
|
||||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 5) ||
|
||||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 1) ||
|
||||
(wndconfig->glMajor == 3 && wndconfig->glMinor > 3))
|
||||
{
|
||||
// OpenGL 1.0 is the smallest valid version
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: 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,
|
||||
"glfwCreateWindow: 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,
|
||||
"glfwCreateWindow: 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,
|
||||
"glfwCreateWindow: Invalid OpenGL version requested");
|
||||
"Invalid OpenGL version %i.%i requested",
|
||||
wndconfig->glMajor, wndconfig->glMinor);
|
||||
return GL_FALSE;
|
||||
}
|
||||
else
|
||||
@@ -309,7 +294,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_ENUM,
|
||||
"glfwCreateWindow: Invalid OpenGL profile requested");
|
||||
"Invalid OpenGL profile requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -320,7 +305,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
// and above
|
||||
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Context profiles only exist for "
|
||||
"Context profiles only exist for "
|
||||
"OpenGL version 3.2 and above");
|
||||
return GL_FALSE;
|
||||
}
|
||||
@@ -330,25 +315,24 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
{
|
||||
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Forward compatibility only exist "
|
||||
"for OpenGL version 3.0 and above");
|
||||
"Forward compatibility only exist for OpenGL "
|
||||
"version 3.0 and above");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
else if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
|
||||
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0 ||
|
||||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 1) ||
|
||||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 0))
|
||||
{
|
||||
// OpenGL ES 1.0 is the smallest valid version
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Invalid OpenGL ES version requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
if (wndconfig->glMajor == 1 && wndconfig->glMinor > 1)
|
||||
{
|
||||
// OpenGL ES 1.x series ended with version 1.1
|
||||
// OpenGL ES 2.x series ended with version 2.0
|
||||
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Invalid OpenGL ES version requested");
|
||||
"Invalid OpenGL ES version %i.%i requested",
|
||||
wndconfig->glMajor, wndconfig->glMinor);
|
||||
return GL_FALSE;
|
||||
}
|
||||
else
|
||||
@@ -360,8 +344,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
{
|
||||
// OpenGL ES does not support profiles
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Context profiles are not supported "
|
||||
"by OpenGL ES");
|
||||
"Context profiles are not supported by OpenGL ES");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -369,8 +352,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
{
|
||||
// OpenGL ES does not support forward-compatibility
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Forward compatibility is not "
|
||||
"supported by OpenGL ES");
|
||||
"Forward compatibility is not supported by OpenGL ES");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -381,8 +363,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
wndconfig->glRobustness != GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Invalid OpenGL robustness mode "
|
||||
"requested");
|
||||
"Invalid OpenGL robustness mode requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -393,7 +374,6 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
|
||||
//========================================================================
|
||||
// Reads back context properties
|
||||
// It blames glfwCreateWindow because that's the only caller
|
||||
//========================================================================
|
||||
|
||||
GLboolean _glfwRefreshContextParams(void)
|
||||
@@ -418,41 +398,77 @@ GLboolean _glfwRefreshContextParams(void)
|
||||
if (!window->GetStringi)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"glfwCreateWindow: Entry point retrieval is broken");
|
||||
"Entry point retrieval is broken");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Read back forward-compatibility flag
|
||||
if (window->clientAPI == GLFW_OPENGL_API)
|
||||
{
|
||||
window->glForward = GL_FALSE;
|
||||
// Read back context flags (OpenGL 3.0 and above)
|
||||
if (window->glMajor >= 3)
|
||||
{
|
||||
GLint flags;
|
||||
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||
|
||||
if (window->clientAPI == GLFW_OPENGL_API && window->glMajor >= 3)
|
||||
{
|
||||
GLint flags;
|
||||
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
||||
window->glForward = GL_TRUE;
|
||||
|
||||
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
||||
window->glForward = GL_TRUE;
|
||||
if (flags & 0)
|
||||
window->glDebug = GL_TRUE;
|
||||
}
|
||||
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||
window->glDebug = GL_TRUE;
|
||||
else if (glfwExtensionSupported("GL_ARB_debug_output"))
|
||||
{
|
||||
// HACK: This is a workaround for older drivers (pre KHR_debug)
|
||||
// not setting the debug bit in the context flags for debug
|
||||
// contexts
|
||||
window->glDebug = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Read back OpenGL context profile (OpenGL 3.2 and above)
|
||||
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;
|
||||
}
|
||||
|
||||
// Read back robustness strategy
|
||||
if (glfwExtensionSupported("GL_ARB_robustness"))
|
||||
{
|
||||
// NOTE: We avoid using the context flags for detection, as they are
|
||||
// only present from 3.0 while the extension applies from 1.1
|
||||
|
||||
GLint strategy;
|
||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
|
||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
||||
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
|
||||
}
|
||||
}
|
||||
|
||||
// Read back OpenGL context profile
|
||||
else
|
||||
{
|
||||
window->glProfile = 0;
|
||||
// Read back robustness strategy
|
||||
if (glfwExtensionSupported("GL_EXT_robustness"))
|
||||
{
|
||||
// NOTE: The values of these constants match those of the OpenGL ARB
|
||||
// one, so we can reuse them here
|
||||
|
||||
if (window->glMajor > 3 || (window->glMajor == 3 && window->glMinor >= 2))
|
||||
{
|
||||
GLint mask;
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||
GLint strategy;
|
||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
|
||||
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;
|
||||
}
|
||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
||||
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
@@ -461,7 +477,6 @@ GLboolean _glfwRefreshContextParams(void)
|
||||
|
||||
//========================================================================
|
||||
// Checks whether the current context fulfils the specified requirements
|
||||
// It blames glfwCreateWindow because that's the only caller
|
||||
//========================================================================
|
||||
|
||||
GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
|
||||
@@ -479,8 +494,7 @@ GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
|
||||
// For API consistency, we emulate the behavior of the
|
||||
// {GLX|WGL}_ARB_create_context extension and fail here
|
||||
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"glfwCreateWindow: The requested OpenGL version is not available");
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE, NULL);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
+56
-45
@@ -175,7 +175,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
|
||||
// Create the actual OpenGL(|ES) context
|
||||
//========================================================================
|
||||
|
||||
#define setEGLattrib(attribs, index, attribName, attribValue) \
|
||||
#define setEGLattrib(attribName, attribValue) \
|
||||
{ \
|
||||
attribs[index++] = attribName; \
|
||||
attribs[index++] = attribValue; \
|
||||
@@ -186,7 +186,7 @@ static int createContext(_GLFWwindow* window,
|
||||
EGLint fbconfigID)
|
||||
{
|
||||
int attribs[40];
|
||||
EGLint count, index;
|
||||
EGLint count;
|
||||
EGLConfig config;
|
||||
EGLContext share = NULL;
|
||||
|
||||
@@ -195,10 +195,10 @@ static int createContext(_GLFWwindow* window,
|
||||
|
||||
// Retrieve the previously selected EGLConfig
|
||||
{
|
||||
index = 0;
|
||||
int index = 0;
|
||||
|
||||
setEGLattrib(attribs, index, EGL_CONFIG_ID, fbconfigID);
|
||||
setEGLattrib(attribs, index, EGL_NONE, EGL_NONE);
|
||||
setEGLattrib(EGL_CONFIG_ID, fbconfigID);
|
||||
setEGLattrib(EGL_NONE, EGL_NONE);
|
||||
|
||||
eglChooseConfig(_glfwLibrary.EGL.display, attribs, &config, 1, &count);
|
||||
if (!count)
|
||||
@@ -209,10 +209,8 @@ static int createContext(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the corresponding visual
|
||||
// NOTE: This is the only non-portable code in this file.
|
||||
// Maybe it would not hurt too much to add #ifdefs for different platforms?
|
||||
#if defined(_GLFW_X11)
|
||||
// Retrieve the visual corresponding to the chosen EGL config
|
||||
{
|
||||
int mask;
|
||||
EGLint redBits, greenBits, blueBits, alphaBits, visualID = 0;
|
||||
@@ -264,8 +262,7 @@ static int createContext(_GLFWwindow* window,
|
||||
{
|
||||
if (!eglBindAPI(EGL_OPENGL_ES_API))
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: OpenGL ES is not supported");
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR, "EGL: OpenGL ES is not supported");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -273,66 +270,65 @@ static int createContext(_GLFWwindow* window,
|
||||
{
|
||||
if (!eglBindAPI(EGL_OPENGL_API))
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: OpenGL is not supported");
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR, "EGL: OpenGL is not supported");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
index = 0;
|
||||
|
||||
if (_glfwLibrary.EGL.KHR_create_context)
|
||||
{
|
||||
setEGLattrib(attribs, index, EGL_CONTEXT_MAJOR_VERSION_KHR, wndconfig->glMajor);
|
||||
setEGLattrib(attribs, index, EGL_CONTEXT_MINOR_VERSION_KHR, wndconfig->glMinor);
|
||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||
|
||||
if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness)
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
{
|
||||
int flags = 0;
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
|
||||
|
||||
if (wndconfig->glForward)
|
||||
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||
|
||||
if (wndconfig->glDebug)
|
||||
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||
|
||||
if (wndconfig->glRobustness)
|
||||
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||
|
||||
setEGLattrib(attribs, index, EGL_CONTEXT_FLAGS_KHR, flags);
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
flags = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
flags = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
|
||||
|
||||
setEGLattrib(attribs, index, EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, flags);
|
||||
}
|
||||
|
||||
if (wndconfig->glRobustness)
|
||||
{
|
||||
int strategy;
|
||||
|
||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
strategy = EGL_NO_RESET_NOTIFICATION_KHR;
|
||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
strategy = EGL_LOSE_CONTEXT_ON_RESET_KHR;
|
||||
|
||||
setEGLattrib(attribs, index, EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, strategy);
|
||||
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||
}
|
||||
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
{
|
||||
setEGLattrib(EGL_CONTEXT_MAJOR_VERSION_KHR, wndconfig->glMajor);
|
||||
setEGLattrib(EGL_CONTEXT_MINOR_VERSION_KHR, wndconfig->glMinor);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
setEGLattrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
|
||||
|
||||
if (flags)
|
||||
setEGLattrib(EGL_CONTEXT_FLAGS_KHR, flags);
|
||||
|
||||
if (strategy)
|
||||
setEGLattrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, strategy);
|
||||
|
||||
setEGLattrib(EGL_NONE, EGL_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
setEGLattrib(attribs, index, EGL_CONTEXT_CLIENT_VERSION, wndconfig->glMajor);
|
||||
}
|
||||
int index = 0;
|
||||
|
||||
setEGLattrib(attribs, index, EGL_NONE, EGL_NONE);
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
setEGLattrib(EGL_CONTEXT_CLIENT_VERSION, wndconfig->glMajor);
|
||||
|
||||
setEGLattrib(EGL_NONE, EGL_NONE);
|
||||
}
|
||||
|
||||
window->EGL.context = eglCreateContext(_glfwLibrary.EGL.display,
|
||||
config, share, attribs);
|
||||
@@ -341,8 +337,7 @@ static int createContext(_GLFWwindow* window,
|
||||
{
|
||||
// TODO: Handle all the various error codes here
|
||||
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: Failed to create context");
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR, "EGL: Failed to create context");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -499,6 +494,22 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Analyzes the specified context for possible recreation
|
||||
//========================================================================
|
||||
|
||||
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
#if _GLFW_WIN32
|
||||
return _GLFW_RECREATION_NOT_NEEDED;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Make the OpenGL context associated with the specified window current
|
||||
//========================================================================
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
// This path may need to be changed if you build GLFW using your own setup
|
||||
// We ship and use our own copy of eglext.h since GLFW uses fairly new
|
||||
// extensions and not all operating systems come with an up-to-date version
|
||||
#include "../support/GL/eglext.h"
|
||||
#include "../support/EGL/eglext.h"
|
||||
|
||||
// Do we have support for dlopen/dlsym?
|
||||
#if defined(_GLFW_HAS_DLOPEN)
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ GLFWAPI void glfwSetGamma(float gamma)
|
||||
if (gamma <= 0.f)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwSetGamma: Gamma value must be greater than zero");
|
||||
"Gamma value must be greater than zero");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+87
-83
@@ -221,7 +221,7 @@ static int errorHandler(Display *display, XErrorEvent* event)
|
||||
// Create the actual OpenGL context
|
||||
//========================================================================
|
||||
|
||||
#define setGLXattrib(attribs, index, attribName, attribValue) \
|
||||
#define setGLXattrib(attribName, attribValue) \
|
||||
attribs[index++] = attribName; \
|
||||
attribs[index++] = attribValue;
|
||||
|
||||
@@ -230,7 +230,6 @@ static int createContext(_GLFWwindow* window,
|
||||
GLXFBConfigID fbconfigID)
|
||||
{
|
||||
int attribs[40];
|
||||
int dummy, index;
|
||||
GLXFBConfig* fbconfig;
|
||||
GLXContext share = NULL;
|
||||
|
||||
@@ -239,17 +238,18 @@ static int createContext(_GLFWwindow* window,
|
||||
|
||||
// Retrieve the previously selected GLXFBConfig
|
||||
{
|
||||
index = 0;
|
||||
int dummy, index = 0;
|
||||
|
||||
setGLXattrib(attribs, index, GLX_FBCONFIG_ID, (int) fbconfigID);
|
||||
setGLXattrib(attribs, index, None, None);
|
||||
setGLXattrib(GLX_FBCONFIG_ID, (int) fbconfigID);
|
||||
setGLXattrib(None, None);
|
||||
|
||||
if (_glfwLibrary.GLX.SGIX_fbconfig)
|
||||
{
|
||||
fbconfig = _glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.screen,
|
||||
attribs,
|
||||
&dummy);
|
||||
fbconfig =
|
||||
_glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.screen,
|
||||
attribs,
|
||||
&dummy);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -270,8 +270,9 @@ static int createContext(_GLFWwindow* window,
|
||||
// Retrieve the corresponding visual
|
||||
if (_glfwLibrary.GLX.SGIX_fbconfig)
|
||||
{
|
||||
window->GLX.visual = _glfwLibrary.GLX.GetVisualFromFBConfigSGIX(_glfwLibrary.X11.display,
|
||||
*fbconfig);
|
||||
window->GLX.visual =
|
||||
_glfwLibrary.GLX.GetVisualFromFBConfigSGIX(_glfwLibrary.X11.display,
|
||||
*fbconfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -288,95 +289,98 @@ static int createContext(_GLFWwindow* window,
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (!_glfwLibrary.GLX.ARB_create_context ||
|
||||
!_glfwLibrary.GLX.ARB_create_context_profile ||
|
||||
!_glfwLibrary.GLX.EXT_create_context_es2_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"GLX: OpenGL ES requested but "
|
||||
"GLX_EXT_create_context_es2_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->glForward)
|
||||
{
|
||||
if (!_glfwLibrary.GLX.ARB_create_context)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"GLX: Forward compatibility requested but "
|
||||
"GLX_ARB_create_context_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
{
|
||||
if (!_glfwLibrary.GLX.ARB_create_context ||
|
||||
!_glfwLibrary.GLX.ARB_create_context_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"GLX: An OpenGL profile requested but "
|
||||
"GLX_ARB_create_context_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_glfwLibrary.GLX.ARB_create_context)
|
||||
{
|
||||
index = 0;
|
||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
{
|
||||
// Request an explicitly versioned context
|
||||
|
||||
setGLXattrib(attribs, index, GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
||||
setGLXattrib(attribs, index, GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
||||
}
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (!_glfwLibrary.GLX.ARB_create_context_profile ||
|
||||
!_glfwLibrary.GLX.EXT_create_context_es2_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"GLX: OpenGL ES 2.x requested but "
|
||||
"GLX_EXT_create_context_es2_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
setGLXattrib(attribs, index,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB,
|
||||
GLX_CONTEXT_ES2_PROFILE_BIT_EXT);
|
||||
}
|
||||
|
||||
if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if (wndconfig->glForward)
|
||||
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||
|
||||
if (wndconfig->glDebug)
|
||||
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
||||
|
||||
if (wndconfig->glRobustness)
|
||||
if (wndconfig->glProfile)
|
||||
{
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
}
|
||||
}
|
||||
else
|
||||
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||
|
||||
if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
|
||||
{
|
||||
if (_glfwLibrary.GLX.ARB_create_context_robustness)
|
||||
{
|
||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
|
||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
|
||||
|
||||
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
|
||||
setGLXattrib(attribs, index, GLX_CONTEXT_FLAGS_ARB, flags);
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if (!_glfwLibrary.GLX.ARB_create_context_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"GLX: An OpenGL profile requested but "
|
||||
"GLX_ARB_create_context_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
flags = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
flags = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
|
||||
setGLXattrib(attribs, index, GLX_CONTEXT_PROFILE_MASK_ARB, flags);
|
||||
}
|
||||
|
||||
if (wndconfig->glRobustness)
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
{
|
||||
int strategy;
|
||||
// NOTE: Only request an explicitly versioned context when
|
||||
// necessary, as explicitly requesting version 1.0 does not always
|
||||
// return the highest available version
|
||||
|
||||
if (!_glfwLibrary.GLX.ARB_create_context_robustness)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"GLX: An OpenGL robustness strategy was "
|
||||
"requested but GLX_ARB_create_context_robustness "
|
||||
"is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
|
||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
|
||||
|
||||
setGLXattrib(attribs,
|
||||
index,
|
||||
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
strategy);
|
||||
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
||||
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
||||
}
|
||||
|
||||
setGLXattrib(attribs, index, None, None);
|
||||
if (mask)
|
||||
setGLXattrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||
|
||||
if (flags)
|
||||
setGLXattrib(GLX_CONTEXT_FLAGS_ARB, flags);
|
||||
|
||||
if (strategy)
|
||||
setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy);
|
||||
|
||||
setGLXattrib(None, None);
|
||||
|
||||
// This is the only place we set an Xlib error handler, and we only do
|
||||
// it because glXCreateContextAttribsARB generates a BadMatch error if
|
||||
@@ -422,7 +426,7 @@ static int createContext(_GLFWwindow* window,
|
||||
// TODO: Handle all the various error codes here
|
||||
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"GLX: Failed to create OpenGL context");
|
||||
"GLX: Failed to create context");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -323,7 +323,7 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
|
||||
if (key < 0 || key > GLFW_KEY_LAST)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_ENUM,
|
||||
"glfwGetKey: The specified key is invalid");
|
||||
"The specified key is invalid");
|
||||
return GLFW_RELEASE;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
|
||||
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_ENUM,
|
||||
"glfwGetMouseButton: The specified mouse button is invalid");
|
||||
"The specified mouse button is invalid");
|
||||
return GLFW_RELEASE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ int _glfwInitOpenGL(void)
|
||||
if (pthread_key_create(&_glfwCurrentTLS, NULL) != 0)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa/NSGL: Failed to create context TLS");
|
||||
"NSOpenGL: Failed to create context TLS");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
+124
-71
@@ -329,12 +329,16 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||
// Creates an OpenGL context on the specified device context
|
||||
//========================================================================
|
||||
|
||||
#define setWGLattrib(attribName, attribValue) \
|
||||
attribs[index++] = attribName; \
|
||||
attribs[index++] = attribValue;
|
||||
|
||||
static GLboolean createContext(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
int pixelFormat)
|
||||
{
|
||||
int attribs[40];
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int i = 0, attribs[40];
|
||||
HGLRC share = NULL;
|
||||
|
||||
if (wndconfig->share)
|
||||
@@ -356,94 +360,56 @@ static GLboolean createContext(_GLFWwindow* window,
|
||||
|
||||
if (window->WGL.ARB_create_context)
|
||||
{
|
||||
// Use the newer wglCreateContextAttribsARB creation method
|
||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
{
|
||||
// Request an explicitly versioned context
|
||||
|
||||
attribs[i++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
|
||||
attribs[i++] = wndconfig->glMajor;
|
||||
attribs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB;
|
||||
attribs[i++] = wndconfig->glMinor;
|
||||
}
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||
{
|
||||
if (!window->WGL.ARB_create_context_profile ||
|
||||
!window->WGL.EXT_create_context_es2_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"Win32/WGL: OpenGL ES 2.x requested but "
|
||||
"WGL_EXT_create_context_es2_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
||||
attribs[i++] = WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||
}
|
||||
|
||||
if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if (wndconfig->glForward)
|
||||
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||
|
||||
if (wndconfig->glDebug)
|
||||
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
||||
|
||||
if (wndconfig->glRobustness)
|
||||
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
|
||||
attribs[i++] = WGL_CONTEXT_FLAGS_ARB;
|
||||
attribs[i++] = flags;
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if (!window->WGL.ARB_create_context_profile)
|
||||
if (wndconfig->glProfile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"WGL: OpenGL profile requested but "
|
||||
"WGL_ARB_create_context_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||
flags = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
flags = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
|
||||
attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
||||
attribs[i++] = flags;
|
||||
}
|
||||
else
|
||||
mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||
|
||||
if (wndconfig->glRobustness)
|
||||
{
|
||||
int strategy = 0;
|
||||
|
||||
if (!window->WGL.ARB_create_context_robustness)
|
||||
if (window->WGL.ARB_create_context_robustness)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"WGL: An OpenGL robustness strategy was "
|
||||
"requested but WGL_ARB_create_context_robustness "
|
||||
"is unavailable");
|
||||
return GL_FALSE;
|
||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
strategy = WGL_NO_RESET_NOTIFICATION_ARB;
|
||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
strategy = WGL_LOSE_CONTEXT_ON_RESET_ARB;
|
||||
|
||||
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
}
|
||||
|
||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
strategy = WGL_NO_RESET_NOTIFICATION_ARB;
|
||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
strategy = WGL_LOSE_CONTEXT_ON_RESET_ARB;
|
||||
|
||||
attribs[i++] = WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB;
|
||||
attribs[i++] = strategy;
|
||||
}
|
||||
|
||||
attribs[i++] = 0;
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
{
|
||||
setWGLattrib(WGL_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
||||
setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
||||
}
|
||||
|
||||
if (flags)
|
||||
setWGLattrib(WGL_CONTEXT_FLAGS_ARB, flags);
|
||||
|
||||
if (mask)
|
||||
setWGLattrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||
|
||||
if (strategy)
|
||||
setWGLattrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy);
|
||||
|
||||
setWGLattrib(0, 0);
|
||||
|
||||
window->WGL.context = window->WGL.CreateContextAttribsARB(window->WGL.DC,
|
||||
share,
|
||||
@@ -483,6 +449,8 @@ static GLboolean createContext(_GLFWwindow* window,
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
#undef setWGLattrib
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
@@ -554,6 +522,91 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Analyzes the specified context for possible recreation
|
||||
//========================================================================
|
||||
|
||||
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
GLboolean required = GL_FALSE;
|
||||
|
||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||
{
|
||||
if (wndconfig->glForward)
|
||||
{
|
||||
if (!window->WGL.ARB_create_context)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"WGL: A forward compatible OpenGL context "
|
||||
"requested but WGL_ARB_create_context is "
|
||||
"unavailable");
|
||||
return _GLFW_RECREATION_IMPOSSIBLE;
|
||||
}
|
||||
|
||||
required = GL_TRUE;
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
{
|
||||
if (!window->WGL.ARB_create_context_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"WGL: OpenGL profile requested but "
|
||||
"WGL_ARB_create_context_profile is unavailable");
|
||||
return _GLFW_RECREATION_IMPOSSIBLE;
|
||||
}
|
||||
|
||||
required = GL_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!window->WGL.ARB_create_context ||
|
||||
!window->WGL.ARB_create_context_profile ||
|
||||
!window->WGL.EXT_create_context_es2_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"WGL: OpenGL ES requested but "
|
||||
"WGL_ARB_create_context_es2_profile is unavailable");
|
||||
return _GLFW_RECREATION_IMPOSSIBLE;
|
||||
}
|
||||
|
||||
required = GL_TRUE;
|
||||
}
|
||||
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
{
|
||||
if (window->WGL.ARB_create_context)
|
||||
required = GL_TRUE;
|
||||
}
|
||||
|
||||
if (wndconfig->glDebug)
|
||||
{
|
||||
if (window->WGL.ARB_create_context)
|
||||
required = GL_TRUE;
|
||||
}
|
||||
|
||||
if (fbconfig->samples > 0)
|
||||
{
|
||||
// We want FSAA, but can we get it?
|
||||
// FSAA is not a hard constraint, so otherwise we just don't care
|
||||
|
||||
if (window->WGL.ARB_multisample && window->WGL.ARB_pixel_format)
|
||||
{
|
||||
// We appear to have both the extension and the means to ask for it
|
||||
required = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (required)
|
||||
return _GLFW_RECREATION_REQUIRED;
|
||||
|
||||
return _GLFW_RECREATION_NOT_NEEDED;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -105,6 +105,10 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
|
||||
// between applications using different versions of GLFW
|
||||
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
||||
|
||||
#define _GLFW_RECREATION_NOT_NEEDED 0
|
||||
#define _GLFW_RECREATION_REQUIRED 1
|
||||
#define _GLFW_RECREATION_IMPOSSIBLE 2
|
||||
|
||||
|
||||
#if defined(_GLFW_WGL)
|
||||
#include "wgl_platform.h"
|
||||
@@ -218,6 +222,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
|
||||
// Fullscreen support
|
||||
void _glfwSetVideoMode(int* width, int* height,
|
||||
|
||||
+5
-50
@@ -866,7 +866,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
GLboolean recreateContext = GL_FALSE;
|
||||
int status;
|
||||
|
||||
window->Win32.desiredRefreshRate = wndconfig->refreshRate;
|
||||
|
||||
@@ -900,57 +900,12 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
if (!createWindow(window, wndconfig, fbconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||
{
|
||||
if (window->WGL.ARB_create_context)
|
||||
recreateContext = GL_TRUE;
|
||||
}
|
||||
status = _glfwAnalyzeContext(window, wndconfig, fbconfig);
|
||||
|
||||
if (wndconfig->glDebug)
|
||||
{
|
||||
if (window->WGL.ARB_create_context)
|
||||
recreateContext = GL_TRUE;
|
||||
}
|
||||
if (status == _GLFW_RECREATION_IMPOSSIBLE)
|
||||
return GL_FALSE;
|
||||
|
||||
if (wndconfig->glForward)
|
||||
{
|
||||
if (!window->WGL.ARB_create_context)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"WGL: A forward compatible OpenGL context requested "
|
||||
"but WGL_ARB_create_context is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
recreateContext = GL_TRUE;
|
||||
}
|
||||
|
||||
if (wndconfig->glProfile)
|
||||
{
|
||||
if (!window->WGL.ARB_create_context_profile)
|
||||
{
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"WGL: OpenGL profile requested but "
|
||||
"WGL_ARB_create_context_profile is unavailable");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
recreateContext = GL_TRUE;
|
||||
}
|
||||
|
||||
if (fbconfig->samples > 0)
|
||||
{
|
||||
// We want FSAA, but can we get it?
|
||||
// FSAA is not a hard constraint, so otherwise we just don't care
|
||||
|
||||
if (window->WGL.ARB_multisample && window->WGL.ARB_pixel_format)
|
||||
{
|
||||
// We appear to have both the FSAA extension and the means to ask for it
|
||||
recreateContext = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (recreateContext)
|
||||
if (status == _GLFW_RECREATION_REQUIRED)
|
||||
{
|
||||
// Some window hints require us to re-create the context using WGL
|
||||
// extensions retrieved through the current context, as we cannot check
|
||||
|
||||
+2
-3
@@ -253,7 +253,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
||||
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
|
||||
wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
|
||||
wndconfig.glProfile = _glfwLibrary.hints.glProfile;
|
||||
wndconfig.glRobustness = _glfwLibrary.hints.glRobustness ? GL_TRUE : GL_FALSE;
|
||||
wndconfig.glRobustness = _glfwLibrary.hints.glRobustness;
|
||||
wndconfig.monitor = (_GLFWmonitor*) monitor;
|
||||
wndconfig.share = (_GLFWwindow*) share;
|
||||
|
||||
@@ -266,8 +266,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwCreateWindow: Invalid window size");
|
||||
_glfwSetError(GLFW_INVALID_VALUE, "Invalid window size");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user