openMSX
GLContext.hh
Go to the documentation of this file.
1#ifndef GL_CONTEXT_HH
2#define GL_CONTEXT_HH
3
4#include "GLUtil.hh"
5#include "gl_mat.hh"
6#include <memory>
7#include <optional>
8
9namespace openmsx { class GLScaler; }
10
11namespace gl {
12
13struct Context
14{
17 Context();
19
20 // Simple texture program. It expects
21 // uniforms:
22 // unifTexColor: values from texture map are multiplied by this 4D color
23 // unifTexMvp: Model-View-Projection-matrix
24 // attributes:
25 // 0: 4D vertex positions, get multiplied by Model-View-Projection-matrix
26 // 1: 2D texture coordinates
27 // textures:
28 // the to be applied texture must be bound to the 1st texture unit
32
33 // Simple color-fill program. It expects
34 // uniforms:
35 // unifFillMvp: Model-View-Projection-matrix
36 // attributes:
37 // 0: 4D vertex positions, get multiplied by Model-View-Projection-matrix
38 // 1: 4D vertex color
41
42 // Model-View-Projection-matrix that maps integer vertex positions to host
43 // display pixel positions. (0,0) is the top-left pixel, (width-1,height-1) is
44 // the bottom-right pixel.
46
47 // Fallback scaler
49
50 // Setup model-view-projection matrix. Should be called before drawing,
51 // at least once after the window resolution has changed. (E.g. call it
52 // once per frame).
53 void setupMvpMatrix(gl::vec2 logicalSize);
54
55private:
56 std::unique_ptr<openmsx::GLScaler> fallbackScaler;
57};
58
59extern std::optional<Context> context;
60
61} // namespace gl
62
63#endif
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
Definition GLUtil.hh:383
Abstract base class for OpenGL scalers.
Definition GLScaler.hh:16
Definition gl_mat.hh:23
std::optional< Context > context
Definition GLContext.cc:10
This file implemented 3 utility functions:
Definition Autofire.cc:9
Context()
Initialize global openGL state.
Definition GLContext.cc:12
ShaderProgram progFill
Definition GLContext.hh:39
GLint unifTexColor
Definition GLContext.hh:30
void setupMvpMatrix(gl::vec2 logicalSize)
Definition GLContext.cc:49
GLint unifTexMvp
Definition GLContext.hh:31
ShaderProgram progTex
Definition GLContext.hh:29
mat4 pixelMvp
Definition GLContext.hh:45
openmsx::GLScaler & getFallbackScaler()
Definition GLContext.cc:41
GLint unifFillMvp
Definition GLContext.hh:40