I've been using GLGraphics to work with -for now mainly fragment- shaders. All computation is handled within the shader which is working really well. To tweak settings in real-time, I'm sending some (uniform) variables from Processing to the shader. Again, working fine.
Now I'd like to send an array of variables* to the shader. Is this possible in GLGraphics? And if so, how?
* meaning: more variables than 4 floats into a vec4, rather something like vec2 or vec3
The GLSLShader class doesn't expose the glUniformNfv (glUniform1fv, glUniform2fv, etc) you would need to pass an array of values to the shader. As a workaround, you could just call them after grabbing a reference to the GL object:
I forgot to mention my program runs the fragment shader through the GLTextureFilter class. It is very convenient as it returns the result directly into the GLTexture. I will try out your suggestion with the GLSLShader class. However, is something like this also possible when using the GLTextureFilter class?
Actually, you can set a filter parameter of type "array" which you can use to store arrays of floats of arbitrary length. For instance, to define a float array of 7 elements, you should add to the filter's xml file a line similar to this:
With these two solutions I have different routes to realise what I want.
What I like a lot about the manual glUniformNfv solution is that it's very easy to pour a float array into another data type array like vec2, vec3 or vec4 which might make more sense within the context of the shader. Is such a float to vecN array transfer also possible with GLTextureFilter parameters?