1
0
Fork 0

GfxDriver: add getName() getVersion() and getCardName()

This commit is contained in:
Henrik Hautakoski 2023-05-01 17:46:37 +02:00
parent 43354fc9b4
commit 5c5d9fe09a
3 changed files with 33 additions and 9 deletions

View file

@ -14,8 +14,16 @@ public:
};
public:
// Get the name of the driver.
virtual std::string getName() const = 0;
// Get the version of the driver
virtual std::string getVersion() const = 0;
virtual std::string getVendor() const = 0;
virtual std::string getCardName() const = 0;
virtual void setViewport(int x, int y, int width, int height) = 0;
virtual void setClearColor(float r, float g, float b, float a) = 0;
@ -25,10 +33,10 @@ public:
virtual void clearColorBuffer() = 0;
// Resources.
// CreateIndexBuffer()
// CreateVertexBuffer()
// Draw calls
};

View file

@ -4,14 +4,14 @@
namespace sp {
std::string OpenGLDrv::getVendor() const
{
char buf[512];
std::string OpenGLDrv::getName() const {
return "OpenGL";
}
std::string OpenGLDrv::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);
@ -19,11 +19,21 @@ std::string OpenGLDrv::getVendor() const
prof = "Core";
}
snprintf(buf, sizeof(buf), "OpenGL %s %s profile - %s %s", ver, prof.c_str(), ren, ven);
snprintf(buf, sizeof(buf), "%s %s", prof.c_str(), glGetString(GL_VERSION));
return std::string(buf);
}
std::string OpenGLDrv::getVendor() const
{
return std::string((char*)glGetString(GL_VENDOR));
}
std::string OpenGLDrv::getCardName() const
{
return std::string((char*)glGetString(GL_RENDERER));
}
void OpenGLDrv::setViewport(int x, int y, int width, int height)
{
glViewport(x, y, width, height);

View file

@ -9,8 +9,14 @@ namespace sp {
class OpenGLDrv : public GfxDriver
{
public:
virtual std::string getName() const;
virtual std::string getVersion() const;
virtual std::string getVendor() const;
virtual std::string getCardName() const;
virtual void setViewport(int x, int y, int width, int height);
virtual void setClearColor(float r, float g, float b, float a);