Questions tagged [glm-math]

GLM is a C++ math library designed to mimic the OpenGL Shading Language's math functions and types (vectors, matrices) as closely as possible.

GLM is a C++ math library designed to mimic the OpenGL Shading Language's math functions and types (vectors, matrices) as closely as possible.

OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications.

Do not confuse the tags and (Generalized linear models)

1335 questions
71
votes
4 answers

Understanding glm::lookAt()

I am following a tutorial to learn OpenGL in which they used glm::lookAt() function to build a view but I cannot understand the working of glm::lookAt() and apparently, there is no detailed documentation of GLM. Can anyone help me understand the…
Cashif Ilyas
  • 1,619
  • 2
  • 14
  • 22
61
votes
6 answers

How do I print vector values of type glm::vec3 that have been passed by reference?

I have a small obj loader and it takes two parameters and passes them back to the input variables.. however this is my first time doing this and i'm not sure how to print said values now. Here is my main function to test if the loader is working. I…
iKlsR
  • 2,642
  • 6
  • 27
  • 45
47
votes
3 answers

How to initialize a glm::mat4 with an array?

I'm using the OpenGL Mathematics Library (glm.g-truc.net) and want to initialize a glm::mat4 with a float-array. float aaa[16]; glm::mat4 bbb(aaa); This doesn't work. I guess the solution is trivial, but I don't know how to do it. I couldn't find a…
j00hi
  • 5,420
  • 3
  • 45
  • 82
36
votes
6 answers

What does left-to-right associativity mean?

I am confused about the definition of left-to-right and right-to-left associativity. I have also seen them called left associativity and right associativity and would like to know which corresponds to which. I know that it relates to the order that…
Francis
  • 1,151
  • 1
  • 13
  • 29
34
votes
2 answers

glm::perspective explanation

I am trying to understand what the following code does: glm::mat4 Projection = glm::perspective(35.0f, 1.0f, 0.1f, 100.0f); Does it create a projection matrix? Clips off anything that is not in the user's view? I wasn't able to find anything on the…
Trt Trt
  • 5,330
  • 13
  • 53
  • 86
30
votes
1 answer

Is glm::ortho() actually wrong?

I recently thought it would be a good idea to switch from the old (deprecated) functionality that OpenGL provides, such as matrix operations and the fixed function pipeline. I am using GLM as my matrix library to simplify things a bit. The problem…
Jamie Syme
  • 528
  • 2
  • 6
  • 10
26
votes
2 answers

Multiplying a matrix and a vector in GLM (OpenGL)

I have a transformation matrix, m, and a vector, v. I want to do a linear transformation on the vector using the matrix. I'd expect that I would be able to do something like this: glm::mat4 m(1.0); glm::vec4 v(1.0); glm::vec4 result = v * m; This…
n s
  • 1,361
  • 2
  • 12
  • 24
22
votes
2 answers

Why can't C++ find GLM headers?

I do not have permissions to put GLM into usr/local/include or usr/include but I need to use GLM for openGL. The code (I am not able to change) looks for GLM like this: #include #include #include…
Barney Chambers
  • 2,720
  • 6
  • 42
  • 78
22
votes
2 answers

Convert glm::vec4 to glm::vec3

How do I convert a glm::vec4 to a glm::vec3? Only x, y, z is required- the w component can be dropped. In GLSL this can be done with .xyz[1], but in glm this results in a compile error: error: 'glm::vec4' has no member named 'xyz' [1]…
SystemParadox
  • 8,203
  • 5
  • 49
  • 57
20
votes
3 answers

Formal parameter with __declspec(align('16')) won't be aligned

I am trying to make function for setting shader uniforms, but when I try to compile it I get this error : Error 2 error C2719: 'value': formal parameter with __declspec(align('16')) won't be aligned Here is code of function: void…
Jozef Culen
  • 344
  • 1
  • 2
  • 10
18
votes
1 answer

glm combine rotation and translation

I have an object which I first want to rotate (about its own center) then translate it to some point. I have a glm::quat that holds the rotation and a glm::vec3 that holds the point to which it needs to be translated. glm::vec3 position; glm::quat…
Jubei
  • 1,686
  • 1
  • 17
  • 28
18
votes
1 answer

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…
JuStTheDev
  • 204
  • 1
  • 2
  • 9
17
votes
3 answers

glm rotate usage in Opengl

I am rendering a cone, and I would like to rotate it, 90 degrees anti-clockwise, so that the pointy end faces west! I am using OpenGL 3+. Here is my code in my Cone.cpp so far: //PROJECTION glm::mat4 Projection = glm::perspective(45.0f, 1.0f,…
Test Test
  • 2,831
  • 8
  • 44
  • 64
16
votes
1 answer

Does the GLM library for OpenGL not have a magnitude function?

I'm new to using the GLM library, but it appears it does not have a magnitude function. Is this correct? If so, what is the reasoning?
Darkenor
  • 4,349
  • 8
  • 40
  • 67
16
votes
4 answers

Trouble Including / Using GLM library

I am having trouble properly including / using the glm math library (http://glm.g-truc.net/ ) in my c++ project. Since glm is a "header only" library, I thought I could just include it with this line: #include "glm/glm.hpp" At first this seemed to…
null
  • 1,187
  • 1
  • 8
  • 20
1
2 3
88 89