all repos — mgba @ bed6a0c1302d49ae673b6df31cdbb4410abba4f5

mGBA Game Boy Advance Emulator

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
34#ifdef USE_PIXMAN
35#include <pixman.h>
36#endif
37
38struct SDLSoftwareRenderer {
39	struct GBAVideoSoftwareRenderer d;
40	struct GBASDLAudio audio;
41	struct GBASDLEvents events;
42	struct GBASDLPlayer player;
43
44	bool (*init)(struct SDLSoftwareRenderer* renderer);
45	void (*runloop)(struct GBAThread* context, struct SDLSoftwareRenderer* renderer);
46	void (*deinit)(struct SDLSoftwareRenderer* renderer);
47
48#if SDL_VERSION_ATLEAST(2, 0, 0)
49	SDL_Window* window;
50	SDL_Texture* sdlTex;
51	SDL_Renderer* sdlRenderer;
52#endif
53
54	int viewportWidth;
55	int viewportHeight;
56	int ratio;
57
58	bool lockAspectRatio;
59	bool filter;
60
61#ifdef BUILD_GL
62	GLuint tex;
63#endif
64
65#ifdef USE_PIXMAN
66	pixman_image_t* pix;
67	pixman_image_t* screenpix;
68#endif
69
70#ifdef BUILD_RASPI
71	EGLDisplay display;
72	EGLSurface surface;
73	EGLContext context;
74	EGL_DISPMANX_WINDOW_T window;
75	GLuint tex;
76	GLuint fragmentShader;
77	GLuint vertexShader;
78	GLuint program;
79	GLuint bufferObject;
80	GLuint texLocation;
81	GLuint positionLocation;
82#endif
83
84#ifdef BUILD_PANDORA
85	int fb;
86	int odd;
87	void* base[2];
88#endif
89};
90
91void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer);
92
93#ifdef BUILD_GL
94void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer);
95#endif
96#endif