PDA

View Full Version : glDepthRange ... Calling OpenGL gurus..


scratt
2006-01-09, 03:38
Can someone explain to me if my understanding of glDepthRange is correct please?

Based on what I thought...

If I set it to say (0,0.2) and draw some "stuff", and then set it to (0.4,1) and draw some more "stuff" shouldn't the second set of "stuff" be behind the first regardless of anything else?

In effect isn't it a form of render bin?

Can someone tell me if I am understanding this correctly...

Thanks...

Dave
2006-01-09, 08:38
It looks like it changes the range of depth. Like if something was 20 units away, then you set the range to (0, 0.5), it would be drawn as if it were 10 units away. See my disclaimer for more info.

Disclaimer: I've never in my entire life written a single line of OpenGL code, and my understanding of 3D graphics is limited to what I picked up from casual conversations with my high school math teacher who liked to program 3D rotating cubes in pascal. Any information presented here was gathered through no more than 5 minutes of searching through the top hits on google. In fact, I think it's taken my longer to write this all out than it did for me to find an answer, which probably means I'm wrong.

scratt
2006-01-09, 08:42
Wicked Dave!

If nothing else it's as good as my guess at the moment.. And it made me laugh!

Isn't it wierd how we can all read English, but seem to have a problem reading documentation in said language! Because so far I've done about the same as you, apart from try and fail at gettting it to do what I want in a bit of code....! ;)

Dave
2006-01-09, 08:58
Isn't it wierd how we can all read English, but seem to have a problem reading documentation in said language!
Yeah, that's why I like pictures in my books.

thuh Freak
2006-01-11, 01:24
i've never heard of glDepthRange before, but i've done a good amount of ogl programming. from my reading of the docs, glDepthRange defines the visible z min and z max (in percentages based on the window properties). i dont think it affects the physical location of the points or objects that you might draw (thus, can't decide which version of stuff is further along z. think of it this way: when you actually draw the objects (like with glutSolidSphere(), or glBegin/glEnd, and glVertex and whatever), if their rendered z component doesn't jive with the current DepthRange{x,y}, then that object isn't rendered. depthrange doesn't translate their positions, it culls based on position. actually, since ogl tends to be this state system, and depthrange seems to me more like a render pipeline process, calling depth range over and over again will probably lead to successive calls cancelling out previous calls. the final one before a buffer swap, i'm guessing now, would take effect for that given frame.

atleast, thats how i read it. but i'm a druggist, so like. i'm probably kinda high right now. and stuff.

on the other hand, i get the feeling that you're looking for a function like glTranslate{f/d}.
glTranslated( 0.0, 1.0, 0.0 );
glutSolidSphere(1.0, 10, 10);
glTranslated( 1.0,0.0,0.0) ;
glutSolidSphere(1.0,20,20);

the first sphere is to be drawn at (1,0), and teh second will be at (1,1). the params for glTranslate are the x,y,z offsets. glTranslate doesn't move to the exact x,y,z location, it offsets everything that is drawn after it, by the x,y,z amts.

scratt
2006-01-11, 03:44
atleast, thats how i read it. but i'm a druggist, so like. i'm probably kinda high right now. and stuff.

Cracked me up, buddy!

Actually in the end it turned out to be me not using a 'clear node' correctly in the scene graph I was using...

I am still a bit confuddled by the whole opengl thing... Although I have to admit to having splattered a few of those commands at key points through my code where they seemed to solve problems... Bound to cause loads of interesting buugs later on... I will make sure to post back here when they do.. Just for peoples amusement! ;)

But at least we both have our habits to dull the pain! :)

glTranslate{f/d}.
glTranslated( 0.0, 1.0, 0.0 );
glutSolidSphere(1.0, 10, 10);
glTranslated( 1.0,0.0,0.0) ;
glutSolidSphere(1.0,20,20);

the first sphere is to be drawn at (1,0), and teh second will be at (1,1). the params for glTranslate are the x,y,z offsets. glTranslate doesn't move to the exact x,y,z location, it offsets everything that is drawn after it, by the x,y,z amts.

I may well have a play with that suggestion just to see what happens... :) Thx.