SFML community forums

Help => Graphics => Topic started by: fallahn on January 18, 2016, 08:51:12 pm

Title: Errors setting transform with new shader API
Post by: fallahn on January 18, 2016, 08:51:12 pm
I've recently updated to the latest revision of SFML eager to try out the new shader uniform settings (particularly the ability to set arrays of data) and run into the following problem when trying to set a matrix parameter with sf::Transform:

int main()
{
    sf::Shader shader;
    shader.loadFromMemory(xy::Shader::NormalMapped::vertex, xy::Shader::NormalMapped::fragment);

    sf::Transform tx;
    shader.setUniform("u_inverseWorldViewMat", tx);

    return 0;
}
 

won't compile because 'setUniform(const std::string&, sf::Glsl::Mat3&) and setUniform(const std::string&, sf::Glsl::Mat4&) are ambiguous', and

int main()
{
    sf::Shader shader;
    shader.loadFromMemory(xy::Shader::NormalMapped::vertex, xy::Shader::NormalMapped::fragment);

    sf::Transform tx;
    shader.setUniform("u_inverseWorldViewMat", sf::Glsl::Mat4(tx));

    return 0;
}
 

gives me:

Error   LNK2001   unresolved external symbol "void __cdecl sf::priv::copyMatrix(class sf::Transform const &,struct sf::priv::Matrix<4,4> &)" (?copyMatrix@priv@sf@@YAXABVTransform@2@AAU?$Matrix@$03$03@12@@Z)   Example   C:\Users\Documents\Visual Studio 2015\Projects\xygine\Example\main.obj   1   

Clean build and install of SFML using the latest revision with Visual Studio 2015 Community, Windows 7 Pro 64bit. I can see the function in question in Glsl.cpp which is included in the solution generated by CMake, so I'm not sure why it should be unresolved. The old setParameter() functions work fine.
Title: Re: Errors setting transform with new shader API
Post by: Tank on January 20, 2016, 12:05:45 pm
Just tested this and fixed it by prepending SFML_GRAPHICS_API to "void copyMatrix(const Transform& source, Matrix<4, 4>& dest)" in Glsl.inl.

copyMatrix() is being called by template code, thus it gets effectively called by the user. Ergo it has to be exported.

As the copyMatrix()/copyVector() functions (and probably others) are no templates, I suggest moving them to Glsl.hpp, to eliminate confusion.