Hello all ,
I'm evert , and new to allegro. But i'm using allegro for my school project that needs to be finished in a few weeks. I've followed some allegro tutorials and I feld ready to start on my game.
So i started with selection stuff : drawing a selection box to select the units. But here comes the problem ; I'm drawing that box with 4 lines().
My code is allright and i'm having the same problems on code that some people from the irc channel have written for me.
The 'game' is just lagging like hell when i draw my selection box , also there is a big latency on the time my mouse moves , and the selection box is drawn on the screen. When i try it on a ubuntu live cd , it all works great.
So my code is just all-right .
I'm using gentoo linux , but I really don't know a solution or fix for this. Is there a list of required packages ? So i can check i'm not missing a stupid package ?
Already thanks , evert
Install your grafic card driver.
You have an Nvidia, Ati ?
I'm drawing that box with 4 lines()
Why not a rect()?
And do not draw directly to screen.
Draw to a buffer and blit the buffer onto the screen !
Wow , a lot of answers in a short period of time . Thanks already.
I'm having installed nvidia drivers , and it's working on the live cd wich even doesn't has got nvidia drivers.
evert@localhost ~/C++/GIP $ glxinfo |grep direct
direct rendering: Yes
So that's ok.
I'm ofcourse using a buffer , so not directly drawing to the screen. And without a buffer it also wouldn't have worked on that live cd.
Why not using a rect() ? The same problem is going on with a rect (only a bit less lagging) , and i'm going to implement in the future still some elements why i need that line in place of rect().
I'm evert
Prove it!
Anyway, do you have some example code that shows the problem (the smallest code sample you can write that compiles)? It's hard to say what's wrong without actually seeing the code in question.
Aside, what version of Allegro are you using?
Evert+1 !
Yeah. Now we do need some code to see what is going wrong.
_
Ok , here some code what normally needs to work. Like i said , the problem isn't the code ... Because it is working on other systems / live cd's.
edit : Hmm i see i'm not using 'line()' in this code (it isn't even my code , i got it from mimix on irc for testing) but this code has got the same lagging problem.
Can't reproduce the problem on my system (KDE/gentoo with an oldish kernel).
I'm inclined to say it's a problem with the way your system is set up rather than a problem with your code. Are there any other processes using up CPU time in the background?
I know it's a problem with my gentoo install, because with a live cd and by other people it is working....
There is no other proces using my cpu power , direct rendering is enabled , ... So i really can't see what's the problem
It worked fine for me, so I don't know what your problem is, but try:
1.) Compile with -O3
2.) Update your whole system
3.) Allegro uses software rendering, not OpenGL, so your graphics drivers are irrelevant (AFAIK...)
4.) Show us the compile command you are using
I hope you haven't re-emerged your GUI library like I told you on IRC, because I understood you were talking about selection boxes in GTK / Qt.
In case, I'm sorry for my misunderstanding
I'm compiling it with the following command :
g++ main.cpp unit.cpp 2dmath.cpp input.cpp gui.cpp game.cpp `allegro-config --cflags --static` -o risk
Hehe no problem about the miscomprehension , i've got recompiled my whole KDE , but that was not only and just for allegro. I needed it to do for some new use-flags etc.
Why are you static linking?
I'm not saying it's bad, just asking why. I usually only static link when I distribute a binary.
To be honest , i did it at the very first , when i got the 'compile command' from the allegro IRC channel. I was new to allegro and i didn't knew how to compile stuff with it.
After that i kept using the static , because it's easy to test that executable somewhere else. It's not doing some bad stuff as far as I know ?
so is it the mouse causing the delay or the drawing?
I suggest you remove stuff and retry to narrow it down, e.g. is it the timer, the rect, the drawing buffer, the mouse, etc.
But the same problem is happening with real basic test code they gave me at the Allegro IRC channel , so the problem isn't the code , neither my system. (I guess something in my gentoo).