Drawing in GLArea with GJS

,

Hey! I am trying to draw the OpenGL in GLArea, with JavaScript in Workbench. And I can’t find something about using GLArea with JS, I tried this, for example , just clear the area :

const gl_area = workbench.builder.get_object("gl_area");

let render = function (area, context) {
  //?glClearColor...
  //?area.clear_color...;
  //?context.clear_color..
  //?context.clearColor...

  return true;
};
gl_area.connect("render", render);

All functions in comments do not possible to find.

Any advices, suggestions, something?

*also will be usefull if you know apps with OpenGL with GJS

OpenGL is not introspected via gobject-introspection, and gjs does not have a custom binding for it. That means that it cannot be used from javascript.

1 Like

Maybe you know a not custom bindings? I mean, Epoxy in C and in GTK, and it possible to write a custom binding(cuz all possible,heh). I mean I can be very naive in this, and had saw the Gobject-Inrospection site, and not sure can I or not can I write it, not really understand complexity of this, and from where to start also…

Libepoxy is not a GObject-based library, so you can’t use introspection to make bindings for it. You would need something like the Cairo module in GJS, with handwritten bindings; unfortunately, the API exposed by libepoxy is dependent on the GL specification, which means you’d have to generate the binding code as well. In practice, it’s not exactly trivial to write a JavaScript binding for OpenGL.

1 Like

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