Re: OpenGL graphics state during draw callback

New Message Reply Date view Thread view Subject view Author view

Shankar Swamy (shankar++at++redwood.rt.cs.boeing.com)
Wed, 27 Aug 1997 20:42:20 -0700


>
> So my question is: In the draw callback does the
> graphics context we are handed retain any state from the channel call made
> previously? Or, do we have set the view transformation explicitly every time
> > do OpenGL rendering?
>

I haven't seen this documented anywhere, but it appears like the
transformation matrices are handed over to the draw callbacks.
This makes sense since this would save a glLoadIdentity()
or a glPopMatrix() in the performer (source) code, which would
be required to change/restore the matrix.

In fact, the post-draw callback for the (n-1)th frame will have the same
viewing matrix that the pre-draw callback for the n-th frame gets. You
can verify that by printing the matrices from the callbacks with something
like:

int preDrawCB(pfTraverser*, void*){
  static int ii = 0 ;

  float myMat[16] ;
  printf("Iteration no. %d IN PRE-DRAW\n", ii++) ;

  glMatrixMode(GL_MODELVIEW_MATRIX) ;
  glGetFloatv(GL_MODELVIEW_MATRIX, myMat) ;

  printf("Row 0: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[0], myMat[4], myMat[8], myMat[12]);
  printf("Row 1: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[1], myMat[5], myMat[9], myMat[13]);
  printf("Row 2: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[2], myMat[6], myMat[10], myMat[14]);
  printf("Row 3: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[3], myMat[7], myMat[11], myMat[15]);

return NULL ; } //preDrawCB(...)

int postDrawCB(pfTraverser* myTr, void*) {
  static int ii = 0 ;

  float myMat[16] ;
  printf("Iteration no. %d IN POST-DRAW\n", ii++) ;

  glMatrixMode(GL_MODELVIEW_MATRIX) ;
  glGetFloatv(GL_MODELVIEW_MATRIX, myMat) ;

  printf("Row 0: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[0], myMat[4], myMat[8], myMat[12]);
  printf("Row 1: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[1], myMat[5], myMat[9], myMat[13]);
  printf("Row 2: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[2], myMat[6], myMat[10], myMat[14]);
  printf("Row 3: %5.3f, %5.3f, %5.3f, %5.3f\n",
        myMat[3], myMat[7], myMat[11], myMat[15]);

  return NULL ; } //postDrawCB(...)

 - shankar swamy
 -------------------------------------------------------------------
 shankar++at++boeing.com

=======================================================================
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:55:47 PDT

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