Added support for GL_KHR_context_flush_control.

This commit is contained in:
Camilla Berglund
2014-08-21 19:21:45 +02:00
parent cfc47abf0d
commit 44c899ce70
13 changed files with 164 additions and 38 deletions
+22
View File
@@ -198,6 +198,17 @@ GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
}
}
if (ctxconfig->release)
{
if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid context release behavior requested");
return GL_FALSE;
}
}
return GL_TRUE;
}
@@ -468,6 +479,17 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
}
}
if (glfwExtensionSupported("GL_KHR_context_flush_control"))
{
GLint behavior;
glGetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
if (behavior == GL_NONE)
window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;
}
#endif // _GLFW_USE_OPENGL
return GL_TRUE;
+3
View File
@@ -381,6 +381,9 @@ int _glfwCreateContext(_GLFWwindow* window,
setEGLattrib(EGL_NONE, EGL_NONE);
}
// Context release behaviors (GL_KHR_context_flush_control) are not yet
// supported on EGL but are not a hard constraint, so ignore and continue
window->egl.context = eglCreateContext(_glfw.egl.display,
config, share, attribs);
+20
View File
@@ -255,6 +255,9 @@ int _glfwInitContextAPI(void)
if (_glfwPlatformExtensionSupported("GLX_EXT_create_context_es2_profile"))
_glfw.glx.EXT_create_context_es2_profile = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_ARB_context_flush_control"))
_glfw.glx.ARB_context_flush_control = GL_TRUE;
return GL_TRUE;
}
@@ -384,6 +387,23 @@ int _glfwCreateContext(_GLFWwindow* window,
}
}
if (ctxconfig->release)
{
if (_glfw.glx.ARB_context_flush_control)
{
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
{
setGLXattrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
}
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
{
setGLXattrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
}
}
}
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
// NOTE: Only request an explicitly versioned context when
+1
View File
@@ -105,6 +105,7 @@ typedef struct _GLFWlibraryGLX
GLboolean ARB_create_context_profile;
GLboolean ARB_create_context_robustness;
GLboolean EXT_create_context_es2_profile;
GLboolean ARB_context_flush_control;
#if defined(_GLFW_DLOPEN_LIBGL)
void* libGL; // dlopen handle for libGL.so
+3
View File
@@ -173,6 +173,7 @@ struct _GLFWctxconfig
GLboolean debug;
int profile;
int robustness;
int release;
_GLFWwindow* share;
};
@@ -242,6 +243,7 @@ struct _GLFWwindow
GLboolean forward, debug;
int profile;
int robustness;
int release;
} context;
#if defined(_GLFW_USE_OPENGL)
@@ -338,6 +340,7 @@ struct _GLFWlibrary
int debug;
int profile;
int robustness;
int release;
} hints;
double cursorPosX, cursorPosY;
+3
View File
@@ -115,6 +115,9 @@ int _glfwCreateContext(_GLFWwindow* window,
// Context robustness modes (GL_KHR_robustness) are not yet supported on
// OS X but are not a hard constraint, so ignore and continue
// Context release behaviors (GL_KHR_context_flush_control) are not yet
// supported on OS X but are not a hard constraint, so ignore and continue
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
+27
View File
@@ -57,6 +57,7 @@ static void initWGLExtensions(_GLFWwindow* window)
window->wgl.ARB_create_context_robustness = GL_FALSE;
window->wgl.EXT_swap_control = GL_FALSE;
window->wgl.ARB_pixel_format = GL_FALSE;
window->wgl.ARB_context_flush_control = GL_FALSE;
window->wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
wglGetProcAddress("wglGetExtensionsStringEXT");
@@ -119,6 +120,9 @@ static void initWGLExtensions(_GLFWwindow* window)
if (window->wgl.GetPixelFormatAttribivARB)
window->wgl.ARB_pixel_format = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("WGL_ARB_context_flush_control"))
window->wgl.ARB_context_flush_control = GL_TRUE;
}
// Returns the specified attribute of the specified pixel format
@@ -421,6 +425,23 @@ int _glfwCreateContext(_GLFWwindow* window,
}
}
if (ctxconfig->release)
{
if (window->wgl.ARB_context_flush_control)
{
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
{
setWGLattrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
}
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
{
setWGLattrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
}
}
}
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
// NOTE: Only request an explicitly versioned context when
@@ -535,6 +556,12 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
required = GL_TRUE;
}
if (ctxconfig->release)
{
if (window->wgl.ARB_context_flush_control)
required = GL_TRUE;
}
}
else
{
+1
View File
@@ -65,6 +65,7 @@ typedef struct _GLFWcontextWGL
GLboolean ARB_create_context_profile;
GLboolean EXT_create_context_es2_profile;
GLboolean ARB_create_context_robustness;
GLboolean ARB_context_flush_control;
} _GLFWcontextWGL;
+7 -1
View File
@@ -178,6 +178,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
ctxconfig.debug = _glfw.hints.debug ? GL_TRUE : GL_FALSE;
ctxconfig.profile = _glfw.hints.profile;
ctxconfig.robustness = _glfw.hints.robustness;
ctxconfig.release = _glfw.hints.release;
ctxconfig.share = (_GLFWwindow*) share;
// Check the OpenGL bits of the window config
@@ -272,7 +273,7 @@ void glfwDefaultWindowHints(void)
memset(&_glfw.hints, 0, sizeof(_glfw.hints));
// The default is OpenGL with minimum version 1.0
_glfw.hints.api = GLFW_OPENGL_API;
_glfw.hints.api = GLFW_OPENGL_API;
_glfw.hints.major = 1;
_glfw.hints.minor = 0;
@@ -383,6 +384,9 @@ GLFWAPI void glfwWindowHint(int target, int hint)
case GLFW_OPENGL_PROFILE:
_glfw.hints.profile = hint;
break;
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
_glfw.hints.release = hint;
break;
default:
_glfwInputError(GLFW_INVALID_ENUM, NULL);
break;
@@ -623,6 +627,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->context.debug;
case GLFW_OPENGL_PROFILE:
return window->context.profile;
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
return window->context.release;
}
_glfwInputError(GLFW_INVALID_ENUM, NULL);