Art of Concise Coding

I’ve had a slightly successful first day at my new job. Given to code review a game project for the iphone, I expected to dally a couple of days with getting myself upto speed. But being thrust immediately into bug fixing is what actually happened. Not that I’m complaining.

I had to fix 3 bugs, and guess what, they were ALL solved by commenting out extra lines of code. There were lines that were just not needed. I confess being a culprit of the same crime many times, being safe rather than sorry when the compiler throws a couple of value not initialized errors. But its a journey on the path of programming zen that comes with experience.

One of the bugs was that the iphone screen was flickering. Its a problem that is widely documented by many, just Google it. And many solutions work. I feel it might be helpful to some if I described what made the difference in this particular case. It was the case of some liberal usage of “swapbuffers”. As we all know, OpenGL can be configured with a timer which in turn processes each frame. When the framebuffers are ready with the data processed in that particular “loop”, the buffers are swapped, send to show up on the screen while we go back to the loop and process the next buffers. But calling the swapbuffers command repeatedly many times within each frame leaves the clearly visible flicker. Try keeping it down to only once each frame render.

Another small clue to solving that flickering problem you might be having…

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.