Thread: BGI C Help!!!!

  1. #1
    Deseis
    Guest

    BGI C Help!!!!

    Hi
    Im using the borland turbo C/C++ compiler and i did some animation of a simple drawing that is 20*20 in size.
    Im using the getimage and putimage to put it up and redraw it in order to move it. I entered 2 objects to the buffers (with allocation) and it works ok when they are working seperately.
    But when im running them both onscreen they seem to...BLINK. when i disable one it moves smoothly...Now cant be that the bgi is too slow to run 2 objects smoothly?!
    I use a third empty buffer inorder to "delete" the former object position.
    it looks like this:
    while (ch!=27) {
    putimage(x,y,buff[1],COPY_PUT); //the object
    delay(7);
    putimage(x,y,buff[2],COPY_PUT); // Overrides the former with blank.
    y+=1;
    }
    thats basicly how it looks like (for 1 object).
    Like i said when i use a second one (in like different position of the screen to run arround it just blinks....HELP).
    Any idea?

    Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You need to wait for the vertical refresh before messing with the screen
    http://www.inversereality.org/files/verticalsync.pdf

    Basically
    - wait for vertical retrace (see the doc)
    - remove old
    - draw new

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you are not using a double buffer all of your images will blink. This is because each image will disappear, albeit for a very brief time, and reappear. I do not know how to use a double buffer in BGI graphics. But if you drop BGI and move to accessing the hardware directly I can help.

    Do what Salem says concerning the video refresh. Even with a double buffer if you do not wait for refresh you will get artifacts since you may be updating in the middle of a refresh. This, unfortunately, slows your graphics down to the rate of the refresh since you are waiting on the BIOS.

    Go to www.brackeen.com and drop the BGI idea. BGI is great for starting out but it is not designed for the kind of speed needed in games or animation. It is far easier to drop BGI. You'll be amazed at how simple it is to manipulate the graphic hardware.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BGI Error:
    By it4_saravana in forum C Programming
    Replies: 4
    Last Post: 04-12-2008, 02:48 AM
  2. BGI and text cursor
    By Somnambulist in forum C++ Programming
    Replies: 4
    Last Post: 01-21-2004, 07:54 PM
  3. BGI Graphics in Windows API
    By AtomRiot in forum Windows Programming
    Replies: 1
    Last Post: 07-29-2003, 05:32 PM
  4. BGI Error: Graphics not initialized (use 'initgraph');
    By Jasin14 in forum C Programming
    Replies: 4
    Last Post: 10-02-2002, 12:58 PM
  5. Borland C++ BGI
    By Xterria in forum Game Programming
    Replies: 10
    Last Post: 03-05-2002, 08:39 PM