Allegro

This is a discussion on Allegro within the C++ Programming forums, part of the General Programming Boards category; Anyone know why this won't compile Code: #include <allegro.h> int main() { allegro_init(); install_keyboard(); set_gfx_mode(GFX_VGA,320,200,0,0); textout_centre(screen,font,"Ready. Beep.",160,100,255); readkey(); return 0; ...

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

    Allegro

    Anyone know why this won't compile

    Code:
    #include <allegro.h> 
    
    int main() 
    { 
    allegro_init(); 
    install_keyboard(); 
    set_gfx_mode(GFX_VGA,320,200,0,0); 
    textout_centre(screen,font,"Ready. Beep.",160,100,255); 
    readkey(); 
    return 0; 
    }
    i get the following errors
    Code:
    7 main.cpp 
    `GFX_VGA' undeclared (first use this function) 
    7 main.cpp 
    (Each undeclared identifier is reported only once 
    7 main.cpp 
    for each function it appears in.)
    and the linker errors of
    Code:
    g++: c:\my documents\jeff\tutorial\main.o: No such file or directory 
    g++: file path prefix `C:\DEV-C_~1\BIN\' never used
    thanx for your help??

    by the way I am using dev c++ IDE
    Last edited by kas2002; 06-17-2002 at 01:30 PM.

  2. #2
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    well first of all need

    &nbsp&nbsp&nbsp&nbsp END_OF_MAIN();


    after the closing braket of your main loop. And make sure you are including your liballeg.a file in your linker options.
    What is C++?

  3. #3
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Those linker errors basically mean nothing. Also, you have to use GFX_AUTODETECT, GFX_AUTODETECTWINDOWED, or GFX_AUTODETECTFULLSCREEN. The VGA flag won't work. Another thing, Dev-C++ uses
    Code:
    int main(int argc, char *argv[])
    not int main(). So you'll have to fix that
    Last edited by Quantrizi; 06-17-2002 at 05:34 PM.

  4. #4
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I use Allegro and Dev-C++ and I don't have to use the main with argument handling.

    And a better way to do your colors is

    makecol(R,G,B)

    where R is your R value, G is your G value, so on.

    And since you tried in GFX_VGA I am assuming you are using DOS. Dev-C++ is a windows compiler, take advantage of it. Windows games in Allegro run smoother, because they use DirectX for everything. Plus it's 32bit code instead of 16bit code. And the beauty of Allegro is, you won't have to change one line of code, except for maybe changing GFX_AUTODETECT to GFX_DIRECTX if you want it to always use hardware acceleration (another reason to use windows)

  5. #5
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    also, if you want to use AllegroGL you HAVE to use Windows or Linux, because it uses OpenGL.

    And while we are on the topic of Allegro.

    A dude on the Allegro forums says he got Allegro to compile on PS2 using the Linux kit. That would be cool to see. They are thinking of making an add-on for Allegro 5 (when it comes out) for taking advantage of the Emotion Engine of PS2, and it will include some PS2 assembly language code for blitting and stuff. I would get the add-on, except I need the Linux kit to do it.

  6. #6
    Registered User
    Join Date
    May 2002
    Posts
    208

    thanx

    thanx for the input. The reason I am using dos is because I am newto programing and I am not that comfortable with windows programing yet.

  7. #7
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    It doesn't really matter when you use Allegro w/ windows or dos.

  8. #8
    Registered User
    Join Date
    May 2002
    Posts
    208

    can anyone

    give a exapmle of what you are talking about cause I don't understand 100%
    just the same code as mine with the things I am missig???
    Jeff Paddon
    Undergraduate Research Assistant
    Physics Department
    St. Francis Xavier University

  9. #9
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    No, coding-wise the syntax is a little different from the DJPP compiler and Dev-C++ compiler, but they all function the same, so there really is no better-than || worse features between the two besides the fact the Windows can use Direct X for hardware rendering.

  10. #10
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    there are a FEW Windows specifics, as well as DOS specifics.

    And as I said earlier, the same code will work in DOS as Windows. I was making a RPG a while back in Allegro using DJGPP, then I transferred it to Windows. The ONLY line I had to change was set_gfx_mode(), I changed it from GFX_AUTODETECT to GFX_DIRECTX, although AUTODETECT works in Windows too, I just wanted hardware to be required.

    But the main reason I would convert to Windows, is speed, DirectX (unless you use AllegroGL, then you are using OpenGL), and support. With Win 2k and XP being more and more widespread, DOS is hard to support, since it's just emulated in those platforms.

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, 03: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, 02:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21