PDA

View Full Version : Depth Testing w/DrawSprocket & AGL



Morgan
04-22-2000, 07:08 AM
First, where is everybody? Why can't Mac developers get Mac-specific questions around here?
Anyway, how do I get OpenGL to do depthtesting with DrawSprocket and AGL?

Morgan

04-30-2000, 02:07 PM
Originally posted by Morgan:
First, where is everybody? Why can't Mac developers get Mac-specific questions around here?
Anyway, how do I get OpenGL to do depthtesting with DrawSprocket and AGL?

Morgan

try using the tk library, then put this in...

tkInitPosition(0, 0, 640, 480); /*the size of the viewing area*/
tkInitDisplayMode(TK_RGB | TK_DEPTH); /*adds depth*/
glEnable(GL_DEPTH_TEST); /*makes opengl check for depth*/

agl has nothing to do with depth, just setting up gl contexts. DrawSprocket is just the conveyance of your opengl drawing to the screen. All things to do with depth use opengl, aux, and tk.

Now i have a question for you, how do I load texture maps other then .bw or .rgb ? That seems to be all I can find in Apple's SDK for OpenGL, yet I have found no program that either produces or converters images in those two formats. Can you help?

Morgan
04-30-2000, 06:03 PM
The problem is I was lazy and started learning by using GLUT (which was easier). GLUT allows you to set which buffers are allocated when you init it (using GLUT_DEPTH, GLUT_RGBA, etc.) I use the regular OpenGL functions, but they don't work anymore. So I need to use tk? This will init it into my agl context? Also, once I've inited my screen using DrawSprocket, can I not use AGL and create a GLUT window (do not plan to do this often, only when I need to ensure super easy cross platform porting)?

Morgan

05-01-2000, 12:46 PM
Originally posted by Morgan:
The problem is I was lazy and started learning by using GLUT (which was easier). GLUT allows you to set which buffers are allocated when you init it (using GLUT_DEPTH, GLUT_RGBA, etc.) I use the regular OpenGL functions, but they don't work anymore. So I need to use tk? This will init it into my agl context? Also, once I've inited my screen using DrawSprocket, can I not use AGL and create a GLUT window (do not plan to do this often, only when I need to ensure super easy cross platform porting)?

Morgan

If you plan to keep your programs on the mac, use DrawSprocket for your windows and the like. You won't even need to use GLUT that way (if you have Apple's OpenGL SDK, take a look at what they did in their DrawSprocket example). Use GLUT for anything you want to easily port

Morgan
05-01-2000, 06:00 PM
Ack! didn't work. It looks just the same, any guesses as to what I'm doing wrong? Do I just drop that code infront of my glEnable( GL_DEPTH_TEST ) and that's all? Will glClear( GL_DEPTH_BUFFER_BIT ) still work? What am I missing?
As to my other question, it was really supposed to be: can I use DrawSprocket to init my screen so I can get true full screen when creating GLUT demos on the Mac?

Morgan

Gipsy
05-10-2000, 05:31 AM
Yes,
you can use DrawSprocket to do true
full screen and have full control
over the main loop.

Apple recently release a good example (SetupGL) on how to do that on a tool chest developer CD.

If you are an Apple developer you should have the CD, if not contact me at philip@vtx.ch.
and i will send you the example!

Cheers

Morgan
05-11-2000, 05:23 AM
Yeah, I have SetupGL (downloaded it from Apple's dev site). I prefer not to use GLUT on my Mac though because it makes my apps too large, but I can't figure out how to get depth testing without GLUT. Any more suggests would be greatly appreciated.

Morgan

Eric Chan
05-12-2000, 06:20 PM
A few notes:
- DrawSprocket has nothing to do with depth testing in GL. You should be able to use DrawSprocket without impacting depth testing in GL

- First, you need to set up AGL by calling aglChoosePixelFormat. The third param is a bunch of attributes in an array. One of these attributes must be AGL_DEPTH_SIZE, followed by a size (in bits) specifying the size of your depth buffer. For example, I have my attributes array declared as:

GLint attrib[] = { AGL_RGBA, AGL_DEPTH_SIZE, 24, AGL_DOUBLEBUFFER, AGL_ALL_RENDERERS, AGL_NONE };

once you get everything else set up in AGL, then you use

glEnable(GL_DEPTH_TEST);

to enable depth testing

before drawing each scene (e.g., each frame), you should clear the depth buffer as well as the frame buffer:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Hope this helps ...

ec

Eric Chan
05-12-2000, 06:23 PM
Cr2me, regarding your question on image file formats, check out this page:
http://nate.scuzzy.net/programming.html

There you will find free code on loading and writing targa (.tga) files. The targa format is somewhat brainless (no compression at all, so the files tend to be quite large), but at least you can include an alpha channel which is useful.

Quake 3, for example, writes screenshots to .tga files, and more important, reads .tga files for its textures that require alpha blending.

Hope this helps,
ec

Morgan
05-13-2000, 06:59 AM
Aha! thanks, that's what I was looking for. I was looking for the equivilant of glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH ) (the GLUT_DEPTH part specifically). Thanks the AGL_DEPTH_SIZE, 24, is what I need to add!

Morgan