Sign in to follow this  
TheNerdTk421

Allegro problems..

Recommended Posts

Ok... I am using Dev-C++ and Allegro.. I am try to display a bitmap.. Ive searched the forum and I found out that my code should work.. It compiles without error.. but i get a .. We have encountered an error with this program .. error...
#include <allegro.h>

void init();
void deinit();



int main() {
	init();

	while (!key[KEY_ESC]) {
          set_window_title("Bitmap Display");
   	      BITMAP *my_pic = NULL;
          my_pic = load_bitmap("mainchar.jpg", NULL);
          blit(my_pic, screen, 0, 0, 0, 0, 480, 360);
	}

	deinit();
	return 0;
}
END_OF_MAIN();

void init() {
     
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
}

void deinit() {
	clear_keybuf();
}

[Edited by - TheNerdTk421 on October 24, 2005 3:00:41 PM]

Share this post


Link to post
Share on other sites
You're trying to load a jpg file through Allegro, while it should be a bmp file. You'll need the JPG Allegro lib. So go to Downloads/Updates and select the Devpaks.org find the devpak called JPGalleg. Then download the library and include it in your project and you're set to go.

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