SDL lagging cursor image

Hello and thank you for any help you can offer.
I am currently using SDL to make a simple game. My problem lies in loading an image at the mouse position when it is moving. A very simple version of my frame loop is as follows:
showbackground(); //here I apply the background surface
updatemousepos(); /*this function updates my mouse position using event.type == SDL_MOUSEMOTION */
showcursor();//this applies an image at my cursor position


My problem is that the image at the cursor only shows once I stop moving the cursor or if I move it slowly. However if I continue to move the mouse quickly it will not show until I stop.
Any help would be greatly appreciated.
Thanks,
Ewan
Are you using SDL_PollEvent inside updatemousepos()? It's important that you handle ALL the events in the event queue because moving the mouse might generate many events. If you only handle one event each frame you might not get the most up to date position until much later.
1
2
3
4
5
SDL_Event event;
while (SDL_PollEvent(&event))
{
	// handle event
}
Thanks for the quick reply. This has sorted my problem and its working perfectly now, thanks very much
Topic archived. No new replies allowed.