all repos — mgba @ 147852898c8c1c8b50970ea8033583c4603f9702

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#else
53	bool fullscreen;
54#endif
55
56	int viewportWidth;
57	int viewportHeight;
58	int ratio;
59
60	bool lockAspectRatio;
61	bool filter;
62
63#ifdef BUILD_GL
64	struct GBAGLContext gl;
65#elif BUILD_GLES2
66	struct GBAGLES2Context gl;
67#endif
68
69#ifdef USE_PIXMAN
70	pixman_image_t* pix;
71	pixman_image_t* screenpix;
72#endif
73
74#ifdef BUILD_RASPI
75	EGLDisplay display;
76	EGLSurface surface;
77	EGLContext context;
78	EGL_DISPMANX_WINDOW_T window;
79#endif
80
81#ifdef BUILD_PANDORA
82	int fb;
83	int odd;
84	void* base[2];
85#endif
86};
87
88void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer);
89
90#ifdef BUILD_GL
91void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer);
92#endif
93
94#ifdef BUILD_GLES2
95void GBASDLGLES2Create(struct SDLSoftwareRenderer* renderer);
96#endif
97#endif