src/platform/sdl/main.h (view raw)
1/* Copyright (c) 2013-2014 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 "renderers/video-software.h"
10
11#include "sdl-audio.h"
12#include "sdl-events.h"
13
14#ifdef BUILD_GL
15#ifdef __APPLE__
16#include <OpenGL/gl.h>
17#else
18#include <GL/gl.h>
19#endif
20#endif
21
22#ifdef BUILD_RASPI
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wunused-function"
25#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
26#include <SDL/SDL.h>
27#include <GLES2/gl2.h>
28#include <EGL/egl.h>
29
30#include <bcm_host.h>
31#pragma GCC diagnostic pop
32#endif
33
34struct SDLSoftwareRenderer {
35 struct GBAVideoSoftwareRenderer d;
36 struct GBASDLAudio audio;
37 struct GBASDLEvents events;
38
39#if SDL_VERSION_ATLEAST(2, 0, 0)
40 SDL_Window* window;
41#ifndef BUILD_GL
42 SDL_Texture* tex;
43 SDL_Renderer* sdlRenderer;
44#endif
45#endif
46
47 int viewportWidth;
48 int viewportHeight;
49 int ratio;
50
51#ifdef BUILD_GL
52 GLuint tex;
53#endif
54
55#ifdef BUILD_RASPI
56 EGLDisplay display;
57 EGLSurface surface;
58 EGLContext context;
59 EGL_DISPMANX_WINDOW_T window;
60 GLuint tex;
61 GLuint fragmentShader;
62 GLuint vertexShader;
63 GLuint program;
64 GLuint bufferObject;
65 GLuint texLocation;
66 GLuint positionLocation;
67#endif
68};
69
70bool GBASDLInit(struct SDLSoftwareRenderer* renderer);
71void GBASDLDeinit(struct SDLSoftwareRenderer* renderer);
72void GBASDLRunloop(struct GBAThread* context, struct SDLSoftwareRenderer* renderer);
73
74#endif
75