SFML community forums
General => General discussions => Topic started by: Phynx on May 27, 2016, 09:47:11 pm
-
I just had to register and say thanks for the new features that was added to sf::shader, being able to set array uniforms is what I've needed for awhile.
was wondering about being able to set custom struct arrays, would that be possible now?
ex:
#define MAX_LIGHTS 32
struct Light{
vec3 position;
vec4 color;
};
uniform Light sceneLights[MAX_LIGHTS];
-
Aye the new interface is far more useful than the now deprecated one. As far as I can tell opengl itself doesn't provide a way to supply struct data unless you directly address its members like this (http://stackoverflow.com/questions/23591264/how-to-pass-uniform-array-of-struct-to-shader-via-c-code) or this (https://github.com/fallahn/xygine/blob/master/Example/src/ParticleDemoState.cpp#L126). If you prefer, and you can ensure an opengl > 3 context, I have found uniform buffers (https://www.opengl.org/wiki/Uniform_Buffer_Object) can work well (https://github.com/fallahn/xygine/blob/master/xygine/include/xygine/mesh/UniformBuffer.hpp#L39) with SFML.
-
Thanks, I will need to look into those for sure since with any sfml build newer than the stable 2.3.2 I run into a stack overflow when loading textures in a thread