#149897 - simonjhall - Sat Jan 26, 2008 4:31 pm
Sup.
I seems to remember having this problem ages ago, but I don't think I ever found a solution to it.
I'm drawing lots of quads in 3D to form my HUD (and this is done with glOrtho) and some quads overlap others. The HUD is effectively drawn back-to-front, so anything drawn first should be drawn over anything drawn later.
Regardless of the Z that I use I always get the same result: no kind of depth sorting and quads that overlap appear as if the top part of the quad is drawn at a different Z to the bottom of the quad. I've checked again and again to see if I'm doing anything silly and I'm not. I then thought it could be a precision problem, so the first quad is drawn at 1.0, the next at 2.0 etc etc and I still get the exact same resut! Messing around with znear/zfar does nothing interesting.
For my swap buffers command I'm using '0' which apparenty means Z sorting.
Has anyone else had issues like this? What're the solutions?
Btw, here's the code for the orthographic projection matrix: (from libnds)
_________________
Big thanks to everyone who donated for Quake2
I seems to remember having this problem ages ago, but I don't think I ever found a solution to it.
I'm drawing lots of quads in 3D to form my HUD (and this is done with glOrtho) and some quads overlap others. The HUD is effectively drawn back-to-front, so anything drawn first should be drawn over anything drawn later.
Regardless of the Z that I use I always get the same result: no kind of depth sorting and quads that overlap appear as if the top part of the quad is drawn at a different Z to the bottom of the quad. I've checked again and again to see if I'm doing anything silly and I'm not. I then thought it could be a precision problem, so the first quad is drawn at 1.0, the next at 2.0 etc etc and I still get the exact same resut! Messing around with znear/zfar does nothing interesting.
For my swap buffers command I'm using '0' which apparenty means Z sorting.
Has anyone else had issues like this? What're the solutions?
Btw, here's the code for the orthographic projection matrix: (from libnds)
Code: |
GL_STATIC_INL void glOrthof32(int32 left, int32 right, int32 bottom, int32 top, int32 zNear, int32 zFar) {
MATRIX_MULT4x4 = divf32(inttof32(2), right - left); MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = divf32(inttof32(2), top - bottom); MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = divf32(inttof32(-2), zFar - zNear); MATRIX_MULT4x4 = 0; MATRIX_MULT4x4 = -divf32(right + left, right - left);//0; MATRIX_MULT4x4 = -divf32(top + bottom, top - bottom); //0; MATRIX_MULT4x4 = -divf32(zFar + zNear, zFar - zNear);//0; MATRIX_MULT4x4 = floattof32(1.0F); } |
_________________
Big thanks to everyone who donated for Quake2