mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 19:42:00 +00:00
Add GLFW_CONTEXT_NO_ERROR window hint
This adds support for the GL_KHR_no_error extension.
This commit is contained in:
parent
962497bdc9
commit
7be8209d14
@ -67,6 +67,7 @@ used by the tests and examples and are not required to build the library.
|
||||
- Added `glfwSetWindowSizeLimits` and `glfwSetWindowAspectRatio` for setting
|
||||
absolute and relative window size limits
|
||||
- Added `GLFW_NO_API` for creating window without contexts
|
||||
- Added `GLFW_CONTEXT_NO_ERROR` context hint for `GL_KHR_no_error` support
|
||||
- Added `GLFW_TRUE` and `GLFW_FALSE` as client API independent boolean values
|
||||
- Removed dependency on external OpenGL or OpenGL ES headers
|
||||
- [Cocoa] Removed support for OS X 10.6
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
@section news_32 New features in 3.2
|
||||
|
||||
|
||||
@subsection news_32_sizelimits Window size limit support
|
||||
|
||||
GLFW now supports setting both absolute and relative window size limits with
|
||||
|
@ -293,6 +293,15 @@ Context release behaviors are described in detail by the
|
||||
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
|
||||
extension.
|
||||
|
||||
`GLFW_CONTEXT_NO_ERROR` specifies whether errors should be generated by the
|
||||
context. If enabled, situations that would have generated errors instead cause
|
||||
undefined behavior.
|
||||
|
||||
@par
|
||||
The no error mode for OpenGL and OpenGL ES is described in detail by the
|
||||
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
|
||||
extension.
|
||||
|
||||
|
||||
@subsubsection window_hints_values Supported and default values
|
||||
|
||||
|
@ -658,6 +658,7 @@ extern "C" {
|
||||
#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
|
||||
#define GLFW_OPENGL_PROFILE 0x00022008
|
||||
#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
|
||||
#define GLFW_CONTEXT_NO_ERROR 0x0002200A
|
||||
|
||||
#define GLFW_NO_API 0
|
||||
#define GLFW_OPENGL_API 0x00030001
|
||||
|
@ -403,6 +403,9 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
||||
// debug contexts
|
||||
window->context.debug = GLFW_TRUE;
|
||||
}
|
||||
|
||||
if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
|
||||
window->context.noerror = GLFW_TRUE;
|
||||
}
|
||||
|
||||
// Read back OpenGL context profile (OpenGL 3.2 and above)
|
||||
|
@ -264,6 +264,8 @@ int _glfwInitContextAPI(void)
|
||||
|
||||
_glfw.egl.KHR_create_context =
|
||||
_glfwPlatformExtensionSupported("EGL_KHR_create_context");
|
||||
_glfw.egl.KHR_create_context_no_error =
|
||||
_glfwPlatformExtensionSupported("EGL_KHR_create_context_no_error");
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
@ -345,6 +347,12 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
||||
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
|
||||
|
||||
if (_glfw.egl.KHR_create_context_no_error)
|
||||
{
|
||||
if (ctxconfig->noerror)
|
||||
flags |= EGL_CONTEXT_OPENGL_NO_ERROR_KHR;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctxconfig->debug)
|
||||
|
@ -88,6 +88,7 @@
|
||||
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
|
||||
#define EGL_CONTEXT_FLAGS_KHR 0x30fc
|
||||
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
|
||||
#define EGL_NATIVE_VISUAL_ID 0x302e
|
||||
#define EGL_NO_SURFACE ((EGLSurface) 0)
|
||||
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
|
||||
@ -160,6 +161,7 @@ typedef struct _GLFWlibraryEGL
|
||||
EGLint major, minor;
|
||||
|
||||
GLFWbool KHR_create_context;
|
||||
GLFWbool KHR_create_context_no_error;
|
||||
|
||||
void* handle;
|
||||
|
||||
|
@ -380,6 +380,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
|
||||
if (ctxconfig->debug)
|
||||
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
||||
if (ctxconfig->noerror)
|
||||
flags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
|
||||
|
||||
if (ctxconfig->robustness)
|
||||
{
|
||||
|
@ -65,6 +65,7 @@
|
||||
#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82fb
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc
|
||||
#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
|
||||
|
||||
typedef int GLint;
|
||||
typedef unsigned int GLuint;
|
||||
@ -195,6 +196,7 @@ struct _GLFWctxconfig
|
||||
int minor;
|
||||
GLFWbool forward;
|
||||
GLFWbool debug;
|
||||
GLFWbool noerror;
|
||||
int profile;
|
||||
int robustness;
|
||||
int release;
|
||||
@ -262,7 +264,7 @@ struct _GLFWwindow
|
||||
struct {
|
||||
int api;
|
||||
int major, minor, revision;
|
||||
GLFWbool forward, debug;
|
||||
GLFWbool forward, debug, noerror;
|
||||
int profile;
|
||||
int robustness;
|
||||
int release;
|
||||
|
@ -382,6 +382,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
|
||||
if (ctxconfig->debug)
|
||||
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
||||
if (ctxconfig->noerror)
|
||||
flags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
|
||||
|
||||
if (ctxconfig->robustness)
|
||||
{
|
||||
|
@ -357,6 +357,9 @@ GLFWAPI void glfwWindowHint(int target, int hint)
|
||||
case GLFW_OPENGL_DEBUG_CONTEXT:
|
||||
_glfw.hints.context.debug = hint ? GLFW_TRUE : GLFW_FALSE;
|
||||
break;
|
||||
case GLFW_CONTEXT_NO_ERROR:
|
||||
_glfw.hints.context.noerror = hint ? GLFW_TRUE : GLFW_FALSE;
|
||||
break;
|
||||
case GLFW_OPENGL_PROFILE:
|
||||
_glfw.hints.context.profile = hint;
|
||||
break;
|
||||
@ -629,6 +632,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
return window->context.profile;
|
||||
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
|
||||
return window->context.release;
|
||||
case GLFW_CONTEXT_NO_ERROR:
|
||||
return window->context.noerror;
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute");
|
||||
|
@ -88,6 +88,7 @@ static void usage(void)
|
||||
printf(" --stereo request stereo rendering\n");
|
||||
printf(" --srgb request an sRGB capable framebuffer\n");
|
||||
printf(" --singlebuffer request single-buffering\n");
|
||||
printf(" --no-error request a context that does not emit errors\n");
|
||||
}
|
||||
|
||||
static void error_callback(int error, const char* description)
|
||||
@ -226,7 +227,7 @@ int main(int argc, char** argv)
|
||||
MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
|
||||
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
||||
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
||||
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER };
|
||||
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR };
|
||||
const struct option options[] =
|
||||
{
|
||||
{ "behavior", 1, NULL, BEHAVIOR },
|
||||
@ -255,6 +256,7 @@ int main(int argc, char** argv)
|
||||
{ "stereo", 0, NULL, STEREO },
|
||||
{ "srgb", 0, NULL, SRGB },
|
||||
{ "singlebuffer", 0, NULL, SINGLEBUFFER },
|
||||
{ "no-error", 0, NULL, NOERROR },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
@ -447,6 +449,9 @@ int main(int argc, char** argv)
|
||||
case SINGLEBUFFER:
|
||||
glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_FALSE);
|
||||
break;
|
||||
case NOERROR:
|
||||
glfwWindowHint(GLFW_CONTEXT_NO_ERROR, GLFW_TRUE);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
@ -500,6 +505,8 @@ int main(int argc, char** argv)
|
||||
printf(" debug");
|
||||
if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB)
|
||||
printf(" robustness");
|
||||
if (flags & 8/*GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR*/)
|
||||
printf(" no-error");
|
||||
putchar('\n');
|
||||
|
||||
printf("%s context flags parsed by GLFW:", get_api_name(api));
|
||||
@ -510,6 +517,8 @@ int main(int argc, char** argv)
|
||||
printf(" debug");
|
||||
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
printf(" robustness");
|
||||
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_NO_ERROR))
|
||||
printf(" no-error");
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user