how to draw two times in draw callback function

New Message Reply Date view Thread view Subject view Author view

From: Changhee Han (changhee++at++ict.usc.edu)
Date: 06/17/2001 23:11:38


Hi performer,
Sorry for serveral times mails.
But I pin down a little bit more. So by chance I'd like to get some idea
even in case
many of you do not use vega.

My purpose is to use another buffer(AUX buffer) to compute my own rendering
while making audience to see original correct demo image.
Thus I think it needs two times drawings onto BACK buffer and onto AUX
buffer in drawing callback function. So I have tested my module with
chan->setTravFunc(PFTRAV_DRAW, my_draw_callback) or
vgAddFunc(chan,VGCHAN_POSTDRAW, my_draw_callback, NULL).

For experiment, I inserted my own module into one of vega sample codes,
/..../vega/sample/pguide/ch3/stereo.c

Belows are the inserted parts
...............
#include <vgperf.h>
#include <pf/pfTraverser.h>
#include <pr/pfLinMath.h>
//for stereotown.adf
#define width 500
#define height 500
..............
.............
vgConfigSys(); //////<======original part of stereo.c colde
DIMR_vega_post_config(); //my own module
/* there has to be at least one window, get the first one */
win = vgGetWin( 0 ); ///////<=====original part of stereo.c colde
.............
.............

void my_draw_callback(vgChannel* vgchan, void* _userData) {
//void my_draw_callback(pfChannel* pfchan, void* _userData) { //#1.
...........
glDrawBuffer(GL_AUX0);
//glDrawBuffer(GL_BACK); //#2.
pfDraw();
glReadBuffer(GL_AUX0);
//glReadBuffer(GL_BACK); //#3.
glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE, image);
fprintf(fp, "P6\n%d %d\n255\n", width, height);
fwrite(image, width*height*3*sizeof(char),1,fp);
fclose(fp);
//glDrawBuffer(GL_BACK); //#4.
//pfDraw(); //#5.
}

void DIMR_vega_post_config( void ) {
int n, i;
pfChannel *pfchan;
n= vgGetNumChan();
vgChannel* chan = vgGetChan( i );
for( i=0;i<n;i++ ){
vgChannel* chan = vgGetChan( i );
pfchan= vgGetPfChan(chan);
//pfchan->setTravFunc(PFTRAV_DRAW, my_draw_callback); //#6.
vgAddFunc( chan, VGCHAN_POSTDRAW, my_draw_callback, NULL );
}
}

I tested it with stereotown.adf mostly and also used the other adf files in
/..../ch3/ and all the two adf files in /...../ch4/
And comment #1 to #6 can be uncommneted according to use of either vgAddFunc
or setTravFunc. Instead, other lines can be commented if necessary.

Here are my problems(questions):
1. With "setTravFunc", if I want to show correct image to audience(on the
screen), it fails.
  Why fail? (I think performer API should run correctly inside of vega.)
2. For my own purpose(two times drawings on AUX and BACK), if I use
"setTravFunc", then image on screen and saved image files are all bad(most
of them are backen, darken, etc).
3. For my own purpose, if somebody recommends me to use vgAddFunc, in this
case I got the image on the screen for audience being flashed(blinking
fastly). Saved files by AUX buffer look fine(? not sure). But only with
stereotown.adf, the image in screen and in saved files look fine.

I think this is the good way to do two times drawings for audience and my
own usage. I am very eager to solve my purpose by this way.
But if it has a harm like above and somebody knows how to do my purpose,
please let me share with your valuable knowledge.

Please advice me with your valuable comments.
Thanks in advance,
changhee


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sun Jun 17 2001 - 23:07:02 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.