CPU spikes on OSX with SDL and OpenGL

Started by
3 comments, last by Jack Sotac 16 years, 9 months ago
Hey everyone, I'm having a problem with my game under OSX. Every so often, at completely random intervals, the game will freeze for a few hundred milliseconds, which is a big problem since my game is very twitch based. The game runs at about 90 fps normally, with only around 20% cpu usage, so there is plenty of cpu to go around. When I run the game on windows xp, the problem goes away. Here is a very high level view of my game loop. for(;;){ clear screen and depth buffer update game logic draw game SDL_GL_SwapBuffers();//copy back draw buffer to screen SDL_Delay(5);//wait 5 ms, needed to keep from pegging the cpu at 100% on windows } note that removing the SDL_Delay does nothing to the freeze problem on osx. Anyone have any ideas?
Infested Furbyinfestedfurby@hotmail.cominfestedfurby.cjb.net
Advertisement
What computer / OS are you running? I've had cases of this sort of thing with my older mac in any game.
Are you processing SDL events? Sometimes the OS X version of SDL is kind of weird if you're not at least pumping the event queue.
Yeah, I call SDL_PumpEvents() every frame.
I'm running OSX 10.4.9 on a 2ghz (core duo) Intel MacBook with 512 megs of ram.
Infested Furbyinfestedfurby@hotmail.cominfestedfurby.cjb.net
Have you tried using SDL_PollEvent() instead? Are you using multiple threads. Does the windowsXP machine run on dual or single core? Try setting CPU affinity to run program on one core. Anything running in the background on the Mac(updaters/monitors). Have you tried running a empty loop without running the gamelogic to see if the hiccup still exist?

0xa0000000

This topic is closed to new replies.

Advertisement