glClear not working with black in GTK4 with pyopengl


I’ve been testing GTK.GLArea to render a grid with the gpu. However when I use glClear(0,0,0,1) it does not work; it simply does not clear with the black color, as if it was transparent, instead the background window color is shown. If I use glClear(0.0001,0,0,1) it will work as expected, same with glClear(0,0,0,0.9999) or glClear(1,0,0,1)

I’ve been thinking pure black is somehow masked by GTK4 or OpenGL but all leads have died. What’s the issue and how can I fix this?

Minimal example:

import gi

gi.require_version('Gtk', '4.0')
from gi.repository import Gtk

from OpenGL import GL

def on_render( glarea, glcontext):

def on_activate(app):
    win = Gtk.ApplicationWindow(application=app)
    glarea = Gtk.GLArea()
    glarea.connect("render", on_render )

    win.set_child( glarea )

app = Gtk.Application()
app.connect('activate', on_activate)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.