![]() |
|
slow graphics, but move fast when window is moved |
peter walker
Member #8,572
April 2007
|
Hi everyone, I was hoping someone could help me. I am finding that my graphics routine is running slow. I converted my code from VC++ Windows GDI to Allegro and I am finding that there is a significant decrease in the speed in which the graphics is being updated on the screen. A snippet of my code is below. All it does is create a window and place 3 circles in the window and updates the location of those objects via the Update() function. The really strange thing is that if I move the window created by Allegro i.e. the window inwhich all the graphics is being displayed, the graphics move much faster. Would anyone know what is going on? Cheers, ----------------------------------
|
mEmO
Member #1,124
March 2001
![]() |
You should use the desktop color depth, use desktop_color_depth() to get it. --------------------------------------------- |
Archon
Member #4,195
January 2004
![]() |
You should control the execution speed of your program with rests. |
gnolam
Member #2,030
March 2002
![]() |
... no. No you shouldn't. Use proper timing. Not rest(). -- |
Neil Walker
Member #210
April 2000
![]() |
That code suggests you're drawing everything directly to the screen. Use a backbuffer instead, e.g. BITMAP* double=NULL; ... somewhere in initialisation... double=create_bitmap(SCREEN_W,SCREEN_H); void moveCircle(){ {... other routines} clear(double); for ( int i = 0; i < numberOfObjects; i++ ) { member<i>.Update( ); member<i>.Draw(double); // draws circle (screen, x, y, r, color); } blit(double, screen, etc, etc);
Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
peter walker
Member #8,572
April 2007
|
Thanks for the replies everyone. I'll incorporate the suggestions into my code and see how well it executes. Im away from my code till monday. I want the graphics to run as fast as possible. That is my primary aim - fast object movement - no rest or pauses in the program. Thanks again |
Kris Asick
Member #1,424
July 2001
|
Quote: You should control the execution speed of your program with rests.
Quote: ... no. No you shouldn't. Use proper timing. Not rest(). Actually, you're both right. Proper timing should be implemented using Allegro's timer system or the Windows High Performance Timer, but you should also add a rest(0) or Sleep(0) to the end of a program loop so that CPU time can be properly given to Allegro's other threads and to other programs running in the background. Also, if the application runs faster while you're moving the window than when not you might want to disable your background applications and see if one of them is eating up the resources your application wants. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Audric
Member #907
January 2001
|
peter walker said: I want the graphics to run as fast as possible. That is my primary aim - fast object movement - no rest or pauses in the program. OK for the idea of "timing your drawing code", but don't dismiss rest(0). If you don't explicitely yield to Windows when it's the best moment to do so, Windows WILL suspend your program at random moments, and it will cause an extra waste of time every time it's in the middle of a sensitive operation - like a screen redraw, with locked DirecX surfaces. |
Neil Black
Member #7,867
October 2006
![]() |
[n00b question] I've asked here before, but I still don't know how to use proper timing instead of rest() I'll probalby just go look it up in the manual though, so don't worry.[/n00b question]
|
Goalie Ca
Member #2,579
July 2002
![]() |
Aah.. time to spread the love of the wiki: http://wiki.allegro.cc/Timers note: as a community we really should post all answers to common (and not so common) questions on the wiki and points users to that. ------------- |
|