Skip to main content
gamedev.net
🔒 Locked

buffer basics

Started by SonicSoul 4 replies 1k views
Original Post
SonicSoul
SonicSoul
Hello =) I hope you are all well... I'm drawing a solar system and to the best of my beginner knowledge I have enabled and disable lighting and buffer to work as follows: a) bodies do not show when they are behind other bodies b) orbit lines are not visible when behind something or while the planet is travelling through them. as one would expect. c) Lighting should only affect bodies and not orbital lines. However non of the above work and lighting does not even affect bodies (which are texture mapped). The appropriate code... http://cpp.sourceforge.net/?show=19395 Many Thanks & Kind Regards
zedzeek
zedzeek
disable buffer? u mean disable depth testing
u want this enabled
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );
glDepthFunc( GL_LEQUAL );
SonicSoul
SonicSoul
Hmm, that didn't change a thing, still having the EXACT same problems.
Kalidor
Kalidor
Quote:
Original post by SonicSoul
Hmm, that didn't change a thing, still having the EXACT same problems.
Are you sure you actually get a depth buffer? If you don't have a depth buffer then it is as if the fragment always passes the depth test. I don't see the window initialization code there so you might not be asking for a depth buffer correctly. You can query OpenGL for how many depth bits you have with glGet*.

A couple other comments...

You can't call glLineStipple or glLineWidth between a glBegin/glEnd pair. You should be checking for OpenGL errors as well (this generates GL_INVALID_OPERATION errors).

I don't see you enabling texturing anywhere. You should enable texturing before rendering anything you want affected by texturing (ie: the bodies). You should also disable texturing before rendering anything you don't want affected by texturing (ie: the orbits).

One reason you might not be noticing lighting on the bodies is because of your texture environment mode. If it's set to GL_REPLACE, then the texturing stage will replace the incoming color (possibly calculated from the lighting stage) with the color from the texture. If this is your problem, you are most likely using glTexEnv to set the texture environment mode to GL_REPLACE in your LoadSSGLTextures function.
MARS_999
MARS_999
In your windows setup code, you need to look at the cDepthBits variable of the
PIXELFORMATDESCRIPTOR and make sure you have at least 16.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.