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.
1,315
questions
-3
votes
0
answers
47
views
Problem with initiializing cpp class in a c file [closed]
I have four relevant files for this problem:
Camera.cpp:
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
class Camera{
public:
Camera() {
position = ...
1
vote
0
answers
55
views
How do I transform a ray correctly?
How can I transform this ray, So that it is in front of the square
I'm trying to cast a ray from the player(small square).
The yellow part is the front end of the player
The ray should stop if it hits ...
-2
votes
1
answer
38
views
Why is this grid of squares not getting drawn correctly? [closed]
Why is this grid of squares not getting drawn correctly?
I have an array of how the grid gets drawn
// Here, 1 means a wall and 0 means an empty square
const int mapX = 8, mapY = 8, mapSize=mapX*mapY;...
1
vote
1
answer
30
views
Applying MVP transformation renders nothing OpenGL
I'm trying to apply MVP Transformation to a Square in OpenGL
But, it shows nothing.
If I remove the mvp from the Vertex Shader, The Square Gets Rendered
I'm using cglm as the math library, but there ...
-1
votes
2
answers
33
views
Can't send uniform values to shader
I'm trying to set some uniform values for my shader, but I can only get a texture I already used before(slot 0), and all matrix were filled with 0.
Here is a part of my code.
glUseProgram(...
0
votes
0
answers
44
views
How to install GLM on MinGW64 in Windows
I am getting an error:
mingw32-make: *** No rule to make target 'install'. Stop.
...when installing GLM.
I have downloaded the latest GLM from here. I am trying to copy the header files to path C:\...
-1
votes
1
answer
41
views
Problem with rendering a texture as it shows as completely black
I am having trouble with rendering a sprite despite having copied the code from learnopengl in practice section. First I thought that nothing rendered at all, but after changing from black to sort of ...
-2
votes
1
answer
44
views
OpenGL problem: I can only get white when I trying to draw my depth texture
I tried to draw a depth texture on a square but there is only white like this
white square with a cottage
besides, I also tried to generate a point light shadow cubemap, but it is still only white.
...
0
votes
1
answer
85
views
OpenGL - Moving Object using Modelmatrix
I am working on an OpenGL project. In this project, I would like to simulate a 3D chess game in c++. Of course, the pieces should be movable at will. The chessboard and pieces are already displayed ...
3
votes
0
answers
67
views
GLM: assign 3x3 sub matrix of 4x4 matrix
Let's say I have a 4x4 matrix M and a 3x3 matrix R.
How can write the 3x3 submatrix of M with R?
The naive way would be using two loops:
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++...
0
votes
2
answers
60
views
Building the set of unique vertices gives trashed result with random triangles around initial mesh
I have a problem with creating a set of unique vertices containing Position Coordinate, Texture Coordinade and Normals. I decided to use std::set for this kind of problem. The problem is that it seems ...
0
votes
1
answer
55
views
What's the meaning of the right multiplication of the GLM transform functions?
I encountered some problems when using matrix multiplication to transform the coordinates of a point, which made me realize that the default multiplication order of the glm transform functions are ...
0
votes
1
answer
78
views
glm::lookAt with custom rotation does not work properly
I want to control my camera so that it can rotate around the model.
The theoretical code should be:
// `camera_rotation_angle_x_` and `camera_rotation_angle_y_` are initialized to 0, and can be ...
1
vote
1
answer
36
views
How to create a PyGLM array of float32 type from a list of python floats
I have this function to modify it:
def buffers_init_pnt() -> None:
global mPoints
global POINTS_VAOID
global POINTS_VBOID
global glmverts_pnt_init
floatlist = []
for item ...
-1
votes
1
answer
38
views
Unexpected transformationMatrix and offset Matrix with Skeletal Animation
What I use:
Assimp to import .fbx files from blender
OpenGL for rendering
glm lib for handling matrices and vectors
I am trying to make skeletal animation work. I dont read the .fbx file directly ...
1
vote
0
answers
51
views
How to rotate a cube around it's edges in OpenGL using c++?
I want to write a function that expects 2 points and a rotation value.
With that information I want to rotate the cube on the edge between the two given points by the given rotation.
That's what I ...
-1
votes
2
answers
70
views
Texture mapping on cube only shows two sides correctly
I tried to make a cube in openGL and render a default texture on each side. I've been messing around with it for days but I cant get it to work. I really don't know what the problem is as I am ...
0
votes
0
answers
61
views
Loading OBJ model data using regexes?
I'm trying to write a class for loading a *.obj model, but I ran into a problem.
I'm fetching vertex data and vertex indexes from a *.obj file. For this I use regular expressions.
With prefix v:
Regex:...
0
votes
0
answers
26
views
GLSL std140 layout misunderstanding [duplicate]
Padding and formatting between C++ code and GLSL code is working but doesn't make sense. I would be happy if someone can explain.
I am sending this struct with uniform buffer to my shader.
struct ...
0
votes
0
answers
40
views
How to get the exact world coordinates of mouse click position
I have a mesh loaded (assimp) in 3D environment in OpenGL. I want to move it along the mouse click (dragging) from one point to another. My present solution is behaving weirdly, the unprojected ...
1
vote
1
answer
37
views
lookAt that returns camera matrix instead of view matrix
I can generate the camera matrix as follows:
void lookAt(vec3 center) {
vec3 f = normalize(center - this->eye);
vec3 u(0, 1, 0);
vec3 r = normalize(cross(f, u));
u = cross(r, f);
...
1
vote
1
answer
43
views
how do I maintain relative transformation b/w 2 objects after changing transformation of any one without a scenegraph?
Say I have 2 objects, a camera and a cube, both on XZ plane, the cube has some arbitrary rotation, and camera is facing the cube.
now if a transformation R is applied to the camera such that it has a ...
0
votes
1
answer
265
views
Calculating a "lookat" Rotation Vector
I've already got some code that uses the glm function lookat in order to point a camera at a target (it's a third person chase cam kind of thingy).
This works fine, but I need it in slightly different ...
0
votes
1
answer
21
views
How do I get a calculation result from a shader?
I load a 3D-model from a file and need to see it all on my screen. All vertices should be on the screen within the main window. Then I rotate and zoom the model and at some point I would like to fit ...
0
votes
1
answer
74
views
OpenGL Camera Rotation with glm [closed]
I'm trying to rotate camera but instead it rotates and changes position.
float m_CameraRotation = 30.0f;
TShader.Bind();
glm::mat4 proj = glm::ortho(0.0f, 1000.0f, 0.0f, 1000.0f, -1.0f, 1.0f);
glm::...
0
votes
0
answers
35
views
Importing opencv MAT object into shader from OpenGL ES 3.0 and convert color format YUV to RGB [duplicate]
How can I convert the color format to RGB by sending an OpenCV mat object that comes from the camera buffer and contains data in UYVY format into the shader in OpenGL ES 3.0.
If you have, can you ...
-1
votes
1
answer
254
views
How I can load 2nd gltf Model with different position, translation and texture
I am trying to load gltf 2.0 models in openGl. For 1st model it is works fine. But for 2nd model, Model is loading well but have same texture as previous one. I don't know how to apply different ...
1
vote
1
answer
88
views
rotate function works in main and not when called - opengl
so here is some opengl code on matrix transformations. the scaling and moving of the camera is working all fine, but the rotation part is not. what we are trying to do is rotate the camera around the ...
0
votes
1
answer
141
views
OpenGL: screen-to-world transformation and good use of glm::unProject
I have what I believed to be a basic need: from "2D position of the mouse on the screen", I need to get "the closest 3D point in the 3D world". Looks like ray-tracing common ...
0
votes
1
answer
92
views
How to move a figure to a desired position by linear interpolation
I want to move two figures to the origin and then move them back to their original positions.
So, I try to move each figure to the origin using linear interpolation, but the current position of the ...
1
vote
1
answer
187
views
How do I rotate an object, with another object as pivot
Say I have object A and object B, I have control of A's movement and rotation.
I'm trying to link A and B together in such way, that when A moves, relative distance b/w A and B remains same. and when ...
1
vote
1
answer
131
views
Why is this OpenGL code using texelFetch not working?
I've written this code to render a 2d map of square tiles:
#define TILE_NUM_INDICES 6
inline static u32 GetRandomIntBetween(u32 min, u32 max) {
return (u32)rand() % (max - min + 1) + min;
}
...
2
votes
2
answers
88
views
Draw colored quad as background in OpenGL Program
I am trying to draw a quad as the background and set it to a constant color in the fragment shader. However, only one triangle of the quad gets drawn and its scaled weirdly.
My vertices for the ...
0
votes
1
answer
65
views
How to get cursor position in world space
I'm a Vulkan beginner and I've never worked with 3D graphics before. So, I want to move an object to a place where I click with the cursor. I found a few topics on stackoverflow and reddit. My ...
-1
votes
1
answer
92
views
Code supposed to draw cubes draws nothing instead?
Can someone tell me which part of the code is wrong?
this is the main.cpp file converted to c via this repo, the program stopped working between the vertices and the mainloop
// depth testing (...
-2
votes
1
answer
64
views
how to properly make pipes in flappy bird clone
how to properly make(spawn) pipes?
i rly don't know how to make it properly and i`m making it for my school project from scratch and guide from learopengl.com, and i have an idea just to make 6 pipes, ...
0
votes
1
answer
264
views
How to create two shapes using OpenGL and shaders
I am trying to create a cylinder and plane to put underneath cylinder. Before I created a new vertex buffer object for the plane, the cylinder was rendering just fine. But for some reason, neither the ...
1
vote
1
answer
187
views
How to make the base of a cylinder with shaders in OpenGL
I am trying make a cylinder with using vertices and indices in OpenGL. I am still trying to build the base of a cylinder using triangles and cosine and sine functions and render it. But for some ...
1
vote
1
answer
47
views
Something in shader is messing the rendering function
#include <GL\glew.h>
#include <GLFW\glfw3.h>
#include <iostream>
// GLM library
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/...
0
votes
0
answers
31
views
Unresolved externals in OpenGL project [duplicate]
I am trying to run a program and test whether the input functions are working. But whenever I run the code, I get a set of errors saying:
Severity Code Description Project File Line ...
0
votes
0
answers
40
views
OpenGL rotating an object around it's own axis
I am trying to rotate an object around its own x-axis. It works exactly as expected when it is on the right side of the y-axis but showcases strange behavior when it on the left.
void Animation::...
0
votes
1
answer
644
views
How to set the pitch, yaw, roll of a quaternion
How to set the pitch, yaw, roll of a quaternion
What I need help with:
Hello! I have a quaternion that stores the orientation of my camera and what I would like to do is set the pitch, yaw and roll of ...
1
vote
0
answers
96
views
Angle between two 3D vectors in degrees
My goal is to rotate the enemies in my game to look towards my player. The code for it looks like this:
struct Entity {
glm::vec3 Position;
glm::vec3 Scale;
glm::vec3 Rotation;
};
void ...
0
votes
0
answers
56
views
calculate cube vertices to NDC coordinate
I have an OBJ simple Cube and I'm transforming it's vertices to screen coordinate.
The problem is I'm getting some strange values, looks like that all the points lie in the same plane.
Code for ...
0
votes
1
answer
339
views
Implicit vector conversion in ImGui (ImVec <--> glm::vec)
I am trying to get the implicit conversion between ImGui's (ImVec) and glm's (glm::vec) vector types working.
In here I read, that I have to change the following lines in the imconfig.h file:
#define ...
0
votes
1
answer
104
views
Camera movement in OpenGL raymarched scene
I'm working on a project with OpenGL that uses raymarched graphics and I've run into some trouble controlling the camera.
The scene is generated entirely inside the vertex shader, which is rendered on ...
0
votes
0
answers
28
views
GLM plane to plane trasformation
I am trying to use plane to plane transformation method in glm.
But rotations are wrong, I use this code in Eigen, also in CGAL libraries. Everything was working correctly. But something off is in GLM....
2
votes
0
answers
150
views
Changing coordinate system causes clockwise rotations
The task
I need to convert the coordinate system to +X forward, +Y right and +Z up (left-handed, like the one in Unreal Engine). The crucial part is that I want my camera to face its forward axis (...
0
votes
1
answer
594
views
How to set the pitch, yaw, roll of a quaternion relative to the world
So I have a quaternion that stores the orientation of an object and I have functions to change the pitch, yaw and roll of the quaternion like so:
void pitch(float amount)
{
orientation *= glm::...
1
vote
1
answer
218
views
OpenGL GLM rotate 2D shape around Z-axis
This is similar to this question, but I have a 2D triangle I'm trying to rotate solely about the z-axis, so I don't think I have to do any negative rotations. I have intentionally picked a triangle ...