Upgrading to Performer 2.1, OpenGL and IR

New Message Reply Date view Thread view Subject view Author view

Salvador Cabaruvias (sal++at++mbsgi2.mdc.com)
Mon, 23 Sep 1996 14:26:28 -0700


Hi everybody,

We did the unmentionable by doing everything at once!

We upgrade to 2 pipe InfiniteReality, moved our Sirius on to the
InfiniteReality, upgrade to Perf. 2.1, and last but not least, converted to
OpenGL. All said and done, we are stuck at this bug/feature(?).

We used Sirius video example, complex.c (perf 1.2) to display video on a
polygon. We generate our sensor image on pipe 1. Output this via the composite
video on Pipe 1 to the Sirius video. Using complex.c example of creating
texture memory and then subtexload the video on to the polygon in preDraw
callback in GL.

Questions:

This doesn't seem to work in OpenGL. How do we do this for OpenGL? Can you
still do this in the Draw Process? I have an example but it does it in the
CULL process.

I have include the routines for doing the Sirius Video and our attempts to
get OpenGL to work with Sirius Video in Performer 2.1

Thanks in advance for your help.
sal

-- 
--------------------------------------------------------------------------------
Salvador Cabaruvias                       |     sal++at++sgidev.mdc.com             |
--------------------------------------------------------------------------------
CSSL                                      |     "Well I be done seen about every  
McDonnell Douglas                         |      thing when I see an elephant 
(310) 593-6719                            |      fly"  --Dumbo--

/* $Log: noise.c,v $ * Revision 1.17 1996/09/23 05:54:32 olivier */

/* general includes */ #include <stdlib.h> #include <stdio.h>

#include <vl/vl.h> #include <vl/dev_sirius.h>

#include <Performer/pf.h> #include <Performer/pr.h> #include "_es.h"

/* * VL defines */ static VLControlValue size,origin, timing, tex; static VLControlValue format; static VLControlValue cap_type; static VLServer svr; static VLPath path; static VLNode src; static VLNode drn;

static int DoFields = 1; static float s_scale, t_scale;

static float ident_matrix[4][4] = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };

typedef struct { pfTexture *PVidTex; float texture_matrix[4][4]; int t_width; int t_height; #ifndef OPENGL long VideoTexture; /* GL handler on performer texture */ float s_fraction; float t_fraction; #endif } textures;

#ifdef TWOZERO pfNodeTravFuncType Pre_Vid(pfTraverser *trav, void *data) #else static long Pre_Vid(pfTraverser *trav, void *data) #endif { #ifdef OPENGL GLint gmtmp; #endif short MAT_mode; textures *mytex = (textures*)data; int i,j; #ifdef DEBUG printf("Pre_Vid: \n"); printf("texture_matrix: \n"); for(i=0;i<4;i++){for (j=0;j<4;j++){ printf("%d %d %f \n",i,j,mytex->texture_matrix[i][j]);}} #ifndef OPENGL printf("s_fraction=%f t_fraction=%f \n", mytex->s_fraction,mytex->t_fraction); printf("VideoTexture=%d \n",mytex->VideoTexture); #endif #endif

#ifndef OPENGL MAT_mode = getmmode(); mmode( MTEXTURE); loadmatrix( mytex->texture_matrix); mmode(MAT_mode); #else /* OGLXXX * getmmode: translate returned values * GLint mmtmp; */ MAT_mode = (glGetIntegerv(GL_MATRIX_MODE, &gmtmp), gmtmp); glMatrixMode( GL_TEXTURE); glLoadMatrixf( mytex->texture_matrix); glMatrixMode(MAT_mode); #endif pfApplyTex (mytex->PVidTex);

#ifdef VIDEO /* Load the texture from Sirius to Texture memory */ #ifndef OPENGL subtexload(TX_TEXTURE_0,mytex->VideoTexture,0.0,mytex->s_fraction, 0.0,mytex->t_fraction,0,(unsigned long *)0,SIR_VEN_16BIT_TEXEL); #else glTexSubImage2DEXT(GL_TEXTURE_2D,0, 0,0, mytex->t_width,mytex->t_height, GL_RGBA,GL_UNSIGNED_BYTE,(const GLvoid *)NULL); #endif #endif pfOverride(PFSTATE_TEXTURE, PF_ON); return PFTRAV_CONT; } #ifdef TWOZERO pfNodeTravFuncType Post_Vid(pfTraverser *trav, void *data) #else static long Post_Vid(pfTraverser *trav, void *data) #endif { #ifdef OPENGL GLint gmtmp; #endif short MAT_mode; int i,j;

#ifdef DEBUG printf("Post_Vid: \n"); printf("ident_matrix: \n"); for(i=0;i<4;i++){for (j=0;j<4;j++){ printf("%d %d %f \n",i,j,ident_matrix[i][j]);}} #endif

#ifndef OPENGL MAT_mode = getmmode(); mmode( MTEXTURE); loadmatrix( ident_matrix); mmode(MAT_mode); #else /* OGLXXX * getmmode: translate returned values * GLint mmtmp; */ MAT_mode = (glGetIntegerv(GL_MATRIX_MODE, &gmtmp), gmtmp); glMatrixMode( GL_TEXTURE); glLoadMatrixf( ident_matrix); glMatrixMode(MAT_mode); #endif

pfOverride(PFSTATE_TEXTURE, PF_OFF); return PFTRAV_CONT; } void doHudDisplay(pfNode *node_hud) { #ifdef OPENGL GLint gmtmp; #endif short MAT_mode; int i,j;

static esObject *hud; static textures *mytex;

mytex = pfMalloc(sizeof(textures), pfGetSharedArena()); printf("texture structure allocated\n"); mytex->PVidTex = pfNewTex( pfGetSharedArena()); printf("video/image texture allocated\n"); for(i=0;i<4;i++){for (j=0;j<4;j++){mytex->texture_matrix[i][j]=0.f;}}; mytex->texture_matrix[0][0] = 1.f; mytex->texture_matrix[1][1] = 1.f; mytex->texture_matrix[2][2] = 1.f; mytex->texture_matrix[3][3] = 1.f;

#ifndef VIDEO printf("DON'T DO VIDEO on HudDisplay\n"); pfLoadTexFile(mytex->PVidTex, "n1.rgb"); printf("texture n1.rgb loaded\n"); #else printf("DO VIDEO on HudDisplay\n"); /* open the server */ if( !(svr = vlOpenVideo(""))) { printf("couldn't open video\n"); exit(1); } else{printf("opened video\n");} /* Get the Video Source */ src = vlGetNode( svr, VL_SRC, VL_VIDEO, VL_ANY); /* Get the Texture Drain */ drn = vlGetNode( svr, VL_DRN, VL_TEXTURE, 0); /* Create the path */ path = vlCreatePath( svr, VL_ANY, src, drn); if( path < 0) { vlPerror("vlCreatePath"); exit(1); } else{printf("created path\n");} /* setup path */ if( vlSetupPaths( svr, (VLPathList)&path, 1, VL_SHARE, VL_SHARE) < 0) { vlPerror("vlSetupPaths"); exit(1); } else{printf("setup path\n");} /* select the appropriate events */ if( vlSelectEvents( svr, path, VLStreamPreemptedMask | VLControlChangedMask) < 0) { vlPerror("Select Events"); exit(1); } else{printf("selected events\n");} if(DoFields){ cap_type.intVal = VL_CAPTURE_NONINTERLEAVED; printf("DoFields=1, VL_CAPTURE_NONINTERLEAVED\n");} else{ cap_type.intVal = VL_CAPTURE_INTERLEAVED; printf("DoFields=0, VL_CAPTURE_INTERLEAVED\n");} if( vlSetControl( svr, path, drn, VL_CAP_TYPE, &cap_type) < 0) { vlPerror("vlSetControl"); exit(1); } else{printf("set control cap type \n");}

/* Update the video Timing Format */ /* Get the timing from input source */ if( vlGetControl( svr, path, src, VL_TIMING, &timing) < 0) { vlPerror("vlGetControl"); exit(1); } else{printf("got timing from source \n");} /* Set texture drain's timing to input source */ if( vlSetControl( svr, path, drn, VL_TIMING, &timing) < 0) { vlPerror("vlSetControl"); exit(1); } else{printf("set timing to drain \n");} if( vlGetControl( svr, path, src, VL_SIZE, &size) < 0) { vlPerror("vlGetControl/VL_SIZE"); exit(1); } else{printf("source size x=%d y=%d \n",size.xyVal.x,size.xyVal.y);}

if( vlGetControl( svr, path, drn, VL_SIZE, &size) < 0) { vlPerror("vlGetControl/VL_SIZE"); exit(1); } else{printf("drain size x=%d y=%d \n",size.xyVal.x,size.xyVal.y);}

#if 0 if( vlGetControl( svr, path, src, VL_ORIGIN, &origin) < 0) { vlPerror("vlGetControl/VL_ORIGIN"); exit(1); } else{printf("source origin x=%d y=%d\n",origin.xyVal.x,origin.xyVal.y);} origin.xyVal.x=639; origin.xyVal.y=511; if( vlSetControl( svr, path, src, VL_ORIGIN, &origin) < 0) { vlPerror("vlSetControl/VL_ORIGIN"); exit(1); } else{printf("set control gfx grab origin\n");} #endif

/* negotiate with GL */ /* pfInitGfx( p); */

/* define a Performer texture for use with sirius video */ pfTexRepeat(mytex->PVidTex, PFTEX_WRAP, PFTEX_CLAMP); pfTexFilter(mytex->PVidTex, PFTEX_MINFILTER, PFTEX_BILINEAR); pfTexFilter(mytex->PVidTex, PFTEX_MAGFILTER, PFTEX_BILINEAR); pfTexFormat(mytex->PVidTex, PFTEX_SUBLOAD_FORMAT, PF_ON); pfTexFormat(mytex->PVidTex, PFTEX_FAST_DEFINE, PF_ON); pfTexFormat(mytex->PVidTex, PFTEX_INTERNAL_FORMAT, PFTEX_RGB_5); /* 625 textures are bigger than 525 textures */ if(( timing.intVal == VL_TIMING_525_SQ_PIX) ||(timing.intVal == VL_TIMING_525_CCIR601)) { mytex->t_width = 1024; mytex->t_height = 512; } else { mytex->t_width = 1024; mytex->t_height = 1024; } /* Sirius always transfers 768 pixels */ /* mytex->t_width=768; */ /* frames, in fields is different */ if(DoFields)mytex->t_height=mytex->t_height>>1; printf("t_width=%d t_height=%d \n",mytex->t_width,mytex->t_height);

s_scale = (size.xyVal.x-1) / (float)mytex->t_width; t_scale = size.xyVal.y / (float)mytex->t_height; printf("s_scale=%f t_scale=%f \n",s_scale,t_scale); #ifndef OPENGL mytex->s_fraction = size.xyVal.x/(float)mytex->t_width; mytex->t_fraction = size.xyVal.y/(float)mytex->t_height; printf("s_fraction=%f t_fraction=%f \n",mytex->s_fraction,mytex->t_fraction); #endif pfTexImage(mytex->PVidTex,NULL,SIR_VEN_16BIT_TEXEL, mytex->t_width,mytex->t_height,0); #ifndef OPENGL mytex->VideoTexture = pfGetGLHandle((pfObject *)mytex->PVidTex); printf("VideoTexture=%d \n",mytex->VideoTexture); #endif mytex->texture_matrix[0][0] = s_scale; mytex->texture_matrix[1][1] = -t_scale; mytex->texture_matrix[3][1] = t_scale;

printf("doHudDisplay: \n"); printf("texture_matrix: \n"); for(i=0;i<4;i++){for (j=0;j<4;j++){ printf("%d %d %f \n",i,j,mytex->texture_matrix[i][j]);}} #ifndef OPENGL MAT_mode = getmmode(); mmode(MTEXTURE); loadmatrix( mytex->texture_matrix); #else /* OGLXXX * getmmode: translate returned values * GLint mmtmp; */ MAT_mode = (glGetIntegerv(GL_MATRIX_MODE, &gmtmp), gmtmp); glMatrixMode(GL_TEXTURE); glLoadMatrixf( mytex->texture_matrix); #endif /* Set the Texture packing mode */ tex.intVal = SIR_TEX_PACK_RGB_5; if( vlSetControl( svr, path, drn, VL_PACKING, &tex) < 0) { vlPerror("vlSetControl"); exit(1); } else{printf("set packing mode \n");}

#ifndef OPENGL loadmatrix( ident_matrix); mmode(MAT_mode); #else glLoadMatrixf( ident_matrix); glMatrixMode(MAT_mode); printf("End of dosethud, GL error is: %s\n",gluErrorString(glGetError())); #endif printf("loaded ident matrix \n"); vlBeginTransfer(svr, path, 0, NULL); printf("Began transfer \n"); #endif

/* pfEnable( PFEN_TEXTURE); causes core dump*/

pfNodeTravFuncs(node_hud,PFTRAV_DRAW,Pre_Vid,Post_Vid); pfNodeTravData(node_hud, PFTRAV_DRAW, mytex); }

======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:37 PDT

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