Merge branch 'master' into multi-monitor

This commit is contained in:
Camilla Berglund
2012-10-02 03:11:32 +02:00
9 changed files with 260 additions and 160 deletions
+7
View File
@@ -729,6 +729,13 @@ static GLboolean createContext(_GLFWwindow* window,
else if (colorBits < 15)
colorBits = 15;
if (wndconfig->clientAPI != GLFW_OPENGL_ES_API)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"Cocoa/NSOpenGL: NSOpenGL does not support OpenGL ES");
return GL_FALSE;
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
// Fail if any OpenGL version above 2.1 other than 3.2 was requested
if (wndconfig->glMajor > 3 ||
+3
View File
@@ -101,6 +101,7 @@ struct _GLFWhints
GLboolean resizable;
GLboolean visible;
int samples;
int clientAPI;
int glMajor;
int glMinor;
GLboolean glForward;
@@ -122,6 +123,7 @@ struct _GLFWwndconfig
int refreshRate;
GLboolean resizable;
GLboolean visible;
int clientAPI;
int glMajor;
int glMinor;
GLboolean glForward;
@@ -190,6 +192,7 @@ struct _GLFWwindow
char key[GLFW_KEY_LAST + 1];
// OpenGL extensions and context attributes
int clientAPI;
int glMajor, glMinor, glRevision;
GLboolean glForward, glDebug;
int glProfile;
+110 -68
View File
@@ -36,15 +36,17 @@
//========================================================================
// Parses the OpenGL version string and extracts the version number
// Parses the client API version string and extracts the version number
//========================================================================
static GLboolean parseGLVersion(int* major, int* minor, int* rev)
static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev)
{
int i, _major, _minor = 0, _rev = 0;
int i, _api = GLFW_OPENGL_API, _major, _minor = 0, _rev = 0;
const char* version;
const char* prefixes[] =
{
"OpenGL ES-CM ",
"OpenGL ES-CL ",
"OpenGL ES ",
NULL
};
@@ -63,6 +65,7 @@ static GLboolean parseGLVersion(int* major, int* minor, int* rev)
if (strncmp(version, prefixes[i], length) == 0)
{
version += length;
_api = GLFW_OPENGL_ES_API;
break;
}
}
@@ -73,6 +76,7 @@ static GLboolean parseGLVersion(int* major, int* minor, int* rev)
return GL_FALSE;
}
*api = _api;
*major = _major;
*minor = _minor;
*rev = _rev;
@@ -249,83 +253,119 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
{
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
if (wndconfig->clientAPI != GLFW_OPENGL_API &&
wndconfig->clientAPI != GLFW_OPENGL_ES_API)
{
// OpenGL 1.0 is the smallest valid version
_glfwSetError(GLFW_INVALID_VALUE,
"glfwCreateWindow: Invalid OpenGL version requested");
_glfwSetError(GLFW_INVALID_ENUM,
"glfwCreateWindow: Invalid client API 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");
return GL_FALSE;
}
else
{
// For now, let everything else through
}
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE)
if (wndconfig->clientAPI == GLFW_OPENGL_API)
{
if (wndconfig->glMajor != 2 || wndconfig->glMinor < 0)
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
{
// The OpenGL ES 2.0 profile is currently only defined for version
// 2.0 (see {WGL|GLX}_EXT_create_context_es2_profile), but for
// compatibility with future updates to OpenGL ES, we allow
// everything 2.x and let the driver report invalid 2.x versions
// OpenGL 1.0 is the smallest valid version
_glfwSetError(GLFW_INVALID_VALUE,
"glfwCreateWindow: Invalid OpenGL ES 2.x version requested");
"glfwCreateWindow: Invalid OpenGL version requested");
return GL_FALSE;
}
}
else if (wndconfig->glProfile)
{
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE &&
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5)
{
_glfwSetError(GLFW_INVALID_ENUM,
"glfwCreateWindow: Invalid OpenGL profile requested");
return GL_FALSE;
}
if (wndconfig->glMajor < 3 ||
(wndconfig->glMajor == 3 && wndconfig->glMinor < 2))
{
// Desktop OpenGL context profiles are only defined for version 3.2
// and above
// OpenGL 1.x series ended with version 1.5
_glfwSetError(GLFW_INVALID_VALUE,
"glfwCreateWindow: Context profiles only exist for "
"OpenGL version 3.2 and above");
"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");
return GL_FALSE;
}
else
{
// For now, let everything else through
}
if (wndconfig->glProfile)
{
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE &&
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
{
_glfwSetError(GLFW_INVALID_ENUM,
"glfwCreateWindow: Invalid OpenGL profile requested");
return GL_FALSE;
}
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,
"glfwCreateWindow: Context profiles only exist for "
"OpenGL version 3.2 and above");
return GL_FALSE;
}
}
if (wndconfig->glForward && wndconfig->glMajor < 3)
{
// 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");
return GL_FALSE;
}
}
if (wndconfig->glForward && wndconfig->glMajor < 3)
else if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
{
// 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");
return GL_FALSE;
if (wndconfig->glMajor < 1 || 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
_glfwSetError(GLFW_INVALID_VALUE,
"glfwCreateWindow: Invalid OpenGL ES version requested");
return GL_FALSE;
}
else
{
// For now, let everything else through
}
if (wndconfig->glProfile)
{
// OpenGL ES does not support profiles
_glfwSetError(GLFW_INVALID_VALUE,
"glfwCreateWindow: Context profiles are not supported "
"by OpenGL ES");
return GL_FALSE;
}
if (wndconfig->glForward)
{
// OpenGL ES does not support forward-compatibility
_glfwSetError(GLFW_INVALID_VALUE,
"glfwCreateWindow: Forward compatibility is not "
"supported by OpenGL ES");
return GL_FALSE;
}
}
if (wndconfig->glRobustness)
@@ -334,7 +374,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
wndconfig->glRobustness != GLFW_OPENGL_LOSE_CONTEXT_ON_RESET)
{
_glfwSetError(GLFW_INVALID_VALUE,
"glfwCreateWindow: Invalid OpenGL robustness mode requested");
"glfwCreateWindow: Invalid OpenGL robustness mode "
"requested");
return GL_FALSE;
}
}
@@ -352,7 +393,8 @@ GLboolean _glfwRefreshContextParams(void)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
if (!parseGLVersion(&window->glMajor,
if (!parseGLVersion(&window->clientAPI,
&window->glMajor,
&window->glMinor,
&window->glRevision))
{
@@ -378,7 +420,7 @@ GLboolean _glfwRefreshContextParams(void)
{
window->glForward = GL_FALSE;
if (window->glMajor >= 3)
if (window->clientAPI == GLFW_OPENGL_API && window->glMajor >= 3)
{
GLint flags;
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
+15 -11
View File
@@ -356,6 +356,21 @@ static GLboolean createContext(_GLFWwindow* window,
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;
@@ -385,21 +400,10 @@ static GLboolean createContext(_GLFWwindow* window,
return GL_FALSE;
}
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
!window->WGL.EXT_create_context_es2_profile)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"WGL: OpenGL ES 2.x profile requested but "
"WGL_EXT_create_context_es2_profile is unavailable");
return GL_FALSE;
}
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;
else if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE)
flags = WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
attribs[i++] = flags;
+14 -6
View File
@@ -76,7 +76,8 @@ void _glfwSetDefaultWindowHints(void)
{
memset(&_glfwLibrary.hints, 0, sizeof(_glfwLibrary.hints));
// The default minimum OpenGL version is 1.0
// The default is OpenGL with minimum version 1.0
_glfwLibrary.hints.clientAPI = GLFW_OPENGL_API;
_glfwLibrary.hints.glMajor = 1;
_glfwLibrary.hints.glMinor = 0;
@@ -84,11 +85,12 @@ void _glfwSetDefaultWindowHints(void)
_glfwLibrary.hints.resizable = GL_TRUE;
_glfwLibrary.hints.visible = GL_TRUE;
// The default is 24 bits of depth, 8 bits of color
_glfwLibrary.hints.depthBits = 24;
_glfwLibrary.hints.redBits = 8;
_glfwLibrary.hints.greenBits = 8;
_glfwLibrary.hints.blueBits = 8;
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
_glfwLibrary.hints.redBits = 8;
_glfwLibrary.hints.greenBits = 8;
_glfwLibrary.hints.blueBits = 8;
_glfwLibrary.hints.depthBits = 24;
_glfwLibrary.hints.stencilBits = 8;
}
@@ -262,6 +264,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.visible = _glfwLibrary.hints.visible ? GL_TRUE : GL_FALSE;
wndconfig.clientAPI = _glfwLibrary.hints.clientAPI;
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
@@ -430,6 +433,9 @@ GLFWAPI void glfwWindowHint(int target, int hint)
case GLFW_FSAA_SAMPLES:
_glfwLibrary.hints.samples = hint;
break;
case GLFW_CLIENT_API:
_glfwLibrary.hints.clientAPI = hint;
break;
case GLFW_OPENGL_VERSION_MAJOR:
_glfwLibrary.hints.glMajor = hint;
break;
@@ -734,6 +740,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
return window->resizable;
case GLFW_VISIBLE:
return window->visible;
case GLFW_CLIENT_API:
return window->clientAPI;
case GLFW_OPENGL_VERSION_MAJOR:
return window->glMajor;
case GLFW_OPENGL_VERSION_MINOR:
+16 -11
View File
@@ -295,6 +295,22 @@ static int createContext(_GLFWwindow* window,
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;
@@ -323,21 +339,10 @@ static int createContext(_GLFWwindow* window,
return GL_FALSE;
}
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
!_glfwLibrary.GLX.EXT_create_context_es2_profile)
{
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
"GLX: OpenGL ES 2.x profile requested but "
"GLX_EXT_create_context_es2_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;
else if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE)
flags = GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
setGLXattrib(attribs, index, GLX_CONTEXT_PROFILE_MASK_ARB, flags);
}