#include "GfxDriver/OpenGL/OpenGLDrv.h" #include #include namespace sp { Graphics::Graphics(PlatformApplication *platform) { m_width = 800; m_height = 600; m_window = new Window(); // Only have OpenGL atm. m_gfxdrv = new OpenGLDrv(); } Graphics::~Graphics() { shutdown(); delete m_window; delete m_gfxdrv; } bool Graphics::init() { DisplayMode mode(m_width, m_height); WindowDescription desc(mode); if (!m_window->create(desc)) { return false; } setClearColor(0.0f, 0.0f, 0.0f); swapBuffers(); return true; } void Graphics::shutdown() { m_window->destroy(); } std::string Graphics::getVersion() const { return m_gfxdrv->getVendor(); } void Graphics::setWindowMode(Window::Mode mode) { m_window->setVideoMode(mode); } void Graphics::setSize(int width, int height) { m_window->setSize(width, height); } void Graphics::setViewport(int x, int y, int width, int height) { m_gfxdrv->setViewport(x, y, width, height); } void Graphics::setClearColor(float r, float g, float b) { m_gfxdrv->setClearColor(r, g, b, 1.0f); } void Graphics::clearBuffer() { m_gfxdrv->clearColorBuffer(); } void Graphics::swapBuffers() { m_window->swapBuffers(); } GfxDriver* Graphics::getDriver() { return m_gfxdrv; } Window* Graphics::getWindow() { return m_window; } } // namespace sp