[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [linuxgames] Poll: Video Access



It seems that everyone uses SDL, reaching (i suppose) good performances.
I'll have to do some serious benchmark... it runs quite slow...
(thanx to all, you've all been very kind)

So, i've a question about SDL.
My game writes all the graphic in a memory buffer, then blits this memory 
buffer to screen.

The memory buffer is larger than the screen, so that i can safely draw outside 
the screen without the need to check any pixel drawn.

The problem is that SDL does not allow me to create a virtual screen larger 
than the physical (or window) screen, so that i must blit the buffer to a 
memory bitmap of the same size of the physical screen, and then blit it to 
the screen:


/* INITIALIZATION CODE */
SDL_Surface *sdl_screen;
SDL_Surface *sdl_vscreen;


sdl_screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 16, SDL_HWSURFACE);
if(sdl_screen == NULL) return -1;

sdl_vscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, VSCREEN_W, VSCREEN_H, 16,
    31<<11,	//Rmask
    63<<5,		//Gmask
    31,		//Bmask
    0);			//Amask


/* SCREEN REFRESH CODE */
SDL_Rect sdl_src;
SDL_Rect sdl_dst;

pix *ext_draw() { return sdl_vscreen->pixels; }	/* pixels are drawn here */

void ext_update(int x, int y, int w, int h)
{
 sdl_src.x = x + SCREEN_X;	/* screen X offset */
 sdl_src.y = y + SCREEN_Y;	/* screen Y offset */
 sdl_dst.x = x;
 sdl_dst.y = y;

 sdl_src.w = sdl_dst.w = w;
 sdl_src.h = sdl_dst.h = h;

 /* copy larger virtual screen to smaller memory screen */
 SDL_BlitSurface(sdl_vscreen, &sdl_src, sdl_screen, &sdl_dst);

 /* blit memory screen to 'hardware' screen */
 SDL_UpdateRect(sdl_screen, 0, 0, SCREEN_W, SCREEN_H);
}


/*EOF==================================================*/



ALLEGRO can blit the virtual screen directly to the 'hardware' screen, with a 
significant performance improvement.
Is there anyway to speed up things with SDL (other than resizing the virtual 
screen to hardware screen size?)

Thanks,
Francesco Orsenigo