Louvre  v2.3.2-1
C++ library for Wayland compositors
Static Public Member Functions | List of all members
LOpenGL Class Reference

OpenGL utility functions. More...

Static Public Member Functions

static char * openShader (const std::filesystem::path &file)
 Open a GLSL shader file. More...
 
static const char * glErrorString (GLenum error)
 Gets a string representation of an OpenGL error code. More...
 
static GLuint maxTextureUnits ()
 Maximum number of texture units. More...
 
static GLuint compileShader (GLenum type, const char *shaderString)
 Compile a shader. More...
 
static LTextureloadTexture (const std::filesystem::path &file)
 Create a texture from an image file. More...
 
static bool hasExtension (const char *extensions, const char *extension)
 Check if a specific OpenGL extension is available. More...
 

Detailed Description

OpenGL utility functions.

Set of OpenGL ES 2.0 utility functions.

Member Function Documentation

◆ openShader()

char * openShader ( const std::filesystem::path &  file)
static

Open a GLSL shader file.

Note
The returned string must be manually freed when no longer used.
Parameters
filePath to the shader file.
Returns
A string with the contents of the shader or nullptr in case of error.

◆ glErrorString()

const char * glErrorString ( GLenum  error)
static

Gets a string representation of an OpenGL error code.

This function converts an OpenGL error code obtained from glGetError() into a human-readable string.

Parameters
errorThe OpenGL error code returned by glGetError().
Returns
A const char pointer containing the error message.

◆ maxTextureUnits()

GLuint maxTextureUnits ( )
static

Maximum number of texture units.

Returns
An integer with the maximum number of texture units supported by OpenGL.

◆ compileShader()

GLuint compileShader ( GLenum  type,
const char *  shaderString 
)
static

Compile a shader.

Parameters
typeType of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER).
shaderStringString with the shader source code.
Returns
The shader ID or 0 if an error occurs.

◆ loadTexture()

LTexture * loadTexture ( const std::filesystem::path &  file)
static

Create a texture from an image file.

Loads and creates a texture from an image file.

Note
The image format is always converted to DRM_FORMAT_ARGB8888 or DRM_FORMAT_ABGR8888.
Parameters
filePath to the image file. Must be an image format supported by STB Image (JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC).
Returns
A new texture or nullptr in case of error.

◆ hasExtension()

bool hasExtension ( const char *  extensions,
const char *  extension 
)
static

Check if a specific OpenGL extension is available.

This function queries the list of supported OpenGL extensions and determines whether the specified extension is among them.

Parameters
extensionThe name of the OpenGL extension to check.
Returns
true if the extension is available, false otherwise.