all repos — mgba @ 073dbd6b8df389ea050b31e2398f1e2f82337602

mGBA Game Boy Advance Emulator

src/platform/sdl/main.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 SDL_MAIN_H
 7#define SDL_MAIN_H
 8
 9#include "gba/renderers/video-software.h"
10
11#include "sdl-audio.h"
12#include "sdl-events.h"
13
14#ifdef BUILD_GL
15#ifdef __APPLE__
16#include <OpenGL/gl.h>
17#else
18#include <GL/gl.h>
19#endif
20#endif
21
22#ifdef BUILD_RASPI
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wunused-function"
25#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
26#include <SDL/SDL.h>
27#include <GLES2/gl2.h>
28#include <EGL/egl.h>
29
30#include <bcm_host.h>
31#pragma GCC diagnostic pop
32#endif
33
34#ifdef USE_PIXMAN
35#include <pixman.h>
36#endif
37
38struct SDLSoftwareRenderer {
39	struct GBAVideoSoftwareRenderer d;
40	struct GBASDLAudio audio;
41	struct GBASDLEvents events;
42
43#if SDL_VERSION_ATLEAST(2, 0, 0)
44	SDL_Window* window;
45#ifndef BUILD_GL
46	SDL_Texture* tex;
47	SDL_Renderer* sdlRenderer;
48#endif
49#endif
50
51	int viewportWidth;
52	int viewportHeight;
53	int ratio;
54
55	bool lockAspectRatio;
56	bool filter;
57
58#ifdef BUILD_GL
59	GLuint tex;
60#endif
61
62#ifdef USE_PIXMAN
63	pixman_image_t* pix;
64	pixman_image_t* screenpix;
65#endif
66
67#ifdef BUILD_RASPI
68	EGLDisplay display;
69	EGLSurface surface;
70	EGLContext context;
71	EGL_DISPMANX_WINDOW_T window;
72	GLuint tex;
73	GLuint fragmentShader;
74	GLuint vertexShader;
75	GLuint program;
76	GLuint bufferObject;
77	GLuint texLocation;
78	GLuint positionLocation;
79#endif
80
81#ifdef BUILD_PANDORA
82	int fb;
83	int odd;
84	void* base[2];
85#endif
86};
87
88bool GBASDLInit(struct SDLSoftwareRenderer* renderer);
89void GBASDLDeinit(struct SDLSoftwareRenderer* renderer);
90void GBASDLRunloop(struct GBAThread* context, struct SDLSoftwareRenderer* renderer);
91
92#endif
93