Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Runtime problem

This thread is locked; no one can reply to it. rss feed Print
Runtime problem
Kevin Adrian
Member #7,087
April 2006
avatar

I've written an Allegro game for the Linux OS. It runs fast and without problems. Now I'm going to compile this game for Windows. I could compile and link it successfully, but the game runs very slowly. I've already tried to set GFX_DIRECTX instead of GFX_AUTODETECT_FULLSCREEN, but that didn't solve the problem. I hope somebody can help me.

My mouth will speak words of wisdom; the utterance from my heart will give understanding. (Psalm 49:3)

gnolam
Member #2,030
March 2002
avatar

Show code.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

GullRaDriel
Member #3,861
September 2003
avatar

I second Gnolam, but you could start with some things before:

Check your GFX driver, are they up to date ?
Check your DirectX version

Tell us:

Your windows version
The compiler you use
The allegro version

Make a virus scan (hé, you are under windows, you never know ;-) )

Thanks.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Kevin Adrian
Member #7,087
April 2006
avatar

OS: Windows98
Allegro version 4.1
Compiler Mingw32

I've changed some things in my program, now it runs a little bit faster but even not satisfiable.

My mouth will speak words of wisdom; the utterance from my heart will give understanding. (Psalm 49:3)

Audric
Member #907
January 2001

This should have noticeable effects : acquire_bitmap()

manual said:

locking a DirectDraw surface is very slow, so you will get much better performance if you acquire the screen just once at the start of your main redraw function, and only release it when the drawing is completely finished

Kitty Cat
Member #2,815
October 2002
avatar

For better or worse. Used properly it may give you a boost, used improperly it will slow everything down (or worse).

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Kris Asick
Member #1,424
July 2001

My best guess, since you're switching from Linux to Windows, is that you're drawing each of your individual objects to the screen or a video bitmap without locking the memory using acquire_bitmap() and release_bitmap().

DirectX in Windows, like anything in Windows, does a ton of memory swapping, so in order to make large changes to a bitmap being accessed by the video card, it needs to lock the memory first, make its writes, then unlock it. Now, Allegro will do this locking and unlocking for you automatically, but will do it EVERY time you draw to a video memory surface if you haven't locked it manually.

So what you need to do is draw everything to a regular Allegro bitmap, then draw that bitmap to the screen each frame, OR put all your screen rendering code together, lock the screen, draw everything, unlock.

Be careful you don't do anything besides rendering between locking and unlocking a piece of video memory or the screen. If you do you could lock up or crash your program. (Or the system.)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Kevin Adrian
Member #7,087
April 2006
avatar

Thank you for your help. Now my game runs without problems.

My mouth will speak words of wisdom; the utterance from my heart will give understanding. (Psalm 49:3)

Go to: