all repos — mgba @ ac02bd4dbb7de277ccf5f5efe1ceaa61462ec210

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 GBAGLES2UniformValue {
26	GLfloat f;
27	GLint i;
28	GLuint ui;
29	GLboolean b;
30	GLfloat fvec2[2];
31	GLfloat fvec3[3];
32	GLfloat fvec4[4];
33	GLint ivec2[2];
34	GLint ivec3[3];
35	GLint ivec4[4];
36	GLboolean bvec2[2];
37	GLboolean bvec3[3];
38	GLboolean bvec4[4];
39	GLfloat fmat2x2[4];
40	GLfloat fmat3x3[9];
41	GLfloat fmat4x4[16];
42};
43
44struct GBAGLES2Uniform {
45	const char* name;
46	GLenum type;
47	union GBAGLES2UniformValue value;
48	GLuint location;
49};
50
51struct GBAGLES2Shader {
52	unsigned width;
53	unsigned height;
54	bool filter;
55	bool blend;
56	GLuint tex;
57	GLuint fbo;
58	GLuint fragmentShader;
59	GLuint vertexShader;
60	GLuint program;
61	GLuint texLocation;
62	GLuint positionLocation;
63
64	struct GBAGLES2Uniform* uniforms;
65	size_t nUniforms;
66};
67
68struct GBAGLES2Context {
69	struct VideoBackend d;
70
71	GLuint tex;
72	GLuint texLocation;
73	GLuint positionLocation;
74
75	struct GBAGLES2Shader initialShader;
76	struct GBAGLES2Shader finalShader;
77
78	struct GBAGLES2Shader* shaders;
79	size_t nShaders;
80};
81
82struct GBAGLES2ShaderMetadata {
83	const char* name;
84	const char* author;
85	const char* description;
86};
87
88void GBAGLES2ContextCreate(struct GBAGLES2Context*);
89
90void GBAGLES2ShaderInit(struct GBAGLES2Shader*, const char* vs, const char* fs, int width, int height, struct GBAGLES2Uniform* uniforms, size_t nUniforms);
91void GBAGLES2ShaderDeinit(struct GBAGLES2Shader*);
92void GBAGLES2ShaderAttach(struct GBAGLES2Context*, struct GBAGLES2Shader*, size_t nShaders);
93void GBAGLES2ShaderDetach(struct GBAGLES2Context*);
94
95struct VDir;
96bool GBAGLES2ShaderLoad(struct GBAGLES2Shader**, size_t* nShaders, struct GBAGLES2ShaderMetadata*, struct VDir*);
97void GBAGLES2ShaderFree(struct GBAGLES2Shader*, size_t nShaders);
98
99#endif