GLM is a C++ math library based on the GLSL language.

learn more… | top users | synonyms

0
votes
1answer
17 views

Creating a movable camera using glm::lookAt()

I came across this tutorial on how to create a movable camera in OpenGL using glm::lookAt(glm::vec3 position, glm::vec3 target, glm::vec3 up). In the tutorial, in order to keep the camera always ...
1
vote
1answer
91 views

Algorithm to draw particles in correct order?

For a game I'm making as a hobbyist project, I need to be able to draw smoke on the screen. I am doing this by setting up a particle system. The problem is I need all the particles drawn in order from ...
0
votes
1answer
78 views

Calculating vertex_normals (vn) causes ugly lines C++/openGL

Im trying to procedurally generate planets for a project I'm working on. By adding noise to each vertex, I'm able to generate elevation, but without having updated vertice normals for my shader. It ...
0
votes
2answers
49 views

Why does glm only have a translate function that returns a 4x4 matrix and not 3x3?

I'm working on a 2D game engine project and I want to implement matrices for my transformations (shocking I know) and I'm going to use the glm math library to do so. Since my game is only 2D I figured ...
1
vote
1answer
43 views

What is the best way of storing transformations for an object and then applying them with OpenGL?

First some background info... I have been working on a platformer game, which I draw with OpenGL. The platforms are cubes and the player is a cube. The platforms and the player (both cubes) are ...
0
votes
0answers
19 views

How to add side friction to vehicle physic model?

I'm writing a very simple vehicle physic model using information from this thread, but I'm stucked with side friction calculation. My vehicle slides on surface and don't loose speed at the drift. Here ...
0
votes
0answers
52 views

Transform class and gimbal lock

I am facing gimbal lock in my Rubik Cube program (opengl3.3+glm). I am using my own Transform class which is implemented this way: class Transform{ private: glm::vec3 position, rotation, scale; ...
1
vote
0answers
40 views

How to use 3D transformation matrices with GLM old version that has simd functions

I need matrix 3D transformation, model transformation i.e scale-rotate-translate and then that model into world space so model-projection-view matrices. I need it with GLM specified simd vectors and ...
0
votes
2answers
60 views

glm::perspective isn't working?

So I'm learning how to make games and program, and while trying to setup a projection camera using GLM in GFLW, this line of code refuses to work and I can't figuire out why. The code is in the image ...
0
votes
1answer
64 views

Wierd behaviour upon limiting rotation on Y-axis

Okay, this is the code that works for a FPS camera, except it allows the player to flip it over by going under/over -/+90° rotation on Y-axis: transformation->rotateObjectFromRight(glm::radians(...
1
vote
1answer
174 views

How to use GLM Simd using GLM version 0.9.8.2?

I am new user for GLM, can somebody guide me how to use GLM SIMD using its version 0.9.8.2. According to its Manual using #define GLM_FORCE_SSE2 For example, if I write: #define GLM_FORCE_SSE2 #...
0
votes
0answers
46 views

Merging multiple vertices into one (OpenGL)

I have a class where it crates a cube, load a shader, and render it, but i would like to know, how do I create two cubes, with two different vertices, two different matrices, and then merge these ...
0
votes
1answer
43 views

Axis of affine transformation matrix

Lets say I have a right handed column major 4x4 transformation matrix. Can I safely assume (even tough there exist non uniform scale) that first column is X axis vector, second cloumn is Y axis vector ...
1
vote
1answer
99 views

Should I use the X-Y-plane when using an orthographic projection in OpenGL?

I'm currently at a loss rendering a tile-based 3D map with an orthographic projection in OpenGL. Imagine any isometric 3D game (using actual geometry instead of sprites). Internally, the tiles of my ...
1
vote
0answers
60 views

Shadow Mapping, why does my shadow change size and position when I rotate my light?

I have looked far and wide for this and have not found any issue like this, so far. Basically, when my light is at a certain angle my shadows seem to be correctly positioned and scaled, yet if I ...
1
vote
0answers
82 views

Limit/Clamp camera movement using quaternions

I'm making a camera object for rendering with OpenGL. However, instead of using the typical "LookAt" method I'm trying to use just a Quaternion for orientation and a Vector3 for position. Instead of ...
1
vote
1answer
225 views

Quaternion based camera pitch freaking out, and Z-axis drift

This is the code I use to control my (first person) camera's movement and rotation. Translation successfully keeps orientation in mind, so that up and left and such are always in the expected ...
0
votes
1answer
51 views

Problem with Frustum Culling Right-Handed(LookAtRH GLM)

I am trying to do Frustum Culling based on Goemetric Approach, however don't matter how much i try, the frustrum rotate to opposite side, i tried to find a solution over all internet, but couldn't ...
3
votes
0answers
76 views

I get weird perspective using GLM where the depth is flipped. Please help

The depth is rendered wrong and I can't figure out why. using namespace std; using namespace glm; int width = 640; int height = 480; float aspect = (float)width/height; int fps = 60; void start(){ ...
1
vote
0answers
127 views

AssImp Skeletal Animation Issues [closed]

Tried creating an animated mesh but I render it, it comes up as a flat mesh that moves with the camera. Followed the OGL Animation tutorial here (http://www.ogldev.org/www/tutorial38/tutorial38.html). ...
2
votes
1answer
296 views

Drawn frustum does not match with glm::perspective

I am working on a personal project and I got a 3d viewport with moving camera working nicely. Now I am working on being able to freeze the time and switch to a debug camera and move in the game freely....
1
vote
2answers
927 views

Convert a direction vector (normalized) to rotation?

Say i have something like this: pos += glm::normalize(target - pos) //PLEASE NOTE: pos is a glm::vec3 and so is target This makes "pos" translate towards "target", but what if i want to make my ...
0
votes
1answer
223 views

Why does invoking glm::refract function return NaN?

At the present time, I make a simple raytracing project and I encounter an issue : When I invoking the glm::refract function, it returns me a vec3 with "NaN" values. However, my input data seems to be ...
0
votes
0answers
60 views

How to get correct quaternion value from real world to screen?

I'm writing an application (not a game per se, but close enough) where we use attitude sensors (an IMU) in the real world to affect the orientation of an object in the application's 3D space (OpenGL). ...
0
votes
1answer
556 views

How do you build a rotation matrix from a normalized vector?

I'm trying to find the correct way to build a rotation matrix from a unit vector. I have two arbitrary points in space (p1 and p2), and I'm trying to create the vertices for a rectangle to span ...
1
vote
1answer
323 views

OpenGL Arc-Ball Camera Yaw Pitch GLM::Rotate

I'm currently working on a small Voxel-Editor Project. In the editor, I plan on using an Arc-Ball camera which rotate around the model. My camera is currently working but in an odd way. I can't seem ...
1
vote
1answer
189 views

Failed to understand how to use glm::unProject (OpenGL 4.3)

Situation: I use OpenGL 4.3, FreeGLUT 3.0, and GLM library. Let say i have a simple 2D object (a ball) and it moves accordingly to the simple equations: x = x_0 + v_0 * t * cosf(alpha); y = y_0 + ...
0
votes
1answer
590 views

How should I rotate vertices around the origin on the CPU?

I have tried using glm::rotate and such. glm::translate works fine, but rotate doesn't work (if I rotate before/after a translation). Here is my current setup: glm::vec4 Off = glm::vec4(0, 0, 0, 1); ...
1
vote
1answer
248 views

C++ Opengl transforming a glm::vec4 with a glm::mat4

Its easy enough doing it on the gpu via GLSL, but how would I do this in c++? When I try it gives me an error telling me I cant cast a glm::mat4 to float, Which makes sense, but how should I do it? ...
1
vote
1answer
168 views

Converting normalized device coordinates to world space coordinates flipping my sprites

I'm trying to convert my game's camera system to use world space coordinates rather than OpenGL's default normalized device coordinates, however in doing so my sprites are being rendered improperly as ...
2
votes
1answer
66 views

Shaders wont bind to the uniform block

I'm having an issue with interface block binding. Example shader: const char* vertexShader = "#version 330 core\n" "uniform globalMatrices" "{" " mat4 ...
1
vote
3answers
101 views

Storing component vectors to avoid matrix and quaternion inaccuracies?

I read that I "should really be storing the component vectors (rotation, translation, scale) in addition to the quaternion and matrix forms." The reason for this is that, over time, compound numerical ...
3
votes
1answer
204 views

Make Camera Look at point using a World transformation matrix?

Variants of this question might have been asked on this site, but none of the answers I found worked in my case. I am trying to make a Camera look at a point. The camera has a world transformation ...
2
votes
1answer
60 views

Formula for model matrix with mouse coordinates

I'm trying to create a simple OpenGL app where I can drag objects with the mouse. The code below is based on a raycasting algorithm covered here. I'm using the diff between the current mouse coord ...
1
vote
1answer
135 views

Smooth matrix rotation

I have a coded a simple example for a matrix rotation. The example rotates a sphere around its center. The problem is that the rotation is not running perfectly smooth and I'm wondering why. Here is ...
1
vote
1answer
416 views

OpenGL 3.3+ Problem with ortho projection for UI/HUD

I have to a little bit of a problem with drawing HUD elements on top of my 3d world using a ortho projection. My 3D world keep getting render but there is nothing showing of my UI. I wrap the code ...
1
vote
1answer
228 views

Using glm to rotate the modelview matrix based on the cursor position

I am rendering a 3D model of an object, and I want the user to be able to rotate around that object by dragging the mouse. To do this, I want to use the cursor position to continually update the ...
0
votes
1answer
161 views

glm Z coordinates are flipped

I am trying to render a 3D model using OpenGL. And for the projection and transformation matrices, I am using glm. I've got my model on the screen and it works just like I intended it to; except one ...
1
vote
2answers
2k views

How to find the “up” direction of the view matrix, with GLM

Using OpenGL and the GLM matrix library, I want to translate my camera relative to the world coordinate system. This requires me to compute the necessary view matrix. To initialise the view matrix, I ...
1
vote
0answers
68 views

Quaternion camera in 3D space with Pitch and Yaw

I am having trouble implementing a quaternion camera that can fly freely in 3D space with only Pitch and Yaw rotations. It works fine except when you look up or down and then try to look left or ...
0
votes
1answer
123 views

issue with ray/physics collision detection

All, I am trying to pick object using ray collision and bullet physics I am initializing my projection and view matrix only once, here is the code projectionMatrix = glm::perspective(90.0f, 4.0f ...
1
vote
0answers
138 views

Transformed Vertices have wrong Z Axis

For quite some time I've been working on my open 3D game engine, to learn how this stuff works. You can see the full codebase relating to my problem here on GitHub. I'm using an OpenGL 3.3 Core ...
2
votes
2answers
4k views

How can I set up an intuitive perspective projection/view matrix combination in OpenGL, using GLM?

Could anyone help me set up an intuitive perspective camera matrix using OpenGL and the GLM library? By "intuitive" I mean that I want the camera to be looking at the middle of the screen down the -Z ...
0
votes
2answers
6k views

Rotating an object with quaternion

I have a question in regards to using quaternions for the rotation of my graphics object. I have a Transform class which has the following constructor with default parameters: Transform(const glm::...
0
votes
0answers
804 views

OpenGL - Arcball camera rotation

I'm implementing arcball camera rotation, whereby a camera is looking at a coordinate and rotates around it in the x-axis or the y-axis such that the camera is circulating around it; the y-axis will ...
0
votes
1answer
287 views

Directional lights (not) rotating with camera (opposite problem)

I am trying to implement a shader for directional lights correctly, but I am bit confused as to why it works when it shouldn't and vice versa. People usually encounter problem with lights changing ...
1
vote
2answers
2k views

Weird GLM perspective problems with my 2D Game

I am trying to create the graphics system of a 2D game using OpenGL 3.3. To help me in this task I am using the GLM math libraries. However I am having some trouble. When my objects (for now they ...
3
votes
1answer
3k views

glm direction vector rotation

I'm working on a flight simulator, but I'm stuck with my airplane orientation. I tried some things but noone worked correctly. This is what I have : To be able to move it and roll it around himself, ...
1
vote
1answer
1k views

Compute billboard rotation

I'm trying to compute a matrix to have object always facing the camera. For the moment, my result look pretty good, the problem is that my original billboard scale isn't preserved (Every billboard ...
4
votes
1answer
1k views

How to calculate directional light frustum from camera frustum

I'm playing around with OpenGL for a few weeks now. For the following screenshot I picked the glm::ortho values for my lightsource by trial and error. There are two directional light sources with ...