Fullscreen 400X240 With Allegro 4


el_pango

Member
Joined
May 31, 2006
Messages
145
Location
California
Hi all,

I'm not sure how many people here use Allegro, as it seems to be less popular than SDL, but if you are using it or working on porting an older full-screen app that 'expects' 320x240 and ran into performance issues with stretch_blit(), this might be of use to you.

When I initialize my app, I do this:
Code:
int fbdev;
void * scrn_ptr;
BITMAP *double_buffer;

//--------- setup ----------------------------//

        // set allegro's internal state up 
	set_color_depth(16);
	set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,400,240,0,0);

        // prepare the pandora's hardware framebuffer for use  
	system("ofbset -fb /dev/fb1 -pos 0 0 -size 800 480 -mem 192000 -en 1 ");
	system("fbset -fb /dev/fb1 -g 400 240 400 240 16");
	fbdev 	= open("/dev/fb1", O_RDWR);
	scrn_ptr = mmap(0,400 * 240 * 2, PROT_WRITE | PROT_READ, MAP_SHARED, fbdev, 0);

        double_buffer = create_system_bitmap(screen->w, screen->h);

//--------- after drawing to double_buffer ---------//

     // copy from our buffer to hardware framebuffer
     unsigned long src_px_addr = double_buffer->line[0];
     src_px_addr = bmp_read_line(double_buffer,0);
     memmove(scrn_ptr, src_px_addr, 400*240*2);

//-------- on app exit --------------------//

	munmap(scrn_ptr, 400*240*2);
	close(fbdev);
	system("ofbset -fb /dev/fb1 -pos 0 0 -size 0 0 -mem 0 -en 0");

This gives us a -fast- full-screen mode to work with.
 
Nice :) Thanks for posting.
I use Allegro from time to time, the API seems nicer than SDL, probably because I started using it first. It's nice to know that this is possible.
I'm guessing it wouldn't be too much work to hide this inside the Pandora Allegro port in case a 400x240 screen mode is selected.

Wish I had a pandora to try, fingers crossed for the next batch....

This is also a nice illustration of drawing directly to the framebuffer, somthing I've never had to do before, it's good to see how easy it can be.
 
Back
Top