//////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { pArgc = &argc; pArgv = argv; char *ref_file = NULL; printf("%s Starting...\n\n", sSDKsample); if (checkCmdLineFlag(argc, (const char **)argv, "file")) { fpsLimit = frameCheckNumber; getCmdLineArgumentString(argc, (const char **)argv, "file", &ref_file); } if (ref_file) { chooseCudaDevice(argc, argv, false); loadVolumeData(argv[0]); runAutoTest(ref_file, argv[0]); } else { // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. initGL(&argc, argv); // use command-line specified CUDA device, otherwise use device with highest Gflops/s chooseCudaDevice(argc, argv, true); // OpenGL buffers initGLBuffers(); loadVolumeData(argv[0]); } printf("Press space to toggle animation\n" "Press '+' and '-' to change displayed slice\n"); #if defined (__APPLE__) || defined(MACOSX) atexit(cleanup); #else glutCloseFunc(cleanup); #endif glutMainLoop(); exit(EXIT_SUCCESS); }
Volume* DefFileReader::loadVolume( std::string filePath ) { FILE* fp; int nx, ny, nz, offset; float dx, dy, dz; char data_file[256]; char transf_file[256]; fp = fopen(filePath.c_str(), "r"); if (!fp) return 0; fscanf(fp, "%d %d %d %f %f %f %d\n", &nx, &ny, &nz, &dx, &dy, &dz, &offset); fscanf(fp, "%s\n", data_file); fscanf(fp, "%s\n", transf_file); fclose(fp); Volume* volume = new Volume( nx, ny, nz, dx, dy, dz, offset ); size_t pos = filePath.find_last_of( "/\\" ); std::string dataPath = filePath.substr( 0, pos + 1 ); dataPath += data_file; loadVolumeData( dataPath, volume, offset ); std::string transferPath = filePath.substr( 0, pos + 1 ); transferPath += transf_file; loadVolumeTransfer( transferPath, volume ); return volume; }
int main(int argc, char **argv) { if(argc < 2) { std::cout << "IBL.exe configFile.txt" << std::endl; return 0; } loadArguments(argc, argv); loadVolumeData(); if(!strcmp(IBLext, "cam")) lightProbeCapture = new LightProbeCapture(); precomputeSphericalHarmonics(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_ALPHA); glutInitWindowSize(windowWidth, windowHeight); glutCreateWindow("Image-Based Lighting"); glutReshapeFunc(reshape); glutDisplayFunc(display); glutIdleFunc(idle); glutKeyboardFunc(keyboard); glutSpecialFunc(specialKeyboard); glewInit(); initGL(); initShader("Shaders/IBL", 0); initShader("Shaders/VRRaycasting", 1); initShader("Shaders/VRImage", 2); initShader("Shaders/FinalRendering", 3); glUseProgram(0); glutMainLoop(); delete volume; delete minMaxOctree; delete transferFunction; delete myGLTextureViewer; delete hdrImage; if(!strcmp(IBLext, "cam")) delete lightProbeCapture; return 0; }