27#include "gl_helper.hpp"
29#include "engine_logger.hpp"
35using namespace brenta;
41 if (!gladLoadGLLoader(loadproc))
43 ERROR(
"Failed to initialize GLAD");
50 glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
51 glEnable(GL_DEPTH_TEST);
52 INFO(
"Enabled GL_DEPTH_TEST");
58 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
59 INFO(
"Enabled GL_BLEND (transparency)");
66 glEnable(GL_CULL_FACE);
67 INFO(
"Enabled GL_CULL_FACE (draw only visible triangles)");
74 glEnable(GL_MULTISAMPLE);
75 INFO(
"Enabled GL_MULTISAMPLE");
78 GLenum errcode = gl::check_error();
80 INFO(
"OpenGl loaded");
87 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
88 INFO(
"Enabled GL_POLYGON_MODE (wireframe)");
92 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
93 INFO(
"Disabled GL_POLYGON_MODE (fill)");
99 glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
104 glClearColor(r, g, b, a);
109 glDrawArrays(mode, first, count);
114 glDrawElements(mode, count, type, indices);
120 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
125 glBindVertexArray(n);
131 while ((errorCode = glGetError()) != GL_NO_ERROR)
136 case GL_INVALID_ENUM:
137 error =
"INVALID_ENUM";
139 case GL_INVALID_VALUE:
140 error =
"INVALID_VALUE";
142 case GL_INVALID_OPERATION:
143 error =
"INVALID_OPERATION";
145 case GL_STACK_OVERFLOW:
146 error =
"STACK_OVERFLOW";
148 case GL_STACK_UNDERFLOW:
149 error =
"STACK_UNDERFLOW";
151 case GL_OUT_OF_MEMORY:
152 error =
"OUT_OF_MEMORY";
154 case GL_INVALID_FRAMEBUFFER_OPERATION:
155 error =
"INVALID_FRAMEBUFFER_OPERATION";
162 error +=
" | " + std::string(file) +
" (" + std::to_string(line) +
")";
static void set_viewport(int x, int y, int SCR_WIDTH, int SCR_HEIGHT)
Set Viewport.
static void set_color(float r, float g, float b, float a)
Set Clear Color.
static void clear()
Clear.
static void set_poligon_mode(GLboolean enable)
Set Poligon Mode.
static void draw_elements(GLenum mode, int count, GLenum type, const void *indices)
Draw Elements.
static void load_opengl(bool gl_blending=true, bool gl_cull_face=true, bool gl_multisample=true, bool gl_depth_test=true)
Load OpenGL.
static void bind_vertex_array(unsigned int n)
Enable Depth Test.
static GLenum check_error_(const char *file, int line)
Check OpenGL error.
static void draw_arrays(GLenum mode, int first, int count)
Draw Arrays.
static GLFWglproc get_proc_address()
Get the OpenGL function pointer.
static int get_width()
Get the width of the window.
static int get_height()
Get the height of the window.