diff --git a/include/Spectre/Graphics.h b/include/Spectre/Graphics.h index 6999ec1..ceb35fb 100644 --- a/include/Spectre/Graphics.h +++ b/include/Spectre/Graphics.h @@ -2,6 +2,7 @@ #ifndef GRAPHICS_H #define GRAPHICS_H +#include #include namespace sp { @@ -42,12 +43,17 @@ public : void swapBuffers(); + GfxDriver* getDriver(); + protected : int m_width; int m_height; Display *m_display; + + // Graphics Driver. OpenGL/Vulcan/DirectX etc. + GfxDriver *m_gfxdrv; }; } // namespace sp diff --git a/source/Graphics/OpenGL.cpp b/source/Graphics/Graphics.cpp similarity index 63% rename from source/Graphics/OpenGL.cpp rename to source/Graphics/Graphics.cpp index da752dd..1c246bb 100644 --- a/source/Graphics/OpenGL.cpp +++ b/source/Graphics/Graphics.cpp @@ -1,6 +1,6 @@ +#include "GfxDriver/OpenGL/OpenGLDrv.h" #include -#include #include namespace sp { @@ -11,6 +11,9 @@ Graphics::Graphics(PlatformApplication *platform) m_height = 600; m_display = new Display(); + + // Only have OpenGL atm. + m_gfxdrv = new OpenGLDrv(); } Graphics::~Graphics() @@ -42,22 +45,7 @@ void Graphics::shutdown() std::string Graphics::getVersion() const { - char buf[512]; - - std::string prof = "Compability"; - char *ver = (char*) glGetString(GL_VERSION); - char *ven = (char*) glGetString(GL_VENDOR); - char *ren = (char*) glGetString(GL_RENDERER); - GLint flags; - - glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &flags); - if (flags & GL_CONTEXT_CORE_PROFILE_BIT) { - prof = "Core"; - } - - snprintf(buf, sizeof(buf), "OpenGL %s %s profile - %s %s", ver, prof.c_str(), ren, ven); - - return std::string(buf); + return m_gfxdrv->getVendor(); } void Graphics::setDisplayMode(Display::Mode mode) @@ -72,17 +60,17 @@ void Graphics::setSize(int width, int height) void Graphics::setViewport(int x, int y, int width, int height) { - glViewport(x, y, width, height); + m_gfxdrv->setViewport(x, y, width, height); } void Graphics::setClearColor(float r, float g, float b) { - glClearColor(r, g, b, 1.0f); + m_gfxdrv->setClearColor(r, g, b, 1.0f); } void Graphics::clearBuffer() { - glClear(GL_COLOR_BUFFER_BIT); + m_gfxdrv->clearColorBuffer(); } void Graphics::swapBuffers()