PDA

View Full Version : OpenGL to Quicktime



brokawc
02-09-2002, 10:45 AM
If I use OpenGL to generate a series of 3D drawings, how can I export them to files that can eventually be used to create Quicktime animations? I don't see any agl call for saving images to common file formats such as PICT, GIF or TIFF.

OneSadCookie
02-11-2002, 05:41 PM
Use glReadPixels to get a buffer and then a graphics export component to write the file (or simply add it to a movie directly).

Note that glReadPixels is really slow, though there are certain things you can do to speed it up.

brokawc
03-21-2002, 03:00 PM
I have now worked up the programming to use glReadPixels and then write the image in memory into a TIFF file. This works fine if I run the program (Carbon) under OSX: the TIFF files have proper images when examined with Resourcerer or GraphicConverter, etc. on either OSX or 9.2.
But if I run the program (or a version compiled as a Classic app) under 9.2, the image is garbage. The TIFF header is OK.
Is there a difference between the way glReadPixels works on OSX or 9.2 ?

Gavin
03-22-2002, 02:07 AM
No, should be the same, whats the code?

brokawc
03-23-2002, 06:44 PM
here is a code fragment that misbehaves:

outputsize = sizeof(tiffheader)+viewport[3]*viewport[2]*3;
Handle DH = ::NewHandleClear(outputsize);
::HLock(DH);
memcpy(*DH,tiffheader,sizeof(tiffheader) );
glReadPixels(0,0,viewport[2],viewport[3],GL_RGB, GL_UNSIGNED_BYTE,*DH+sizeof(tiffheader) );
::HUnlock(DH);

DH is then passed to PowerPlant LFile::WriteDataFork() in DoSave

Using CodeWarrior 7.0, on Mac OS10.1.2 and producing a Carbon application.
This works fine (other than putting the image upside down, which I can fix) when I run the application under OSX and open the image with a Mac OSX application such as Resourcerer. If I run under Mac OS 9 (either Carbon or Classic builds) the image is garbage.