87 lines
1.3 KiB
C++
87 lines
1.3 KiB
C++
|
|
#include "GfxDriver/OpenGL/OpenGLDrv.h"
|
|
#include <Spectre/Graphics.h>
|
|
#include <string>
|
|
|
|
namespace sp {
|
|
|
|
Graphics::Graphics(PlatformApplication *platform)
|
|
{
|
|
m_width = 800;
|
|
m_height = 600;
|
|
|
|
m_display = new Display();
|
|
|
|
// Only have OpenGL atm.
|
|
m_gfxdrv = new OpenGLDrv();
|
|
}
|
|
|
|
Graphics::~Graphics()
|
|
{
|
|
shutdown();
|
|
delete m_display;
|
|
delete m_gfxdrv;
|
|
}
|
|
|
|
bool Graphics::init()
|
|
{
|
|
DisplayMode mode(m_width, m_height);
|
|
DisplayDescription desc(mode);
|
|
|
|
if (!m_display->create(desc)) {
|
|
return false;
|
|
}
|
|
|
|
setClearColor(0.0f, 0.0f, 0.0f);
|
|
|
|
swapBuffers();
|
|
|
|
return true;
|
|
}
|
|
|
|
void Graphics::shutdown()
|
|
{
|
|
m_display->destroy();
|
|
}
|
|
|
|
std::string Graphics::getVersion() const
|
|
{
|
|
return m_gfxdrv->getVendor();
|
|
}
|
|
|
|
void Graphics::setDisplayMode(Display::Mode mode)
|
|
{
|
|
m_display->setVideoMode(mode);
|
|
}
|
|
|
|
void Graphics::setSize(int width, int height)
|
|
{
|
|
m_display->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_display->swapBuffers();
|
|
}
|
|
|
|
Display* Graphics::getDisplay()
|
|
{
|
|
return m_display;
|
|
}
|
|
|
|
} // namespace sp
|