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.

AppGameKit Classic Chat / Sync, Update, Render, Swap - Confused

Author
Message
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 9th Sep 2019 02:34
Hi,

Trying to improve HTML5 performance...

We looked at below, but are confused:
https://www.appgamekit.com/documentation/Reference/Core/Swap.htm

Can someone explain the following commands?:
1. Sync
2. Update
3. Render
4. Swap

Thanks!

Jesse
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
Qube_
9
Years of Service
User Offline
Joined: 21st Oct 2014
Location: Omnipresent
Posted: 9th Sep 2019 03:59 Edited at: 9th Sep 2019 04:00
In a nutshell Sync does 2, 3 and 4 in one go. For more control you have Swap but need to use 2 and 3 ( plus others ) depending on what other commands you are using like physics for example. Swap is used for when you want to manually control when the others are called ( see documentation for what each command handles ).

Bit confusing perhaps but Sync() handles everything in one go but Swap() allows finer control.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th Sep 2019 04:16 Edited at: 9th Sep 2019 04:17
an example of using render is when you are trying to grab an image
off of the screen eg render has to be called prior to any getimage
command if you used sync the drawn lines would be gone
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 9th Sep 2019 11:46
Can someone explain what each command does?
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 9th Sep 2019 12:30 Edited at: 9th Sep 2019 12:33
Quote: "1) Sync()

Updates the scene with the latest information, draws all sprites, updates global objects, and swaps the backbuffer into view. Does not draw sprites you have created using pointers in tier 2, you must draw these manually by calling the sprite's Draw function or assigning them to a sprite manager for batch drawing.



2) Update()

Updates all 2D and 3D objects based on the given time, animation, physics, etc. If time is 0 it uses the last frame time to step the simulation. If you have already called StepPhysics this frame it will not be called again for this frame. Called automatically by Sync, you may either use Sync or Update(), Render(), Swap() to manually sync. If you wish to have more control you can break this down further by replacing Update with Update2D, Update3D()



3) Render()

Draws all 2D and 3D created using an ID number to the current frame buffer. It does not swap the backbuffer to the screen. It does not draw sprites or objects you have created using pointers, you will either have to draw them individually or assign them to a sprite manager to batch draw them. In this case Render should still be called as it also draws the print text. Called automatically by Sync, you may either use Sync or Update(), Render(), Swap() to manually sync. If you wish to have more control you can break this down further and replace Render with Render2DBack, ClearDepthBuffer, Render3D, ClearDepthBuffer, Render2DFront



4) Swap()

Displays the back buffer to the screen and clears the backbuffer for the next frame, updates global time variables. Called automatically by Sync, you may either use Sync or Update, Render, Swap one after the other to manually sync. "


Straight from the documentation, so now you know just as much about them as we do.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-04-26 20:54:37
Your offset time is: 2024-04-26 20:54:37