Brenta Engine 1.1
Loading...
Searching...
No Matches
gl_helper.hpp
1/*
2 * MIT License
3 *
4 * Copyright (c) 2024 Giovanni Santini
5
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 */
26
27/*
28 * Helper functions to interact with OpenGL.
29 */
30
31#pragma once
32
33#include <glad/glad.h> /* OpenGL driver */
34
35namespace brenta
36{
37
43class gl
44{
45 public:
56 static void load_opengl(bool gl_blending = true, bool gl_cull_face = true,
57 bool gl_multisample = true,
58 bool gl_depth_test = true);
63 static void set_poligon_mode(GLboolean enable);
74 static void set_viewport(int x, int y, int SCR_WIDTH, int SCR_HEIGHT);
85 static void set_color(float r, float g, float b, float a);
95 static void draw_arrays(GLenum mode, int first, int count);
107 static void draw_elements(GLenum mode, int count, GLenum type,
108 const void *indices);
114 static void clear();
120 static void bind_vertex_array(unsigned int n);
128 static GLenum check_error_(const char *file, int line);
129#define check_error() gl::check_error_(__FILE__, __LINE__)
130};
131
132} // namespace brenta
OpenGL helper functions.
Definition gl_helper.hpp:44
static void set_viewport(int x, int y, int SCR_WIDTH, int SCR_HEIGHT)
Set Viewport.
Definition gl_helper.cpp:97
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.
Definition gl_helper.cpp:83
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.
Definition gl_helper.cpp:37
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.