allegro flicker problem(mappy)

This is a discussion on allegro flicker problem(mappy) within the Game Programming forums, part of the General Programming Boards category; Hey, I just created a jetman like game using allegro and c. I used Mappy to create the map and ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    84

    allegro flicker problem(mappy)

    Hey,
    I just created a jetman like game using allegro and c. I used Mappy to create the map and stored it as a .fmp file.
    The problem is that there is alot of flickering in the game, even though im using a double buffer. I even tried using hardware acceleration and i still have the same problem. I tried using another (much larger) map and the game works perfectly.
    does anyone know what the problem could be with the current map i am using.
    Would it help if i stored the map as an array and read the values directly ?
    Thanks!

  2. #2
    verbose cat
    Join Date
    Jun 2003
    Posts
    209
    I am not familiar with the Allegro library, so you will need to refer to the documentation for specifics. However, there should probably be a way for you to tell the library to wait for a vertical retrace before pushing your back buffer to the display.

    Basically your monitor is displaying a "new" image x times every second (x is your monitor's refresh rate, for example 85Hz is 85 times each second). Each time it displays a new image, the electron gun moves quickly from left to right for each line, and top line to bottom line for the screen. Then it has to travel back to the start position at the top left of the screen before it can display the next image. This is the vertical retrace, and is when you want to have the back buffer copied to the display buffer.

    If you only push the back buffer to the display at this time (by having your program wait for a vsync signal, or whatever the Allegro library calls it) then you will not see any flicker. If you push the back buffer at any other time, then the electron gun is in the middle of drawing when the frame changes and causes the flicker you are seeing. (Flat panel displays don't use an electron gun, but it is the same principal.)

    By having your program wait for that vsync signal (basically a signal from the monitor that it is retracing) before pushing the back buffer to the front, your double buffer will work exactly as you are expecting. The worst case scenario is that it will take so long for your program to process the next frame that the monitor will redraw the screen several times before you are ready to push the back buffer. This would still not flicker, it would instead show up as a lower framerate (choppy movement).

    Unless the framerate drops down so low that you begin to notice the choppiness, you don't need to worry about improving the efficiency of how you read your map.

    This applies whether you are using Allegro, DirectX or any other graphics library. In the end it is displayed on the monitor so you have to bow to the physics of the monitor.
    abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    84
    Wow, Thanks ! i didnt know that...i always wondered what vsync() was! now i know ..although i was using vsync(); before i posted the message. The problem still remains whether or not i add/remove the vsync(); But i think theres a problem with the map..because..i tried using 3 other maps from my other games and all of them work perfectly!..the only difference was that all those maps were huge.. 15000 x 20 .. and this one is only 100 x 20. But those ones also use a background image in a loop , this one uses tiles throughout!..do you know what could be the reason for that ? I have a background and a foreground layer. I just discovered something, the map only flickers when i start scrolling ,i.e when the xoffset increases.. it doesnt flicker if i stay on the screen without moving.. ?

  4. #4
    verbose cat
    Join Date
    Jun 2003
    Posts
    209
    Another guess is that perhaps you have the wrong variable somewhere. Check to make sure you are not calling one or more drawing functions with the wrong buffer variable. If you are, then you are probably drawing those elements to the screen buffer rather than the back buffer. If it was only pushing the back buffer to the screen buffer during the vsync, then there should not be any flickering.

    Without seeing your code, we can only guess at what the problem might be.
    abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. installing and setting up Allegro
    By Emotions in forum Game Programming
    Replies: 11
    Last Post: 12-30-2004, 06:28 PM
  2. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 03:00 AM
  3. problem in allegro with sprite leaving trail
    By Leeman_s in forum C++ Programming
    Replies: 18
    Last Post: 09-13-2002, 04:04 PM
  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