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