Added real Doublebuffering to SDL-build; While on the way, making Bpp selection available for SDL-build, too

This commit is contained in:
zicodxx 2010-01-29 21:53:17 +00:00
parent 1850ac1a09
commit 2bcf54b77a
8 changed files with 40 additions and 28 deletions

View file

@ -4,6 +4,7 @@ D1X-Rebirth Changelog
--------
main/automap.c, main/automap.h, main/game.c, main/gamecntl.c, main/kconfig.c, main/multi.c, main/multi.h, main/net_ipx.c, main/net_udp.c, main/newmenu.c: For multiplayer, close menus from game_handler by doing frame processing in response to EVENT_WINDOW_DRAW, replacing multi_menu_poll system with single multi_menu_check call
main/newmenu.c: Initialise lb->first_item to 0, not -1, preventing crash if you make a listbox selection very quickly
d1x.ini, arch/ogl/gr.c, arch/sdl/gr.c, include/args.h, main/inferno.c, main/newmenu.c, misc/args.c: Added real Doublebuffering to SDL-build; While on the way, making Bpp selection available for SDL-build, too
20100128
--------

View file

@ -73,9 +73,9 @@ int ogl_init_window(int x, int y)
}
SDL_WM_SetCaption(DESCENT_VERSION, "Descent");
if (!SDL_SetVideoMode(x, y, GameArg.DbgGlBpp, SDL_OPENGL | (ogl_fullscreen ? SDL_FULLSCREEN : 0)))
if (!SDL_SetVideoMode(x, y, GameArg.DbgBpp, SDL_OPENGL | (ogl_fullscreen ? SDL_FULLSCREEN : 0)))
{
Error("Could not set %dx%dx%d opengl video mode: %s\n", x, y, GameArg.DbgGlBpp, SDL_GetError());
Error("Could not set %dx%dx%d opengl video mode: %s\n", x, y, GameArg.DbgBpp, SDL_GetError());
}
SDL_ShowCursor(0);
@ -97,7 +97,7 @@ void gr_do_fullscreen(int f)
ogl_fullscreen=f;
if (gl_initialized)
{
if (!SDL_VideoModeOK(curx, cury, GameArg.DbgGlBpp, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0)))
if (!SDL_VideoModeOK(curx, cury, GameArg.DbgBpp, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0)))
{
con_printf(CON_URGENT,"Cannot set %ix%i. Fallback to 640x480\n",curx,cury);
curx=640;
@ -203,7 +203,7 @@ int gr_check_mode(u_int32_t mode)
w=SM_W(mode);
h=SM_H(mode);
return SDL_VideoModeOK(w, h, GameArg.DbgGlBpp, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0));
return SDL_VideoModeOK(w, h, GameArg.DbgBpp, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0));
}
int gr_set_mode(u_int32_t mode)
@ -217,7 +217,7 @@ int gr_set_mode(u_int32_t mode)
w=SM_W(mode);
h=SM_H(mode);
if (!SDL_VideoModeOK(w, h, GameArg.DbgGlBpp, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0)))
if (!SDL_VideoModeOK(w, h, GameArg.DbgBpp, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0)))
{
con_printf(CON_URGENT,"Cannot set %ix%i. Fallback to 640x480\n",w,h);
w=640;

View file

@ -20,11 +20,18 @@
#include "config.h"
int sdl_video_flags = SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF;
SDL_Surface *screen;
SDL_Surface *screen,*canvas;
int gr_installed = 0;
void gr_flip()
{
SDL_Rect src, dest;
dest.x = src.x = dest.y = src.y = 0;
dest.w = src.w = canvas->w;
dest.h = src.h = canvas->h;
SDL_BlitSurface(canvas, &src, screen, &dest);
SDL_Flip(screen);
}
@ -42,7 +49,7 @@ int gr_check_mode(u_int32_t mode)
w=SM_W(mode);
h=SM_H(mode);
return SDL_VideoModeOK(w,h,8,sdl_video_flags);
return SDL_VideoModeOK(w,h,GameArg.DbgBpp,sdl_video_flags);
}
int gr_set_mode(u_int32_t mode)
@ -58,9 +65,9 @@ int gr_set_mode(u_int32_t mode)
SDL_WM_SetCaption(DESCENT_VERSION, "Descent");
if(SDL_VideoModeOK(w,h,8,sdl_video_flags))
if(SDL_VideoModeOK(w,h,GameArg.DbgBpp,sdl_video_flags))
{
screen=SDL_SetVideoMode(w, h, 8, sdl_video_flags);
screen=SDL_SetVideoMode(w, h, GameArg.DbgBpp, sdl_video_flags);
}
else
{
@ -68,12 +75,19 @@ int gr_set_mode(u_int32_t mode)
w=640;
h=480;
Game_screen_mode=mode=SM(w,h);
screen=SDL_SetVideoMode(w, h, 8, sdl_video_flags);
screen=SDL_SetVideoMode(w, h, GameArg.DbgBpp, sdl_video_flags);
}
if (screen == NULL)
{
Error("Could not set %dx%dx8 video mode\n",w,h);
Error("Could not set %dx%dx%d video mode\n",w,h,GameArg.DbgBpp);
exit(1);
}
canvas = SDL_CreateRGBSurface(sdl_video_flags, w, h, 8, 0, 0, 0, 0);
if (canvas == NULL)
{
Error("Could not create canvas surface\n");
exit(1);
}
@ -86,9 +100,9 @@ int gr_set_mode(u_int32_t mode)
grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0;
grd_curscreen->sc_canvas.cv_bitmap.bm_w = w;
grd_curscreen->sc_canvas.cv_bitmap.bm_h = h;
grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = screen->pitch;
grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = canvas->pitch;
grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR;
grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)screen->pixels;
grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)canvas->pixels;
gr_set_current_canvas(NULL);
SDL_ShowCursor(0);
@ -163,6 +177,7 @@ void gr_close()
gr_installed = 0;
d_free(grd_curscreen);
SDL_ShowCursor(1);
SDL_FreeSurface(canvas);
}
}
@ -184,7 +199,7 @@ void gr_palette_step_up( int r, int g, int b )
last_g = g;
last_b = b;
palette = screen->format->palette;
palette = canvas->format->palette;
if (palette == NULL)
return; // Display is not palettised
@ -217,7 +232,7 @@ void gr_palette_step_up( int r, int g, int b )
colors[i].b = temp * 4;
}
SDL_SetColors(screen, colors, 0, 256);
SDL_SetColors(canvas, colors, 0, 256);
}
#undef min
@ -231,7 +246,7 @@ void gr_palette_load( ubyte *pal )
ubyte gamma[64];
if (memcmp(pal,gr_current_pal,768))
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
SDL_FillRect(canvas, NULL, SDL_MapRGB(canvas->format, 0, 0, 0));
for (i=0; i<768; i++ )
{
@ -240,10 +255,10 @@ void gr_palette_load( ubyte *pal )
gr_current_pal[i] = 63;
}
if (screen == NULL)
if (canvas == NULL)
return;
palette = screen->format->palette;
palette = canvas->format->palette;
if (palette == NULL)
return; // Display is not palettised
@ -261,7 +276,7 @@ void gr_palette_load( ubyte *pal )
colors[j].b = (min(gr_current_pal[i++] + gr_palette_gamma, 63)) * 4;
}
SDL_SetColors(screen, colors, 0, 256);
SDL_SetColors(canvas, colors, 0, 256);
init_computed_colors();
}
@ -270,7 +285,7 @@ void gr_palette_read(ubyte * pal)
SDL_Palette *palette;
int i, j;
palette = screen->format->palette;
palette = canvas->format->palette;
if (palette == NULL)
return; // Display is not palettised

View file

@ -52,8 +52,8 @@
;-showmeminfo Show memory statistics
;-nodoublebuffer Disable Doublebuffering
;-bigpig Use uncompressed RLE bitmaps
;-16bpp Use 16Bpp instead of 32Bpp
;-gl_oldtexmerge Use old texmerge, uses more ram, but _might_ be a bit faster
;-gl_16bpp Use 16Bpp Color Depth
;-gl_intensity4_ok <n> Override DbgGlIntensity4Ok - Default: 1
;-gl_luminance4_alpha4_ok <n> Override DbgGlLuminance4Alpha4Ok - Default: 1
;-gl_rgba2_ok <n> Override DbgGlRGBA2Ok - Default: 1

View file

@ -80,9 +80,9 @@ typedef struct Arg
int DbgShowMemInfo;
int DbgUseDoubleBuffer;
int DbgBigPig;
int DbgBpp;
#ifdef OGL
int DbgAltTexMerge;
int DbgGlBpp;
int DbgGlIntensity4Ok;
int DbgGlLuminance4Alpha4Ok;
int DbgGlRGBA2Ok;

View file

@ -164,9 +164,9 @@ void print_commandline_help()
printf( " -showmeminfo %s\n", "Show memory statistics");
printf( " -nodoublebuffer %s\n", "Disable Doublebuffering");
printf( " -bigpig %s\n", "Use uncompressed RLE bitmaps");
printf( " -16bpp %s\n", "Use 16Bpp instead of 32Bpp");
#ifdef OGL
printf( " -gl_oldtexmerge %s\n", "Use old texmerge, uses more ram, but _might_ be a bit faster");
printf( " -gl_16bpp %s\n", "Use 16Bpp Color Depth");
printf( " -gl_intensity4_ok <n> %s\n", "Override DbgGlIntensity4Ok - Default: 1");
printf( " -gl_luminance4_alpha4_ok <n> %s\n", "Override DbgGlLuminance4Alpha4Ok - Default: 1");
printf( " -gl_rgba2_ok <n> %s\n", "Override DbgGlRGBA2Ok - Default: 1");

View file

@ -1137,9 +1137,7 @@ int newmenu_draw(window *wind, d_event *event, newmenu *menu)
int string_width, string_height, average_width;
gr_set_current_canvas( NULL );
#ifdef OGL
nm_draw_background1(menu->filename);
#endif
if (menu->filename == NULL)
nm_draw_background(menu->x-(menu->is_scroll_box?FSPACX(5):0),menu->y,menu->x+menu->w,menu->y+menu->h);
@ -1885,9 +1883,7 @@ int listbox_draw(window *wind, d_event *event, listbox *lb)
{
int i;
#ifdef OGL
nm_draw_background1(NULL);
#endif
nm_draw_background( lb->box_x-BORDERX,lb->box_y-lb->title_height-BORDERY,lb->box_x+lb->box_w+BORDERX,lb->box_y+lb->height+BORDERY );
gr_set_curfont(MEDIUM3_FONT);
gr_string( 0x8000, lb->box_y - lb->title_height, lb->title );

View file

@ -204,10 +204,10 @@ void ReadCmdArgs(void)
GameArg.DbgShowMemInfo = FindArg("-showmeminfo");
GameArg.DbgUseDoubleBuffer = !FindArg("-nodoublebuffer");
GameArg.DbgBigPig = !FindArg("-bigpig");
GameArg.DbgBpp = (FindArg("-16bpp") ? 16 : 32);
#ifdef OGL
GameArg.DbgAltTexMerge = !FindArg("-gl_oldtexmerge");
GameArg.DbgGlBpp = (FindArg("-gl_16bpp") ? 16 : 32);
GameArg.DbgGlIntensity4Ok = get_int_arg("-gl_intensity4_ok", 1);
GameArg.DbgGlLuminance4Alpha4Ok = get_int_arg("-gl_luminance4_alpha4_ok", 1);
GameArg.DbgGlRGBA2Ok = get_int_arg("-gl_rgba2_ok", 1);