Check for graphics driver support.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m44s

This commit is contained in:
2024-09-19 19:39:07 -04:00
parent e712a5aaa3
commit 131ce4c78e
3 changed files with 17 additions and 1 deletions

View File

@@ -34,6 +34,8 @@ namespace JGL {
void Update(const Vector2& window_size);
inline void PurgeFontCache() { fontCache.purgeCache(); }
std::vector<GLfloat> OpenGLPerspectiveProjectionRH(float fovY, float aspect, float z_near, float z_far);
/// Returns true if the graphics driver meets the requirements (GL Version & Extensions).
bool MeetsRequirements();
/// Drawing functions for primitive 2D Shapes.
namespace J2D {

View File

@@ -4,6 +4,7 @@
#include <Colors.hpp>
#include <chrono>
#include <J3ML/LinearAlgebra/Vector2.hpp>
#include <JGL/logger/logger.h>
using J3ML::LinearAlgebra::Vector2;
using namespace JGL;
@@ -99,8 +100,11 @@ class JGLDemoWindow : public ReWindow::RWindow
public:
void initGL() {
camera = new Camera;
gladLoadGL();
if (!JGL::MeetsRequirements()) {
Logger::Fatal("The graphics driver does not meet the minimum requirements to run this program.");
exit(-1);
}
JGL::InitTextEngine();
JGL::Update(getSize());
J3D::Init(getSize(), 90, 100);

View File

@@ -34,6 +34,16 @@ namespace JGL {
glViewport(0, 0, (int) wS.x, (int) wS.y);
}
bool MeetsRequirements() {
if (!GLAD_GL_VERSION_2_1)
return false;
if (!GLAD_GL_EXT_framebuffer_object)
return false;
if (!GLAD_GL_ARB_framebuffer_object)
return false;
return true;
}
#pragma region J2D
void J2D::Begin(RenderTarget* rt, bool clear_buffers) {
GLfloat old_clear_color[4];