Mercurial > sdl-ios-xcode
comparison src/video/dummy/SDL_nullvideo.c @ 1666:6e7ec5cb83c3 SDL-1.3
The dummy video driver compiles. :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 21:56:07 +0000 |
parents | 782fd950bd46 |
children | 1fddae038bc8 |
comparison
equal
deleted
inserted
replaced
1665:28193f833b2b | 1666:6e7ec5cb83c3 |
---|---|
49 #define DUMMYVID_DRIVER_NAME "dummy" | 49 #define DUMMYVID_DRIVER_NAME "dummy" |
50 | 50 |
51 /* Initialization/Query functions */ | 51 /* Initialization/Query functions */ |
52 static int DUMMY_VideoInit (_THIS); | 52 static int DUMMY_VideoInit (_THIS); |
53 static int DUMMY_SetDisplayMode (_THIS, const SDL_DisplayMode * mode); | 53 static int DUMMY_SetDisplayMode (_THIS, const SDL_DisplayMode * mode); |
54 static SDL_Surface *DUMMY_CreateWindowSurface (_THIS, SDL_Window * window); | 54 static void DUMMY_CreateWindowSurface (_THIS, SDL_Window * window, |
55 Uint32 flags); | |
55 static void DUMMY_VideoQuit (_THIS); | 56 static void DUMMY_VideoQuit (_THIS); |
56 | 57 |
57 /* DUMMY driver bootstrap functions */ | 58 /* DUMMY driver bootstrap functions */ |
58 | 59 |
59 static int | 60 static int |
96 SDL_memset (device->hidden, 0, (sizeof *device->hidden)); | 97 SDL_memset (device->hidden, 0, (sizeof *device->hidden)); |
97 | 98 |
98 /* Set the function pointers */ | 99 /* Set the function pointers */ |
99 device->VideoInit = DUMMY_VideoInit; | 100 device->VideoInit = DUMMY_VideoInit; |
100 device->SetDisplayMode = DUMMY_SetDisplayMode; | 101 device->SetDisplayMode = DUMMY_SetDisplayMode; |
102 device->CreateWindowSurface = DUMMY_CreateWindowSurface; | |
101 device->VideoQuit = DUMMY_VideoQuit; | 103 device->VideoQuit = DUMMY_VideoQuit; |
102 device->InitOSKeymap = DUMMY_InitOSKeymap; | 104 device->InitOSKeymap = DUMMY_InitOSKeymap; |
103 device->PumpEvents = DUMMY_PumpEvents; | 105 device->PumpEvents = DUMMY_PumpEvents; |
104 | 106 |
105 device->free = DUMMY_DeleteDevice; | 107 device->free = DUMMY_DeleteDevice; |
126 DUMMY_SetDisplayMode (_THIS, const SDL_DisplayMode * mode) | 128 DUMMY_SetDisplayMode (_THIS, const SDL_DisplayMode * mode) |
127 { | 129 { |
128 return 0; | 130 return 0; |
129 } | 131 } |
130 | 132 |
131 static SDL_Surface * | 133 static void |
132 DUMMY_CreateWindowSurface (_THIS, SDL_Window * window) | 134 DUMMY_CreateWindowSurface (_THIS, SDL_Window * window, Uint32 flags) |
133 { | 135 { |
134 int bpp; | 136 int bpp; |
135 Uint32 Rmask, Gmask, Bmask, Amask; | 137 Uint32 Rmask, Gmask, Bmask, Amask; |
136 | 138 |
137 if (_this->hidden->buffer) { | 139 SDL_PixelFormatEnumToMasks (SDL_GetCurrentDisplayMode ()->format, &bpp, |
138 SDL_free (_this->hidden->buffer); | 140 &Rmask, &Gmask, &Bmask, &Amask); |
139 } | 141 window->surface = |
140 | 142 SDL_CreateRGBSurface (flags, window->w, window->h, bpp, Rmask, Gmask, |
141 _this->hidden->buffer = | 143 Bmask, Amask); |
142 SDL_malloc (mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format)); | |
143 if (!_this->hidden->buffer) { | |
144 SDL_SetError ("Couldn't allocate buffer for requested mode"); | |
145 return (NULL); | |
146 } | |
147 | |
148 /* printf("Setting mode %dx%d\n", width, height); */ | |
149 | |
150 SDL_memset (_this->hidden->buffer, 0, | |
151 mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format)); | |
152 | |
153 /* Allocate the new pixel format for the screen */ | |
154 SDL_PixelFormatEnumToMasks (mode->format, &bpp, &Rmask, &Gmask, &Bmask, | |
155 &Amask); | |
156 if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, Amask)) { | |
157 SDL_free (_this->hidden->buffer); | |
158 _this->hidden->buffer = NULL; | |
159 SDL_SetError | |
160 ("Couldn't allocate new pixel format for requested mode"); | |
161 return (NULL); | |
162 } | |
163 | |
164 /* Set up the new mode framebuffer */ | |
165 current->flags = flags & SDL_FULLSCREEN; | |
166 _this->hidden->w = current->w = mode->w; | |
167 _this->hidden->h = current->h = mode->h; | |
168 current->pitch = current->w * SDL_BYTESPERPIXEL (mode->format); | |
169 current->pixels = _this->hidden->buffer; | |
170 | |
171 /* We're done */ | |
172 return (current); | |
173 } | |
174 | |
175 SDL_Surface * | |
176 DUMMY_SetVideoMode (_THIS, SDL_Surface * current, | |
177 const SDL_DisplayMode * mode, Uint32 flags) | |
178 { | |
179 int bpp; | |
180 Uint32 Rmask, Gmask, Bmask, Amask; | |
181 | |
182 if (_this->hidden->buffer) { | |
183 SDL_free (_this->hidden->buffer); | |
184 } | |
185 | |
186 _this->hidden->buffer = | |
187 SDL_malloc (mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format)); | |
188 if (!_this->hidden->buffer) { | |
189 SDL_SetError ("Couldn't allocate buffer for requested mode"); | |
190 return (NULL); | |
191 } | |
192 | |
193 /* printf("Setting mode %dx%d\n", width, height); */ | |
194 | |
195 SDL_memset (_this->hidden->buffer, 0, | |
196 mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format)); | |
197 | |
198 /* Allocate the new pixel format for the screen */ | |
199 SDL_PixelFormatEnumToMasks (mode->format, &bpp, &Rmask, &Gmask, &Bmask, | |
200 &Amask); | |
201 if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, Amask)) { | |
202 SDL_free (_this->hidden->buffer); | |
203 _this->hidden->buffer = NULL; | |
204 SDL_SetError | |
205 ("Couldn't allocate new pixel format for requested mode"); | |
206 return (NULL); | |
207 } | |
208 | |
209 /* Set up the new mode framebuffer */ | |
210 current->flags = flags & SDL_FULLSCREEN; | |
211 _this->hidden->w = current->w = mode->w; | |
212 _this->hidden->h = current->h = mode->h; | |
213 current->pitch = current->w * SDL_BYTESPERPIXEL (mode->format); | |
214 current->pixels = _this->hidden->buffer; | |
215 | |
216 /* We're done */ | |
217 return (current); | |
218 } | 144 } |
219 | 145 |
220 /* Note: If we are terminated, this could be called in the middle of | 146 /* Note: If we are terminated, this could be called in the middle of |
221 another SDL video routine -- notably UpdateRects. | 147 another SDL video routine -- notably UpdateRects. |
222 */ | 148 */ |
223 void | 149 void |
224 DUMMY_VideoQuit (_THIS) | 150 DUMMY_VideoQuit (_THIS) |
225 { | 151 { |
226 if (_this->hidden->buffer) { | |
227 SDL_free (_this->hidden->buffer); | |
228 } | |
229 } | 152 } |
230 | 153 |
231 /* vi: set ts=4 sw=4 expandtab: */ | 154 /* vi: set ts=4 sw=4 expandtab: */ |