Problems with two macOS opengl3 windows drawing widgets with opengl2 ( bad draw and crashes on exit)

19 views
Skip to first unread message

Gonzalo Garramuno

unread,
Nov 22, 2022, 2:52:59 AM11/22/22
to fltkc...@googlegroups.com

Find attached a modified version of OpenGL3text.cxx which crashes on exit on macOS.
Two OpenGL3 windows drawing widgets are created but only on the second window the buttons appear (and without labels)..

To compile:

$ fltk-config —use-gl —compile OpenGL3test.cxx

To make it crash:

Close the two windows and It will crash


Gonzalo Garramuno
ggar...@gmail.com




Gonzalo Garramuno

unread,
Nov 22, 2022, 2:57:14 AM11/22/22
to fltkc...@googlegroups.com
Oops. I forgot the OpenGL3test.cxx attachment.
OpenGL3test.cxx

melcher....@googlemail.com

unread,
Nov 22, 2022, 6:18:01 AM11/22/22
to fltk.coredev
I traced the code and it uses a method switch_to_GL1() in the OpenGL graphics driver that I don't understand. I'll have to hand this to Manolo. As an aside, if we implement a second OpenGL3 graphics driver, I can reimplement the FLTK drawing calls to use GL3 instead of GL1, so there is no need for this context switching. Manolo?

Manolo

unread,
Nov 22, 2022, 1:27:13 PM11/22/22
to fltk.coredev
Le mardi 22 novembre 2022 à 08:52:59 UTC+1, ggar...@gmail.com a écrit :

Find attached a modified version of OpenGL3text.cxx which crashes on exit on macOS.
Two OpenGL3 windows drawing widgets are created but only on the second window the buttons appear (and without labels)..

I believe there was a problem with memory deallocation that should be fixed with commit 4daec2a.

Your program may also have other problems because program OpenGL3test.cxx is not meant for
2 GL3 scenes  and contains global variables (Fl_Text_Display *output) and static variables
(e.g., bool first) that won't work well with 2 objects from class SimpleGL3Window.

Manolo

unread,
Nov 22, 2022, 1:34:59 PM11/22/22
to fltk.coredev
Le mardi 22 novembre 2022 à 12:18:01 UTC+1, Matthias a écrit :
I traced the code and it uses a method switch_to_GL1() in the OpenGL graphics driver that I don't understand. I'll have to hand this to Manolo. As an aside, if we implement a second OpenGL3 graphics driver, I can reimplement the FLTK drawing calls to use GL3 instead of GL1, so there is no need for this context switching. Manolo?

Is this proposal  to implement, say, class Fl_OpenGL3_Graphics_Driver that would use GL3 in addition
to the existing GL1-based class Fl_OpenGL_Graphics_Driver, and to use the new driver to draw into GL3 windows ?

That would remove indeed the need for the context switching. Please, notice this driver would not be necessary
under X11 and Windows. Notice also the need for a solution for text drawing compatible with both GL1 and GL3 contexts.

melcher....@googlemail.com

unread,
Nov 22, 2022, 3:32:27 PM11/22/22
to fltk.coredev
Manolo schrieb am Dienstag, 22. November 2022 um 19:34:59 UTC+1:
Le mardi 22 novembre 2022 à 12:18:01 UTC+1, Matthias a écrit :
I traced the code and it uses a method switch_to_GL1() in the OpenGL graphics driver that I don't understand. I'll have to hand this to Manolo. As an aside, if we implement a second OpenGL3 graphics driver, I can reimplement the FLTK drawing calls to use GL3 instead of GL1, so there is no need for this context switching. Manolo?

Is this proposal  to implement, say, class Fl_OpenGL3_Graphics_Driver that would use GL3 in addition
to the existing GL1-based class Fl_OpenGL_Graphics_Driver, and to use the new driver to draw into GL3 windows ?

Exactly. It's a great use for drivers.
 
That would remove indeed the need for the context switching. Please, notice this driver would not be necessary
under X11 and Windows. Notice also the need for a solution for text drawing compatible with both GL1 and GL3 contexts.

Hmm, so you can mix OGL and OGL3 on other platforms? I don't know much about OGL3, except that I really need to learn it ;-)

Manolo

unread,
Nov 22, 2022, 5:13:25 PM11/22/22
to fltk.coredev
Le mardi 22 novembre 2022 à 21:32:27 UTC+1, Matthias a écrit :

Hmm, so you can mix OGL and OGL3 on other platforms?
 
This is related to so called "core profiles" vs "compatibility profiles".
macOS implements a core profile which supports only OGL3 and crashes
each time an OGL1 function is called.
Other platforms implement compatibility profiles with which both
OGL3 and OGL1 are usable.

Manolo

unread,
Nov 24, 2022, 3:56:46 PM11/24/22
to fltk.coredev
Le mardi 22 novembre 2022 à 08:52:59 UTC+1, ggar...@gmail.com a écrit :

Find attached a modified version of OpenGL3text.cxx which crashes on exit on macOS.
Two OpenGL3 windows drawing widgets are created but only on the second window the buttons appear (and without labels)..

With commit c3011e3, the handling of several OpenGL3 windows with text under macOS should be much better.
Reply all
Reply to author
Forward
0 new messages