PDA

View Full Version : More on this DepthFunc thingy



Kurt B
05-24-2000, 10:53 AM
I changed the near to .00001...etc.
I also moved the rotation to the XZ axis.

However, when I put gl_less it always puts the last object drawn behind the other objects even if it's closer. Using Gl_greater I don't see anything at all..same with gl_equal.

I'm putting the related code in here, maybe someone can spot what's wrong.
It's in VB

This is called first, everytime anything changes...

Public Sub Reshape(p As Object, cc As Single)
Dim W As GLfloat
Dim h As GLfloat
W = p.ScaleWidth
h = p.ScaleHeight
glViewport 0, 0, W, h
glMatrixMode GL_PROJECTION
glLoad
gluPerspective 45, W / h, 5,0.00000000001
glMatrixMode GL_MODELVIEW
glLoadIdentity

End Sub
glEnable (GL_CULL_FACE)
glFrontFace (GL_CCW)
psphere = gluNewQuadric()
gluQuadricDrawStyle psphere, GLU_FILL
gluQuadricNormals psphere, qnSmooth
gluQuadricTexture psphere, GLU_TRUE
glTexEnvi GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, tepModulate
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT

glCullFace faceFront
glFrontFace ffCW
glDepthFunc GL_LESS
glClearDepth 1
glEnable GL_DEPTH_TEST
glShadeModel smSmooth
glEnable GL_NORMALIZE

Gorg
05-24-2000, 01:42 PM
Just a detail about the depth test: It doesn't matter on what direction your are looking for the z-buffer to work, simply because the transformations "changes" the view to point toward the z-axis before the z-buffer test is done.

In algebra term(well not totally http://www.opengl.org/discussion_boards/ubb/smile.gif)There is a transformation of the view coordinates system to a coordinates system where the z-axis is in and out of the screen. A good graphic books should explain those things. I suggest Real-Time rendering by Thomas Haines and Eric Muller. Go get it at amazon.com! Very worth it.

Anyway, for your problem, I believe you don't see anything because your are culling the frontfaces. Get rid of all the culling code or cull the back faces just to see.

And keep the depth func to GL_LESS. Also, turn off texturing just for testing purposes.