gl_FragData in GL Programmable Renderer

I’m trying to port a shader #version 120 to #version 150, since I’m using the GL Programmable Renderer.

The standard functions and variable names are easy to translate.

However, the shader is using gl_FragData and I’m not being able to port it properly. I know it’s been deprecated since OpenGL 3.0 and that I need to use glBindFragDataLocation, but I’m not sure how to properly set it up in OF.

Anyone out there with experience in this topic?

I always appreciate any kind of help or comment from the OF community!

if i remember well you just need to define several variables in the fragment shader as out and each will go to a different target in the order they are defined. like:

out vec4 data0; 
out vec4 data1;
....

but if that doesn’t work, you might need to compile the shader manually instead of using load and then before linking use glBindFragDataLocation for each of the out variables:

shader.setupShaderFromFile(GL_VERTEX_SHADER, "shader.vert");
shader.setupShaderFromFile(GL_FRAGMENT_SHADER, "shader.frag");
glBindFragDataLocation(shader.getProgram(), 0, "data0");
glBindFragDataLocation(shader.getProgram(), 1, "data1");
shader.linkProgram();

That’s what I thought. But thanks for making it clearer. It’s a great example!

Anyway, I realised the problem wasn’t there, while porting the shaders to #version 150.

It wasn’t as straight forward as I though, but I will figure it out.