Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OpenGL Contexts in Panther




On Feb 20, 2005, at 2:19 PM, R. Scott Thompson wrote:

I'm trying to render graphics into a Quartz context created by CGGLContextCreate, but I have found precious little documentation of its behavior, and no sample code to speak of.

To the routine I am passing the context returned to me by aglCreateContext (a double buffering context OpenGL context whose drawable is set to a window). I pass in the size of my viewport and use NULL for the color space (which is supposed to choose the default RGB color space).

I've tried drawing the Quartz graphics before and after the call to aglSwapBuffer but the Quartz Graphics don't show up.

Are there limitations to the support for GLContexts in Panther? (can they only be used with CGL contexts, full screen contexts, only if the software renderer is being used... something like that?)

If I'm using a double buffered GL context.. should I draw the Quartz graphics before or after the buffers are swapped?

To respond to my own post.

My expectation was that when you created a CGContext on top of an OpenGL context, that you would end up with a CGContext that happened to share a memory buffer with the GL context. In other words, when you drew into the CGContext it would simply take the current color buffer and use it as the drawing destination (much the same way a QuickDraw port and a CGContext can share a PixMap).

What it appears is happening, instead, is when you issue CGContext graphics commands, the computer translates those commands into actual 3D geometry and asks OpenGL to render that geometry. In order to get my graphics to show up as I expected it to, I had to reset the projection matrix to an orthographic projection and turn off the lighting calculations (so the colors weren't affected by lighting calculations).

For the most part things seem to be working pretty well, but I am still seeing some unexpected behavior. At the moment I'm drawing two Quartz 2D primitives, a line and a square. The line is a simple, stroked, moveto/lineto path (one segment) and draws as expected. The square, however, does not draw in the region where the bounding box of the line and the square intersect.

You can see a picture of this at <http://homepage.mac.com/easco/QuartzGLDrawing.jpg>

The really odd thing, however, is if I reverse the order of the line and rectangle drawing (so the rectangle is drawn first) then the rectangle draws as expected, the line draws everywhere except where the rectangle is, and none of my 3D content draws at all.

This would imply (to me at least) that the Quartz 2D drawing may be changing something in the GL State that I'm not expecting. Not being too terribly familiar with OpenGL, I don't have enough experience to be able to guess what setting that might be. Can someone suggest what GL state variables could be changed by the Quartz 2D drawing that I need to save and restore around my Quartz 2D drawings?


Scott
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.