Ok, I'm currently moving from Dev-c++ to MS Visual C++ 2005 express edition. I've got it set up, with the microsoft platform SDK, and then followed this to install allegro:
http://wiki.allegro.cc/VisualCExpress2005
Anyway, I've got allegro sorted ok but when I declare a bitmap pointer using:
BITMAP *a = load_bitmap( "a.bmp", NULL);
This gives the error "This application has requested the runtime to terminate it in an unusual way."
Please help...
You need to check your return values:
BITMAP *a = load_bitmap( "a.bmp", NULL); if(!a) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Bitmap failed to load!"); exit(1); }
Once you do that, put a.bmp into the Debug or Release folder of your project directory.
Ok, this is weird but it says
"syntax error : 'if'
syntax error : missing ';' before '{'
'{' : missing function header (old-style formal list?)"
Thats only shown on the code you just posted.
Oh, of course. You can't load a bitmap on the global scope, you have to do it inside of a function. The reason is because allegro_init hasn't been called yet on the global scope, nor has set_color_depth or set_gfx_mode. So:
1 | BITMAP* a = NULL; |
2 | |
3 | int main(int argc, char* argv[]) |
4 | { |
5 | allegro_init(); |
6 | set_color_depth(32); |
7 | set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); |
8 | |
9 | a = load_bitmap( "a.bmp", NULL); |
10 | if(!a) |
11 | { |
12 | set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); |
13 | allegro_message("Bitmap failed to load!"); |
14 | return 1; |
15 | } |
16 | |
17 | destroy_bitmap(a); |
18 | return 0; |
19 | } |
Ok, I'm currently moving from Dev-c++ to MS Visual C++ 2005 express edition.
Why?
Because Dev-C++ is a bad IDE, MSVS has a great debugger, and it's free?
Oh, of course. You can't load a bitmap on the global scope, you have to do it inside of a function. The reason is because allegro_init hasn't been called yet on the global scope, nor has set_color_depth or set_gfx_mode. So:
BITMAP* a = NULL;
int main(int argc, char* argv[])
{
allegro_init();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
a = load_bitmap( "a.bmp", NULL);
if(!a)
{
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
allegro_message("Bitmap failed to load!");
return 1;
}
destroy_bitmap(a);
return 0;
}
I can't belive I missed that. Thanks! BTW: MSVS IS free but requires registration. It's more stable, easier to use(for example on really long peices of code, voids can be minimized) and the debugger really is supreme.
It requires registration? I never had to register for my copies...