comparison src/video/SDL_video.c @ 5125:dc0dfdd58f27

Removed completely non-portable event thread hack. Next I'll be working on generalizing the event sources and making the event queue lock-free. :)
author Sam Lantinga <slouken@libsdl.org>
date Thu, 27 Jan 2011 22:44:08 -0800
parents 797b37c0c046
children da10636e5eca
comparison
equal deleted inserted replaced
5124:0ec550f04bbc 5125:dc0dfdd58f27
29 #include "SDL_blit.h" 29 #include "SDL_blit.h"
30 #include "SDL_pixels_c.h" 30 #include "SDL_pixels_c.h"
31 #include "SDL_renderer_gl.h" 31 #include "SDL_renderer_gl.h"
32 #include "SDL_renderer_gles.h" 32 #include "SDL_renderer_gles.h"
33 #include "SDL_renderer_sw.h" 33 #include "SDL_renderer_sw.h"
34 #include "../events/SDL_sysevents.h"
35 #include "../events/SDL_events_c.h" 34 #include "../events/SDL_events_c.h"
36 35
37 #if SDL_VIDEO_DRIVER_WINDOWS 36 #if SDL_VIDEO_DRIVER_WINDOWS
38 #include "windows/SDL_windowsvideo.h" 37 #include "windows/SDL_windowsvideo.h"
39 extern void IME_Present(SDL_VideoData *videodata); 38 extern void IME_Present(SDL_VideoData *videodata);
170 169
171 /* 170 /*
172 * Initialize the video and event subsystems -- determine native pixel format 171 * Initialize the video and event subsystems -- determine native pixel format
173 */ 172 */
174 int 173 int
175 SDL_VideoInit(const char *driver_name, Uint32 flags) 174 SDL_VideoInit(const char *driver_name)
176 { 175 {
177 SDL_VideoDevice *video; 176 SDL_VideoDevice *video;
178 int index; 177 int index;
179 int i; 178 int i;
180 179
181 /* Check to make sure we don't overwrite '_this' */ 180 /* Check to make sure we don't overwrite '_this' */
182 if (_this != NULL) { 181 if (_this != NULL) {
183 SDL_VideoQuit(); 182 SDL_VideoQuit();
184 } 183 }
185 184
186 /* Toggle the event thread flags, based on OS requirements */
187 #if defined(MUST_THREAD_EVENTS)
188 flags |= SDL_INIT_EVENTTHREAD;
189 #elif defined(CANT_THREAD_EVENTS)
190 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
191 SDL_SetError("OS doesn't support threaded events");
192 return -1;
193 }
194 #endif
195
196 /* Start the event loop */ 185 /* Start the event loop */
197 if (SDL_StartEventLoop(flags) < 0) { 186 if (SDL_StartEventLoop() < 0 ||
187 SDL_KeyboardInit() < 0 ||
188 SDL_MouseInit() < 0 ||
189 SDL_TouchInit() < 0 ||
190 SDL_QuitInit() < 0) {
198 return -1; 191 return -1;
199 } 192 }
200 193
201 /* Select the proper video driver */ 194 /* Select the proper video driver */
202 index = 0; 195 index = 0;
885 SDL_VideoDisplay *display; 878 SDL_VideoDisplay *display;
886 SDL_Window *window; 879 SDL_Window *window;
887 880
888 if (!_this) { 881 if (!_this) {
889 /* Initialize the video system if needed */ 882 /* Initialize the video system if needed */
890 if (SDL_VideoInit(NULL, 0) < 0) { 883 if (SDL_VideoInit(NULL) < 0) {
891 return NULL; 884 return NULL;
892 } 885 }
893 } 886 }
894 if (flags & SDL_WINDOW_OPENGL) { 887 if (flags & SDL_WINDOW_OPENGL) {
895 if (!_this->GL_CreateContext) { 888 if (!_this->GL_CreateContext) {
2805 int i, j; 2798 int i, j;
2806 2799
2807 if (!_this) { 2800 if (!_this) {
2808 return; 2801 return;
2809 } 2802 }
2803
2810 /* Halt event processing before doing anything else */ 2804 /* Halt event processing before doing anything else */
2805 SDL_QuitQuit();
2806 SDL_MouseQuit();
2807 SDL_KeyboardQuit();
2811 SDL_StopEventLoop(); 2808 SDL_StopEventLoop();
2809
2812 SDL_EnableScreenSaver(); 2810 SDL_EnableScreenSaver();
2813 2811
2814 /* Clean up the system video */ 2812 /* Clean up the system video */
2815 for (i = _this->num_displays; i--;) { 2813 for (i = _this->num_displays; i--;) {
2816 SDL_VideoDisplay *display = &_this->displays[i]; 2814 SDL_VideoDisplay *display = &_this->displays[i];