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 SDL_GLContext* glCtx;
49#endif
50
51 int viewportWidth;
52 int viewportHeight;
53 int ratio;
54
55 bool lockAspectRatio;
56 bool filter;
57
58#ifdef BUILD_GL
59 struct GBAGLContext gl;
60#endif
61
62#ifdef USE_PIXMAN
63 pixman_image_t* pix;
64 pixman_image_t* screenpix;
65#endif
66
67#ifdef BUILD_RASPI
68 EGLDisplay display;
69 EGLSurface surface;
70 EGLContext context;
71 EGL_DISPMANX_WINDOW_T window;
72 GLuint tex;
73 GLuint fragmentShader;
74 GLuint vertexShader;
75 GLuint program;
76 GLuint bufferObject;
77 GLuint texLocation;
78 GLuint positionLocation;
79#endif
80
81#ifdef BUILD_PANDORA
82 int fb;
83 int odd;
84 void* base[2];
85#endif
86};
87
88void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer);
89
90#ifdef BUILD_GL
91void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer);
92#endif
93#endif