OpenGL, objects disappear at a certain z distance
Posted
by
smoth190
on Game Development
See other posts from Game Development
or by smoth190
Published on 2012-10-13T02:47:13Z
Indexed on
2012/10/13
3:49 UTC
Read the original article
Hit count: 207
I'm writing a managed OpenGL library in C++, and I'm having a pretty annoying problem. Whenever I set an objects position to -2.0 or lower, the object disappears. And at distances 0 through -1.9, it doesn't appear to move away from them camera. I have a world matrix (which is multiplied by the objects position to move it), a view matrix (which is just the identity matrix currently) and a projection matrix, which is setup like this:
- FOV: 45.0f
- Aspect Ratio: 1
- zNear: 0.1f
- zFar: 100.0f
using GLMs glm::perspective
method. The order the matrices are multiplied by in the shader is world, view, projection, then position.
I can move the object along the X and Y axis perfectly fine. I have depth testing enabled, using GL_LEQUAL
. I can change the actually vertices positions to anything I want, and they move away from the camera or towards it perfectly fine. It just seems to be the world matrix acting up. I'm using glm::mat4
for the world matrix, and glm::vec3
for positions. Whats going on here?
I'm also using OpenGL 3.1, GLSL version 140 (1.4?).
© Game Development or respective owner