|
Allegro Linux slower than Allegro Windows? |
jamyskis
Member #6,557
November 2005
|
Hi all, I've been writing a simple Space Invaders game in Allegro and managed it perfectly under Linux. It runs at a respectable pace and is fairly bug free. When I tried to compile it under Windows however, it runs at a blinding, unplayable speed. The thing I tried first of all was to see if this problem reproduces itself under Linux, by removing the vsync() from the game loop. Nope - the game runs at exactly the same speed. I've tried a number of solutions for controlling the speed of the game (including install_int(60,game_display); install_int(60, update_logic); ) which does absolutely nothing under Windows and SEGFAULTs under Linux. Is Allegro Linux generally slower than the Windows version? Funny, because the opposite is true for SDL, where the Windows version is chronically slow! __________________________________________________________________ |
BrknPhoenix
Member #7,304
June 2006
|
I think you should look at your timer code again... I'm using windows and timers control the speed of my stuff just fine |
Evert
Member #794
November 2000
|
Quote: When I tried to compile it under Windows however, it runs at a blinding, unplayable speed. Post the smallest sample program that reproduces the behavior. Quote: I've tried a number of solutions for controlling the speed of the game (including install_int(60,game_display); install_int(60, update_logic); ) which does absolutely nothing under Windows and SEGFAULTs under Linux. Then you are definately doing it incorrectly. Post your code. Quote: Is Allegro Linux generally slower than the Windows version?
No, but you do not get hardware acceleration using X11. This can reduce your framerate. |
gnolam
Member #2,030
March 2002
|
Show us your code. Your timing code, for example. -- |
Frank Drebin
Member #2,987
December 2002
|
in windows allegro uses directx in linux isn't such a thing. |
jamyskis
Member #6,557
November 2005
|
That's fair enough, the speed of the Linux version is fine for me anyway, although it strikes me as odd that the game always runs at the same speed whether it's chucking around 50-60 sprites or just 3. It also doesn't get affected by vsync(), as I've discovered from commenting it out in the code. Does Linux Allegro automatically vsync() regardless? Anyway, the code, including modifications to the Windows version was thus.
I know the code is extremely untidy and very amateurish, but then I am still quite newbie in these things. __________________________________________________________________ |
Archon
Member #4,195
January 2004
|
Quote: I've tried a number of solutions for controlling the speed of the game (including install_int(60,game_display); install_int(60, update_logic); ) which does absolutely nothing under Windows and SEGFAULTs under Linux. It would sound like you're putting a heap of coding in your timer functions and then calling them. You'll have troubles if the computer can't compute all of the calcultions in time for the function to be called again. Quote:
install_int(update_logic,6); Why do you have 2 timers? You just need 1 for the entire game! |
hazul
Member #4,338
February 2004
|
Are the timers really running at 6 msecs = 167 per second ?
* * * * * |
Jonatan Hedborg
Member #4,886
July 2004
|
you should never, ever, EVER put anything more than just a simple interger increment or similar in your timer functions. It is not multithreading, just a function that is called on a regular basis. (which will die if you try to call it again before it is done)
|
jamyskis
Member #6,557
November 2005
|
So basically the best way is to use the interrupts to change a bool variable from false to true and then call update_logic()/game_display() while the variable is true, changing it to false right at the end? __________________________________________________________________ |
Thomas Fjellstrom
Member #476
June 2000
|
No, you just increment a integer, and then follow the many examples of how to regulate the main loop execution.. -- |
Archon
Member #4,195
January 2004
|
Quote: So basically the best way is to use the interrupts to change a bool variable from false to true and then call update_logic()/game_display() while the variable is true, changing it to false right at the end? Use an integer to count how many 'ticks' you have missed, and then update_logic() that many times until there are none left, then draw the game. If your update_logic is too slow and that the ticks never reach 0, then you've got a problem... Also, you should probably have a maximum number of times the update_logic will execute before you force a redraw on the screen (in case there are say, 30 logic updates) you don't want to miss an entire second of the game - or maybe you do - it depends on the game. |
|