let-def / wall

(mirror) A vector graphics renderer like NanoVG in OCaml
https://gitea.lakaban.net/def/wall
BSD 3-Clause "New" or "Revised" License
79 stars 6 forks source link

Feature request: an OpenGL canvas inside Wall 2D graphic window #4

Closed ghost closed 1 year ago

ghost commented 2 years ago

Hello Frédéric,

I would like to use Wall for developing an audio scope & spectrum analyzer, for this I would need to get an OpenGL (well, gles2) canvas inside my Wall window. Is it possible that you implement such a thing in a not too far future?

NanoGUI do this, but it's C++ and I want to keep coding in OCaml :-)

Thank for this very neat project, BTW!

let-def commented 2 years ago

That should not be too difficult, but I am not sure how to integrate it nicely. The problem is to compose the state of the internal renderer with any effect done in the canvas.

It could be as simple as a callback invoked at the right point with some information on the state of the openGL renderer. Alternatively, the canvas could be rendered to another target (an FBO) and blitted by wall.

Do you have any thought on that?

ghost commented 2 years ago

No I don't have any ideas, my first exposure with OpenGL is fairly new, I'm a DSP guy doing a bit of programming, without an addiction to Matlab :-)

Do I really need a full blown canvas? I need to draw GL_LINE_STRIP and GL_LINES at 60fps. But drawing those lines with more than 2 API calls is just too ugly.

Here's a screenshot of what I need.

Thanks, Frédéric!

let-def commented 2 years ago

This can be done directly in Wall, using Path API, a stroke and a gradient. It should be very efficient (translating to two draw calls and doing close to no (OCaml) allocation). It will be a lot work to do better (I can tune the implementation a bit if necessary, I paid attention to the hot path but I haven't stressed this particular case), especially if you care about anti-aliasing.

ghost commented 2 years ago

Oh great, you mean that I can use Path.line_to 500 times and GL API is only called at the stroke?

let-def commented 2 years ago

Indeed :)