Questions tagged [glm]
16 questions
21
votes
1 answer
Get vector length with GLM
I am quite confused over how GLM library is behaving or I am using it improperly.
glm::vec2 testVec(6,-4);
float len = testVec.length();
I get the value 2 with the above code snippet. I believe I am trying to get the length of the vector defined…
sajis997
- 1,209
- 1
- 9
- 13
11
votes
4 answers
Multiple viewports with modern OpenGL?
I use SDL2.
Currently my only shader has a MVP matrix, and transforms the points with it.
I calculate my View and Projection matrix for a camera with GLM:
glm::lookAt(pos, pos + forward, up);
glm::perspective(fov, aspectRatio, zNear, zFar);
I…
Tudvari
- 313
- 1
- 2
- 13
4
votes
1 answer
Three quaternions interpolation with barycentric coordinates
I have three quaternions A, B, C.
I also have a 3D vector P which describes the barycentric coordinate to interpolate.
I want to interpolate the three quaternions with respect to the barycentric coordinate P
This Image shows how to do it would A, B…
Thomas
- 631
- 1
- 3
- 11
4
votes
1 answer
understanding glm::perspective vs glm::ortho
I'm new to computer graphics. I played around with OpenGL and now am trying out Vulkan.
Basically what I want to do, in 2D is have an 800x800 window, and I want that to represent 800 meters by 800 meters. Then I want a circle with a radius of 1…
mikeglaz
- 259
- 4
- 6
3
votes
1 answer
Screen to World coordinates glm::unProject
I'm having some trouble trying to figure out how to go from a coordinate on the screen, to 3D world coordinates on a plane.
My case is as seen on the picture further down. World origin is in the center with the grid representing the X-Y plane.
I…
remi000
- 230
- 3
- 8
3
votes
1 answer
Ray-tracing the Cornell Box results in really inconsistent image
So I have a vector of glm::vec3 containing the triangles for the classic Cornell Box called triangles. The Draw method casts a ray for each pixel on the screen and calls ClosestIntersection which returns true or false and updates a struct containing…
swedish_fisk
- 33
- 2
2
votes
0 answers
What is the projection matrix of reverse (Byzantine) perspective?
I would like to construct a projection matrix for reverse perspective.
I'm using OpenGL and tried to modify concepts from this excelent tutorial.
I came up with:
$$
\begin{bmatrix}
2\frac{(near-M)}{right-left} & 0 & \frac{right + left}{right-left}…
Peter
- 21
- 1
2
votes
0 answers
With OpenGL, is it correct to apply model transformation to rotate the camera?
Having taken a basic CG course, I remember that transformations are relative, so rotating the camera is identical to rotating the view in the opposite direction. Right now I want to implement camera rotation using the mouse. In OpenGL, I can see the…
iksemyonov
- 121
- 2
1
vote
0 answers
360 degrees rotation around x axis
How do we rotate the camera around x axis 360 degrees, without having to flip the axis, meaning without having the strange flip after we go over +-90 degrees on x axis.
Mine behaves exactly the same way spherical coordinates would, I'm using euler…
Test
- 31
- 2
1
vote
1 answer
My (ADS) shader doesn't render the light direction correctly
This is what I'm doing:
vertex shader:
#version 400
layout ( location = 0 ) in vec3 vertex_position;
layout ( location = 1 ) in vec3 vertex_normal;
uniform mat4 ModelViewMatrix; //view*model
uniform mat3 NormalMatrix;…
Charlie
- 203
- 1
- 7
1
vote
1 answer
Am I passing the correct matrices for my shader? openGL/C++
On page 89 of David Wolff - OpenGL 4.0 Shading Language Cookbook book, it suggests a way to set up up a Phong shader in the fragment stage. It lists some different matrices to pass via uniform, and I suspect I might be passing slightly incorrect…
Charlie
- 203
- 1
- 7
1
vote
1 answer
Converting points, vectors, normals between world and object space for a ray tracer gives weird results
I'm writing a ray tracer but having trouble converting rays and normals between world space and object space.
I am creating a Ray, then transforming it with transformation matrices, calculating intersections and return them.
Constructing…
Cedric
- 13
- 2
0
votes
1 answer
Wrong reflection
Here is a youtube video showing my problem:
youtube.com/watch?v=y8J7VhS2pkM
I think I'm either doing the texture lookup on the reflection texture wrong, or the reflection or view matrix is somehow wrong.
The reflection matrix is calculated after…
Martin Gerhardy
- 101
- 1
0
votes
0 answers
How to rotate an object in OpenGL on the X, Y and Z axis on its local coordinates?
I've read multiple tutorials, but I still can't understand how do I properly rotate an object in 3D space on all 3 axis at once. For example, I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees. How can I…
John
- 101
- 2
-1
votes
2 answers
How can i wrap the earth image around a 3D Sphere using OpenGL, GLFW, GLAD, GLM?
Please help me out with this thing and currently i am a little more than a beginner so please tell me in that context. i don't need any obsolete methods for creating this like using GLUT or GLEW.can you just tell me its algorithm to create the…
b_cass_
- 25
- 5