• Advertisement
Sign in to follow this  

SDL_UpdateRect() slow on Mac OS X

This topic is 4309 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, I have a small program that makes a rapid succession of calls to SDL_UpdateRect(), with only a small area to update each time. It runs like blazes on Linux and Windows, but it's a dog on Mac OS X. If I change the parameters to SDL_UpdateRect() to 0,0,0,0 (the whole window), the Linux and Win versions slow down to match the Mac version, which remains unchanged. This makes me think that the coordinates are being ignored on the Mac. I should add that I'm using the CVS version of SDL on the Mac, because I'm building from the command line, which isn't supported by the precompiled Mac version of the library; and 1.2.9 wouldn't compile on my system (this is on Mac OS X 10.4.5, PPC). Here's the program, if you'd like to try it: http://wmcbrine.webhop.net/print.tar.gz This is only my second SDL program. :-) The problem is in the randfill() function. (This is based on similar code in PDCurses' newdemo.c... I'm working on porting PDCurses to SDL, but I'm only in the research stage now.)

Share this post


Link to post
Share on other sites
Advertisement
I don't have a Mac so I really cannot debug the problem. What I can do is point you to the SDL source code.
Is the Max(QZ_UpdateRects()?) doing more work than the Linux(DirectFB_WindowedUpdate()?) and Windows(DX5_WindowUpdate()?) versions?
Does the source actually show the coordinates are being ignored?
Does enabling double-buffer(SDL_DOUBLEBUF) make any difference?
Do your timing methods have any bias in them?
Any difference between CVS and 1.2.9 versions of this function?

Good luck on your project.

Share this post


Link to post
Share on other sites
Thanks. I've managed to fix it by hacking SDL. Not ideal, but I guess I'll take that up with the SDL people...

Re: Timing methods, the difference isn't subtle: less than a second vs. over a minute. :-)

The source didn't show a problem, and double-buffering made no difference. But I found that it ran almost instantly if the window was in the background. So I tried commenting out the "if ( ! QZ_IsWindowObscured (qz_window) )" section in QZ_UpdateRects() in src/video/quartz/SDL_QuartzVideo.m, but that made no difference. Then I tried assuming the test was reversed, and that worked.

QZ_UpdateRects() looks the same in 1.2.9 and CVS. Maybe it's always been slow? I can't compare the performance since I can't build 1.2.9.

P.S. One more oddity: The window title doesn't appear, and the window doesn't get focus, until the program hits the event loop. Doesn't happen in Windows or Linux.

Share this post


Link to post
Share on other sites
Although it completely depends on how you're using SDL_UpdateRect, it might be a better idea to use SDL_Flip to make use of SDL's buffer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement