From 940efee6d24e0d2aabcde7177c9b5bc24b0a1f9e Mon Sep 17 00:00:00 2001 From: korenkonder Date: Mon, 19 May 2025 18:51:39 +0300 Subject: [PATCH] Handle GL errors before GL state get --- src/CRE/gl_state.cpp | 3 +++ src/CRE/shared.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/CRE/gl_state.cpp b/src/CRE/gl_state.cpp index 9013b7e2..26dc8e0a 100644 --- a/src/CRE/gl_state.cpp +++ b/src/CRE/gl_state.cpp @@ -4,6 +4,7 @@ */ #include "gl_state.hpp" +#include "shared.hpp" gl_state_struct gl_state; @@ -96,6 +97,8 @@ bool gl_state_struct::check_texture_binding_cube_map() { } void gl_state_struct::get() { + gl_get_error_all_print(); + glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&texture_binding_2d); glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, (GLint*)&texture_binding_cube_map); diff --git a/src/CRE/shared.cpp b/src/CRE/shared.cpp index 31131deb..b7e0e418 100644 --- a/src/CRE/shared.cpp +++ b/src/CRE/shared.cpp @@ -16,9 +16,16 @@ void fbo_blit(p_gl_rend_state& p_gl_rend_st, GLuint src_fbo, GLuint dst_fbo, } void gl_get_error_all_print() { + const int32_t max_count = 0x100; + int32_t count = 0; GLenum error; - while (error = glGetError()) + while (error = glGetError() && count < max_count) { printf_debug("GL Error: 0x%04X\n", error); + count++; + } + + if (count == max_count) + printf_debug("GL returned more than %d consecutive errors!\n", max_count); } GLenum gl_get_error_print() {