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 filter;
57 bool blend;
58 GLuint tex;
59 GLuint fbo;
60 GLuint fragmentShader;
61 GLuint vertexShader;
62 GLuint program;
63 GLuint texLocation;
64 GLuint positionLocation;
65
66 struct GBAGLES2Uniform* uniforms;
67 size_t nUniforms;
68};
69
70struct GBAGLES2Context {
71 struct VideoBackend d;
72
73 GLuint tex;
74 GLuint texLocation;
75 GLuint positionLocation;
76
77 struct GBAGLES2Shader initialShader;
78 struct GBAGLES2Shader finalShader;
79
80 struct GBAGLES2Shader* shaders;
81 size_t nShaders;
82};
83
84void GBAGLES2ContextCreate(struct GBAGLES2Context*);
85
86void GBAGLES2ShaderInit(struct GBAGLES2Shader*, const char* vs, const char* fs, int width, int height, struct GBAGLES2Uniform* uniforms, size_t nUniforms);
87void GBAGLES2ShaderDeinit(struct GBAGLES2Shader*);
88void GBAGLES2ShaderAttach(struct GBAGLES2Context*, struct GBAGLES2Shader*, size_t nShaders);
89void GBAGLES2ShaderDetach(struct GBAGLES2Context*);
90
91struct VDir;
92bool GBAGLES2ShaderLoad(struct VideoShader*, struct VDir*);
93void GBAGLES2ShaderFree(struct VideoShader*);
94
95#endif