GDI programming with Allegro

This is a discussion on GDI programming with Allegro within the Game Programming forums, part of the General Programming Boards category; So how is it done? I've tried this only to get a messagebox stating that I don't have Direct X ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    380

    GDI programming with Allegro

    So how is it done?

    I've tried this only to get a messagebox stating that I don't have Direct X 8. Maybe someone could post a simple sample. Also, I'm using the Borland 5.5 compiler.

    I've taken the sample posted by Justin_W and tried modifying it.

    Code:
    #include <allegro.h>
    
    int main() 
    { 
     // Initialize Allegro.        
     allegro_init();
    
    
     // Set the resolution to 640 by 480 with SAFE autodetection.
     set_gfx_mode(GFX_GDI, 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();

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    Hmm, that is really odd, especially since my installer sets Borland up with what it needs of the DirectX SDK. Try the following instead of GFX_GDI: GFX_AUTODETECT_WINDOWED

    Also, you shouldn't need this, but you might try making the #includes look like this:

    #include <allegro.h>
    #include <winalleg.h>

    Let me know if any of that helps.

    (For more help support, you might also try the forums at www.allegro.cc)

    -Justin
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    I know why I get the error message. Its because I don't have the Direct X runtime files. The reason for this that in the past when I have tried a coincidence of hardware failure occurred. I'm looking at GDI as a alternative to Direct X. Unless Allegro for windows is all built on it. Of course your suggests and everything else won't work cause of this.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    If you set it to GFX_GDI, then the video should definitely be going through plain old GDI. Thus the error is confusing. Please try the two things I suggested and tell me the result, perhaps we can narrow down the trouble.. (and again, you might try allegro.cc forums, as someone else there may have experienced this before.)
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Trying both possible solutions I still get the same results. A error message pops up stating that it can't find the "dinput.dll" file. Also, I am compiling this using the batch file. If it matters I'm using Windows 95.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    Oh right, I see it now. "dinput" is referring to DirectInput, which is used in the example program here:
    install_keyboard();
    You have to set it to only use GDI functions, even for input. This is unfortunately a tad trickier. You can use:
    install_keyboard_hooks()
    (from the keyboard docs) and tie it in with the message loop. See the Windows docs for more info on this. As for an example, I haven't played with this yet, and it will probably take a bit of time, but I think I'll look into it this comming weekend... unless you've figured it out by then.

    Hope that helps, sorry it isn't quite an easy fix.
    -Justin
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows GDI vs. Java Graphics
    By Perspective in forum Windows Programming
    Replies: 7
    Last Post: 05-07-2007, 11:05 AM
  2. Allegro, OpenGL.. or even DirectX?
    By Zeusbwr in forum C++ Programming
    Replies: 1
    Last Post: 11-14-2004, 08:16 AM
  3. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 03:00 AM
  4. double buffering for allegro
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 09-12-2002, 03:45 PM
  5. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM

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