2019-05-17 14:00:34 -07:00

123 lines
2.0 KiB
C

/* Copyright (c) 2013-2019 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef VIDEO_GL_H
#define VIDEO_GL_H
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/core/core.h>
#include <mgba/gba/interface.h>
#include <mgba/internal/gba/io.h>
#include <mgba/internal/gba/renderers/common.h>
#include <mgba/internal/gba/video.h>
#ifdef USE_EPOXY
#include <epoxy/gl.h>
#elif defined(BUILD_GL)
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#else
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#else
#include <GLES2/gl2.h>
#endif
struct GBAVideoGLAffine {
int16_t dx;
int16_t dmx;
int16_t dy;
int16_t dmy;
int32_t sx;
int32_t sy;
};
struct GBAVideoGLBackground {
GLuint fbo;
GLuint tex;
unsigned index;
int enabled;
unsigned priority;
uint32_t charBase;
int mosaic;
int multipalette;
uint32_t screenBase;
int overflow;
int size;
int target1;
int target2;
uint16_t x;
uint16_t y;
int32_t refx;
int32_t refy;
struct GBAVideoGLAffine affine[4];
};
enum {
GBA_GL_FBO_OBJ = 0,
GBA_GL_FBO_COMPOSITE = 1,
GBA_GL_TEX_OBJ_COLOR = 0,
GBA_GL_TEX_OBJ_FLAGS = 1,
GBA_GL_TEX_COMPOSITE_FLAGS = 2,
};
struct GBAVideoGLRenderer {
struct GBAVideoRenderer d;
struct GBAVideoGLBackground bg[4];
int oamMax;
struct GBAVideoRendererSprite sprites[128];
GLuint fbo[2];
GLuint layers[3];
GLuint outputTex;
GLuint paletteTex;
bool paletteDirty;
GLuint oamTex;
bool oamDirty;
GLuint vramTex;
unsigned vramDirty;
GLuint bgProgram[6];
GLuint objProgram[4];
GLuint compositeProgram;
GBARegisterDISPCNT dispcnt;
unsigned target1Obj;
unsigned target1Bd;
unsigned target2Obj;
unsigned target2Bd;
enum GBAVideoBlendEffect blendEffect;
uint16_t blda;
uint16_t bldb;
uint16_t bldy;
GBAMosaicControl mosaic;
int firstAffine;
int scale;
};
void GBAVideoGLRendererCreate(struct GBAVideoGLRenderer* renderer);
CXX_GUARD_END
#endif