all repos — mgba @ 51a174e4c57ca7a8189ee53b6bc227fe5698442a

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/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 GBAVideoGLBackground {
 33	GLuint fbo;
 34	GLuint tex;
 35
 36	unsigned index;
 37	int enabled;
 38	unsigned priority;
 39	uint32_t charBase;
 40	int mosaic;
 41	int multipalette;
 42	uint32_t screenBase;
 43	int overflow;
 44	int size;
 45	int target1;
 46	int target2;
 47	uint16_t x;
 48	uint16_t y;
 49	int32_t refx;
 50	int32_t refy;
 51	int16_t dx;
 52	int16_t dmx;
 53	int16_t dy;
 54	int16_t dmy;
 55	int32_t sx;
 56	int32_t sy;
 57};
 58
 59struct GBAVideoGLRenderer {
 60	struct GBAVideoRenderer d;
 61
 62	struct GBAVideoGLBackground bg[4];
 63
 64	GLuint fbo[2];
 65	GLuint layers[4];
 66
 67	color_t* outputBuffer;
 68	int outputBufferStride;
 69
 70	GLuint paletteTex;
 71	bool paletteDirty;
 72
 73	GLuint oamTex;
 74	bool oamDirty;
 75
 76	GLuint vramTex;
 77	unsigned vramDirty;
 78
 79	GLuint bgProgram[6];
 80	GLuint objProgram;
 81
 82	GLuint compositeProgram;
 83
 84	GBARegisterDISPCNT dispcnt;
 85
 86	unsigned target1Obj;
 87	unsigned target1Bd;
 88	unsigned target2Obj;
 89	unsigned target2Bd;
 90	enum GBAVideoBlendEffect blendEffect;
 91	uint16_t blda;
 92	uint16_t bldb;
 93	uint16_t bldy;
 94
 95	GBAMosaicControl mosaic;
 96};
 97
 98void GBAVideoGLRendererCreate(struct GBAVideoGLRenderer* renderer);
 99
100CXX_GUARD_END
101
102#endif