private void trace(){
  glUseProgram(rayTracingProgram);
  if (mouseDown) {
    currRotationAboutY=rotationAboutY + (mouseX - mouseDownX) * 0.01f;
  }
 else {
    currRotationAboutY=rotationAboutY;
  }
  cameraPosition.set((float)sin(-currRotationAboutY) * 3.0f,2.0f,(float)cos(-currRotationAboutY) * 3.0f);
  viewMatrix.setLookAt(cameraPosition,cameraLookAt,cameraUp);
  if (resetFramebuffer) {
    projMatrix.setPerspective((float)Math.toRadians(60.0f),(float)width / height,1f,2f);
    resizeFramebufferTexture();
    resetFramebuffer=false;
  }
  projMatrix.invertPerspectiveView(viewMatrix,invViewProjMatrix);
  updateCameraSettingsUbo();
  long thisTime=System.nanoTime();
  float elapsedSeconds=(thisTime - firstTime) / 1E9f;
  glUniform1f(timeUniform,elapsedSeconds);
  float blendFactor=frameNumber / (frameNumber + 1.0f);
  glUniform1f(blendFactorUniform,blendFactor);
  glUniform1i(bounceCountUniform,bounceCount);
  glUniform1f(widthUniform,width);
  glUniform1f(heightUniform,height);
  glBindBufferBase(GL_UNIFORM_BUFFER,this.cameraSettingsUboBinding,this.cameraSettingsUbo);
  glBindFramebuffer(GL_FRAMEBUFFER,fbo);
  glBindVertexArray(vao);
  glBindTexture(GL_TEXTURE_2D,tex);
  glBindSampler(0,this.sampler);
  glDrawArrays(GL_TRIANGLES,0,6);
  glBindSampler(0,0);
  glBindTexture(GL_TEXTURE_2D,0);
  glBindVertexArray(0);
  glBindFramebuffer(GL_FRAMEBUFFER,0);
  glUseProgram(0);
  glBindBufferBase(GL_UNIFORM_BUFFER,this.cameraSettingsUboBinding,0);
  frameNumber++;
}

private void trace ( ) { glUseProgram ( rayTracingProgram ) ; if ( mouseDown ) { currRotationAboutY = rotationAboutY + ( mouseX - mouseDownX ) * 0.01f ; } else { currRotationAboutY = rotationAboutY ; } cameraPosition . set ( ( float ) sin ( - currRotationAboutY ) * 3.0f , 2.0f , ( float ) cos ( - currRotationAboutY ) * 3.0f ) ; viewMatrix . setLookAt ( cameraPosition , cameraLookAt , cameraUp ) ; if ( resetFramebuffer ) { projMatrix . setPerspective ( ( float ) Math . toRadians ( 60.0f ) , ( float ) width / height , 1f , 2f ) ; resizeFramebufferTexture ( ) ; resetFramebuffer = false ; } projMatrix . invertPerspectiveView ( viewMatrix , invViewProjMatrix ) ; updateCameraSettingsUbo ( ) ; long thisTime = System . nanoTime ( ) ; float elapsedSeconds = ( thisTime - firstTime ) / 1E9f ; glUniform1f ( timeUniform , elapsedSeconds ) ; float blendFactor = frameNumber / ( frameNumber + 1.0f ) ; glUniform1f ( blendFactorUniform , blendFactor ) ; glUniform1i ( bounceCountUniform , bounceCount ) ; glUniform1f ( widthUniform , width ) ; glUniform1f ( heightUniform , height ) ; glBindBufferBase ( GL_UNIFORM_BUFFER , this . cameraSettingsUboBinding , this . cameraSettingsUbo ) ; glBindFramebuffer ( GL_FRAMEBUFFER , fbo ) ; glBindVertexArray ( vao ) ; glBindTexture ( GL_TEXTURE_2D , tex ) ; glBindSampler ( 0 , this . sampler ) ; glDrawArrays ( GL_TRIANGLES , 0 , 6 ) ; glBindSampler ( 0 , 0 ) ; glBindTexture ( GL_TEXTURE_2D , 0 ) ; glBindVertexArray ( 0 ) ; glBindFramebuffer ( GL_FRAMEBUFFER , 0 ) ; glUseProgram ( 0 ) ; glBindBufferBase ( GL_UNIFORM_BUFFER , this . cameraSettingsUboBinding , 0 ) ; frameNumber ++ ; }
compute one frame by tracing the scene using our ray tracing shader and presenting that image on the screen .
