gl_draw() on OpenGL 3

14 views
Skip to first unread message

Gonzalo Garramuno

unread,
Nov 17, 2022, 3:57:58 PM11/17/22
to fltkc...@googlegroups.com
As you may be aware, I am working with OpenGL which is working great. However, now in my program I am facing the need for font rendering. The video library I am using has font drawing using free type and shaders but it is limited to just two fonts.

FLTK.supports all fonts (and internationaliztation) on widgets, which I can show to my gl window and it works. However, I am also in the need for drawing the font with transparency (alpha channel).

In my previous version of my video program, I would show a FL_Multiline_Input to edit the text. Then once the user would confirm the input by pressing on the green X on my custom widget, I would switch to GL drawing of the font using gl_draw and would change the glColor() of the font to make it fade in and fade out while playing the video.

Sadly, with OpenGL3 gl_draw() will not work. So I am looking for advice and suggestions.



Gonzalo Garramuno
ggar...@gmail.com




imm

unread,
Nov 17, 2022, 4:27:16 PM11/17/22
to coredev fltk
Can you draw a (transparent) window over your GL3 region, and draw into that with regular fltk methods, or as "basic" GL where gl_draw() can work?
Would that work?

Did Manolo not have some mechanism for enabling GL.old drawing into a GL3 context?
If that were done, then gl_draw() ought to then work I'd imagine?

--
Ian
From my Fairphone FP3

Manolo

unread,
Nov 18, 2022, 1:51:10 AM11/18/22
to fltk.coredev
Le jeudi 17 novembre 2022 à 22:27:16 UTC+1, imacarthur a écrit :


Did Manolo not have some mechanism for enabling GL.old drawing into a GL3 context?
If that were done, then gl_draw() ought to then work I'd imagine?

Yes. Here is this mechanism as an example.
Replace line #142 of example/OpenGL3test.cxx by this :

    //Fl_Gl_Window::draw(); // Draw FLTK child widgets.
    Fl_Gl_Window::draw_begin(); // Set up 1:1 projection
    Fl_Window::draw();          // Draw FLTK children
    fl_color(FL_FREE_COLOR);
    fl_font(FL_TIMES_ITALIC, 25);
    gl_draw("Drawn by gl_draw()", 10, 100);
    Fl_Gl_Window::draw_end();   // Restore GL state

and you'll see text drawn by gl_draw() above the GL3 scene in a partially transparent white
(that color was defined before in function add_widgets()).

But, the GL1 scene containing text doesn't use the same coordinates as
those used in the GL3 scene below. Therefore, you would have to  compute
adequately the coordinates of the point where to draw text.

 

Manolo

unread,
Nov 18, 2022, 2:00:14 AM11/18/22
to fltk.coredev
Alternatively, a developer who masters GL3 may study the present FLTK code that
supports the gl_draw() function to draw text in a GL1 scene, and suggest how to transform it
to draw text directly to a GL3 scene.

imacarthur

unread,
Nov 18, 2022, 7:12:45 AM11/18/22
to fltk.coredev
This (attached) doesn't really do what Gonzalo was asking for, but it sort of looks like it does...
Not really a solution, but might work as a stopgap until something better comes up!
 
fade_text.zip

Gonzalo Garramuno

unread,
Nov 19, 2022, 6:14:11 AM11/19/22
to fltkc...@googlegroups.com


> El 18 nov. 2022, a las 03:51, Manolo <manol...@gmail.com> escribió:
>
>
>
> Le jeudi 17 novembre 2022 à 22:27:16 UTC+1, imacarthur a écrit :
>
>
> Did Manolo not have some mechanism for enabling GL.old drawing into a GL3 context?
> If that were done, then gl_draw() ought to then work I'd imagine?
>
> Yes. Here is this mechanism as an example.
> Replace line #142 of example/OpenGL3test.cxx by this :
>

Thanks, Manolo. It works great!

>
> and you'll see text drawn by gl_draw() above the GL3 scene in a partially transparent white
> (that color was defined before in function add_widgets()).
>
> But, the GL1 scene containing text doesn't use the same coordinates as
> those used in the GL3 scene below. Therefore, you would have to compute
> adequately the coordinates of the point where to draw text.

Duly noted. I am now struggling with the matrix transformations to make both things match. The thing that makes it difficult in my case is that I need to support zooming and panning in my viewer.


Gonzalo Garramuno
ggar...@gmail.com




Reply all
Reply to author
Forward
0 new messages