Allegro and multitasking
pav0

I wrote a game using Allegro for graphics and libnet for networking and it seems to have a serious problem with multitasking. When I run in Windows (98) two instances of the program, only the one on foreground seems to work. When both windows are 'unfocused', they work, but they're both updating screen very slowly.
When I run two windows in Linux, they work and communicate without lag, but they're still slow. The graphics are very simple, but it looks like my program is always eating 100% of CPU time.
What can I do to fix the problem?

(I'm setting switch_mode to BACKGROUND/BACKAMNESIA in Allegro, and I put rest(0) in the main game loop, like the manual advises).

ReyBrujo

Allegro always tries to use 100% of CPU. You need to call rest(1); inside your main loop to get a lower CPU usage. As for foreground only working, see set_display_switch_mode.

(Edited: It is rest(1), rest(0) yields CPU, which is something you don't want. As for SWITCH, set it AFTER setting the graphics mode, not before. Also, see Kitty Cat comment).

A J

rest(0) is saying to the scheduler, i'll rest if you have something else to do, else i'll continue.

rest(1) says to teh scheduler, i will rest 1 millisecond.

pav0

I changed the call to rest(1) and now it works well. Thanks for advice.

Thread #561126. Printed from Allegro.cc