node-gtk
node-gtk copied to clipboard
How to use GLArea in node-gtk?
I keep trying a few codes but it's not working at all.
I have been trying this:
const gi = require('node-gtk');
const Gtk = gi.require('Gtk', '3.0');
Gtk.init();
const win = new Gtk.Window({
type: Gtk.WindowType.TOPLEVEL,
title: 'Gtk.GLArea Example',
});
win.setDefaultSize(800, 600);
win.on('destroy', () => Gtk.mainQuit());
const glArea = new Gtk.GLArea();
glArea.on('realize', () => {
glArea.makeCurrent();
console.log('done');
});
glArea.on('render', () => {
const gl = glArea.getContext();
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
return true;
});
win.add(glArea);
win.showAll();
Gtk.main();
the gl seems to be an instance of GdkWaylandGLContext but it keeps saying TypeError: gl.clearColor is not a function. How am i supposed to actually use GLArea inside of node-gtk and is it even possible?
The functions need to be bound through GObject-Introspection for C objects to be usable in javascript. Is this example working for any other GIR library such as pygobject or GJS?