Getting OpenGL frames to Quicktime

Under OS 9, I could use the following to get OpenGL frames to the QT encoder to make a QT movie on the fly as my OpenGL simulation ran. With the windowing changes for OS X, it no longer works.

'Save the oldWorld (a pointer to CGrafPort)
call GetGWorld(oldWorld,oldDevice)

'Set GWorld to movieWorld (the CGrafPort for the QT movie)
Call setGWorld(movieWorld,0)

'Copy the pixel map from oldWorld to movieWorld
CopyBits(oldWorld.portpixmap&,movieWorld.portpixmap&,oldWorld.portRect,movieWorld.portRect,0,0)

'Set the GWorld back to oldWorld
Call SetGWorld(oldWorld,oldDevice)

'Compress the image
Err = Fn CompressImage(movieWorld.portpixmap&,movieRect,movieQuality,movieCodec,ImageDescH,compressedDataPtr)
handleSize = fn gethandlesize(compressedHandle)

'Add the frame to the QT movie
Err = Fn AddMediaSample(theMedia,compressedHandle,0,handleSize,_kVideoTimeScale/movieFPS,ImageDescH,1,0,=_nil)

I think the reason this isn’t working is because the OpenGL frame can not be pulled through the oldWorld port. I’m not accessing the OpenGL image properly with GetGWorld. For example, if I use ordinary QuickDraw commands to draw things into that OpenGL window while the simulation is running (e.g., circles, text, lines), all of it is correctly piped through to the QT movie … not a hint of an OpenGL frame … all the while, the OpenGL frames are playing properly in the window on my display.

Anybody know how I can get the OpenGL pixel map set up to use copybits to get it into movieWorld?

Thanks,

LL

You need to use glReadPixels to transfer OpenGL’s pixels back to the CPU. That it works on 9 is really a fluke…

Moderator -

Thanks - thanks a ton for that tip. Lars G. just told me an hour ago that he thought I would have to pull the pixmap from OpenGL.

I’ll dig into that command right now -

Luke

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.