Sign in to follow this  
coden4fun

Double Buffering Allegro Error source code provided

Recommended Posts

I'm trying to make my Street Fighter II clone with a double buffer to hopefully make the graphics go faster, but when I applied the double buffer my splash screen to my menu didn't work at all. In fact, it worked well without the double buffer. It went to splash screen wait 3 seconds, then it went to my draw menu screen. But with the double buffer it goes straight to the menu and no matter how long you wait it either doesn't show the splash screen at all, or shows it for a split second, and that is it. What am I doing wrong here? If I comment out the draw menu then the buffer draws the splash screen just fine, but if I don't comment it out the way I have my switch statement then the it doesn't draw the splash screen, but goes straight to my menu. What is wrong with my code?
#include <allegro.h>
#include <stdlib.h>
 
//Global variables
int gold, white;
BITMAP *bmp;
BITMAP *buffer = NULL;
BITMAP *plr_slct;
PALLETE pallete;

int gameflag;


//loading our files
void LoadFiles()
{
	gameflag = 0;
	bmp = load_bitmap("images/sf2_logo.bmp", pallete);
	if(!bmp) allegro_message("Could load file");

}

//The Splash screen.
void Splash()
{
	//define the color for our text
	gold = makecol(255, 255, 10);	
	white = makecol(255, 255, 255);

	//draw the splash creen 
	draw_sprite(buffer, bmp, 200, 100);
	textout_centre_ex(buffer, font, "U.S. Gold", 320, 220, gold, 0); 
	textout_centre_ex(buffer, font, "Creative Materials", 320, 230, gold, 0);
	textout_centre_ex(buffer, font, "Presentation", 320, 240, gold, 0);
	textout_centre_ex(buffer, font, "Street Fighter  II", 320, 250, gold, 0);
	textout_centre_ex(buffer, font, "Is a Reg. Trademark of Capcom USA INC.", 320, 260, white, 0);
	
}

//draw the menu of the game
void drawMenu()
{
	rectfill(buffer, 0, 0, SCREEN_W, SCREEN_H, 15);

}

int main(void)
{
	allegro_init();
	install_keyboard();
	install_timer();
	srand(time(NULL));
	set_color_depth(32);
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	buffer = create_bitmap(640, 480);
	
	//Let's load some files needed.
	LoadFiles();
	
	

	//initialize video mode to 640x480
	rectfill(buffer, 0, 0, SCREEN_W, SCREEN_H, 0);


	//while the game is going on!
	while(!key[KEY_ESC])
	{   
		blit(buffer, screen, 0, 0, 0, 0, 640, 480);
		
		switch(gameflag)
		{
				case 0:
				{
					Splash();
					rest(3000);
					gameflag += 1;
					break;
				}

				case 1:
				{
					//drawMenu();
					break;
				}
		}
	}

	//end program
	 
	allegro_exit();
	return 0;

}END_OF_MAIN()

Please help me

Share this post


Link to post
Share on other sites
For those who are reading this I simply for got to se the color depth, and something else that was needed before calling the videomode. or I had call them after setting videomode which you can't do. Big no no. Either way everyone go to my bLeftTrigger get the_event.motion post

where i'm trying to use my xbox360 controller to control the mouse around on the screen, so I can make a tutorial putting XInput and SDL together, so no one else has to do what I've done for a straight 2 days.

Thanks,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this