Runtime problem
Kevin Adrian

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.

gnolam

Show code.

GullRaDriel

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.

Kevin Adrian

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.

Audric

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

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

Kris Asick

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

Kevin Adrian

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

Thread #586947. Printed from Allegro.cc