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#else
58 bool fullscreen;
59#endif
60
61 unsigned width;
62 unsigned height;
63 int viewportWidth;
64 int viewportHeight;
65 int ratio;
66
67 bool lockAspectRatio;
68 bool lockIntegerScaling;
69 bool filter;
70
71#ifdef BUILD_GL
72 struct mGLContext gl;
73#endif
74#if defined(BUILD_GLES2) || defined(USE_EPOXY)
75 struct mGLES2Context gl2;
76#endif
77
78#ifdef USE_PIXMAN
79 pixman_image_t* pix;
80 pixman_image_t* screenpix;
81#endif
82
83#ifdef BUILD_RASPI
84 EGLDisplay eglDisplay;
85 EGLSurface eglSurface;
86 EGLContext eglContext;
87 EGL_DISPMANX_WINDOW_T eglWindow;
88#endif
89
90#ifdef BUILD_PANDORA
91 int fb;
92 int odd;
93 void* base[2];
94#endif
95};
96
97void mSDLSWCreate(struct mSDLRenderer* renderer);
98
99#ifdef BUILD_GL
100void mSDLGLCreate(struct mSDLRenderer* renderer);
101#endif
102
103#if defined(BUILD_GLES2) || defined(USE_EPOXY)
104void mSDLGLES2Create(struct mSDLRenderer* renderer);
105#endif
106
107CXX_GUARD_END
108
109#endif