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 
9 namespace openmsx { class GLScaler; }
10 
11 namespace gl {
12 
13 struct Context
14 {
17  Context(int width, int height);
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
30  GLuint unifTexColor;
31  GLuint unifTexMvp;
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
40  GLuint unifFillMvp;
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 private:
51  std::unique_ptr<openmsx::GLScaler> fallbackScaler;
52 
53 };
54 
55 extern std::optional<Context> context;
56 
57 } // namespace gl
58 
59 #endif
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
Definition: GLUtil.hh:388
Abstract base class for OpenGL scalers.
Definition: GLScaler.hh:15
Definition: gl_mat.hh:23
std::optional< Context > context
Definition: GLContext.cc:9
This file implemented 3 utility functions:
Definition: Autofire.cc:9
ShaderProgram progFill
Definition: GLContext.hh:39
GLuint unifFillMvp
Definition: GLContext.hh:40
GLuint unifTexColor
Definition: GLContext.hh:30
Context(int width, int height)
Initialize global openGL state.
Definition: GLContext.cc:11
ShaderProgram progTex
Definition: GLContext.hh:29
mat4 pixelMvp
Definition: GLContext.hh:45
GLuint unifTexMvp
Definition: GLContext.hh:31
openmsx::GLScaler & getFallbackScaler()
Definition: GLContext.cc:42