Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use GLArea in node-gtk? #368

Open
kevinJ045 opened this issue Jul 25, 2024 · 1 comment
Open

How to use GLArea in node-gtk? #368

kevinJ045 opened this issue Jul 25, 2024 · 1 comment

Comments

@kevinJ045
Copy link

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?

@romgrk
Copy link
Owner

romgrk commented Jul 25, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants