tests/cuda4.1sdk/tests/volumeFiltering/volumeFiltering.cpp
void display()
{
  cutilCheckError(cutStartTimer(timer));  

  // use OpenGL to build view matrix
  GLfloat modelView[16];
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glRotatef(-viewRotation.x, 1.0, 0.0, 0.0);
  glRotatef(-viewRotation.y, 0.0, 1.0, 0.0);
  glTranslatef(-viewTranslation.x, -viewTranslation.y, -viewTranslation.z);
  glGetFloatv(GL_MODELVIEW_MATRIX, modelView);
  glPopMatrix();

  invViewMatrix[0] = modelView[0]; invViewMatrix[1] = modelView[4]; invViewMatrix[2] = modelView[8]; invViewMatrix[3] = modelView[12];
  invViewMatrix[4] = modelView[1]; invViewMatrix[5] = modelView[5]; invViewMatrix[6] = modelView[9]; invViewMatrix[7] = modelView[13];
  invViewMatrix[8] = modelView[2]; invViewMatrix[9] = modelView[6]; invViewMatrix[10] = modelView[10]; invViewMatrix[11] = modelView[14];

  filter();
  render();

  // display results
  glClear(GL_COLOR_BUFFER_BIT);

  // draw image from PBO
  glDisable(GL_DEPTH_TEST);

  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  // draw using texture
  // copy from pbo to texture
  glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
  glBindTexture(GL_TEXTURE_2D, volumeTex);
  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
  glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

  // draw textured quad
  glEnable(GL_TEXTURE_2D);
  glBegin(GL_QUADS);
  glTexCoord2f(0, 0); glVertex2f(0, 0);
  glTexCoord2f(1, 0); glVertex2f(1, 0);
  glTexCoord2f(1, 1); glVertex2f(1, 1);
  glTexCoord2f(0, 1); glVertex2f(0, 1);
  glEnd();

  glDisable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, 0);


  if (g_CheckRender && g_CheckRender->IsQAReadback() && g_Verify) {
    // readback for QA testing
    shrLog("\n> (Frame %d) Readback BackBuffer\n", frameCount);
    g_CheckRender->readback( width, height );
    g_CheckRender->savePPM(sOriginal[g_Index], true, NULL);
    if (!g_CheckRender->PPMvsPPM(sOriginal[g_Index], sReference[g_Index], MAX_EPSILON_ERROR, THRESHOLD)) {
      g_TotalErrors++;
    }
    g_Verify = false;
  }
  glutSwapBuffers();
  glutReportErrors();

  cutilCheckError(cutStopTimer(timer));  

  computeFPS();
}
// display results using OpenGL (called by GLUT)
display results using OpenGL (called by GLUT)
display results using OpenGL ( called by GLUT )
void display()
{
  cutilCheckError(cutStartTimer(timer));  
  GLfloat modelView[16];
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glRotatef(-viewRotation.x, 1.0, 0.0, 0.0);
  glRotatef(-viewRotation.y, 0.0, 1.0, 0.0);
  glTranslatef(-viewTranslation.x, -viewTranslation.y, -viewTranslation.z);
  glGetFloatv(GL_MODELVIEW_MATRIX, modelView);
  glPopMatrix();
  invViewMatrix[0] = modelView[0]; invViewMatrix[1] = modelView[4]; invViewMatrix[2] = modelView[8]; invViewMatrix[3] = modelView[12];
  invViewMatrix[4] = modelView[1]; invViewMatrix[5] = modelView[5]; invViewMatrix[6] = modelView[9]; invViewMatrix[7] = modelView[13];
  invViewMatrix[8] = modelView[2]; invViewMatrix[9] = modelView[6]; invViewMatrix[10] = modelView[10]; invViewMatrix[11] = modelView[14];
  filter();
  render();
  glClear(GL_COLOR_BUFFER_BIT);
  glDisable(GL_DEPTH_TEST);
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
  glBindTexture(GL_TEXTURE_2D, volumeTex);
  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
  glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
  glEnable(GL_TEXTURE_2D);
  glBegin(GL_QUADS);
  glTexCoord2f(0, 0); glVertex2f(0, 0);
  glTexCoord2f(1, 0); glVertex2f(1, 0);
  glTexCoord2f(1, 1); glVertex2f(1, 1);
  glTexCoord2f(0, 1); glVertex2f(0, 1);
  glEnd();
  glDisable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, 0);
  if (g_CheckRender && g_CheckRender->IsQAReadback() && g_Verify) {
    shrLog("\n> (Frame %d) Readback BackBuffer\n", frameCount);
    g_CheckRender->readback( width, height );
    g_CheckRender->savePPM(sOriginal[g_Index], true, NULL);
    if (!g_CheckRender->PPMvsPPM(sOriginal[g_Index], sReference[g_Index], MAX_EPSILON_ERROR, THRESHOLD)) {
      g_TotalErrors++;
    }
    g_Verify = false;
  }
  glutSwapBuffers();
  glutReportErrors();
  cutilCheckError(cutStopTimer(timer));  
  computeFPS();
}
void display ( ) { cutilCheckError ( cutStartTimer ( timer ) ) ; GLfloat modelView [ 16 ] ; glMatrixMode ( GL_MODELVIEW ) ; glPushMatrix ( ) ; glLoadIdentity ( ) ; glRotatef ( - viewRotation . x , 1.0 , 0.0 , 0.0 ) ; glRotatef ( - viewRotation . y , 0.0 , 1.0 , 0.0 ) ; glTranslatef ( - viewTranslation . x , - viewTranslation . y , - viewTranslation . z ) ; glGetFloatv ( GL_MODELVIEW_MATRIX , modelView ) ; glPopMatrix ( ) ; invViewMatrix [ 0 ] = modelView [ 0 ] ; invViewMatrix [ 1 ] = modelView [ 4 ] ; invViewMatrix [ 2 ] = modelView [ 8 ] ; invViewMatrix [ 3 ] = modelView [ 12 ] ; invViewMatrix [ 4 ] = modelView [ 1 ] ; invViewMatrix [ 5 ] = modelView [ 5 ] ; invViewMatrix [ 6 ] = modelView [ 9 ] ; invViewMatrix [ 7 ] = modelView [ 13 ] ; invViewMatrix [ 8 ] = modelView [ 2 ] ; invViewMatrix [ 9 ] = modelView [ 6 ] ; invViewMatrix [ 10 ] = modelView [ 10 ] ; invViewMatrix [ 11 ] = modelView [ 14 ] ; filter ( ) ; render ( ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; glDisable ( GL_DEPTH_TEST ) ; glPixelStorei ( GL_UNPACK_ALIGNMENT , 1 ) ; glBindBufferARB ( GL_PIXEL_UNPACK_BUFFER_ARB , pbo ) ; glBindTexture ( GL_TEXTURE_2D , volumeTex ) ; glTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , width , height , GL_RGBA , GL_UNSIGNED_BYTE , 0 ) ; glBindBufferARB ( GL_PIXEL_UNPACK_BUFFER_ARB , 0 ) ; glEnable ( GL_TEXTURE_2D ) ; glBegin ( GL_QUADS ) ; glTexCoord2f ( 0 , 0 ) ; glVertex2f ( 0 , 0 ) ; glTexCoord2f ( 1 , 0 ) ; glVertex2f ( 1 , 0 ) ; glTexCoord2f ( 1 , 1 ) ; glVertex2f ( 1 , 1 ) ; glTexCoord2f ( 0 , 1 ) ; glVertex2f ( 0 , 1 ) ; glEnd ( ) ; glDisable ( GL_TEXTURE_2D ) ; glBindTexture ( GL_TEXTURE_2D , 0 ) ; if ( g_CheckRender && g_CheckRender -> IsQAReadback ( ) && g_Verify ) { shrLog ( " \n \n " , frameCount ) ; g_CheckRender -> readback ( width , height ) ; g_CheckRender -> savePPM ( sOriginal [ g_Index ] , true , NULL ) ; if ( ! g_CheckRender -> PPMvsPPM ( sOriginal [ g_Index ] , sReference [ g_Index ] , MAX_EPSILON_ERROR , THRESHOLD ) ) { g_TotalErrors ++ ; } g_Verify = false ; } glutSwapBuffers ( ) ; glutReportErrors ( ) ; cutilCheckError ( cutStopTimer ( timer ) ) ; computeFPS ( ) ; }
display results using OpenGL (called by GLUT)
display results using OpenGL ( called by GLUT )
// use OpenGL to build view matrix // display results // draw image from PBO // draw using texture // copy from pbo to texture // draw textured quad // readback for QA testing