all repos — mgba @ 509c80abad8221564a0bfade571d868e9e8247af

mGBA Game Boy Advance Emulator

include/mgba/internal/gba/renderers/gl.h (view raw)

  1/* Copyright (c) 2013-2019 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 VIDEO_GL_H
  7#define VIDEO_GL_H
  8
  9#include <mgba-util/common.h>
 10
 11CXX_GUARD_START
 12
 13#include <mgba/core/core.h>
 14#include <mgba/gba/interface.h>
 15#include <mgba/internal/gba/io.h>
 16#include <mgba/internal/gba/renderers/common.h>
 17#include <mgba/internal/gba/video.h>
 18
 19#ifdef USE_EPOXY
 20#include <epoxy/gl.h>
 21#elif defined(BUILD_GL)
 22#ifdef __APPLE__
 23#include <OpenGL/gl3.h>
 24#else
 25#define GL_GLEXT_PROTOTYPES
 26#include <GL/gl.h>
 27#include <GL/glext.h>
 28#endif
 29#else
 30#include <GLES2/gl2.h>
 31#endif
 32
 33struct GBAVideoGLAffine {
 34	int16_t dx;
 35	int16_t dmx;
 36	int16_t dy;
 37	int16_t dmy;
 38	int32_t sx;
 39	int32_t sy;
 40};
 41
 42struct GBAVideoGLBackground {
 43	GLuint fbo;
 44	GLuint tex;
 45	GLuint flags;
 46
 47	unsigned index;
 48	int enabled;
 49	unsigned priority;
 50	uint32_t charBase;
 51	int mosaic;
 52	int multipalette;
 53	uint32_t screenBase;
 54	int overflow;
 55	int size;
 56	int target1;
 57	int target2;
 58	uint16_t x;
 59	uint16_t y;
 60	int32_t refx;
 61	int32_t refy;
 62
 63	struct GBAVideoGLAffine affine[4];
 64};
 65
 66enum {
 67	GBA_GL_FBO_OBJ = 0,
 68	GBA_GL_FBO_COMPOSITE = 1,
 69
 70	GBA_GL_TEX_OBJ_COLOR = 0,
 71	GBA_GL_TEX_OBJ_FLAGS = 1,
 72	GBA_GL_TEX_COMPOSITE_FLAGS = 2,
 73};
 74
 75struct GBAVideoGLRenderer {
 76	struct GBAVideoRenderer d;
 77
 78	struct GBAVideoGLBackground bg[4];
 79
 80	int oamMax;
 81	struct GBAVideoRendererSprite sprites[128];
 82
 83	GLuint fbo[2];
 84	GLuint layers[3];
 85
 86	GLuint outputTex;
 87
 88	GLuint paletteTex;
 89	bool paletteDirty;
 90
 91	GLuint oamTex;
 92	bool oamDirty;
 93
 94	GLuint vramTex;
 95	unsigned vramDirty;
 96
 97	GLuint bgProgram[6];
 98	GLuint objProgram[2];
 99
100	GLuint compositeProgram;
101
102	GBARegisterDISPCNT dispcnt;
103
104	unsigned target1Obj;
105	unsigned target1Bd;
106	unsigned target2Obj;
107	unsigned target2Bd;
108	enum GBAVideoBlendEffect blendEffect;
109	uint16_t blda;
110	uint16_t bldb;
111	uint16_t bldy;
112
113	GBAMosaicControl mosaic;
114
115	int firstAffine;
116
117	int scale;
118};
119
120void GBAVideoGLRendererCreate(struct GBAVideoGLRenderer* renderer);
121
122CXX_GUARD_END
123
124#endif