GLSL shaders

Hey, does someone have some pointers for how one can use GLSL in Haiku? I see Medo has support for GLSL shaders.

I am looking to port Anime4k https://github.com/bloc97/Anime4K/ into a translator, and then figure out how this could be used in ShowImage and MediaPlayer.

Hi nephele. To setup source code to use GLSL, you really need to know OpenGL (preferrebly core profile 3.3+) or GLES 2.0+. To see any quad on screen, you need to setup geometry, transformations, texture buffers + shaders, etc, so you’re looking at 200-300 lines of code at least. There is no shortcut that I know off.

Medo uses OpenGL for effects via a wrapper called Yarra API which simplifies the raw OpenGL part, but again you need to know OpenGL to use it. It’s an example of the bare minimum 200-300 lines of code an app needs to allow GLSL shader code to integrate with an app. See the Yarra directory in the Medo source for the OpenGL bare minimum you need. I have a fully featured 3D engine with the usual featured bells and whistles (cascade shadow maps, skeletal animation, model loading etc), all built on top of that skeleton but that is another story. These days my other projects are Vulkan based.

1 Like

Hmm, i suppose my case is slightly simpler, since i want to render from a bbitmap to a bbitmap, and don’t need any windows to display pixels :g.

I will look at the medo source to try to understand it, I only have a very basic understanding of OpenGL anyhow

GLSL implementation is through the Mesa GLSL compiler. If you maintain GLSL 1.30 compatibillity, your shaders will work on Haiku R1B2. I’ve tested up to GLSL 1.40 on Haiku, so its possible to get things working.

Apparently, Anime4k doesn’t handle shaders itself but is using mpv to do it. Is it possible to do that as a translator?

anime4k /is/ a shader, The question on my oart is a bit how i can use opengl to handle glsl on haiku to then put this in a translator.
I know how it works in a very birad sense, but am a bit clueless for the specifics