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 "util/common.h"
10
11CXX_GUARD_START
12
13#ifdef M_CORE_GBA
14#include "gba/renderers/video-software.h"
15#endif
16
17#ifdef M_CORE_GB
18#include "gb/renderers/software.h"
19#endif
20
21#include "sdl-audio.h"
22#include "sdl-events.h"
23
24#ifdef BUILD_GL
25#include "platform/opengl/gl.h"
26#endif
27
28#ifdef BUILD_RASPI
29#pragma GCC diagnostic push
30#pragma GCC diagnostic ignored "-Wunused-function"
31#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
32#include <SDL/SDL.h>
33#include <EGL/egl.h>
34
35#include <bcm_host.h>
36#pragma GCC diagnostic pop
37#endif
38
39#if defined(BUILD_GLES2) || defined(USE_EPOXY)
40#include "platform/opengl/gles2.h"
41#endif
42
43#ifdef USE_PIXMAN
44#include <pixman.h>
45#endif
46
47struct mCore;
48struct mSDLRenderer {
49 struct mCore* core;
50 color_t* outputBuffer;
51
52 struct mSDLAudio audio;
53 struct mSDLEvents events;
54 struct mSDLPlayer 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 unsigned width;
70 unsigned height;
71 int viewportWidth;
72 int viewportHeight;
73 int ratio;
74
75 bool lockAspectRatio;
76 bool filter;
77
78#ifdef BUILD_GL
79 struct mGLContext gl;
80#endif
81#if defined(BUILD_GLES2) || defined(USE_EPOXY)
82 struct mGLES2Context gl2;
83#endif
84
85#ifdef USE_PIXMAN
86 pixman_image_t* pix;
87 pixman_image_t* screenpix;
88#endif
89
90#ifdef BUILD_RASPI
91 EGLDisplay display;
92 EGLSurface surface;
93 EGLContext context;
94 EGL_DISPMANX_WINDOW_T window;
95#endif
96
97#ifdef BUILD_PANDORA
98 int fb;
99 int odd;
100 void* base[2];
101#endif
102};
103
104void mSDLSWCreate(struct mSDLRenderer* renderer);
105
106#ifdef BUILD_GL
107void mSDLGLCreate(struct mSDLRenderer* renderer);
108#endif
109
110#if defined(BUILD_GLES2) || defined(USE_EPOXY)
111void mSDLGLES2Create(struct mSDLRenderer* renderer);
112#endif
113
114CXX_GUARD_END
115
116#endif