Graphics class: use GfxDriver API.
This commit is contained in:
parent
d3debea41a
commit
4dad1a5d75
2 changed files with 14 additions and 20 deletions
81
source/Graphics/Graphics.cpp
Normal file
81
source/Graphics/Graphics.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
|
||||
#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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
Loading…
Add table
Add a link
Reference in a new issue