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

Author Topic: glm::mat4 in setUniform?  (Read 2366 times)

0 Members and 1 Guest are viewing this topic.

scottyaim

  • Newbie
  • *
  • Posts: 3
    • View Profile
glm::mat4 in setUniform?
« on: October 07, 2016, 10:33:24 pm »
Hi, I am trying to load a glm::mat4 into a shader but there are no overloads for glm::mat4 in shader.setUniform().

Is there any why to upload a glm::mat4 into a uniform with shader.setUniform()?

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: glm::mat4 in setUniform?
« Reply #1 on: October 08, 2016, 06:45:07 am »
Because SFML isn't GLM?

You'll need to pass it as a sf::Glsl::Mat4.

scottyaim

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: glm::mat4 in setUniform?
« Reply #2 on: October 09, 2016, 01:16:49 pm »
Because SFML isn't GLM?

You'll need to pass it as a sf::Glsl::Mat4.

Okay i see. What is an easy why to pass a glm::mat4 for into a Glsl::mat4?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: glm::mat4 in setUniform?
« Reply #3 on: October 09, 2016, 01:54:26 pm »
It's not that hard, just look at the documentation.

Quote
The matrix can be constructed from an array with 4x4
elements, aligned in column-major order. For example,
a translation by (x, y, z) looks as follows:

float array[16] =
{
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0,
    x, y, z, 1
};
sf::Glsl::Mat4 matrix(array);

And then in glm::mat4 you have glm::value_ptr to get a float* out of a glm::mat4.
Laurent Gomila - SFML developer

scottyaim

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: glm::mat4 in setUniform?
« Reply #4 on: October 09, 2016, 02:50:57 pm »
It's not that hard, just look at the documentation.

Quote
The matrix can be constructed from an array with 4x4
elements, aligned in column-major order. For example,
a translation by (x, y, z) looks as follows:

float array[16] =
{
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0,
    x, y, z, 1
};
sf::Glsl::Mat4 matrix(array);

And then in glm::mat4 you have glm::value_ptr to get a float* out of a glm::mat4.

Thank you that solved it!