comparison src/video/android/SDL_androidvideo.c @ 4701:d40bb3165d2b

Added (partially implemented) android video backend and associated files needed to build
author Paul Hunkin <paul@bieh.net>
date Thu, 10 Jun 2010 18:54:23 +1200
parents
children c93b44ddc63e
comparison
equal deleted inserted replaced
4700:cf23d9b8e606 4701:d40bb3165d2b
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22 #include "SDL_config.h"
23
24 /* Android SDL video driver implementation
25 */
26
27 #include "SDL_video.h"
28 #include "SDL_mouse.h"
29 #include "../SDL_sysvideo.h"
30 #include "../SDL_pixels_c.h"
31 #include "../../events/SDL_events_c.h"
32
33 #include "SDL_androidvideo.h"
34 #include "SDL_androidevents_c.h"
35 #include "SDL_androidrender_c.h"
36
37 #define ANDROID_VID_DRIVER_NAME "Android"
38
39 /* Initialization/Query functions */
40 static int Android_VideoInit(_THIS);
41 static int Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
42 static void Android_VideoQuit(_THIS);
43
44 /* GL functions (SDL_androidgl.c) */
45 extern int Android_GL_LoadLibrary(_THIS, const char *path);
46 extern void *Android_GL_GetProcAddress(_THIS, const char *proc);
47 extern void Android_GL_UnloadLibrary(_THIS);
48 //extern int *Android_GL_GetVisual(_THIS, Display * display, int screen);
49 extern SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window);
50 extern int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
51 SDL_GLContext context);
52 extern int Android_GL_SetSwapInterval(_THIS, int interval);
53 extern int Android_GL_GetSwapInterval(_THIS);
54 extern void Android_GL_SwapWindow(_THIS, SDL_Window * window);
55 extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context);
56
57 /* Android driver bootstrap functions */
58
59
60 static int
61 Android_Available(void)
62 {
63 return 1;
64 }
65
66 static void
67 Android_DeleteDevice(SDL_VideoDevice * device)
68 {
69 SDL_free(device);
70 }
71
72 static SDL_VideoDevice *
73 Android_CreateDevice(int devindex)
74 {
75 printf("Creating video device\n");
76 SDL_VideoDevice *device;
77
78 /* Initialize all variables that we clean on shutdown */
79 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
80 if (!device) {
81 SDL_OutOfMemory();
82 if (device) {
83 SDL_free(device);
84 }
85 return (0);
86 }
87
88 /* Set the function pointers */
89 device->VideoInit = Android_VideoInit;
90 device->VideoQuit = Android_VideoQuit;
91 device->SetDisplayMode = Android_SetDisplayMode;
92 device->PumpEvents = Android_PumpEvents;
93
94 device->free = Android_DeleteDevice;
95
96 /* GL pointers */
97 device->GL_LoadLibrary = Android_GL_LoadLibrary;
98 device->GL_GetProcAddress = Android_GL_GetProcAddress;
99 device->GL_UnloadLibrary = Android_GL_UnloadLibrary;
100 device->GL_CreateContext = Android_GL_CreateContext;
101 device->GL_MakeCurrent = Android_GL_MakeCurrent;
102 device->GL_SetSwapInterval = Android_GL_SetSwapInterval;
103 device->GL_GetSwapInterval = Android_GL_GetSwapInterval;
104 device->GL_SwapWindow = Android_GL_SwapWindow;
105 device->GL_DeleteContext = Android_GL_DeleteContext;
106
107 return device;
108 }
109
110 VideoBootStrap Android_bootstrap = {
111 ANDROID_VID_DRIVER_NAME, "SDL Android video driver",
112 Android_Available, Android_CreateDevice
113 };
114
115
116 int
117 Android_VideoInit(_THIS)
118 {
119 SDL_DisplayMode mode;
120
121 /* Use a fake 32-bpp desktop mode */
122 mode.format = SDL_PIXELFORMAT_RGB888;
123 mode.w = 1024;
124 mode.h = 768;
125 mode.refresh_rate = 0;
126 mode.driverdata = NULL;
127 if (SDL_AddBasicVideoDisplay(&mode) < 0) {
128 return -1;
129 }
130 SDL_AddRenderDriver(&_this->displays[0], &Android_RenderDriver);
131
132 SDL_zero(mode);
133 SDL_AddDisplayMode(&_this->displays[0], &mode);
134
135 /* We're done! */
136 return 0;
137 }
138
139 static int
140 Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
141 {
142 return 0;
143 }
144
145 void
146 Android_VideoQuit(_THIS)
147 {
148 }
149
150
151
152 /* vi: set ts=4 sw=4 expandtab: */