View Issue Details

IDProjectCategoryView StatusLast Update
0037004LazarusLCLpublic2020-05-01 20:40
ReporterErik Rößiger Assigned To 
Status newResolutionopen 
Summary0037004: gtk3: Graphics glitches in application with OpenGL widget and Anchor Docking
DescriptionIn my application I am using the Anchor Docking and the OpenGL widget. Both seem to not work well with gtk3 (see attached screenshot).
The form with the OpenGL component renders black and sometimes flickers and briefly shows the controls.
The form with the Anchor Docking components just renders them all at the bottom of the window, the layout entirely broken.

The console is spammed with a good amount of the same error:

(ale_editor_debug_x86_64-linux:14905): Gtk-WARNING **: 18:08:36.868: Negative content height -1 (allocation 1, extents 1x1) while allocating gadget (node scrolledwindow, owner GtkScrolledWindow)

The application works perfectly in gtk2, though. No rendering issues and no critical warnings there.
TagsNo tags attached.
Fixed in Revision
Attached Files


Erik Rößiger

2020-05-01 18:19


grafik.png (35,091 bytes)   
grafik.png (35,091 bytes)   

Chris Rorden

2020-05-01 20:17

reporter   ~0122584

Last edited: 2020-05-01 20:19

View 2 revisions

1. Be aware that GTK3 only supports the OpenGL Core profile. This is not a limitation of Lazarus, but a feature of GTK3. Therefore, if you use the OpenGL legacy profile (e.g. your 'uses' section includes 'gl', 'glext' or 'dglOpenGL') it will not work with GTK3.
The following examples show how to use the OpenGL Core specification (with 'glcorearb' in the uses section). (only projects named "*_gl.lpi")
The core specification removes support for legacy features like the fixed function pipeline, glMatrix, etc. So upgrading a project to the Core profile is not trivial. On the other hand, OpenGL core is similar to OpenGL ES, Vulkan and Metal. So a Core OpenGL project is typically easier to port to these other APIs. Further, it removes poor performance features, so typically uses your GPU resources much more efficiently.

2. Be aware that GTK3's OpenGL does not support multi-sampling. Therefore, visual appearance will be poorer than other Widgetsets (GTK2, QT5, Windows, Cocoa). This is an inherent limitation of GTK3, not Lazarus. Since development has moved to GTK4, this will not be fixed. This makes GTK3 a poor target for OpenGL projects.

The good news is that the Lazarus QT5 widgets has advanced rapidly, and seems pretty mature. For my own OpenGL projects (MRIcroGL, Surfice) I moved from GTK2 to QT5. Lazarus made this transition seamless.

Erik Rößiger

2020-05-01 20:40

reporter   ~0122586

Alright, thank you for those hints! I will check the code for those dependencies and see if GTK3 is even suitable for me then.

Issue History

Date Modified Username Field Change
2020-05-01 18:19 Erik Rößiger New Issue
2020-05-01 18:19 Erik Rößiger File Added: grafik.png
2020-05-01 18:20 Jonas Maebe Project FPC => Lazarus
2020-05-01 20:17 Chris Rorden Note Added: 0122584
2020-05-01 20:19 Chris Rorden Note Edited: 0122584 View Revisions
2020-05-01 20:40 Erik Rößiger Note Added: 0122586