all repos — mgba @ d242638e28fe899406068e11681b002256708d46

mGBA Game Boy Advance Emulator

src/platform/opengl/gles2.h (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef GLES2_H
 7#define GLES2_H
 8
 9#ifdef USE_EPOXY
10#include <epoxy/gl.h>
11#elif defined(BUILD_GL)
12#ifdef __APPLE__
13#include <OpenGL/gl3.h>
14#else
15#define GL_GLEXT_PROTOTYPES
16#include <GL/gl.h>
17#include <GL/glext.h>
18#endif
19#else
20#include <GLES2/gl2.h>
21#endif
22
23#include "platform/video-backend.h"
24
25union mGLES2UniformValue {
26	GLfloat f;
27	GLint i;
28	GLboolean b;
29	GLfloat fvec2[2];
30	GLfloat fvec3[3];
31	GLfloat fvec4[4];
32	GLint ivec2[2];
33	GLint ivec3[3];
34	GLint ivec4[4];
35	GLboolean bvec2[2];
36	GLboolean bvec3[3];
37	GLboolean bvec4[4];
38	GLfloat fmat2x2[4];
39	GLfloat fmat3x3[9];
40	GLfloat fmat4x4[16];
41};
42
43struct mGLES2Uniform {
44	const char* name;
45	GLenum type;
46	union mGLES2UniformValue value;
47	GLuint location;
48	union mGLES2UniformValue min;
49	union mGLES2UniformValue max;
50	const char* readableName;
51};
52
53struct mGLES2Shader {
54	int width;
55	int height;
56	bool integerScaling;
57	bool filter;
58	bool blend;
59	GLuint tex;
60	GLuint fbo;
61	GLuint fragmentShader;
62	GLuint vertexShader;
63	GLuint program;
64	GLuint texLocation;
65	GLuint texSizeLocation;
66	GLuint positionLocation;
67
68	struct mGLES2Uniform* uniforms;
69	size_t nUniforms;
70};
71
72struct mGLES2Context {
73	struct VideoBackend d;
74
75	GLuint tex;
76	GLuint texLocation;
77	GLuint positionLocation;
78
79	struct mGLES2Shader initialShader;
80	struct mGLES2Shader finalShader;
81
82	struct mGLES2Shader* shaders;
83	size_t nShaders;
84};
85
86void mGLES2ContextCreate(struct mGLES2Context*);
87
88void mGLES2ShaderInit(struct mGLES2Shader*, const char* vs, const char* fs, int width, int height, bool integerScaling, struct mGLES2Uniform* uniforms, size_t nUniforms);
89void mGLES2ShaderDeinit(struct mGLES2Shader*);
90void mGLES2ShaderAttach(struct mGLES2Context*, struct mGLES2Shader*, size_t nShaders);
91void mGLES2ShaderDetach(struct mGLES2Context*);
92
93struct VDir;
94bool mGLES2ShaderLoad(struct VideoShader*, struct VDir*);
95void mGLES2ShaderFree(struct VideoShader*);
96
97#endif