allegro help - page flipping?

This is a discussion on allegro help - page flipping? within the Game Programming forums, part of the General Programming Boards category; i'm having some trouble with "page flipping" using allegro.. maybe i don't really understand the concept. i took a look ...

  1. #1
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176

    allegro help - page flipping?

    i'm having some trouble with "page flipping" using allegro.. maybe i don't really understand the concept. i took a look at the link from the allegro thread in the FAQ, but it didn't really help... i've got some code, but i'm sure a lot of it is off.. i did it mostly by copy/pasting and trial and error.. this finally compiled without errors, but won't run.. it crashes. if someone could point me to a tutorial, or an example program, or something, that would be great..

    here's the code i have

    Code:
    #include <allegro.h>
    
    BITMAP *Screen[3], *Buffer, *character[2];
    
    int main() 
    { 
    	// Initialize Allegro.        
    	allegro_init();      
    	set_color_depth(24); 
    	set_gfx_mode(GFX_SAFE, 800, 600, 0, 0);
    	install_keyboard();
    
    	bool vid=1;	
    
    	Screen[0]=create_video_bitmap(800,600);
    	Screen[1]=create_video_bitmap(800,600);
    	Screen[2]=create_video_bitmap(800,600);
    	Buffer=create_bitmap(800,600);
    	character[0] = load_bitmap("MyPicture.bmp", NULL);
    	character[1] = load_bitmap("MyPicture1.bmp", NULL);
    
    	while(!key[KEY_ESC])
    	{
    		clear_bitmap(Buffer);
    		draw_sprite(Buffer, character[vid], 400, 300);
    
    		blit(Buffer, Screen[vid+1], 0, 0, 0, 0, 800, 600);
    
    		show_video_bitmap(Screen[vid+1]);
    
    		vid = !vid;
    	}
    	
    	destroy_bitmap(Buffer);
    	allegro_exit();
    	return 0;
    }
    
    END_OF_MAIN();
    any help is appreciated.

  2. #2
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    follow the link in my sig, and it will take you to my site. there i have two basic, allegro tutorials along with a tutorial explaining the concept of double buffering. you might want to, also, take a look at the links i have up.

  3. #3
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    thanks! it seems like this is a lot easier than page flipping, so why would page flipping be used?

    is this code okay? or is there a better way to do this?
    Code:
    BITMAP *Buffer, *character[2];
    
    int main() 
    { 
    	// Initialize Allegro.        
    
    	int frame = 0;	
    
    	Buffer=create_bitmap(800,600);
    	character[0] = load_bitmap("MyPicture.bmp", NULL);
    	character[1] = load_bitmap("MyPicture2.bmp", NULL);
    
    	while(!key[KEY_ESC])
    	{
    		clear_bitmap(Buffer);
    
    		draw_sprite(Buffer, character[frame], 400, 300);
    
    		blit(Buffer, screen, 0, 0, 0, 0, 800, 600);
    
    		frame = !frame;
    	}
    	
    	destroy_bitmap(Buffer);
    	allegro_exit();
    	return 0;
    }
    this works fine, but is there a better way to do it?

    thanks for the help. now it's time to look into timers.. my little man's feet are gunna get tired

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 03:00 AM
  2. C Graphics - Page Flipping
    By z0diac in forum C Programming
    Replies: 1
    Last Post: 10-29-2002, 01:21 AM
  3. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM
  4. Page flipping
    By JoshG in forum Game Programming
    Replies: 8
    Last Post: 06-04-2002, 08:05 AM
  5. double buffering and page flipping question
    By stupid_mutt in forum C Programming
    Replies: 2
    Last Post: 01-30-2002, 01:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21