comparison src/video/uikit/SDL_uikitvideo.m @ 2765:f55c87ae336b

Final merge of Google Summer of Code 2008 work... Bring SDL to iPhone and iPod Touch by Holmes Futrell, mentored by Sam Lantinga
author Sam Lantinga <slouken@libsdl.org>
date Sat, 04 Oct 2008 06:46:59 +0000
parents
children 99210400e8b9
comparison
equal deleted inserted replaced
2764:4868c0df2e83 2765:f55c87ae336b
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2006 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 #include "SDL_video.h"
25 #include "SDL_mouse.h"
26 #include "../SDL_sysvideo.h"
27 #include "../SDL_pixels_c.h"
28 #include "../../events/SDL_events_c.h"
29
30 #include "SDL_uikitvideo.h"
31 #include "SDL_uikitevents.h"
32 #include "SDL_uikitwindow.h"
33 #include "SDL_uikitopengles.h"
34
35 #include "SDL_renderer_sw.h"
36 #include "SDL_renderer_gles.h"
37
38 #define UIKITVID_DRIVER_NAME "uikit"
39
40 /* Initialization/Query functions */
41 static int UIKit_VideoInit(_THIS);
42 static int UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
43 static void UIKit_VideoQuit(_THIS);
44
45 /* DUMMY driver bootstrap functions */
46
47 static int
48 UIKit_Available(void)
49 {
50 return (1);
51 }
52
53 static void UIKit_DeleteDevice(SDL_VideoDevice * device)
54 {
55 SDL_free(device);
56 }
57
58 static SDL_VideoDevice *
59 UIKit_CreateDevice(int devindex)
60 {
61 SDL_VideoDevice *device;
62
63 /* Initialize all variables that we clean on shutdown */
64 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
65 if (!device) {
66 SDL_OutOfMemory();
67 if (device) {
68 SDL_free(device);
69 }
70 return (0);
71 }
72
73 /* Set the function pointers */
74 device->VideoInit = UIKit_VideoInit;
75 device->VideoQuit = UIKit_VideoQuit;
76 device->SetDisplayMode = UIKit_SetDisplayMode;
77 device->PumpEvents = UIKit_PumpEvents;
78 device->CreateWindow = UIKit_CreateWindow;
79 device->DestroyWindow = UIKit_DestroyWindow;
80
81
82 /* OpenGL (ES) functions */
83 device->GL_MakeCurrent = UIKit_GL_MakeCurrent;
84 device->GL_SwapWindow = UIKit_GL_SwapWindow;
85 device->GL_CreateContext = UIKit_GL_CreateContext;
86 device->GL_DeleteContext = UIKit_GL_DeleteContext;
87 device->GL_GetProcAddress = UIKit_GL_GetProcAddress;
88 device->GL_LoadLibrary = UIKit_GL_LoadLibrary;
89 device->free = UIKit_DeleteDevice;
90
91 device->gl_config.accelerated = 1;
92
93 return device;
94 }
95
96 VideoBootStrap UIKIT_bootstrap = {
97 UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
98 UIKit_Available, UIKit_CreateDevice
99 };
100
101
102 int
103 UIKit_VideoInit(_THIS)
104 {
105 SDL_DisplayMode mode;
106
107 _this->gl_config.driver_loaded = 1;
108
109 SDL_VideoDisplay display;
110 SDL_zero(display);
111
112 /* Use a 32-bpp desktop mode */
113 SDL_zero(mode);
114 mode.format = SDL_PIXELFORMAT_ABGR8888;
115 mode.w = 320;
116 mode.h = 480;
117 mode.refresh_rate = 0;
118 mode.driverdata = NULL;
119
120 display.num_display_modes = 1;
121 display.max_display_modes = 1;
122 display.display_modes = (SDL_DisplayMode *)SDL_malloc(display.max_display_modes * sizeof(SDL_DisplayMode));
123
124 display.display_modes[0] = mode;
125 display.desktop_mode = mode;
126 display.fullscreen_mode = mode;
127 display.current_mode = mode;
128
129 SDL_AddVideoDisplay(&display);
130
131 /* We're done! */
132 return 0;
133 }
134
135 static int
136 UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
137 {
138 return 0;
139 }
140
141 void
142 UIKit_VideoQuit(_THIS)
143 {
144 }
145
146 /* vi: set ts=4 sw=4 expandtab: */