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/video.h>
17
18#ifdef USE_EPOXY
19#include <epoxy/gl.h>
20#elif defined(BUILD_GL)
21#ifdef __APPLE__
22#include <OpenGL/gl3.h>
23#else
24#define GL_GLEXT_PROTOTYPES
25#include <GL/gl.h>
26#include <GL/glext.h>
27#endif
28#else
29#include <GLES2/gl2.h>
30#endif
31
32struct GBAVideoGLAffine {
33 int16_t dx;
34 int16_t dmx;
35 int16_t dy;
36 int16_t dmy;
37 int32_t sx;
38 int32_t sy;
39};
40
41struct GBAVideoGLBackground {
42 GLuint fbo;
43 GLuint tex;
44
45 unsigned index;
46 int enabled;
47 unsigned priority;
48 uint32_t charBase;
49 int mosaic;
50 int multipalette;
51 uint32_t screenBase;
52 int overflow;
53 int size;
54 int target1;
55 int target2;
56 uint16_t x;
57 uint16_t y;
58 int32_t refx;
59 int32_t refy;
60
61 struct GBAVideoGLAffine affine[2];
62};
63
64struct GBAVideoGLRenderer {
65 struct GBAVideoRenderer d;
66
67 struct GBAVideoGLBackground bg[4];
68
69 GLuint fbo[2];
70 GLuint layers[3];
71
72 GLuint outputTex;
73
74 GLuint paletteTex;
75 bool paletteDirty;
76
77 GLuint oamTex;
78 bool oamDirty;
79
80 GLuint vramTex;
81 unsigned vramDirty;
82
83 GLuint bgProgram[6];
84 GLuint objProgram;
85
86 GLuint compositeProgram;
87
88 GBARegisterDISPCNT dispcnt;
89
90 unsigned target1Obj;
91 unsigned target1Bd;
92 unsigned target2Obj;
93 unsigned target2Bd;
94 enum GBAVideoBlendEffect blendEffect;
95 uint16_t blda;
96 uint16_t bldb;
97 uint16_t bldy;
98
99 GBAMosaicControl mosaic;
100
101 int scale;
102};
103
104void GBAVideoGLRendererCreate(struct GBAVideoGLRenderer* renderer);
105
106CXX_GUARD_END
107
108#endif