Inserted OpenGL Error checking

This commit is contained in:
2023-07-23 13:57:25 -07:00
parent a5b36fb24a
commit 7ed019b2c4
20 changed files with 305 additions and 132 deletions

View File

@ -0,0 +1,9 @@
# Copyright (c) 2023 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DAWN_TARGET_NAME}
PRIVATE
assertgl.cpp
)

View File

@ -0,0 +1,58 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "assertgl.hpp"
#include "dawnopengl.hpp"
void assertNotGLErrorCheck(const char *file, int32_t line) {
GLenum errorCode;
std::string fileString = file;
std::string error = "GL Error";
int32_t errorCount = 0;
while((errorCode = glGetError()) != GL_NO_ERROR) {
errorCount++;
switch (errorCode) {
case GL_INVALID_ENUM:
error += "\nINVALID_ENUM";
break;
case GL_INVALID_VALUE:
error += "\nINVALID_VALUE";
break;
case GL_INVALID_OPERATION:
error += "\nINVALID_OPERATION";
break;
case GL_STACK_OVERFLOW:
error += "\nSTACK_OVERFLOW";
break;
case GL_STACK_UNDERFLOW:
error += "\nSTACK_UNDERFLOW";
break;
case GL_OUT_OF_MEMORY:
error += "\nOUT_OF_MEMORY";
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
error += "\nINVALID_FRAMEBUFFER_OPERATION";
break;
default:
error += "\nUNKNOWN GL ERROR ERROR";
break;
}
error += " (" + std::to_string(errorCode) + ")";
}
if(errorCount != 0) {
error += "\n" + std::string(file) + " (" + std::to_string(line) + ")";
assertUnreachable(error);
}
}

View File

@ -0,0 +1,20 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "assert/assert.hpp"
/**
* Asserts that there are no OpenGL errors.
*
* @param file The file the assertion is being made in.
* @param line The line the assertion is being made in.
*/
void assertNotGLErrorCheck(const char *file, int32_t line);
/**
* Asserts that there are no OpenGL errors.
*/
#define assertNoGLError() assertNotGLErrorCheck(__FILE__, __LINE__)