From: Xavier Decoret (Xavier.Decoret++at++imag.fr)
Date: 02/02/2000 03:52:58
Bo Staahle wrote:
>
> Hello
>
> I would like to know, how I can grap an image from the frame buffer in
> a multi channel environment.
>
> I am using pfuSaveImage and I have looked at the source in
> /usr/share/Performer/src/lib/libpfutil/snapwin.c
> but I didn't get any further.
The way I do it is that I read the frame buffer in the draw callback
> I would like to grap an image for each of the channels.
> If I have four channels, then I would like to save four images,
> each showing whats in the specific channel.
Then you can use pass datas to know which channel is "being drawn" in
the draw callback
>
> Is this possible ?
> If so how could I do it?
> Does anybody have any small working examples?
It could be something like that (with 2 channels, called left and right)
In the channel creation
-----------------------
int *leftArg = (int *) left_channel->allocChanData(sizeof(int));
int *rightArg = (int *) right_channel->allocChanData(sizeof(int));
left_channel->passChanData();
right_channel->passChanData();
*leftArg = 0;
*rightArg = 1;
In the draw callback
--------------------
void drawFunc(pfChannel *channel,void *data)
{
char filename[200];
// which buffer is drawn
switch (*(int*)(data)) {
case 0: // left one
sprintf(filename,"left.rgb");
break;
case 1: // right one
sprintf(filename,"right.rgb");
break;
}
// Draw the channel
channel->clear();
pfDraw();
// Read the frame buffer
int width,height;
channel->getSize(&width,&height);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
unsigned char *image = new unsigned char[width*height*3];
glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, image);
// Save the image
saveImage(image,width,height,filename);
}
Where saveImage is your image function saving.
I advice you use the il/ifl library for it (wich allows you to save in
quite any format based on filename's extension).
>
> --
> Bo Sixten Staahle
> mailto:c960355++at++student.dtu.dk,
> mailto:Bo.Sixten.Staahle++at++uni-c.dk
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
-- +------------------+--------------------------------------------------------+ | Xavier DECORET | iMAGIS, Laboratoire GRAVIR/IMAG (CNRS,INRIA,INPG,UJF) | | | INRIA Rhone-Alpes, 655 Av de l'Europe, 38330 Montbonnot| | Doctorant | France. Tel: +33 4 76 61 54 58 - Fax: +33 4 76 61 54 40| +------------------+--------+-----------------------------------------------+ | Xavier.Decoret++at++imag.fr | http://www-imagis.imag.fr/~Xavier.Decoret | +---------------------------+-----------------------------------------------+
This archive was generated by hypermail 2b29 : Wed Feb 02 2000 - 03:53:08 PST