all repos — mgba @ d4ef56cd16bf35a47dfcd26d52fbd0b1909c163c

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	struct GBASDLPlayer player;
43
44#if SDL_VERSION_ATLEAST(2, 0, 0)
45	SDL_Window* window;
46#ifndef BUILD_GL
47	SDL_Texture* tex;
48	SDL_Renderer* sdlRenderer;
49#endif
50#endif
51
52	int viewportWidth;
53	int viewportHeight;
54	int ratio;
55
56	bool lockAspectRatio;
57	bool filter;
58
59#ifdef BUILD_GL
60	GLuint tex;
61#endif
62
63#ifdef USE_PIXMAN
64	pixman_image_t* pix;
65	pixman_image_t* screenpix;
66#endif
67
68#ifdef BUILD_RASPI
69	EGLDisplay display;
70	EGLSurface surface;
71	EGLContext context;
72	EGL_DISPMANX_WINDOW_T window;
73	GLuint tex;
74	GLuint fragmentShader;
75	GLuint vertexShader;
76	GLuint program;
77	GLuint bufferObject;
78	GLuint texLocation;
79	GLuint positionLocation;
80#endif
81
82#ifdef BUILD_PANDORA
83	int fb;
84	int odd;
85	void* base[2];
86#endif
87};
88
89bool GBASDLInit(struct SDLSoftwareRenderer* renderer);
90void GBASDLDeinit(struct SDLSoftwareRenderer* renderer);
91void GBASDLRunloop(struct GBAThread* context, struct SDLSoftwareRenderer* renderer);
92
93#endif
94