Reputation: 103
I have written a program to draw Julia sets and store them in a .bmp file, using SDL 1.2, on windows 7. The program is designed to scan each pixel and draw a certain color, updating the screen regularly, and when that is done, to store the image in a file and wait for the user to exit.
The program compiles and runs OK. However, and this annoys me, after a while the screen will freeze, though the program keeps running. When all the computations are finished, the screen unfreezes, the file is stored correctly, and the program exits normally when the user quits. Also, if the user toggles the window before the calculations are finished and then comes back to it, the screen freezes.
The program itself requires a lot of CPU but very little memory.
Any idea how to fix this ?
Note : first posted on programmers.stackexchange but apparently that was not the right place for the question :-)
Upvotes: 0
Views: 748
Reputation: 8494
I suspect you don't process SDL events frequently enough when the program does the calculations. You need to add events polling inside your calculations:
SDL_Event event;
SDL_PollEvent( &event );
... // here handle mouse, keyboard and user events
Upvotes: 1