Exemplo n.º 1
0
void TopazSample::reshape(int32_t width, int32_t height)
{
	initFramebuffers(width, height);
	oit->InitAccumulationRenderTargets(width, height);

	initScene();
	initCommandList();
	initCommandListWeightBlended();

	CHECK_GL_ERROR();
}
Exemplo n.º 2
0
// Set things up and run
int main(int argc, char** argv) {
	makeWindow(argc, argv);
	acquireSharedOpenCLContext();
	initObjects();
	initPrograms();
	initFramebuffers();
	initShaders();
	setupGlutCallbacks();

	camera.pos = MakeVector(0, 0, -12);
	camera.up = MakeVector(0, 1, 0);
	camera.front = MakeVector(0, 0, 1);
	
	glutSetCursor(GLUT_CURSOR_NONE);
	glutMainLoop();

	releaseSharedOpenCLContext();
}
Exemplo n.º 3
0
/***************************************************
** display function -- what to draw               **
***************************************************/
void display ( void )
{
  /* Initialize our framebuffer objects */
  if (!fb) initFramebuffers();

  /* determing what are fps have been up till now */
  fps = UpdateFPS();

  /* benchmarking may be desired, if so we need to know # of frames done */
  if (benchmarking) frameCount++;

  /* some setup */
  glEnable( GL_NORMALIZE );
  glEnable( GL_DEPTH_TEST );
  glClearDepth( 1.0 );
  glClearColor( 0, 0, 0, 0 );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  /* Draw the scene we want to the framebuffer 'fb' */
  AllowUnclampedColors();  // This process may involve values outside [0..1]
  if (drawRefractionOnly)
	DrawRefractedScene( viewpoint );
  else 
    DrawCausticsSceneWithLightSpaceGatheredPhotons( viewpoint );
  ResumeClampingColors();  // OK, we can allow OpenGL to start clamping to [0..1] again.

  /* we only want to draw to the size of the visible screen, even if 'fb' is bigger! */
  glViewport( 0, 0, screenSize, screenSize );
  
  /* either display our final result, or, depending on user input, some intermediate step */
  if (displayBig > 0)
		DrawBigScreenTexture(displayBig);
  else
  {
	  displayLargeTexture( fb->GetColorTextureID( 0 ), GL_LINEAR, GL_LINEAR );
	
	  /* draw miscellaneous data onscreen */
	  glDisable( GL_DEPTH_TEST );
      if (drawSideImages && displayBig < 1)
		DisplaySideImages();
	  if (drawHelpMenu)
		drawHelpScreen();
      if (shaderLoadError)
		drawErrorMessage();
      if (!screenShot && !makingMovie)
		displayTimer( fps );
      glEnable( GL_DEPTH_TEST );
  }

  /* grab a screenshot if necessary */
  if (screenShot)
  {
    /* note data is stored in memory with y-inverted to how stored in PPM, so invert when writing */
	glReadPixels( 0, 0, screenSize, screenSize, GL_RGB, GL_UNSIGNED_BYTE, screenCapture );
	WritePPM( screenCaptureFilename, PPM_RAW, screenSize, -screenSize, screenCapture );    
	screenShot = 0;
  }

  /* flush GL commands & swap buffers */
  glFlush();
  glutSwapBuffers();

  /* if we're using the built-in movie capture, we need to add a frame */
  if (makingMovie) makeMovie->AddCurrentFrame();
}