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