OXYGENHUB
◆ main openmsx / src / video / GLContext.hh
1.6 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 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
{
15
	/** Initialize global openGL state
16
	 */
17
	Context();
18
	~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
29
	ShaderProgram progTex;
30
	GLint unifTexColor;
31
	GLint 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
39
	ShaderProgram progFill;
40
	GLint 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.
45
	mat4 pixelMvp;
46
47
	// Fallback scaler
48
	openmsx::GLScaler& getFallbackScaler();
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
55
private:
56
	std::unique_ptr<openmsx::GLScaler> fallbackScaler;
57
};
58
59
extern std::optional<Context> context;
60
61
} // namespace gl
62
63
#endif