diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index c0480d3fa42..c9efc60a573 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -46,8 +46,6 @@ Scene::Scene() m_max_distance_function = (FT)0.0; texture = new Texture(m_grid_size,m_grid_size); are_buffers_initialized = false; - context_initialized = false; - } @@ -590,13 +588,7 @@ void Scene::update_bbox() } void Scene::draw(QGLViewer* viewer) -{ - if(!context_initialized) - { - initializeOpenGLFunctions(); - glGenTextures(1, &textureId); - context_initialized = true; - } +{ if(!are_buffers_initialized) initialize_buffers(); QColor color; @@ -1317,3 +1309,9 @@ void Scene::deactivate_cutting_plane() disconnect(m_frame, SIGNAL(modified()), this, SLOT(cutting_plane())); m_view_plane = false; } +void Scene::initGL() +{ + initializeOpenGLFunctions(); + glGenTextures(1, &textureId); + compile_shaders(); +} diff --git a/AABB_tree/demo/AABB_tree/Scene.h b/AABB_tree/demo/AABB_tree/Scene.h index 00858d167a9..0e6616c3fab 100644 --- a/AABB_tree/demo/AABB_tree/Scene.h +++ b/AABB_tree/demo/AABB_tree/Scene.h @@ -81,6 +81,7 @@ public: void update_bbox(); Bbox bbox() { return m_bbox; } ManipulatedFrame* manipulatedFrame() const { return m_frame; } + void initGL(); private: // member data @@ -110,7 +111,6 @@ private: Cut_planes_types m_cut_plane; bool are_buffers_initialized; - bool context_initialized; private: // utility functions @@ -167,6 +167,7 @@ private: void initialize_buffers(); void compute_elements(int mode); void attrib_buffers(QGLViewer*); + void compile_shaders(); void compute_texture(int, int, Color_ramp, Color_ramp); public: @@ -250,7 +251,6 @@ public slots: // cutting plane void cutting_plane(); void changed(); - void compile_shaders(); }; // end class Scene #endif // SCENE_H diff --git a/AABB_tree/demo/AABB_tree/Viewer.cpp b/AABB_tree/demo/AABB_tree/Viewer.cpp index 22c1a8981ac..7a72edb85df 100644 --- a/AABB_tree/demo/AABB_tree/Viewer.cpp +++ b/AABB_tree/demo/AABB_tree/Viewer.cpp @@ -31,7 +31,7 @@ void Viewer::initializeGL() QGLViewer::initializeGL(); setBackgroundColor(::Qt::white); m_pScene->context = this->context(); - m_pScene->compile_shaders(); + m_pScene->initGL(); } void Viewer::mousePressEvent(QMouseEvent* e)