OpenGLRenderer: Add debug wrapper (which handle OpenGL errors)

This commit is contained in:
Jérôme Leclercq
2020-09-03 13:39:34 +02:00
parent df33262ab4
commit 6848ff8b34
2 changed files with 163 additions and 19 deletions

View File

@@ -17,6 +17,8 @@
#include <string>
#include <unordered_set>
#define NAZARA_OPENGLRENDERER_DEBUG 1
namespace Nz
{
class OpenGLDevice;
@@ -93,6 +95,9 @@ namespace Nz::GL
class NAZARA_OPENGLRENDERER_API Context
{
struct SymbolLoader;
friend SymbolLoader;
public:
inline Context(const OpenGLDevice* device);
virtual ~Context();
@@ -107,6 +112,8 @@ namespace Nz::GL
void BindUniformBuffer(UInt32 uboUnit, GLuint buffer, GLintptr offset, GLsizeiptr size) const;
void BindVertexArray(GLuint vertexArray, bool force = false) const;
bool ClearErrorStack() const;
virtual void EnableVerticalSync(bool enabled) = 0;
inline const OpenGLDevice* GetDevice() const;
@@ -125,6 +132,8 @@ namespace Nz::GL
inline void NotifyTextureDestruction(GLuint texture) const;
inline void NotifyVertexArrayDestruction(GLuint vao) const;
bool ProcessErrorStack() const;
void SetCurrentTextureUnit(UInt32 textureUnit) const;
void SetScissorBox(GLint x, GLint y, GLsizei width, GLsizei height) const;
void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height) const;
@@ -133,7 +142,11 @@ namespace Nz::GL
void UpdateStates(const RenderStates& renderStates) const;
#if NAZARA_OPENGLRENDERER_DEBUG
#define NAZARA_OPENGLRENDERER_FUNC(name, sig) std::function<std::remove_pointer_t<sig>> name;
#else
#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr;
#endif
NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_FUNC)
#undef NAZARA_OPENGLRENDERER_FUNC