BLT-With-Graphics-Template/include/blt/gfx/gl_includes.h

65 lines
1.6 KiB
C
Raw Permalink Normal View History

2023-12-16 23:52:18 -05:00
#pragma once
/*
* Created by Brett on 16/12/23.
* Licensed under GNU General Public License V3.0
* See LICENSE file for license detail
*/
#ifndef BLT_GL_INCLUDES_H
#define BLT_GL_INCLUDES_H
2024-05-09 13:51:14 -04:00
#include <blt/std/logging.h>
2023-12-16 23:52:18 -05:00
// emscripten provides its own gl bindings.
#ifndef __EMSCRIPTEN__
2024-05-09 13:51:14 -04:00
2023-12-16 23:52:18 -05:00
#include <glad/gl.h>
2024-05-09 13:51:14 -04:00
2023-12-16 23:52:18 -05:00
#else
2023-12-17 19:37:11 -05:00
#include <GLES2/gl2.h>
2024-04-26 01:11:46 -04:00
#include <GLES3/gl3.h>
#include <GLES3/gl31.h>
#include <GLES3/gl32.h>
2023-12-16 23:52:18 -05:00
#include <emscripten.h>
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
#endif
2024-05-09 13:51:14 -04:00
namespace blt::gfx
{
inline std::string get_error_message(GLenum error)
{
switch (error)
{
case GL_INVALID_ENUM:
return "Invalid Enum";
case GL_INVALID_VALUE:
return "Invalid Value";
case GL_INVALID_OPERATION:
return "Invalid Operation";
case GL_STACK_OVERFLOW:
return "Stack Overflow";
case GL_STACK_UNDERFLOW:
return "Stack Underflow";
case GL_OUT_OF_MEMORY:
return "Out Of Memory";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "Invalid Framebuffer Operation";
case GL_INVALID_INDEX:
return "Invalid Index";
}
return std::string("Unknown Error: ") += std::to_string(error);
}
inline void handle_errors()
{
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR)
{
BLT_ERROR(get_error_message(err));
}
}
}
2023-12-16 23:52:18 -05:00
#endif //BLT_GL_INCLUDES_H