I am reading a heightmap from a file, and rendering it using triangle strips.
The heightmap:
It works well, this is how it looks :
It looks alright, but only from this direction. If I turn the camera a bit, this starts happening :
It seems as if my depth buffer is corrupt. I have it enabled, and it works well with other geometry.
Did anybody have a problem like this before? I don't even know what to search for. Thanks!
Edit :
My projection matrix setup :
1.2062851 0.0 0.0 0.0
0.0 2.1445069 0.0 0.0
0.0 0.0 -1.0 -1.0
0.0 0.0 -0.2 0.0
_fieldOfView(50.0f),
_nearPlane(0.1f),
_farPlane(10000.0f),
_viewportAspectRatio(16.0f/9.0f)
Thank you all for your helpful comments. I found the issue, and hope that others who have this problem will find the solution useful. I had to re-enable depth buffering before each frame (glEnable(GL_DEPTH_TEST)), instead of once at renderer creation. I was under the impression that this was a global state, and thus wouldn't need to be reset everytime I render.
The end product looks like this, with no depth buffer problems :
Anyhow, hope this helps somebody.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With