Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Errors setting transform with new shader API  (Read 2614 times)

0 Members and 1 Guest are viewing this topic.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Errors setting transform with new shader API
« 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.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Errors setting transform with new shader API
« Reply #1 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.