jim
Mon, 22 Sep 1997 15:12:10 -0700
From: "jim" <jim>
Date: Mon, 22 Sep 1997 15:12:10 -0700
To: info-vega++at++paradigmsim.com
Subject: Sky color substitude the color defined in stencil test
Cc: jim
Hi Scott:
Thanks your help and trouble again.
Use stencil test. I can render a circle scope in Vega Channel. But
outside the circle, the sky color cover the color defined in the initial OpenGL
subroutine StencilHUD. ( attached with simple stencil file)
Did anybody encounter this problem in vega?
thanks in advance
-- Support Engineer Jim Tsai System & Technology Corp. Visual Simulation Group www.systech.hinet.net[ Text ] :
#include <GL/gl.h> #include <GL/glu.h> #include <vg.h> #include <vgperf.h> #include <pf.h> #include "aux.h"
#define YELLOWMAT 1
void DrawCB(void); static void StencilHUD(pfPipeWindow *pw);
main( int argc , char *argv[] ) { vgWindow *win; vgChannel *chan; pfPipeWindow *pwin;
if ( argc < 2 ) { printf ( "syntax : %s <config file>\n" , argv[0] ); exit ( -1 ); }
/* init, define, and config the system */ vgInitSys();
vgDefineSys(argv[1]); vgConfigSys();
chan = vgGetChan(0);
/* add predraw call back function to channel */ vgAddFunc(chan, VGCHAN_PREDRAW, DrawCB, NULL); /* pfChanTravFunc(pchan, PFTRAV_DRAW, DrawCB); */ while ( 1 ) { vgSyncFrame (); vgFrame (); } }
static void StencilHUD(pfPipeWindow *pw) { double f; static int mapped = 0; float new_x = 0.0f, new_y = 0.0f;
/* pw->select(); pfSelectPWin(pw) */
glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW);
glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glEnable(GL_STENCIL_TEST);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glClearColor(1.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0f, 0.0f, 0.0f);
/* Clear stencil planes to one over entire window */ glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT);
/* were a drawing */ glStencilFunc(GL_ALWAYS, 0x1, 0x1); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glBegin(GL_TRIANGLE_FAN); for(f = 0.0; f< 359.5; f+=1.0) { pfSinCos((float)f, &new_x, &new_y); glVertex2f(1.0 * new_x, 1.0 * new_y); } glEnd();
glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST);
/* reset framebuffer */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix();
glClearColor(1.0f, 0.0f, 0.0f, 0.0f); }
void DrawCB( void ) { static int first_time = TRUE; pfPipeWindow *pwin; float new_x = 0.0f, new_y = 0.0f, f;
/* get performer pipe window handle */ pwin = vgGetWinPWin( vgGetWin(0) );
/* ======= FIRST TIME INIT ======= */ if (first_time) { StencilHUD(pwin); first_time = FALSE; }
/* enable stencil test */ glStencilFunc(GL_EQUAL, 0x1, 0x1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glEnable(GL_STENCIL_TEST);
}
---End of forwarded mail from <jim> ("jim")
-- Support Engineer Jim Tsai System & Technology Corp. Visual Simulation Group www.systech.hinet.net
Hi Use stencil test. I can render a circle scope in vega. But outside the circle, the sky color cover the color defined in the initial OpenGL subroutine StencilHUD. Does anybody use encounter this problem in vega?
thanks in advance
-- Support Engineer Jim Tsai System & Technology Corp. Visual Simulation Group www.systech.hinet.net
void DrawCB(void); static void StencilHUD(pfPipeWindow *pw);
main( int argc , char *argv[] ) { vgWindow *win; vgChannel *chan; pfPipeWindow *pwin;
if ( argc < 2 ) { printf ( "syntax : %s <config file>\n" , argv[0] ); exit ( -1 ); }
/* init, define, and config the system */ vgInitSys();
vgDefineSys(argv[1]); vgConfigSys();
chan = vgGetChan(0);
/* add predraw call back function to channel */ vgAddFunc(chan, VGCHAN_PREDRAW, DrawCB, NULL); /* pfChanTravFunc(pchan, PFTRAV_DRAW, DrawCB); */ while ( 1 ) { vgSyncFrame (); vgFrame (); } }
static void StencilHUD(pfPipeWindow *pw) { double f; static int mapped = 0; float new_x = 0.0f, new_y = 0.0f;
/* pw->select(); pfSelectPWin(pw) */
glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW);
glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glEnable(GL_STENCIL_TEST);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glClearColor(1.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0f, 0.0f, 0.0f);
/* Clear stencil planes to one over entire window */ glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); /* were a drawing */ glStencilFunc(GL_ALWAYS, 0x1, 0x1); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glBegin(GL_TRIANGLE_FAN); for(f = 0.0; f< 359.5; f+=1.0) { pfSinCos((float)f, &new_x, &new_y); glVertex2f(1.0 * new_x, 1.0 * new_y); } glEnd();
glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST);
/* reset framebuffer */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix();
glClearColor(1.0f, 0.0f, 0.0f, 0.0f); }
void DrawCB( void ) { static int first_time = TRUE; pfPipeWindow *pwin; float new_x = 0.0f, new_y = 0.0f, f;
/* get performer pipe window handle */ pwin = vgGetWinPWin( vgGetWin(0) );
/* ======= FIRST TIME INIT ======= */ if (first_time) { StencilHUD(pwin); first_time = FALSE; }
/* enable stencil test */ glStencilFunc(GL_EQUAL, 0x1, 0x1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glEnable(GL_STENCIL_TEST);
}
======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:58 PDT