Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 637
JuStTheDev Avatar asked Oct 08 '16 21:10

JuStTheDev


1 Answers

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

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

like image 158
Starl1ght Avatar answered Sep 21 '22 18:09

Starl1ght