PDA

View Full Version : Drawing OpenGL on video-stream under Mac OS X


MiloQuarneVanHalen
May 25th, 2005, 03:07 PM
Hello,

I'm trying the following thing:

I want to capture video-stream from my isight-cam and render some OpenGL polygons on the video-stream, so that I actualy see both video-stream and the rendered object. The difference is that I don't use GLUT but AGL and a carbon-window to draw on. So far I have done the following steps being inspired by ART implementation:

- creating new GWorldPtr using QTNewGWorld with k32ARGBPixelFormat
- calling the usual SG routines (SGInitialize, SGSetDataRef, SGSetGWolrd, SGNewChannel, SGSetChannelBounds, SGSetChannelUsage, SGSetDataProc , SGStartRecord)
- creating an AGLPixelFormat with the attributes: { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_STENCIL_SIZE, 8, AGL_SAMPLE_BUFFERS_ARB, 1, AGL_SAMPLES_ARB, 4, AGL_NO_RECOVERY, AGL_NONE }
- creating AGLContext on that pixFmt
- saving current graphics-port to carbon-window port
- aglSetDrawable and aglSetCurrentContext
- initializing GL by aglSetCurrentContext, glMatrixMode(GL_MODELVIEW), glLoadIdentity(), glMatrixMode(GL_PROJECTION), glLoadIdentity(), glOrtho(...), glViewPort(...), glDisable(GL_STENCIL_TEST),
glStencilFunc(GL_ALWAYS, 0, 0), glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)
- GetPixBaseAddress from the created GWorldPtr and drawing it by using glDrawPixels periodicaly in an EventLoopTimer
- aglSwapBuffers

At this point I see the video-stream on the carbon-window but I have problems rendering a simple 2d quad on the window simultaneously.
What I tried after the swapBuffers call was:

- glMatrixMode(GL_MODELVIEW)
- glLoadIdentity();
- glCallList(simpleQuad) (I have created a list with 4 vertices)
- aglSwapBuffers

But the I just see the Quad and no video-stream anymore.

I'm not that experienced with OpenGL, especially not in using different bufffers like stencil and depthbuffer. I was so happy if you could give me any hints.

Thanks a lot!!

Milo

philip_lamb
September 16th, 2005, 01:56 AM
Milo,

You want to remove the first swapBuffers call.. only call swapBuffers when you have finished ALL drawing on your frame.

P.