Brenta Engine 1.0
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
35#define glCheckError() glCheckError_(__FILE__, __LINE__)
36
37namespace Brenta
38{
39
45class GL
46{
47 public:
58 static void LoadOpenGL(bool gl_blending = true, bool gl_cull_face = true,
59 bool gl_multisample = true,
60 bool gl_depth_test = true);
65 static void SetPoligonMode(GLboolean enable);
76 static void SetViewport(int x, int y, int SCR_WIDTH, int SCR_HEIGHT);
87 static void SetColor(float r, float g, float b, float a);
97 static void DrawArrays(GLenum mode, int first, int count);
109 static void DrawElements(GLenum mode, int count, GLenum type,
110 const void *indices);
116 static void Clear();
122 static void BindVertexArray(unsigned int n);
130 static GLenum glCheckError_(const char *file, int line);
131};
132
133} // namespace Brenta
OpenGL helper functions.
Definition gl_helper.hpp:46
static void LoadOpenGL(bool gl_blending=true, bool gl_cull_face=true, bool gl_multisample=true, bool gl_depth_test=true)
Load OpenGL.
Definition gl_helper.cpp:38
static void DrawElements(GLenum mode, int count, GLenum type, const void *indices)
Draw Elements.
static GLenum glCheckError_(const char *file, int line)
Check OpenGL error.
static void DrawArrays(GLenum mode, int first, int count)
Draw Arrays.
static void SetColor(float r, float g, float b, float a)
Set Clear Color.
static void Clear()
Clear.
static void BindVertexArray(unsigned int n)
Enable Depth Test.
static void SetViewport(int x, int y, int SCR_WIDTH, int SCR_HEIGHT)
Set Viewport.
Definition gl_helper.cpp:98
static void SetPoligonMode(GLboolean enable)
Set Poligon Mode.
Definition gl_helper.cpp:84