Fl_Gl_Window glViewport(0,0,pixel_w(),pixel_h()) and child widget size?

7 views
Skip to first unread message

duncan gibson

unread,
Dec 15, 2025, 7:31:58 PM (22 hours ago) Dec 15
to fltk.general
Hi everyone, I'm back for my annual foray with an FLTK OpengGL3 project.

I'm on a MacBook Pro running MacOS 14.0 (Sonoma) with a 3024x1964 Retina XDR display

Can I first just say the CMake support for FetchContent(FLTK) makes life so much easier :-)

My project basically has half of the main window dedicated to user interface widgets.
and the other half is derived from Fl_Gl_Window, and a lot of the setup logic is based
on the OpenGL3test example and previous help in this forum with Apple specifics.

In a previous incarnation, I had an Fl_Box child of the main window, declared after the
derived Fl_Gl_Window, and positioned over it, to be used for status messages, etc.
That mostly worked, but introduced a dependency on the main window that I thought
could be encapsulated as a true child of the derived Fl_GL_Window instead, especially
when I noticed the Fl_Gl_Window docs describing the additional explicit call to begin().

But, there's no example code to base this on, and when I implemented it, I found that
the size of the Fl_Gl_Window Fl_Box child is half what I think it should be, and if I double
the width, the box appears to be clipped half-way across the Fl_Gl_Window.
Is this me not understanding something [as usual] or possibly a bug?

I've simplified the code down as much as possible, so there's no real OpenGL3 code
with shaders,  there's basically just the OpenGL3 checks, initialization and glViewport().

Any insights gratefully received.

main.cpp
CMakeLists.txt

Manolo

unread,
2:29 AM (15 hours ago) 2:29 AM
to fltk.general
I didn't look at the attached code yet but can already put here some probably relevant information:

An example of adding child FLTK widgets to an Fl_Gl_Window is available with test/cube.cxx.
Another one uses OpenGL3 and is at examples/OpenGL3test.cxx.
Both create child widgets with the desired size and work equally well under macOS with and
without a retina display.
They also show how it's possible to otain a partially transparent color in such widgets.

Reply all
Reply to author
Forward
0 new messages