예제 #1
0
void sutilHandleErrorNoContext(RTresult code, const char* file, int line)
{
  char s[2048];
  sprintf(s, "Code: %d\n(%s:%d)", code, file, line);
  sutilReportError( s );
  exit(1);
}
예제 #2
0
void sutilHandleErrorNoExit(RTcontext context, RTresult code, const char* file, int line)
{
  const char* message;
  char s[2048];
  rtContextGetErrorString(context, code, &message);
  sprintf(s, "%s\n(%s:%d)", message, file, line);
  sutilReportError( s );
}
예제 #3
0
void GLUTDisplay2::display() {
	cout << "frame" << endl;
	try {
		ptr->trace();
		displayFrame();
	} catch (optix::Exception& e) {
		sutilReportError(e.getErrorString().c_str());
		exit(2);
	}

	// Swap buffers
	glutSwapBuffers();
}
예제 #4
0
int main( int argc, char** argv )
{
	// Init Physx
	initializePhysx();

	// Init GLUT
	GLUTDisplay::init( argc, argv );

	for(int i = 1; i < argc; ++i) {
		std::string arg = argv[i];
		if(arg == "-P" || arg == "--pbo") {
			CannonBall::m_useGLBuffer = true;
		} else if( arg == "-n" || arg == "--nopbo" ) {
			CannonBall::m_useGLBuffer = false;
		} else if( arg == "--noanimate" ) {
			CannonBall::m_animate = false;
		} else if( arg == "-h" || arg == "--help" ) {
			printUsageAndExit(argv[0]);
		} else {
			std::cerr << "Unknown option '" << arg << "'\n";
			printUsageAndExit(argv[0]);
		}
	}

  if( !GLUTDisplay::isBenchmark() ) printUsageAndExit( argv[0], false );

	// Start
	try{
		CannonBall scene;
		GLUTDisplay::run( "Simple Box Physx", &scene, GLUTDisplay::CDAnimated);
	} catch( optix::Exception& e ){
		sutilReportError( e.getErrorString().c_str() );
		exit(1);
	}

	return 0;
}
예제 #5
0
void GLUTDisplay2::run(PathTracer &pt) {
	ptr = &pt;

	unsigned int buffer_width = 960;
	unsigned int buffer_height = 540;
	glutInitWindowSize(buffer_width, buffer_height);
	glutInitWindowPosition(100, 100);
	glutCreateWindow("test");

	// Initialize GLEW
	if (glewInit() != GLEW_OK) {
		cerr << "Failed to initialize GLEW" << endl;
		return;
	}

	try {
		// Set up scene
		cout << "setup camera" << endl;
		//SampleScene::InitialCameraData camera_data;

		// todo: get camera
		//ptr->initScene(camera_data);

		// Initialize camera according to scene params
		//m_camera = new PinholeCamera(camera_data.eye, camera_data.lookat,
		//		camera_data.up, -1.0f, // hfov is ignored when using keep vertical
		//		camera_data.vfov, PinholeCamera::KeepVertical);
	} catch (optix::Exception& e) {
		sutilReportError(e.getErrorString().c_str());
		exit(2);
	}

	//cout << "make renderer" << endl;
	//renderer = new GLrenderer( pt.getOutputBuffer()->getGLBOId() );

	cout << "init texture" << endl;
	glGenTextures(1, &m_texId);
	glBindTexture(GL_TEXTURE_2D, m_texId);

	// Change these to GL_LINEAR for super- or sub-sampling
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	// GL_CLAMP_TO_EDGE for linear filtering, not relevant for nearest.
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

	glBindTexture(GL_TEXTURE_2D, 0);

	// Initialize state
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, 1, 0, 1, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glViewport(0, 0, buffer_width, buffer_height);

	cout << "begin glut loop" << endl;
	glutDisplayFunc(display);
	glutIdleFunc(idle);
	glutShowWindow();
	glutReshapeWindow( buffer_width, buffer_height );
	glutMainLoop();
}