I'm starting to lean in the direction you went. Though I find Vec2f, Vec3b, Vec4i, etc a bit more readable.
Yes, but this would combine the disadvantage of being inconsistent to SFML's existing vector types with the disadvantage of not representing GLSL types. I don't think introducing a third convention is a good idea
SFML3 with C++11 might allow for some nice ways to work with this.
template<typename T>
using Vec4<T> = std::array<T, 4>;
using Vec4f = Vec4<float>;
Then we have to access members using
[0], [1], [2], [3] instead of
x, y, z, w, which is again inconsistent. Writing a
Vector4 type is really trivial, I would deliberately not provide any mathematical operations.
True. I just find the setUniform<float>(5.3f) syntax a bit nicer than several different function names.
Yes, but is
setUniform<sf::Glsl::Matrix4>(name, values)
also nicer than
setUniformMat4(name, values)
?
There's quite a few reasons that favor
setUniform overloads (not specializations), foremost genericity and type inference. But it forces the user to always use the dedicated SFML types. One one hand, this makes calls more verbose and adds unneeded copies (unless we use pointer semantics):
shader.setUniform(sf::Glsl::Mat4(name, values));
// instead of
shader.setUniformMat4(name, values);
Also, it adds another layer to conversions when there are multiple options, that is:
sf::Transform transform;
shader.setUniform(sf::Glsl::Mat3(transform));
shader.setUniform(sf::Glsl::Mat4(transform));
// instead of
shader.setUniformMat3(transform);
shader.setUniformMat4(transform);
But maybe we can live with that. We just need to get further in this discussion, the same arguments have already been around for months
By the way, we cannot call the namespace
glsl because it conflicts with the naming convention (
sf::Shapes,
sf::Style). However, the user can easily write
namespace glsl = sf::Glsl;
which also shortens the expressions.