I am using a hp dv6000t laptop with a base install of Debian linux. It have a 256mb Geforce go 7400 nvidia graphics card. When I run my programs they get awful framerate. I have run some allegro examples and they all seem to run perfectly. It seems that just my programs lag. Why do they lag? It would be helpful if you told me exactly what to do as I am new to allegro and linux in general. I read somewhere that
using DGA 2.0 drivers made it fast or something. I have tried that but it had a segmentation fault. Thanks for your help in advance.
On Linux, I don't think there is any hardware acceleration of Allegro programs, therefore, if you wish for your programs to perform better, the only advice I can give it to write better code. Look into dirty rectangles for updating the screen and make sure you only blit objects which will actually be displayed.
How big is the framerate difference compared to windows?
What kind of bitmaps are you using (memory, system, video)?
Are you using lots of fancy effects (blending, trasparency)?
When I run my programs they get awful framerate. I have run some allegro examples and they all seem to run perfectly. It seems that just my programs lag. Why do they lag?
Post code. We can't tell what's different between your program and Allegro's examples without seeing them.
It would be helpful if you told me exactly what to do as I am new to allegro and linux in general.
Post code. We need to see what you're doing in order to be able to tell you if you're doing something wrong.
I read somewhere that using DGA 2.0 drivers made it fast or something. I have tried that but it had a segmentation fault.
DGA 2 allows you to use hardware acceleration in X11, but it's officially deprecated (in X11, not Allegro itself). Note that the driver requires root privileges and will fail to initialise if it can't get them (meaning you get a segfault if you don't check the return value of set_gfx_mode).
As you can tell the following is a pong ripoff. Please excuse my global variables and other bad code. I noticed that it only lags when i draw shapes to the screen not bitmaps. On my computer it runs smoothly for three seconds and then lags sooo badly.
variables.h file
misc.h
main.cpp
Loose the acquire/release screen functions and use regular blit to copy buffer to screen.
IIRC, acquire screen was good only when you had to access the screen bitmap several times per frame. Blitting buffer to screen does not qualify for such a situation.
You don't seem to be clearing the buffer each frame. Do you always redraw the entire screen every frame? From the code it doesn't look like that.
Also you might want to learn about allegro timers. Using only rest(1) for timing will not work for anyone else but you.
First off, get rid of all those acquire_screen()s. And as a side note, use blit instead of draw_sprite to copy the backbuffer to screen. Secondly, your desktop is likely running in 32-bit, so opening a 16-bit window may cause further slowdowns. On an unrelated but vital note, you don't seem to have any kind of timer logic.
EDIT: Oh, you think you're clever, do you HoHo? I'm gonna cut you. grumbles
It still lags. Good someone post code that runs at a decent rate on linux. Theres seems to be a bit of a increase in performance but nothing vary noticable.
What's the FPS you are getting?
3-4 at best. Could some one post code?
That wouldn't help. What's your code look like now?
Ok sorry, it did in fact increase performance considerably. But it still gets sub par performance. When I move the paddles its kinda of jumpy. Heres my code.
main.cpp
misc.h
variables.h
You still haven't changed your color depth to 32-bit (assuming that's what your desktop is running). Also, are you running this as root? And, finally, make some proper timing logic. rest() is not a good way to do timing.
I compiled and tested your code and it ran rather nicely on my Linux box in both, 16bit and 32bit when my desktop was 32bit. I think it was around 200-400FPS. It might be because my CPU is quite a bit above the average though.
Also, do you know your rest() doesn't work at all? Problem is you don't install timers. Of cource rest() is not the thing to make your game play at decent framerate. Please learn about timers and proper frame rate keeping. You can start by reading this:
http://www.allegro.cc/forums/thread/589396
Ok I think I added some timers correctly. It runs alot better now. Why does my fps flux? Anyway heres my code. for some unknown reason when I post my code it gets
lots of spaces in it. Just wondering why?
main.cpp
misc.h
</code>