void MyGL::SceneLoadDialog() { QString filepath = QFileDialog::getOpenFileName(0, QString("Load Scene"), QString("../scene_files"), tr("*.xml")); if(filepath.length() == 0) { return; } QFile file(filepath); int i = filepath.length() - 1; while(QString::compare(filepath.at(i), QChar('/')) != 0) { i--; } QStringRef local_path = filepath.leftRef(i+1); //Reset all of our objects scene.Clear(); //integrator = Integrator(); dir_integrator = DirectLightingIntegrator(); intersection_engine = IntersectionEngine(); //Load new objects based on the XML file chosen. xml_reader.LoadSceneFromFile(file, local_path, scene, dir_integrator); dir_integrator.scene = &scene; dir_integrator.intersection_engine = &intersection_engine; tot_integrator.scene = &scene; tot_integrator.intersection_engine = &intersection_engine; intersection_engine.scene = &scene; ResizeToSceneCamera(); update(); }
void MyGL::initializeGL() { // Create an OpenGL context initializeOpenGLFunctions(); // Print out some information about the current OpenGL context debugContextVersion(); // Set a few settings/modes in OpenGL rendering glEnable(GL_DEPTH_TEST); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); // Set the size with which points should be rendered glPointSize(5); // Set the color with which the screen is filled at the start of each render call. glClearColor(0.5, 0.5, 0.5, 1); printGLErrorLog(); // Create a Vertex Attribute Object vao.create(); // Create and set up the diffuse shader prog_lambert.create(":/glsl/lambert.vert.glsl", ":/glsl/lambert.frag.glsl"); // Create and set up the flat-color shader prog_flat.create(":/glsl/flat.vert.glsl", ":/glsl/flat.frag.glsl"); // We have to have a VAO bound in OpenGL 3.2 Core. But if we're not // using multiple VAOs, we can just bind one once. vao.bind(); //Test scene data initialization scene.CreateTestScene(); integrator.scene = &scene; integrator.intersection_engine = &intersection_engine; intersection_engine.scene = &scene; ResizeToSceneCamera(); //create new tree with this new set of geometry! this->intersection_engine.BVHrootNode = new BVHnode(); this->intersection_engine.BVHrootNode = createBVHtree(this->intersection_engine.BVHrootNode, this->scene.objects, 0); update(); }