Allegro slowdown problem!?

This is a discussion on Allegro slowdown problem!? within the Game Programming forums, part of the General Programming Boards category; Code: while(1) { blit(maplayer[0], screenbuffer, 0, 0, 0, 0 , 640 ,480); Draw_Sprite(player.posx, player.posy, screenbuffer); for(i = 0; i < ...

  1. #1
    Master n00b Matty_Alan's Avatar
    Join Date
    Jun 2007
    Location
    Bloody Australia Mate!
    Posts
    96

    Allegro slowdown problem!?

    Code:
    while(1)
    {
    blit(maplayer[0], screenbuffer, 0, 0, 0, 0 , 640 ,480);
    
    Draw_Sprite(player.posx, player.posy, screenbuffer);
    
    for(i = 0; i < enemy_mem+1; i++)                                                   //draw the other sprites
    {
    Draw_Sprite(enemy[i].posx, enemy[i].posy, screenbuffer);
    }
    
    blit(screenbuffer, screen, 0, 0, 0, 0 , 640 ,480);
    }
    This is basicly the part i am having issues with... now the game runs at a decent speed if i comment out that first blit, however that blit copys the background onto to screen buffer then the sprites are drawn ontop... but by drawing the background makes the program run at a speed of about 2 frames a second, whats the deal with that!? Is this a timer issue because i currently don't have one set up...

    cheers matty

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    Is your background bitmap the identical pixel format to the screen?

    Because if it isn't, there's a hell of a lot of conversion work being done per frame.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Master n00b Matty_Alan's Avatar
    Join Date
    Jun 2007
    Location
    Bloody Australia Mate!
    Posts
    96
    You mean like colour depth? and pallete?
    the bitmaps I am loading are 24bit, and i have my set_color_depth(24);

  4. #4
    Master n00b Matty_Alan's Avatar
    Join Date
    Jun 2007
    Location
    Bloody Australia Mate!
    Posts
    96
    Ive just done some test and relized that the tiles are comming out strange colours!? so it has got something to do with that... but im not sure how to fix it

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    > You mean like colour depth? and pallete?
    > the bitmaps I am loading are 24bit, and i have my set_color_depth(24);
    Yes, something like that.
    Whatever it is, it doesn't sound optimal.

    The best-case blit() should be a thinly disguised memcpy(), which should take no time at all.

    If you've compiled your allegro from source, then try using the debugger to step into the blit code. See if you can work out which "expensive" choice it is making, then try to address that in your code so it picks a cheaper alternative.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    Is the color depth the same as your desktop? That might have an effect on it, although it is just speculation.
    -- Will you show me how to c++?

  7. #7
    Master n00b Matty_Alan's Avatar
    Join Date
    Jun 2007
    Location
    Bloody Australia Mate!
    Posts
    96
    Ahh i figgured it out, I was setting my colour depth and my graphics mode in the wrong order at the start of the program.

    Thanks for pointing me in the right direction

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  2. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  3. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  4. problem in allegro with sprite leaving trail
    By Leeman_s in forum C++ Programming
    Replies: 18
    Last Post: 09-13-2002, 03:04 PM
  5. Problem declaring struct in allegro
    By bobish in forum Game Programming
    Replies: 7
    Last Post: 03-08-2002, 08:26 AM

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