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 "gba/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 bool lockAspectRatio;
52 bool filter;
53
54#ifdef BUILD_GL
55 GLuint tex;
56#endif
57
58#ifdef BUILD_RASPI
59 EGLDisplay display;
60 EGLSurface surface;
61 EGLContext context;
62 EGL_DISPMANX_WINDOW_T window;
63 GLuint tex;
64 GLuint fragmentShader;
65 GLuint vertexShader;
66 GLuint program;
67 GLuint bufferObject;
68 GLuint texLocation;
69 GLuint positionLocation;
70#endif
71};
72
73bool GBASDLInit(struct SDLSoftwareRenderer* renderer);
74void GBASDLDeinit(struct SDLSoftwareRenderer* renderer);
75void GBASDLRunloop(struct GBAThread* context, struct SDLSoftwareRenderer* renderer);
76
77#endif
78