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#include "platform/opengl/gl.h"
16#endif
17
18#ifdef BUILD_RASPI
19#pragma GCC diagnostic push
20#pragma GCC diagnostic ignored "-Wunused-function"
21#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
22#include <SDL/SDL.h>
23#include <GLES2/gl2.h>
24#include <EGL/egl.h>
25
26#include <bcm_host.h>
27#pragma GCC diagnostic pop
28#endif
29
30#ifdef USE_PIXMAN
31#include <pixman.h>
32#endif
33
34struct SDLSoftwareRenderer {
35 struct GBAVideoSoftwareRenderer d;
36 struct GBASDLAudio audio;
37 struct GBASDLEvents events;
38 struct GBASDLPlayer player;
39
40 bool (*init)(struct SDLSoftwareRenderer* renderer);
41 void (*runloop)(struct GBAThread* context, struct SDLSoftwareRenderer* renderer);
42 void (*deinit)(struct SDLSoftwareRenderer* renderer);
43
44#if SDL_VERSION_ATLEAST(2, 0, 0)
45 SDL_Window* window;
46 SDL_Texture* sdlTex;
47 SDL_Renderer* sdlRenderer;
48#endif
49
50 int viewportWidth;
51 int viewportHeight;
52 int ratio;
53
54 bool lockAspectRatio;
55 bool filter;
56
57#ifdef BUILD_GL
58 struct GBAGLContext gl;
59#endif
60
61#ifdef USE_PIXMAN
62 pixman_image_t* pix;
63 pixman_image_t* screenpix;
64#endif
65
66#ifdef BUILD_RASPI
67 EGLDisplay display;
68 EGLSurface surface;
69 EGLContext context;
70 EGL_DISPMANX_WINDOW_T window;
71 GLuint tex;
72 GLuint fragmentShader;
73 GLuint vertexShader;
74 GLuint program;
75 GLuint bufferObject;
76 GLuint texLocation;
77 GLuint positionLocation;
78#endif
79
80#ifdef BUILD_PANDORA
81 int fb;
82 int odd;
83 void* base[2];
84#endif
85};
86
87void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer);
88
89#ifdef BUILD_GL
90void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer);
91#endif
92#endif