Jump to content
  • Advertisement
Sign in to follow this  
Hakiko

Having problems exiting from Allegro programs

This topic is 4997 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there any reason this code should not work: while(! key[KEY_ESC]) poll_keyboard(); // Exit program. allegro_exit(); return 0; } END_OF_MAIN(); It seems to work if I print text to the screen but if I draw a line I have to alt-Tab out and close it in the processess manager using ctrl-alt-del I can't seem to figure out why. I took a Hello World program that worked. Deleted the textout() lines and made one hline() command. It draws the line but I cannot exit.

Share this post


Link to post
Share on other sites
Advertisement
#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();

// Draw a line
hline(screen, 100, 100, 300, 10);

// Looping until the ESCape key is pressed.
while(! key[KEY_ESC])
poll_keyboard();

// Exit program.
allegro_exit();
return 0;
}


END_OF_MAIN();

Sorry thought I copied the whole thing.

Share this post


Link to post
Share on other sites
Think I may have found my problem.
For some reason when I seem to need to use void main(void) if I am drawing but int main() if I am writing text.
I do not understand why though. The book I have doesn't even mention that the change was made.

Share this post


Link to post
Share on other sites
Hmmm that only worked once.

OK I think the real problem is that the first time I run a program I can exit properly. If I run it again, even if I make a change and recompile it won't quit corectly.

Share this post


Link to post
Share on other sites
Try compiling that program in that link I posted and see if it works correctly or not. If it does, start with that and slowly remove stuff, until you are left with something that does not work. Then you should be able to compare.

Share this post


Link to post
Share on other sites
Still getting the same problem.
I also noticed on the manager list when I went to stop the process that it is using 3 megs of memory. This seems a little high for a horizontal line on a black background.

Share this post


Link to post
Share on other sites
Ok if I put a rest(30) in the while loop it works well and cuts down on the memory usage a good bit. Thanks for your help. I never would have played around with the while loop if it wasn't for your post.

Share this post


Link to post
Share on other sites
No problem. I still can't see why something so simple as this is not working correctly. Do you have the most recent version of Allegro installed? Also what IDE are you using? On this tutorial here, they do things a little different. Try to do this:

while( !key[KEY_ESC] )
{
acquire_screen();// Get the screen
hline(screen, 100, 100, 300, 10);
release_screen();// Release it
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!