bool Scene::run() { Graphics* ptr_graphics = Graphics::instance(); Audio* ptr_audio = Audio::instance(); TextureCache* ptr_texture_cache = TextureCache::instance(); InputManager* ptr_inputManager = new InputManager(); m_frame_timer.start(m_millis_per_frame); on_setup(); setup_sprites(); on_begin(); while (!m_scene_is_ended) { ptr_inputManager->update(); on_check_input(ptr_inputManager); if (!m_is_paused) { handle_messages(); on_detect_collisions(); on_update(); update_sprites(); ptr_graphics->begin_render(); on_render(ptr_graphics); ptr_graphics->end_render(); } while (!m_frame_timer.has_elapsed()); } cleanup_sprites(); on_cleanup(); return !m_game_is_ended; }
GLEWContext* context::glew_context() { if(!m_glew_context) { on_begin(); m_glew_context.reset(new GLEWContext()); g_current_glew() = m_glew_context.get(); GLenum err = glewInit(); // needs to be called after context creation if (GLEW_OK != err) { k3d::log() << error << "GLEW init failed: " << glewGetErrorString(err) << std::endl; m_glew_context.reset(); } on_end(); assert(m_glew_context); } return m_glew_context.get(); }
void context::begin() { g_current() = this; g_current_glew() = glew_context(); on_begin(); }