[Super-tux-commit] supertux/src setup.cpp,1.32,1.33 texture.cpp,1.9,1.10
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-04-12 21:28:10
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21496/src Modified Files: setup.cpp texture.cpp Log Message: A first attempt to make a simple and clean way of an on the fly videomode change. But there is this problem: it seems to work on the first transition from SDL to OpenGL, but doesn't work well in the following transitions to OpenGL. I think it is not really related with the texture code, but with the st_video_setup_gl(). The way OpenGL is initialized. Ingo/Tobias, please give a look at this ;) Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- setup.cpp 12 Apr 2004 01:55:30 -0000 1.32 +++ setup.cpp 12 Apr 2004 21:14:17 -0000 1.33 @@ -373,6 +373,7 @@ options_menu->additem(MN_LABEL,"Options",0,0); options_menu->additem(MN_HL,"",0,0); + options_menu->additem(MN_TOGGLE,"OpenGL",use_gl,0); options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0); if(audio_device) { @@ -509,18 +510,27 @@ switch (options_menu->check()) { case 2: - if(use_fullscreen != options_menu->item[2].toggled) + if(use_gl != options_menu->item[2].toggled) { - use_fullscreen = !use_fullscreen; +#ifndef NOOPENGL + use_gl = !use_gl; st_video_setup(); +#endif } break; case 3: - if(use_sound != options_menu->item[3].toggled) - use_sound = !use_sound; + if(use_fullscreen != options_menu->item[3].toggled) + { + use_fullscreen = !use_fullscreen; + st_video_setup(); + } break; case 4: - if(use_music != options_menu->item[4].toggled) + if(use_sound != options_menu->item[4].toggled) + use_sound = !use_sound; + break; + case 5: + if(use_music != options_menu->item[5].toggled) { if(use_music) { @@ -540,8 +550,8 @@ } } break; - case 5: - if(show_fps != options_menu->item[5].toggled) + case 6: + if(show_fps != options_menu->item[6].toggled) show_fps = !show_fps; break; } Index: texture.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/texture.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- texture.cpp 3 Apr 2004 13:31:14 -0000 1.9 +++ texture.cpp 12 Apr 2004 21:14:17 -0000 1.10 @@ -17,6 +17,8 @@ #include "setup.h" #include "texture.h" +#define NO_TEXTURE 0 + void (*texture_load) (texture_type* ptexture, const std::string& file, int use_alpha); void (*texture_load_part)(texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha); void (*texture_free) (texture_type* ptexture); @@ -137,6 +139,9 @@ void texture_draw_gl(texture_type* ptexture, float x, float y, Uint8 alpha, bool update) { +if(ptexture->gl_texture == NO_TEXTURE) + texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture); + float pw = power_of_two(ptexture->w); float ph = power_of_two(ptexture->h); @@ -168,6 +173,9 @@ void texture_draw_bg_gl(texture_type* ptexture, Uint8 alpha, bool update) { +if(ptexture->gl_texture == NO_TEXTURE) + texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture); + float pw = power_of_two(ptexture->w); float ph = power_of_two(ptexture->h); @@ -196,6 +204,9 @@ void texture_draw_part_gl(texture_type* ptexture,float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update) { +if(ptexture->gl_texture == NO_TEXTURE) + texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture); + float pw = power_of_two(ptexture->w); float ph = power_of_two(ptexture->h); @@ -254,6 +265,7 @@ ptexture->w = ptexture->sdl_surface->w; ptexture->h = ptexture->sdl_surface->h; + ptexture->gl_texture = NO_TEXTURE; } void texture_load_part_sdl(texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha) @@ -416,5 +428,9 @@ void texture_free_sdl(texture_type* ptexture) { SDL_FreeSurface(ptexture->sdl_surface); +#ifndef NOOPENGL + if(ptexture->gl_texture != NO_TEXTURE) + glDeleteTextures(1, &ptexture->gl_texture); +#endif } |