This class serves as the OpenGL interface for your app, since the engine doesn't directly link OpenGL to the app executable.
More...
#include <OpenGL.hpp>
|
template<typename TResult , typename... TOpenGLArgs, typename... Args> |
static TResult | call (std::source_location location, TResult(*glfun)(TOpenGLArgs...), Args... args) |
| Performs a checked OpenGL call. If the OpenGL call fails, it throws util::OpenGLError.
|
|
static int32_t | shader_type_to_opengl_type (resources::ShaderType type) |
| Converts resources::ShaderType to the OpenGL shader type enum.
|
|
static uint32_t | generate_texture (const std::filesystem::path &path, bool flip_uvs) |
| Loads the texture from path into the OpenGL context.
|
|
static int32_t | texture_format (int32_t number_of_channels) |
| Get texture format for a number_of_channels .
|
|
static uint32_t | init_skybox_cube () |
| Initializes the cube Vertex Array Object used for skybox drawing. Caches the vao result.
|
|
static bool | shader_compiled_successfully (uint32_t shader_id) |
| Check if the shader with the shader_id compiled successfully.
|
|
static uint32_t | compile_shader (const std::string &shader_source, resources::ShaderType shader_type) |
| Compiles the shader from source.
|
|
static uint32_t | load_skybox_textures (const std::filesystem::path &path, bool flip_uvs=false) |
| Loads the skybox textures from the path . Make sure that images are named: front.jpg, back.jpg, up.jpg, down.jpg, left.jpg, down.jpg. They can be of the other extension as well, but the function will assign each texture to the appropriate side of the cubemap based on the texture file name.
|
|
static void | enable_depth_testing () |
| Enables depth testing.
|
|
static void | disable_depth_testing () |
| Disables depth testing.
|
|
static void | clear_buffers () |
| Clears GL_DEPTH_BUFFER_BIT, GL_COLOR_BUFFER_BIT, and GL_STENCIL_BUFFER_BIT.
|
|
static std::string | get_compilation_error_message (uint32_t shader_id) |
| Retrieve the shader compilation error log message.
|
|
|
static void | assert_no_error (std::source_location location) |
| Throws util::OpenGLError if an OpenGL error occurred. Used internally.
|
|
This class serves as the OpenGL interface for your app, since the engine doesn't directly link OpenGL to the app executable.
Any OpenGL additional direct OpenGL calls you need should be added here.
◆ ShaderProgramId
◆ call()
template<typename TResult , typename... TOpenGLArgs, typename... Args>
static TResult engine::graphics::OpenGL::call |
( |
std::source_location |
location, |
|
|
TResult(*)(TOpenGLArgs...) |
glfun, |
|
|
Args... |
args |
|
) |
| |
|
inlinestatic |
Performs a checked OpenGL call. If the OpenGL call fails, it throws util::OpenGLError.
- Parameters
-
location | Source location of where the call was made. |
glfun | OpenGL function to call. |
args | OpenGL function arguments. |
- Returns
- Return value if the
glfun
has it, otherwise void.
◆ shader_type_to_opengl_type()
◆ generate_texture()
uint32_t engine::graphics::OpenGL::generate_texture |
( |
const std::filesystem::path & |
path, |
|
|
bool |
flip_uvs |
|
) |
| |
|
static |
Loads the texture from path
into the OpenGL context.
- Parameters
-
path | path to a texture file. |
flip_uvs | flip_uvs on load. |
- Returns
- OpenGL id of a texture object.
◆ texture_format()
int32_t engine::graphics::OpenGL::texture_format |
( |
int32_t |
number_of_channels | ) |
|
|
static |
Get texture format for a number_of_channels
.
- Parameters
-
number_of_channels | that the texture has. |
- Returns
- GL_RED, GL_RGB, GL_RGBA for the number_of_channels=[1,3,4] respectively.
◆ init_skybox_cube()
uint32_t engine::graphics::OpenGL::init_skybox_cube |
( |
| ) |
|
|
static |
Initializes the cube Vertex Array Object used for skybox drawing. Caches the vao result.
- Returns
- VAO of the cube used for skybox drawing.
◆ shader_compiled_successfully()
bool engine::graphics::OpenGL::shader_compiled_successfully |
( |
uint32_t |
shader_id | ) |
|
|
static |
Check if the shader with the shader_id
compiled successfully.
- Returns
- true if the shader compilation succeeded, false otherwise.
◆ compile_shader()
uint32_t engine::graphics::OpenGL::compile_shader |
( |
const std::string & |
shader_source, |
|
|
resources::ShaderType |
shader_type |
|
) |
| |
|
static |
Compiles the shader from source.
- Parameters
-
shader_source | source code for the shader |
shader_type | the type of the shader to create1 |
- Returns
- OpenGL context object of the shader.
◆ load_skybox_textures()
uint32_t engine::graphics::OpenGL::load_skybox_textures |
( |
const std::filesystem::path & |
path, |
|
|
bool |
flip_uvs = false |
|
) |
| |
|
static |
Loads the skybox textures from the path
. Make sure that images are named: front.jpg, back.jpg, up.jpg, down.jpg, left.jpg, down.jpg. They can be of the other extension as well, but the function will assign each texture to the appropriate side of the cubemap based on the texture file name.
- Parameters
-
path | directory in which cubemap textures are located. |
flip_uvs | wheater to flip_uvs on texture loading. |
- Returns
- OpenGL id to the cubemap texture
◆ enable_depth_testing()
void engine::graphics::OpenGL::enable_depth_testing |
( |
| ) |
|
|
static |
◆ disable_depth_testing()
void engine::graphics::OpenGL::disable_depth_testing |
( |
| ) |
|
|
static |
◆ clear_buffers()
void engine::graphics::OpenGL::clear_buffers |
( |
| ) |
|
|
static |
Clears GL_DEPTH_BUFFER_BIT, GL_COLOR_BUFFER_BIT, and GL_STENCIL_BUFFER_BIT.
◆ get_compilation_error_message()
std::string engine::graphics::OpenGL::get_compilation_error_message |
( |
uint32_t |
shader_id | ) |
|
|
static |
Retrieve the shader compilation error log message.
- Parameters
-
shader_id | Shader id for which the compilation failed. |
- Returns
- shader compilation error message.
◆ assert_no_error()
void engine::graphics::OpenGL::assert_no_error |
( |
std::source_location |
location | ) |
|
|
staticprivate |
Throws util::OpenGLError if an OpenGL error occurred. Used internally.
- Parameters
-
location | Source location from where the OpenGL call was made. |
The documentation for this class was generated from the following files: