Original Post
I've recently moved over from Direct3D to OpenGL and have started running into a problem with the display of some of my meshes. While "2D" graphics all display just fine, 3D meshes seem to handle depth-testing very oddly.

As you can see, when the lighter mesh overlaps the darker mesh it gets drawn "underneath" it, and vice-versa. My first thought was that either depth-testing, depth-writing, or the depth function had something going on with them but even when I explicitly enable everything right before rendering my meshes and play around with the depth function nothing seems to change. Disabling depth-testing and such does what you'd expect (ie, the meshes are drawn in the order specified and one is always overlapping the other).
A render pass from start to finish involves the following: I clear, reset my matrices, enable depth-testing and -writing, enable GL_xyz_ARRAY for the VBOs, bind them, bind their texture and render them, disable GL_xyz_ARRAY, and swap buffers. The mesh itself is just a simple heightmap-based mesh generated at load time.
I'm a little in the dark as to what may be involved and I'd rather not spam-post the entire code but I'll gladly post source for any part of the program if needed.

As you can see, when the lighter mesh overlaps the darker mesh it gets drawn "underneath" it, and vice-versa. My first thought was that either depth-testing, depth-writing, or the depth function had something going on with them but even when I explicitly enable everything right before rendering my meshes and play around with the depth function nothing seems to change. Disabling depth-testing and such does what you'd expect (ie, the meshes are drawn in the order specified and one is always overlapping the other).
A render pass from start to finish involves the following: I clear, reset my matrices, enable depth-testing and -writing, enable GL_xyz_ARRAY for the VBOs, bind them, bind their texture and render them, disable GL_xyz_ARRAY, and swap buffers. The mesh itself is just a simple heightmap-based mesh generated at load time.
I'm a little in the dark as to what may be involved and I'd rather not spam-post the entire code but I'll gladly post source for any part of the program if needed.