Sync
Refreshes the screen. If the optional vwait parameter is set to true, vertical syncing will be enabled, which will lock the screen refresh rate at 60 hertz and prevent screen "tearing".
Syntax
- void Sync(bool vwait=true)
Parameters
- vwait: if set to true, vertical syncing will be enabled, otherwise vertical syncing will be disabled.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
while (true)
{
if (window->Closed() || window->KeyHit(Key::Escape)) break;
Leadwerks::Leadwerks::Time::Update();
context->SetColor(0.0, 0.0, 1.0);
context->Clear();
context->SetColor(1.0, 1.0, 1.0);
context->SetBlendMode(Blend::Alpha);
context->DrawText("FPS: "+String(Leadwerks::Time::UPS()), 0, 0);
bool vsync = !window->KeyDown(Key::Space);
context->DrawText("VSync: " + String(vsync), 0, 20);
context->Sync(vsync);
}
return 0;
}