I quickly threw together a drawing program in SDL and I am having a couple of issues with lag. The program lags really hard when the size is larger than about 700x700 pixels, and I cannot find anything other than a couple of SDL_BlitSurface calls to the 'image' surface in the step function. How long does SDL_BlitSurface take? Also the step function returns the image that I want to blit to the screen, as such I call SDL_BlitSurface to blit its return value to the screen surface. How much time would I save by passing the screen surface to my step function so that it can blit directly to the screen. Finally, the program works by drawing small circles at the cursor position every time step is called while the left mouse button is down. Unfortunately if you move the mouse fast enough you can cause small dots to be drawn instead of a continuous line. From testing I found that it seems like MS paint seems to draw a line from point A to point B when that happens, how can I do this fast enough to make it worthwhile? If you need any sections of the code just tell me.
Jump to Post
There's really only one way to be sure; you have to measure. Either with some kind of code analysis tool that monitors how long functions take, or by sticking in logging and recording the time, or whatever other ways you can think of, but trying to guess what's taking up …
All 3 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.