Thread: allegro

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    21

    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)

  2. #2
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644

    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();

  3. #3
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    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()...

  4. #4
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    >> He used allegro_init(), so he does not need allegro_exit().

    is that really true?
    What is C++?

  5. #5
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    It is true, that is what I was trying to say before

  6. #6
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    So when do you use allegro_exit() then?

  7. #7
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    Read the docs under Using Allegro, it is all there.

  8. #8
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    That was used for earlier versions and only there incase you don't want to use the method I've said

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Allegro in C for a newb
    By Ideius in forum C Programming
    Replies: 5
    Last Post: 12-29-2005, 04:36 PM
  2. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 02:00 AM
  3. double buffering for allegro
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 09-12-2002, 02:45 PM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-20-2002, 11:35 PM
  5. Allegro programming in a window
    By Person Man in forum Windows Programming
    Replies: 0
    Last Post: 11-16-2001, 03:23 PM