#include #include #include namespace sp { GLWindow::GLWindow() { m_context = GLContext::create(); } GLWindow::~GLWindow() { delete m_context; } bool GLWindow::create(WindowDescription description) { if (!Window::create(description)) { return false; } if (!m_context->create(m_impl)) { return false; } enableVSync(false); return activate(true); } void GLWindow::destroy() { m_context->destroy(); Window::destroy(); } bool GLWindow::activate(bool value) { if (value) { return m_context->activate(); } return m_context->deactivate(); } bool GLWindow::enableVSync(bool value) { return m_context->setSwapInterval(value ? 1 : 0); } void GLWindow::swapBuffers() { if (activate(true)) { m_context->swapBuffers(); } } void GLWindow::onReshape(int width, int height) { // TODO: This should even not be here. // Generic Display should not have any GL calls. // But it's better to have it here then in the platform specific GLContext if (activate(true)) { glViewport(0, 0, width, height); } } } // namespace