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 <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include "sdl-audio.h"
14#include "sdl-events.h"
15
16#ifdef BUILD_GL
17#include "platform/opengl/gl.h"
18#endif
19
20#ifdef BUILD_RASPI
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wunused-function"
23#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
24#include <SDL/SDL.h>
25#include <EGL/egl.h>
26
27#include <bcm_host.h>
28#pragma GCC diagnostic pop
29#endif
30
31#if defined(BUILD_GLES2) || defined(USE_EPOXY)
32#include "platform/opengl/gles2.h"
33#endif
34
35#ifdef USE_PIXMAN
36#include <pixman.h>
37#endif
38
39struct mCore;
40struct mSDLRenderer {
41 struct mCore* core;
42 color_t* outputBuffer;
43
44 struct mSDLAudio audio;
45 struct mSDLEvents events;
46 struct mSDLPlayer player;
47
48 bool (*init)(struct mSDLRenderer* renderer);
49 void (*runloop)(struct mSDLRenderer* renderer, void* user);
50 void (*deinit)(struct mSDLRenderer* renderer);
51
52#if SDL_VERSION_ATLEAST(2, 0, 0)
53 SDL_Window* window;
54 SDL_Texture* sdlTex;
55 SDL_Renderer* sdlRenderer;
56 SDL_GLContext* glCtx;
57#endif
58
59 unsigned width;
60 unsigned height;
61 int viewportWidth;
62 int viewportHeight;
63 int ratio;
64
65 bool lockAspectRatio;
66 bool lockIntegerScaling;
67 bool filter;
68
69#ifdef BUILD_GL
70 struct mGLContext gl;
71#endif
72#if defined(BUILD_GLES2) || defined(USE_EPOXY)
73 struct mGLES2Context gl2;
74#endif
75
76#ifdef USE_PIXMAN
77 pixman_image_t* pix;
78 pixman_image_t* screenpix;
79#endif
80
81#ifdef BUILD_RASPI
82 EGLDisplay eglDisplay;
83 EGLSurface eglSurface;
84 EGLContext eglContext;
85 EGL_DISPMANX_WINDOW_T eglWindow;
86#endif
87
88#ifdef BUILD_PANDORA
89 int fb;
90 int odd;
91 void* base[2];
92#endif
93};
94
95void mSDLSWCreate(struct mSDLRenderer* renderer);
96
97#ifdef BUILD_GL
98void mSDLGLCreate(struct mSDLRenderer* renderer);
99#endif
100
101#if defined(BUILD_GLES2) || defined(USE_EPOXY)
102void mSDLGLES2Create(struct mSDLRenderer* renderer);
103#endif
104
105CXX_GUARD_END
106
107#endif