I am trying to program a FPS game with OpenGL.
I am using 3D eight the OpenGL 3.3 programmable pipeline.
I have a gun and a camera that I loaded.
When I load all of the assets for the game, I put everything int a 4x4 matrix, as it is compatible with the view matrix.
I set the corresponding matrix for the model equal to all the needed variables, then I use another variable that I defined in a header file to draw the actual model...
I did some searching because I do not have the code with me, and the closest I could find is learnopengl’s model loading tutorial as that is the most similar.
What I have tried; I have tried multiplying the matrix for the gun’s world info, which I will call the model view matrix (such as position and scale) times the view matrix. I have also tried doing the same but multiplying the model view times the inverse of the normal view matrix.
I already set the guns position equal to the camera’a position, but when I run the application and try to move around, the gun still moves away from the camera.
I knew a way of how to fix this in OpenGL 1.1 by using glLoadIdentity, which is now deprecated with the core version of OpenGL 3.*.
When i try to set the two matrices equal, I get different results because the gun doesn’t move at all.
When I move the camera with the inverse of view times gun, it moves away from the camera...
I learned about the inverse matrix thing from here: https://forums.khronos.org/showthread.php/81932
My matrixes are also set up the same. The gun model view * inverse(view matrix) has worked the best... this link is where I found it.