all repos — mgba @ 13fbf3e6e36bfc345093b8084ffead856f1fa3e0

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#include "platform/opengl/gl.h"
16#endif
17
18#ifdef BUILD_RASPI
19#pragma GCC diagnostic push
20#pragma GCC diagnostic ignored "-Wunused-function"
21#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
22#include <SDL/SDL.h>
23#include <EGL/egl.h>
24
25#include <bcm_host.h>
26#pragma GCC diagnostic pop
27#endif
28
29#ifdef BUILD_GLES2
30#include "platform/opengl/gles2.h"
31#endif
32
33#ifdef USE_PIXMAN
34#include <pixman.h>
35#endif
36
37struct SDLSoftwareRenderer {
38	struct GBAVideoSoftwareRenderer d;
39	struct GBASDLAudio audio;
40	struct GBASDLEvents events;
41	struct GBASDLPlayer player;
42
43	bool (*init)(struct SDLSoftwareRenderer* renderer);
44	void (*runloop)(struct GBAThread* context, struct SDLSoftwareRenderer* renderer);
45	void (*deinit)(struct SDLSoftwareRenderer* renderer);
46
47#if SDL_VERSION_ATLEAST(2, 0, 0)
48	SDL_Window* window;
49	SDL_Texture* sdlTex;
50	SDL_Renderer* sdlRenderer;
51	SDL_GLContext* glCtx;
52#endif
53
54	int viewportWidth;
55	int viewportHeight;
56	int ratio;
57
58	bool lockAspectRatio;
59	bool filter;
60
61#ifdef BUILD_GL
62	struct GBAGLContext gl;
63#endif
64
65#ifdef USE_PIXMAN
66	pixman_image_t* pix;
67	pixman_image_t* screenpix;
68#endif
69
70#ifdef BUILD_RASPI
71	EGLDisplay display;
72	EGLSurface surface;
73	EGLContext context;
74	EGL_DISPMANX_WINDOW_T window;
75	struct GBAGLES2Context gl;
76#endif
77
78#ifdef BUILD_PANDORA
79	int fb;
80	int odd;
81	void* base[2];
82#endif
83};
84
85void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer);
86
87#ifdef BUILD_GL
88void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer);
89#endif
90
91#ifdef BUILD_GLES2
92void GBASDLGLES2Create(struct SDLSoftwareRenderer* renderer);
93#endif
94#endif