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 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 GBAGLES2Uniform {
44 const char* name;
45 GLenum type;
46 union GBAGLES2UniformValue value;
47 GLuint location;
48 union GBAGLES2UniformValue min;
49 union GBAGLES2UniformValue max;
50 const char* readableName;
51};
52
53struct GBAGLES2Shader {
54 unsigned width;
55 unsigned 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 positionLocation;
66
67 struct GBAGLES2Uniform* uniforms;
68 size_t nUniforms;
69};
70
71struct GBAGLES2Context {
72 struct VideoBackend d;
73
74 GLuint tex;
75 GLuint texLocation;
76 GLuint positionLocation;
77
78 struct GBAGLES2Shader initialShader;
79 struct GBAGLES2Shader finalShader;
80
81 struct GBAGLES2Shader* shaders;
82 size_t nShaders;
83};
84
85void GBAGLES2ContextCreate(struct GBAGLES2Context*);
86
87void GBAGLES2ShaderInit(struct GBAGLES2Shader*, const char* vs, const char* fs, int width, int height, bool integerScaling, struct GBAGLES2Uniform* uniforms, size_t nUniforms);
88void GBAGLES2ShaderDeinit(struct GBAGLES2Shader*);
89void GBAGLES2ShaderAttach(struct GBAGLES2Context*, struct GBAGLES2Shader*, size_t nShaders);
90void GBAGLES2ShaderDetach(struct GBAGLES2Context*);
91
92struct VDir;
93bool GBAGLES2ShaderLoad(struct VideoShader*, struct VDir*);
94void GBAGLES2ShaderFree(struct VideoShader*);
95
96#endif