JuStTheDev
JuStTheDev

Reputation: 235

Howto use glm constants in c++/opengl

I am programming with just OpenGL and use GLM (OpenGL Mathematics). I found out that there is this extension in GLM called "GLM_GTC_constants" that should provide a list of built-in constants. This is how a function header looks in constants.hpp:

/// Return the pi constant.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType pi();

The function itself looks like this (constants.inl):

template <typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi()
{
    return genType(3.14159265358979323846264338327950288);
}

Now I'm wondering how to use this function.


glm::pi();

Using the function like above doesn't work.

float PI = glm::pi();

The code above, for example, gives me this error:

error: no matching function for call to ‘pi()’

I searched the documentation but did not find a usage example of those constants anywhere.

Upvotes: 21

Views: 17316

Answers (1)

Starl1ght
Starl1ght

Reputation: 4493

Type should be specified explicitly for using this templated function, since there's no argument deduction.

glm::pi<float>() should do the trick

Upvotes: 45

Related Questions