all repos — mgba @ d68bf5bd1a483c83a9fe30c8d5a0d6adab2286b5

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#include <mgba-util/common.h>
 10
 11CXX_GUARD_START
 12
 13#ifdef USE_EPOXY
 14#include <epoxy/gl.h>
 15#elif defined(BUILD_GL)
 16#ifdef __APPLE__
 17#include <OpenGL/gl3.h>
 18#else
 19#define GL_GLEXT_PROTOTYPES
 20#include <GL/gl.h>
 21#include <GL/glext.h>
 22#endif
 23#else
 24#include <GLES2/gl2.h>
 25#ifdef BUILD_GLES3
 26#include <GLES3/gl3.h>
 27#endif
 28#endif
 29
 30#include "platform/video-backend.h"
 31
 32union mGLES2UniformValue {
 33	GLfloat f;
 34	GLint i;
 35	GLboolean b;
 36	GLfloat fvec2[2];
 37	GLfloat fvec3[3];
 38	GLfloat fvec4[4];
 39	GLint ivec2[2];
 40	GLint ivec3[3];
 41	GLint ivec4[4];
 42	GLboolean bvec2[2];
 43	GLboolean bvec3[3];
 44	GLboolean bvec4[4];
 45	GLfloat fmat2x2[4];
 46	GLfloat fmat3x3[9];
 47	GLfloat fmat4x4[16];
 48};
 49
 50struct mGLES2Uniform {
 51	const char* name;
 52	GLenum type;
 53	union mGLES2UniformValue value;
 54	GLuint location;
 55	union mGLES2UniformValue min;
 56	union mGLES2UniformValue max;
 57	const char* readableName;
 58};
 59
 60struct mGLES2Shader {
 61	int width;
 62	int height;
 63	bool integerScaling;
 64	bool filter;
 65	bool blend;
 66	bool dirty;
 67	GLuint tex;
 68	GLuint fbo;
 69	GLuint vao;
 70	GLuint fragmentShader;
 71	GLuint vertexShader;
 72	GLuint program;
 73	GLuint texLocation;
 74	GLuint texSizeLocation;
 75	GLuint positionLocation;
 76
 77	struct mGLES2Uniform* uniforms;
 78	size_t nUniforms;
 79};
 80
 81struct mGLES2Context {
 82	struct VideoBackend d;
 83
 84	GLuint tex;
 85	GLuint vbo;
 86
 87	struct mGLES2Shader initialShader;
 88	struct mGLES2Shader finalShader;
 89	struct mGLES2Shader interframeShader;
 90
 91	struct mGLES2Shader* shaders;
 92	size_t nShaders;
 93};
 94
 95void mGLES2ContextCreate(struct mGLES2Context*);
 96
 97void mGLES2ShaderInit(struct mGLES2Shader*, const char* vs, const char* fs, int width, int height, bool integerScaling, struct mGLES2Uniform* uniforms, size_t nUniforms);
 98void mGLES2ShaderDeinit(struct mGLES2Shader*);
 99void mGLES2ShaderAttach(struct mGLES2Context*, struct mGLES2Shader*, size_t nShaders);
100void mGLES2ShaderDetach(struct mGLES2Context*);
101
102struct VDir;
103bool mGLES2ShaderLoad(struct VideoShader*, struct VDir*);
104void mGLES2ShaderFree(struct VideoShader*);
105
106CXX_GUARD_END
107
108#endif