SoftwareRendered bool
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 6m23s

This commit is contained in:
2025-01-28 10:45:53 -05:00
parent 47a9340eff
commit d657315bab
3 changed files with 27 additions and 0 deletions

View File

@@ -323,6 +323,10 @@ public:
/// This function instructs the operating system to create the actual window, and give it to us to control.
/// Calling this function, therefore, creates the real 'window' object on the operating system.
[[nodiscard]] virtual bool Open() = 0;
/// @returns True if we are definitely running on a software renderer.
/// @note For some APIs this isn't typically possible.
[[nodiscard]] virtual bool SoftwareRendered() { return false; }
};
// TODO in the event that we can't find OpenGL or the Open() fails, have a way to say so without throwing an exception.
@@ -334,6 +338,7 @@ public:
void SetVsyncEnabled(bool state) override;
std::string GetGraphicsDriverVendor() override;
[[nodiscard]] bool Open() override;
[[nodiscard]] bool SoftwareRendered() override;
public:
OpenGLWindow(const std::string& title, int width, int height, uint8_t gl_major, uint8_t gl_minor);
};

View File

@@ -192,3 +192,12 @@ OpenGLWindow::OpenGLWindow(const std::string& title, int width, int height, uint
OpenGL::glXChooseVisual = (OpenGL::glXChooseVisual_t) dlsym(glx_lib, "glXChooseVisual");
OpenGL::constructor_success = true;
}
bool OpenGLWindow::SoftwareRendered() {
std::string renderer((const char*) OpenGL::glGetString(GL_RENDERER));
if (renderer.find("llvmpipe"))
return true;
if (renderer.find("softpipe"))
return true;
return false;
}

View File

@@ -99,6 +99,19 @@ void OpenGLWindow::SetVsyncEnabled(bool b) {
wglSwapIntervalEXT(b ? 1 : 0);
}
bool OpenGLWindow::SoftwareRendered() {
std::string renderer(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
if (renderer.find("llvmpipe"))
return true;
if (renderer.find("softpipe"))
return true;
if (renderer.find("GDI Generic"))
return true;
if (GetGraphicsDriverVendor().find("Mesa"))
return true;
return false;
}
OpenGLWindow::OpenGLWindow(const std::string& title, int width, int height, uint8_t gl_major, uint8_t gl_minor)
: gl_major(gl_major), gl_minor(gl_minor), RWindow(title, width, height) {
gl_lib = LoadLibrary("opengl32.dll");