I had some lag with mouse movements ( pollevent ) too.
I noticed my loop was reading ALL the events the computer gets, so it
took a lot of time to handle this all, until I stop moving the mouse (
for example ). ( If I made 3 circles, then stop, it was still moving the
cursor on the screen of the first circle, then the others stored in the
poolevent )
The hack I thought about was to flush the pool and get only the last
event ( mouse position ? ) so that was looking fine.
Maybe, when you hit a key, you don’t get only ONE event, but thousands,
just check your poolevent, what was the single significant event, and
consider there was only one … ( keypress, or several keypress )
I don’t know if I am wrong, and if it’s clear, but, for the mouse event
that was the problem.
Btw, it has been a long time since I’ve put my nose in SDL…
Les.
Muzero a ?crit :> Hi to all, i have a problem about performance of code:
im the main cicle of my application i use this code
while(true)
{
…
get_key();
}
where get_key() is so defined:
void get_key()
{
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_KEYDOWN: …
etc etc… i need get_key to allow interaction of the user with the application or to break the execution of code, but the problem is that this piece of code is really, REALLY slow, i have make some tests and it slows down the execution approximately the half!!! :((
how can refine this code in a faster version? Thanks a lot!!!
Muzero
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl