comparison src/video/uikit/SDL_uikitvideo.m @ 2352:1ecbeff9eb4c gsoc2008_iphone

SDL_uikitvideo.m is the main file for the UIKit video driver. It has the UIKit video bootstrap, initialization, device creation, etc.
author Holmes Futrell <hfutrell@umail.ucsb.edu>
date Thu, 17 Jul 2008 22:38:29 +0000
parents
children 491958a6c881
comparison
equal deleted inserted replaced
2351:d2a519d2cc57 2352:1ecbeff9eb4c
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 /* Dummy SDL video driver implementation; this is just enough to make an
25 * SDL-based application THINK it's got a working video driver, for
26 * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it,
27 * and also for use as a collection of stubs when porting SDL to a new
28 * platform for which you haven't yet written a valid video driver.
29 *
30 * This is also a great way to determine bottlenecks: if you think that SDL
31 * is a performance problem for a given platform, enable this driver, and
32 * then see if your application runs faster without video overhead.
33 *
34 * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
35 * of this was cut-and-pasted from Stephane Peter's work in the AAlib
36 * SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
37 */
38
39 #include "SDL_video.h"
40 #include "SDL_mouse.h"
41 #include "../SDL_sysvideo.h"
42 #include "../SDL_pixels_c.h"
43 #include "../../events/SDL_events_c.h"
44
45 #include "SDL_uikitvideo.h"
46 #include "SDL_uikitevents.h"
47 #include "SDL_uikitwindow.h"
48 #include "SDL_uikitopengles.h"
49
50 #include "SDL_renderer_sw.h"
51 #include "SDL_renderer_gles.h"
52
53 #define UIKITVID_DRIVER_NAME "uikit"
54
55 /* Initialization/Query functions */
56 static int UIKit_VideoInit(_THIS);
57 static int UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
58 static void UIKit_VideoQuit(_THIS);
59
60 /* DUMMY driver bootstrap functions */
61
62 static int
63 UIKit_Available(void)
64 {
65 return (1);
66 }
67
68 static void UIKit_DeleteDevice(SDL_VideoDevice * device)
69 {
70 SDL_free(device);
71 }
72
73 static SDL_VideoDevice *
74 UIKit_CreateDevice(int devindex)
75 {
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 = UIKit_VideoInit;
90 device->VideoQuit = UIKit_VideoQuit;
91 device->SetDisplayMode = UIKit_SetDisplayMode;
92 device->PumpEvents = UIKit_PumpEvents;
93 device->CreateWindow = UIKit_CreateWindow;
94 device->DestroyWindow = UIKit_DestroyWindow;
95
96
97 /* OpenGL (ES) functions */
98 device->GL_MakeCurrent = UIKit_GL_MakeCurrent;
99 device->GL_SwapWindow = UIKit_GL_SwapWindow;
100 device->GL_CreateContext = UIKit_GL_CreateContext;
101 device->GL_DeleteContext = UIKit_GL_DeleteContext;
102 device->GL_GetProcAddress = UIKit_GL_GetProcAddress;
103 device->GL_LoadLibrary = UIKit_GL_LoadLibrary;
104 device->free = UIKit_DeleteDevice;
105
106 device->gl_config.accelerated = 1;
107
108 return device;
109 }
110
111 VideoBootStrap UIKIT_bootstrap = {
112 UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
113 UIKit_Available, UIKit_CreateDevice
114 };
115
116
117 int
118 UIKit_VideoInit(_THIS)
119 {
120 SDL_DisplayMode mode;
121
122 printf("UIKit Video init!");
123
124 _this->gl_config.driver_loaded = 1;
125
126 SDL_VideoDisplay display;
127 SDL_zero(display);
128
129 /* Use a 32-bpp desktop mode */
130 SDL_zero(mode);
131 mode.format = SDL_PIXELFORMAT_ABGR8888;
132 mode.w = 320;
133 mode.h = 480;
134 mode.refresh_rate = 0;
135 mode.driverdata = NULL;
136
137 display.num_display_modes = 1;
138 display.max_display_modes = 1;
139 display.display_modes = (SDL_DisplayMode *)SDL_malloc(display.max_display_modes * sizeof(SDL_DisplayMode));
140
141 display.display_modes[0] = mode;
142 display.desktop_mode = mode;
143 display.fullscreen_mode = mode;
144 display.current_mode = mode;
145
146 SDL_AddVideoDisplay(&display);
147
148 /* We're done! */
149 return 0;
150 }
151
152 static int
153 UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
154 {
155 return 0;
156 }
157
158 void
159 UIKit_VideoQuit(_THIS)
160 {
161 }
162
163 /* vi: set ts=4 sw=4 expandtab: */