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#elif BUILD_GLES2
64 struct GBAGLES2Context gl;
65#endif
66
67#ifdef USE_PIXMAN
68 pixman_image_t* pix;
69 pixman_image_t* screenpix;
70#endif
71
72#ifdef BUILD_RASPI
73 EGLDisplay display;
74 EGLSurface surface;
75 EGLContext context;
76 EGL_DISPMANX_WINDOW_T window;
77#endif
78
79#ifdef BUILD_PANDORA
80 int fb;
81 int odd;
82 void* base[2];
83#endif
84};
85
86void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer);
87
88#ifdef BUILD_GL
89void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer);
90#endif
91
92#ifdef BUILD_GLES2
93void GBASDLGLES2Create(struct SDLSoftwareRenderer* renderer);
94#endif
95#endif