libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
gl.hpp File Reference

OpenGL window, shader program, sprite, and text rendering classes. More...

#include "config.h"
#include "mx.hpp"
#include <string>
#include <memory>
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "console.hpp"
Include dependency graph for gl.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  gl::ShaderProgram
 GLSL shader program wrapper (shared-ownership). More...
struct  gl::ShaderProgram::SharedState
class  gl::GLText
 Render SDL_ttf text into an OpenGL texture and display it on screen. More...
class  gl::GLSprite
 A textured screen-space quad drawn with an OpenGL shader. More...
class  gl::GLWindow
 SDL2 + OpenGL/ES window with event loop and console support. More...
class  gl::GLObject
 Abstract interface for scene objects managed by a GLWindow. More...

Namespaces

namespace  gl

Enumerations

enum class  gl::GLMode { gl::DESKTOP , gl::ES }
 OpenGL mode: desktop GL or OpenGL ES. More...

Functions

GLuint gl::loadTexture (const std::string &filename)
 Load a GL texture from a file.
GLuint gl::loadTexture (const std::string &filename, int &w, int &h)
 Load a GL texture from a file and retrieve its dimensions.
void gl::updateTexture (GLuint texture, SDL_Surface *surface, bool flip)
 Replace a GL texture's contents from an SDL_Surface.
GLuint gl::createTexture (SDL_Surface *surface, bool flip)
 Create a new GL texture from an SDL_Surface.
GLuint gl::createTexture (void *buffer, int width, int height)
 Create a new GL texture from a raw pixel buffer.
SDL_Surface * gl::createSurface (int w, int h)
 Allocate a blank RGBA SDL_Surface.

Detailed Description

OpenGL window, shader program, sprite, and text rendering classes.

Provides the core OpenGL abstractions used by libmx applications:

  • ShaderProgram – GLSL vertex/fragment shader compilation and uniform upload.
  • GLText – SDL_ttf text rendered into an OpenGL texture.
  • GLSprite – A textured quad rendered with an arbitrary shader.
  • GLWindow – SDL2 + OpenGL/ES window and event loop.
  • GLObject – Abstract interface for scene objects attached to GLWindow.

Requires the WITH_GL compile-time flag.

Definition in file gl.hpp.