prunkdump
05-01-2009, 06:56 AM
Hi!
I try to make a program that use opengl to generate a series of images, and save them to files. I use ImageMagick for image manipulation and glut or sdl for opengl implementation.
I have tried with glut to put all the code in the display function. That is to say :
void displayFunc(void)
{
set View and Viewport;
generate image `current`( with previously initialized display lists );
glReadPixels(...); (on Back_buffer)
some ImageMagick code to save the file;
current++
}
But I experience instability. On the first pass, glReadPixels give always a black image, the buffer seems not be initialized. Sometimes the second pass to.
The others pass give sometimes corrupt images.
ImageMagick code is between image generation and current++ but it is sometimes not executed ( or return untimely ).
I think the problem come from the fact that glut use a multi thread environment so I can't call MagickWand functions without mutex protection. Or maybe glReadPixel read pixel whereas the frame is not finished?
So can someone explain me how and where call glReadPixels. It is needed to implement mutex for : my variable `current`, access to buffer and save to file?. How can be sure that the frame is finished before reading? Where put my ImageMagick code?
Thanks!!
(Excuse me for my English)
I try to make a program that use opengl to generate a series of images, and save them to files. I use ImageMagick for image manipulation and glut or sdl for opengl implementation.
I have tried with glut to put all the code in the display function. That is to say :
void displayFunc(void)
{
set View and Viewport;
generate image `current`( with previously initialized display lists );
glReadPixels(...); (on Back_buffer)
some ImageMagick code to save the file;
current++
}
But I experience instability. On the first pass, glReadPixels give always a black image, the buffer seems not be initialized. Sometimes the second pass to.
The others pass give sometimes corrupt images.
ImageMagick code is between image generation and current++ but it is sometimes not executed ( or return untimely ).
I think the problem come from the fact that glut use a multi thread environment so I can't call MagickWand functions without mutex protection. Or maybe glReadPixel read pixel whereas the frame is not finished?
So can someone explain me how and where call glReadPixels. It is needed to implement mutex for : my variable `current`, access to buffer and save to file?. How can be sure that the frame is finished before reading? Where put my ImageMagick code?
Thanks!!
(Excuse me for my English)