If I use:
wxGLContextAttrs ctxAttrs;
ctxAttrs.PlatformDefaults().ReleaseFlush().EndList();
wxGLContext* context = new wxGLContext( aCanvas, aOther, &ctxAttrs );to flush the calls, I have to release the context by doing (on MSW):
wglMakeCurrent( nullptr, nullptr );
but there doesn't appear to be an API within wx to do such a call.
Also, wxGLContextAttrs::ReleaseFlush is no-op in EGL but seems like it should be supported.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Sorry, I know nothing about GLX_CONTEXT_RELEASE_BEHAVIOR_ARB (well, I've just quickly looked it up, so now I do know something, but not much), so I don't understand why does using it require calling wglMakeCurrent(0,0), but we could add a static void wxGLContext::ReleaseCurrent() wrapping it, of course. Would its implementation need to do glXMakeCurrent(0,0,0) and eglMakeCurrent(0,0,0,0) in GLX/EGL respectively? And under macOS it looks like we'd need to do [NSOpenGLContext clearCurrentContext], right?
cc @Manolo-ES
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
wglMakeCurrent( NULL, NULL );glXMakeContextCurrent( dpy, None, None, NULL ); for GLX > 1.2glXMakeCurrent( dpy, None, NULL ); for GLX <= 1.2eglMakeCurrent( dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );clearCurrentContext seems correct.—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
OK, thanks, I'll add this soon.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Also, wxGLContextAttrs::ReleaseFlush is no-op in EGL but seems like it should be supported.
Sorry, forgot to ask: do you mean that we can reuse the same implementation as for GLX and have you already tested that it worked by chance? If not, how exactly can I test whether it works or not?
BTW, wxOSX and wxQt don't support this either, but let's leave this for a separate issue (if anybody cares enough to open one).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
do you mean that we can reuse the same implementation as for GLX
Except for EGL, the constants should be:
EGL_CONTEXT_RELEASE_BEHAVIOR_KHR
EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR
EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR
have you already tested that it worked by chance?
I'm only testing on Windows for now and I see in the profiler that using ReleaseFlush + wglMakeCurrent( nullptr, nullptr ); does its thing.
If not, how exactly can I test whether it works or not?
I think you can query it:
Accepted by the <pname> parameter of GetIntegerv, GetFloatv, GetBooleanv
GetDoublev and GetInteger64v:
GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB
Returned in <data> by GetIntegerv, GetFloatv, GetBooleanv
GetDoublev and GetInteger64v when <pname> is
GL_CONTEXT_RELEASE_BEHAVIOR:
GL_NONE 0x0000
GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I've added this function in #25958 but I have some trouble with implementing support for this attribute for EGL: after adding
diff --git a/src/unix/glegl.cpp b/src/unix/glegl.cpp index 78f8f3a6e0..af396b0ec0 100644 --- a/src/unix/glegl.cpp +++ b/src/unix/glegl.cpp @@ -125,8 +125,13 @@ wxGLContextAttrs& wxGLContextAttrs::ResetIsolation() return *this; } -wxGLContextAttrs& wxGLContextAttrs::ReleaseFlush(int) +wxGLContextAttrs& wxGLContextAttrs::ReleaseFlush(int val) { + AddAttribute(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR); + if ( val == 1 ) + AddAttribute(EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR); + else + AddAttribute(EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR); return *this; }
I've modified the sample like this:
diff --git a/samples/opengl/cube/cube.cpp b/samples/opengl/cube/cube.cpp index f2b628ac9d..22107d9c88 100644 --- a/samples/opengl/cube/cube.cpp +++ b/samples/opengl/cube/cube.cpp @@ -128,11 +128,39 @@ static wxImage DrawDice(int size, unsigned num) // TestGLContext // ---------------------------------------------------------------------------- +#include <EGL/egl.h> +#include <EGL/eglext.h> + +wxGLContextAttrs* GetAttrs() +{ + static wxGLContextAttrs s_attrs; + static bool s_initialized = false; + + if ( !s_initialized ) + { + s_attrs.PlatformDefaults().ReleaseFlush(0).EndList(); + s_initialized = true; + } + + return &s_attrs; +} + TestGLContext::TestGLContext(wxGLCanvas *canvas) - : wxGLContext(canvas) + : wxGLContext(canvas, nullptr, GetAttrs()) { SetCurrent(*canvas); + EGLint value; + if (!eglQueryContext(eglGetCurrentDisplay(), eglGetCurrentContext(), + EGL_CONTEXT_RELEASE_BEHAVIOR_KHR, &value)) + { + wxLogDebug("eglQueryContext failed: %x", eglGetError()); + } + else + { + wxLogDebug("EGL_CONTEXT_RELEASE_BEHAVIOR = %x", value); + } + // set up the parameters we want to use glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST);
but this outputs
23:52:02: Debug: eglQueryContext failed: 3004
where 3004 is EGL_BAD_ATTRIBUTE. Do you see something obviously wrong here that I don't by chance?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Closed #25951 as completed via f0309c9.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()