Package: gtk
Class gtk:gl-area
Superclassesgtk:widget, gobject:initially-unowned, gtk:accessible, gtk:buildable, gtk:constraint-target, gobject:object, common-lisp:standard-object, common-lisp:t Documented Subclasses
None
Direct SlotsDetails The gtk:gl-area widget is a widget that allows drawing with OpenGL. ![]() The gtk:gl-area widget sets up its own gdk:gl-context object for the window it creates, and creates a custom GL framebuffer that the widget will do GL rendering onto. It also ensures that this framebuffer is the default GL rendering target when rendering. In order to draw, you have to connect to the "render" signal, or subclass the gtk:gl-area widget and override the render() virtual function. The gtk:gl-area widget ensures that the gdk:gl-context object is associated with the drawing area of the widget, and it is kept updated when the size and position of the drawing area changes. Drawing with GtkGLAreaThe simplest way to draw using OpenGL commands in a gtk:gl-area widget is to create a widget instance and connect to the "render" signal.The render() function will be called when the gtk:gl-area widget is ready for you to draw its content: static gboolean render (GtkGLArea *area, GdkGLContext *context) { // inside this function it's safe to use GL; the given // GdkGLContext has been made current to the drawable // surface used by the `GtkGLArea` and the viewport has // already been set to be the size of the allocationIf you need to initialize OpenGL state, for example buffer objects or shaders, you should use the "realize" signal. You can use the "unrealize" signal to clean up. Since the gdk:gl-context object creation and initialization may fail, you will need to check for errors, using the gtk:gl-area-error function. An example of how to safely initialize the GL state is: static void on_realize (GtkGLarea *area) { // We need to make the context current if we want to // call GL API gtk_gl_area_make_current (area);If you need to change the options for creating the gdk:gl-context object you should use the "create-context" signal. Signal DetailsThe "create-context" signallambda (area) :run-last
The "render" signallambda (area context) :run-last
The "resize" signallambda (area width height) :run-last
| Returned bySlot Access Functions
Inherited Slot Access Functions |
2024-10-26