Adding OpenGL Driver.
This commit is contained in:
parent
ab11f7b9db
commit
d3debea41a
2 changed files with 78 additions and 0 deletions
53
source/GfxDriver/OpenGL/OpenGLDrv.cpp
Normal file
53
source/GfxDriver/OpenGL/OpenGLDrv.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
#include "OpenGLDrv.h"
|
||||
#include <Graphics/GL/gl.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
std::string OpenGLDrv::getVendor() 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);
|
||||
}
|
||||
|
||||
void OpenGLDrv::setViewport(int x, int y, int width, int height)
|
||||
{
|
||||
glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
void OpenGLDrv::setClearColor(float r, float g, float b, float a)
|
||||
{
|
||||
glClearColor(r, g, b, 1.0f);
|
||||
}
|
||||
|
||||
void OpenGLDrv::clearBuffer(GfxDriver::BufferFlags flags)
|
||||
{
|
||||
int glFlags = 0;
|
||||
|
||||
if (flags == GfxDriver::CLEAR_BUFFER_BIT) {
|
||||
glFlags |= GL_COLOR_BUFFER_BIT;
|
||||
}
|
||||
|
||||
glClear(glFlags);
|
||||
}
|
||||
|
||||
void OpenGLDrv::clearColorBuffer()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
25
source/GfxDriver/OpenGL/OpenGLDrv.h
Normal file
25
source/GfxDriver/OpenGL/OpenGLDrv.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
#ifndef SPECTRE_GFXDRIVER_OPENGL_OPENGLDRV_H
|
||||
#define SPECTRE_GFXDRIVER_OPENGL_OPENGLDRV_H
|
||||
|
||||
#include <Spectre/GfxDriver/GfxDriver.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class OpenGLDrv : public GfxDriver
|
||||
{
|
||||
public:
|
||||
virtual std::string getVendor() const;
|
||||
|
||||
virtual void setViewport(int x, int y, int width, int height);
|
||||
|
||||
virtual void setClearColor(float r, float g, float b, float a);
|
||||
|
||||
virtual void clearBuffer(GfxDriver::BufferFlags flags);
|
||||
|
||||
virtual void clearColorBuffer();
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* SPECTRE_GFXDRIVER_GFXDRIVER_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue