display

Hi

I have a scene where there are objects - some that ought to be diplay behind are draw in front of objects draw closer to the screen

any ideas?

You’re probably setting your depth test and zbuffer wrong.

ogl gives you the ability to invert the zbuffer (although the only use I have found for it is when you’re in right handed coordinates)

how’bout i just post some code?
heck, i’m programming right now anyway…
(hope you like c++)

glEnable( GL_DEPTH_TEST );	// Enables Depth Testing
	glDepthFunc( GL_LESS );		// The Type Of Depth Testing To Do
	glClearDepth( 1.0f );		// Set Depth Buffer to Max Dist. when cleared
	glClearColor( 0.0f,0.0f,0.0f,0.0f );				// Black Background
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );	// Clear Screen And Depth Buffer

basically what’s going on is that you first have to enable depth testing, then you have to pick the correct test function based on how your depth buffer’s set up. GL_LESS will tell ogl that “if the pixel being written has a smaller z value (closer), then, and only then, write to the buffer”

the clear depth stuff is to ensure that the zbuffer is set to the maximum depth (all coordinates are normalized from 0 to 1), thus ensuring that anything drawn on the empty screen will pass the test.
it’s when the new objects get on the screen that they might not.

what you probably did was set the glClearDepth to 0, and have the depth func set to GL_GREATER or some likeness.

man do i hope i’m right.

if i am, and it helps you, i am happy.

[This message has been edited by Succinct (edited 11-01-2000).]

Thanx, I try that out - for the z-buffer did you implement it in a special way or just using ogl functions?

Cheers

That didn’t work!!