Thread: ALLEGRO Question

  1. #1
    Unregistered
    Guest

    Unhappy ALLEGRO Question

    Hello...after reading several posts on this board I went hunting and grabbed all the components of the DJGPP compiler as well as the Allegro add-on. I can get all the Allegro examples to run (this I take as proof that I have installed it correctly =) and if I follow an example exactly I get the correct result. But with the following example only gives me a white screen...no errors during compile and it ends cleanly

    #include <stlib.h>
    #include <stdlib.h>

    #include "allegro.h"

    int main()
    {
    BITMAP *scr_buff;
    allegro_init();
    install_keyboard;
    set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
    set_pallete(desktop_pallete);
    scr_buff = create_bitmap(320, 200);
    clear(scr_buff);
    vline(scr_buff, 100, 20, 150, 255);
    // I have tried every primitive routine that uses the bitmap pointer
    // not sure if I am doing something wrong here
    destroy_bitmap(scr_buff);
    readkey();
    return 0;
    }

    Please if anyone has a suggestion let me know...it is getting very
    frustrating.
    BTW I am running win 98 and using a voodoo 3 2000 agp video card..maybe that has something to do with it.
    TIA

  2. #2
    Unregistered
    Guest

    Unhappy

    Opps....didn't mean to cross-post but at first I was thinking this was a c question but then thought no it should be a graphics question **sorry**

  3. #3
    Ethereal Raccoon Procyon's Avatar
    Join Date
    Aug 2001
    Posts
    189
    I don't see anything wrong with the code, but I just switched to DJGPP a week ago so I'm still learning it as well. Have you tried recompiling the example programs without altering them? If the executables work obviously it's not the fault of hardware incompatibilities, so there is probably something wrong with your code or compiler. If you can't recompile the example sources, there's something wrong with the compiler; otherwise you just made an error in the code. That's really all I can say...


    Edit:

    Actually, I think I just figured it out. Replace scr_buff with screen in your primitives calls. I think screen is a global variable which points to the video memory; use that if you want to see your output.

  4. #4
    Unregistered
    Guest
    You're right replacing the scr_buff with screen did work...and yes I can make all the examples compile and run. Now it would seem I am confused with allegro. Why create a pointer to the video memory you carve out and use it as a passing arguement if screen will work as a global...do you even need to create a bitmap if you use 13h?

    hmmmmm.....

  5. #5
    Unregistered
    Guest
    You don't need to create an additional bitmap for using graphics primitives; I think the global screen bitmap should take care of it entirely on its own.

    However, if you want to load sprites, backgrounds, tilesets, and textures in from disk and keep them in memory (an absolute necessity for most games) you'll need your own additional bitmap objects to store them in before blit-ing to the screen.

  6. #6
    Ethereal Raccoon Procyon's Avatar
    Join Date
    Aug 2001
    Posts
    189
    Sorry; for clarification, that was my post. For some reason I wasn't logged in.

  7. #7
    Registered User
    Join Date
    Aug 2001
    Posts
    2

    Lightbulb

    um, your going to kick yourself for this mistake but you forgot to blit the scr_buff to the screen.

  8. #8
    Unregistered
    Guest

    Angry No

    No

  9. #9
    Registered User
    Join Date
    Aug 2001
    Posts
    403

    the reason you are creating another bitmap is to avoid flicker

    your code should run like this

    while(ingame)
    {
    update_logic(); //update positions of players and make sure player doesn't want to exit
    draw_to_buffer(); //draw all the players and enemies to buffer

    vsync();
    blit_from_buffer(); //draw buffer onto screen
    }

  10. #10
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    yes, double buffering [or even more complicated buffering systems] can be a great advantage. fortunately, allegro has conventions for implementing them quite easily... doing it manually is not always an easy task...

    when i built my allegro library in my own system, i did get a lot of warnings... which i could not all prevent... so take heed if you have any further difficulties...
    hasafraggin shizigishin oppashigger...

  11. #11
    Registered User
    Join Date
    Aug 2001
    Posts
    2
    im friggen telling you, the reason it isn showig up on the screen is because you are not drawing it directly to the screen.if you dont do that then you have to use the allegro blit function to "merge" the scr_buff with the screen bitmap.

    example...

    blit(scr_buff, screen, 0,0,320, 200);

    //i think thats right, might wanna double check.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Allegro Programming Question
    By xmltorrent in forum Game Programming
    Replies: 2
    Last Post: 08-24-2006, 02:45 PM
  2. Exam Question - Possible Mistake?
    By Richie T in forum C++ Programming
    Replies: 15
    Last Post: 05-08-2006, 03:44 PM
  3. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM
  4. Allegro Question
    By gnu-ehacks in forum Game Programming
    Replies: 2
    Last Post: 12-23-2001, 11:57 PM
  5. ALLEGRO Question
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 09-14-2001, 11:06 AM