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