GTK3 vs GTK4 GtkGLArea gtk_gl_area_attach_buffers()

Hello,
I am trying to convert my application to GTK4 (initially merely trying to see how much work is needed to do so).
It uses GtkGLArea extensively. My application works without OpenGL errors in GTK3, but the GTK4 version sets a GL error (1282) after gtk_gl_area_attach_buffers() has been called. Additionally, and may be related, there are framebuffer errors (glCheckFramebufferStatus() fails) in the GTK4 version (but not using GTK3). Much of the other OpenGL setup code works OK though. So have I missed something with regards to setting up framebuffers that I need to do in GTK4 that is not needed in GTK3? Maybe I am calling gtk_gl_area_attach_buffers() from the wrong place? I note that the documentation says that gtk_gl_area_attach_buffers() should not be needed much in user code, but I have found that I needed it extensively when making mesh buffers.

Maybe this question should be in “Platform” - I am not sure.

Thanks.

Are you doing drawing outside the render callback? Or can you show the render callback you are using? I remember having similar problems but cannot remember the details, it is possible your GL context is not getting set up correctly.

I should have mentioned that this is going on in the realize() callback - we are not at the drawing stage yet.

The project is called Coot - GitHub - pemsley/coot at gtk4

It is a non-trivial piece of software.

In trying to answer your question I see this:

on_glarea_realize(GTK_GL_AREA(glarea)); // hacketty hack. I don't know why realize is not called
                                        // without this.

So let me have another look and get back to you. Thank you for your time.

That does look like it could be the issue, I seem to remember the GL context will not exist before realize is called.

That was it! I got rid of the hack and found there was some problem with “linking” the realize() and render() callbacks - when the callback functions were in the same file (and above their invocation) then it worked! I really appreciate your insight.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.