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