Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

The 20 Line Challenge / [LOCKED] Bit confused by SYNC command, snippet attached...

Author
Message
NeilF
17
Years of Service
User Offline
Joined: 2nd Aug 2006
Location:
Posted: 18th Aug 2006 20:52
Can someone tell me if I understand this behaviour correctly...



Press the up arror key to prevent sync'ing
Press the down arror key to do an extra sync.

Now am I right in saying that basically SYNC actually freezes/pause the engine in some way?

This explains why just tapping the up key (doing no sync) send the cube's rotation mad. Because basically the code speeds up and rotates the cube madly.

The down key introduces a second sync into the loop, so rather than my cube rotating by a value of 1 per frame, now it only rotates by a value of 1 every 2 frames. Hence its speed halves.


I assume if by chance you run on a slow computer and the coding you're doing takes long than the 1/30 of second that you hoped it would, then the hole game would just slow down? So in a FPS shooter you could run a program in the background to use up CPU time, and you'd be able to play (cheat) in slow motion?


I also notice that the FPS is seemingly always 10% than asked for? ie: I ask for 30fps and get 33? I ask for 50fps and get 55?
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 18th Aug 2006 20:57 Edited at: 18th Aug 2006 20:58
This is the wrong place to post this, but you're new so I'll let you off...

I think sync is more of an UPDATE SCREEN command. Without it the screen will not update properly, thus skipping parts of the cube's rotation visually.

P.S. I'm not sure, wait for more responses.

Whisper Wind
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 18th Aug 2006 23:54
The point of the sync command, the way I understand it (not exactly how it happens, but exaplains the point of it...):

Every frame, all the objects in your scene are rendered to a frame buffer (a big array of pixels the same size as your monitor display settings) separate from what is being displayed on the monitor. When the scene has finished rendering to the frame buffer, the contents of frame buffer should be presented to the monitor all at once. This is so that you cannot see objects drawing to the monitor one at a time. It is also faster. The sync command is what presents the frame buffer to the monitor. Typically, you would use the sync command at the end of your game loop to present the newly written frame buffer to the monitor.

Searching for files named 'sanity'...
No files were found.

Login to post a reply

Server time is: 2024-04-24 03:06:25
Your offset time is: 2024-04-24 03:06:25