Mercurial > sdl-ios-xcode
comparison src/SDL_compat.c @ 1912:8d384b647307
Setting up the OpenGL support
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 16 Jul 2006 09:34:01 +0000 |
parents | 06c27a737b7a |
children | 83420da906a5 |
comparison
equal
deleted
inserted
replaced
1911:7577fd11cee4 | 1912:8d384b647307 |
---|---|
34 static SDL_RendererInfo SDL_VideoRendererInfo; | 34 static SDL_RendererInfo SDL_VideoRendererInfo; |
35 static SDL_TextureID SDL_VideoTexture; | 35 static SDL_TextureID SDL_VideoTexture; |
36 static SDL_Surface *SDL_VideoSurface; | 36 static SDL_Surface *SDL_VideoSurface; |
37 static SDL_Surface *SDL_ShadowSurface; | 37 static SDL_Surface *SDL_ShadowSurface; |
38 static SDL_Surface *SDL_PublicSurface; | 38 static SDL_Surface *SDL_PublicSurface; |
39 static SDL_GLContext *SDL_VideoContext; | |
39 static char *wm_title; | 40 static char *wm_title; |
40 | 41 |
41 char * | 42 char * |
42 SDL_AudioDriverName(char *namebuf, int maxlen) | 43 SDL_AudioDriverName(char *namebuf, int maxlen) |
43 { | 44 { |
333 SDL_DelPaletteWatch(SDL_VideoSurface->format->palette, | 334 SDL_DelPaletteWatch(SDL_VideoSurface->format->palette, |
334 SDL_VideoPaletteChanged, NULL); | 335 SDL_VideoPaletteChanged, NULL); |
335 SDL_FreeSurface(SDL_VideoSurface); | 336 SDL_FreeSurface(SDL_VideoSurface); |
336 SDL_VideoSurface = NULL; | 337 SDL_VideoSurface = NULL; |
337 } | 338 } |
339 if (SDL_VideoContext) { | |
340 SDL_GL_MakeCurrent(0, SDL_VideoContext); | |
341 SDL_GL_DeleteContext(SDL_VideoContext); | |
342 SDL_VideoContext = NULL; | |
343 } | |
338 if (SDL_VideoWindow) { | 344 if (SDL_VideoWindow) { |
339 SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y); | 345 SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y); |
340 } | 346 } |
341 SDL_DestroyWindow(SDL_VideoWindow); | 347 SDL_DestroyWindow(SDL_VideoWindow); |
342 | 348 |
430 } | 436 } |
431 } | 437 } |
432 | 438 |
433 /* If we're in OpenGL mode, just create a stub surface and we're done! */ | 439 /* If we're in OpenGL mode, just create a stub surface and we're done! */ |
434 if (flags & SDL_OPENGL) { | 440 if (flags & SDL_OPENGL) { |
441 SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow); | |
442 if (!SDL_VideoContext) { | |
443 return NULL; | |
444 } | |
445 if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) { | |
446 return NULL; | |
447 } | |
435 SDL_VideoSurface = | 448 SDL_VideoSurface = |
436 SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0); | 449 SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0); |
437 if (!SDL_VideoSurface) { | 450 if (!SDL_VideoSurface) { |
438 return NULL; | 451 return NULL; |
439 } | 452 } |
1416 } | 1429 } |
1417 SDL_free(overlay); | 1430 SDL_free(overlay); |
1418 } | 1431 } |
1419 } | 1432 } |
1420 | 1433 |
1434 int | |
1435 SDL_GL_GetAttribute(SDL_GLattr attr, int *value) | |
1436 { | |
1437 return SDL_GL_GetWindowAttribute(SDL_VideoWindow, attr, value); | |
1438 } | |
1439 | |
1440 void | |
1441 SDL_GL_SwapBuffers(void) | |
1442 { | |
1443 SDL_GL_SwapWindow(SDL_VideoWindow); | |
1444 } | |
1445 | |
1421 /* vi: set ts=4 sw=4 expandtab: */ | 1446 /* vi: set ts=4 sw=4 expandtab: */ |