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 mSDLRenderer {
44 union {
45#ifdef M_CORE_GBA
46 struct GBAVideoSoftwareRenderer d;
47#endif
48#ifdef M_CORE_GB
49 struct GBVideoSoftwareRenderer gb;
50#endif
51 };
52 struct GBASDLAudio audio;
53 struct GBASDLEvents events;
54 struct GBASDLPlayer player;
55
56 bool (*init)(struct mSDLRenderer* renderer);
57 void (*runloop)(struct mSDLRenderer* renderer, void* user);
58 void (*deinit)(struct mSDLRenderer* renderer);
59
60#if SDL_VERSION_ATLEAST(2, 0, 0)
61 SDL_Window* window;
62 SDL_Texture* sdlTex;
63 SDL_Renderer* sdlRenderer;
64 SDL_GLContext* glCtx;
65#else
66 bool fullscreen;
67#endif
68
69 int viewportWidth;
70 int viewportHeight;
71 int ratio;
72
73 bool lockAspectRatio;
74 bool filter;
75
76#ifdef BUILD_GL
77 struct GBAGLContext gl;
78#endif
79#if defined(BUILD_GLES2) || defined(USE_EPOXY)
80 struct GBAGLES2Context gl2;
81#endif
82
83#ifdef USE_PIXMAN
84 pixman_image_t* pix;
85 pixman_image_t* screenpix;
86#endif
87
88#ifdef BUILD_RASPI
89 EGLDisplay display;
90 EGLSurface surface;
91 EGLContext context;
92 EGL_DISPMANX_WINDOW_T window;
93#endif
94
95#ifdef BUILD_PANDORA
96 int fb;
97 int odd;
98 void* base[2];
99#endif
100};
101
102void mSDLSWCreate(struct mSDLRenderer* renderer);
103
104#ifdef BUILD_GL
105void mSDLGLCreate(struct mSDLRenderer* renderer);
106void mSDLGLCreateGB(struct mSDLRenderer* renderer);
107#endif
108
109#if defined(BUILD_GLES2) || defined(USE_EPOXY)
110void mSDLGLES2Create(struct mSDLRenderer* renderer);
111#endif
112#endif