Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11window.c @ 1952:420716272158
Implemented X11 OpenGL support.
Added support for the SDL_VIDEO_OPENGL environment variable.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 28 Jul 2006 08:43:17 +0000 |
parents | 7177581dc9fa |
children | ba0d62354872 |
comparison
equal
deleted
inserted
replaced
1951:7177581dc9fa | 1952:420716272158 |
---|---|
133 int | 133 int |
134 X11_CreateWindow(_THIS, SDL_Window * window) | 134 X11_CreateWindow(_THIS, SDL_Window * window) |
135 { | 135 { |
136 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; | 136 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
137 SDL_DisplayData *displaydata = | 137 SDL_DisplayData *displaydata = |
138 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 138 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
139 Visual *visual; | 139 Visual *visual; |
140 int depth; | 140 int depth; |
141 XSetWindowAttributes xattr; | 141 XSetWindowAttributes xattr; |
142 int x, y; | 142 int x, y; |
143 Window w; | 143 Window w; |
151 x = xinerama_info.x_org; | 151 x = xinerama_info.x_org; |
152 y = xinerama_info.y_org; | 152 y = xinerama_info.y_org; |
153 } | 153 } |
154 */ | 154 */ |
155 #endif | 155 #endif |
156 #ifdef SDL_VIDEO_OPENGL_GLX | |
156 if (window->flags & SDL_WINDOW_OPENGL) { | 157 if (window->flags & SDL_WINDOW_OPENGL) { |
157 /* FIXME: get the glx visual */ | 158 XVisualInfo *vinfo; |
158 } else { | 159 |
160 if (X11_GL_Initialize(_this) < 0) { | |
161 return -1; | |
162 } | |
163 vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen); | |
164 if (!vinfo) { | |
165 return -1; | |
166 } | |
167 visual = vinfo->visual; | |
168 depth = vinfo->depth; | |
169 XFree(vinfo); | |
170 } else | |
171 #endif | |
172 { | |
159 visual = displaydata->visual; | 173 visual = displaydata->visual; |
160 depth = displaydata->depth; | 174 depth = displaydata->depth; |
161 } | 175 } |
162 | 176 |
163 if (window->flags & SDL_WINDOW_FULLSCREEN) { | 177 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
201 w = XCreateWindow(data->display, | 215 w = XCreateWindow(data->display, |
202 RootWindow(data->display, displaydata->screen), x, y, | 216 RootWindow(data->display, displaydata->screen), x, y, |
203 window->w, window->h, 0, depth, InputOutput, visual, | 217 window->w, window->h, 0, depth, InputOutput, visual, |
204 (CWOverrideRedirect | CWBackPixel | CWBorderPixel | | 218 (CWOverrideRedirect | CWBackPixel | CWBorderPixel | |
205 CWColormap), &xattr); | 219 CWColormap), &xattr); |
220 if (!w) { | |
221 #ifdef SDL_VIDEO_OPENGL_GLX | |
222 if (window->flags & SDL_WINDOW_OPENGL) { | |
223 X11_GL_Shutdown(_this); | |
224 } | |
225 #endif | |
226 SDL_SetError("Couldn't create window"); | |
227 return -1; | |
228 } | |
206 | 229 |
207 sizehints = XAllocSizeHints(); | 230 sizehints = XAllocSizeHints(); |
208 if (sizehints) { | 231 if (sizehints) { |
209 if (window->flags & SDL_WINDOW_RESIZABLE) { | 232 if (window->flags & SDL_WINDOW_RESIZABLE) { |
210 sizehints->min_width = 32; | 233 sizehints->min_width = 32; |
368 /* Allow the window to be deleted by the window manager */ | 391 /* Allow the window to be deleted by the window manager */ |
369 XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1); | 392 XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1); |
370 | 393 |
371 /* Finally, show the window */ | 394 /* Finally, show the window */ |
372 if (window->flags & SDL_WINDOW_SHOWN) { | 395 if (window->flags & SDL_WINDOW_SHOWN) { |
396 XEvent event; | |
397 | |
373 XMapRaised(data->display, w); | 398 XMapRaised(data->display, w); |
374 } | 399 do { |
375 XSync(data->display, False); | 400 XCheckWindowEvent(data->display, w, StructureNotifyMask, &event); |
401 } while (event.type != MapNotify); | |
402 } | |
376 | 403 |
377 if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { | 404 if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { |
405 #ifdef SDL_VIDEO_OPENGL_GLX | |
406 if (window->flags & SDL_WINDOW_OPENGL) { | |
407 X11_GL_Shutdown(_this); | |
408 } | |
409 #endif | |
378 XDestroyWindow(data->display, w); | 410 XDestroyWindow(data->display, w); |
379 return -1; | 411 return -1; |
380 } | 412 } |
381 | 413 |
382 X11_SetWindowTitle(_this, window); | 414 X11_SetWindowTitle(_this, window); |
383 | 415 |
384 #ifdef SDL_VIDEO_OPENGL | |
385 /* | |
386 if (window->flags & SDL_WINDOW_OPENGL) { | |
387 if (X11_GL_SetupWindow(_this, window) < 0) { | |
388 X11_DestroyWindow(_this, window); | |
389 return -1; | |
390 } | |
391 } | |
392 */ | |
393 #endif | |
394 return 0; | 416 return 0; |
395 } | 417 } |
396 | 418 |
397 int | 419 int |
398 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) | 420 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) |
484 void | 506 void |
485 X11_SetWindowPosition(_THIS, SDL_Window * window) | 507 X11_SetWindowPosition(_THIS, SDL_Window * window) |
486 { | 508 { |
487 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; | 509 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
488 SDL_DisplayData *displaydata = | 510 SDL_DisplayData *displaydata = |
489 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 511 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
490 Display *display = data->videodata->display; | 512 Display *display = data->videodata->display; |
491 int x, y; | 513 int x, y; |
492 | 514 |
493 if ((window->flags & SDL_WINDOW_FULLSCREEN) || | 515 if ((window->flags & SDL_WINDOW_FULLSCREEN) || |
494 window->x == SDL_WINDOWPOS_CENTERED) { | 516 window->x == SDL_WINDOWPOS_CENTERED) { |
574 { | 596 { |
575 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; | 597 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
576 | 598 |
577 if (data) { | 599 if (data) { |
578 Display *display = data->videodata->display; | 600 Display *display = data->videodata->display; |
579 #ifdef SDL_VIDEO_OPENGL | 601 #ifdef SDL_VIDEO_OPENGL_GLX |
580 /* | 602 if (window->flags & SDL_WINDOW_OPENGL) { |
581 if (window->flags & SDL_WINDOW_OPENGL) { | 603 X11_GL_Shutdown(_this); |
582 X11_GL_CleanupWindow(_this, window); | 604 } |
583 } | |
584 */ | |
585 #endif | 605 #endif |
586 #ifdef X_HAVE_UTF8_STRING | 606 #ifdef X_HAVE_UTF8_STRING |
587 if (data->ic) { | 607 if (data->ic) { |
588 XDestroyIC(data->ic); | 608 XDestroyIC(data->ic); |
589 } | 609 } |