-
allegro
I finally got allegro installed in my computer. I tried it for MSVC++ and Borland 5.0 but there were always errors like unresolved external, missing '}' in allegro.h (??) etc. I got it now working for Dev C++ 4, but I can not execute some code now(It compiles correctly, but it crashes during execution)
The code is
Code:
#include <allegro.h>
int main()
{
// Initialize Allegro.
allegro_init();
// Set the resolution to 640 by 480 with SAFE autodetection.
set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
// Installing the keyboard handler.
install_keyboard();
// Printing text to the screen.
textout(screen, font, "Hello World!", 1, 1, 10);
textout(screen, font, "Press ESCape to quit.", 1, 12, 11);
// Looping until the ESCape key is pressed.
while(! key[KEY_ESC])
poll_keyboard(); // This shouldn't be necessary in Windows.
// Exit program.
allegro_exit();
return 0;
}
// Some Allegro magic to deal with WinMain().
END_OF_MAIN();
At first execution it worked, but now windows gives error
Any help appreciated.(By the way, i'm using XP)
-
Re: allegro
Code:
#include <allegro.h>
int main()
{
// Set the resolution to 640 by 480 with SAFE autodetection.
set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
Use int main(int argc, char *argv[]) if you are using dev-c++. Also, use this for gfx_mode:
Code:
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
Code:
allegro_exit();
return 0;
}
// Some Allegro magic to deal with WinMain().
END_OF_MAIN();
Use readkey(); instead of allegro_exit();
-
Why do you always say to use readkey() instead of allegro_exit()? They are two diferent things. He used allegro_init(), so he does not need allegro_exit(). Why would he need a readkey though?
Look at this part:
Code:
// Looping until the ESCape key is pressed.
while(! key[KEY_ESC])
poll_keyboard(); // This shouldn't be necessary in Windows.
That wait till you hit the escape key, so you don't need readkey()...
-
>> He used allegro_init(), so he does not need allegro_exit().
is that really true?
-
It is true, that is what I was trying to say before
-
So when do you use allegro_exit() then?
-
Read the docs under Using Allegro, it is all there.
-
That was used for earlier versions and only there incase you don't want to use the method I've said