SetCurrent

This function makes a context the current context for drawing operations.

Syntax

Parameters

Example

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();

//Create a rendering context
Context* context = Context::Create(window);

//Set the current context (not needed, but here it is):
Context::SetCurrent(context);

while (true)
{
Context* context = Context::GetCurrent();
Leadwerks::Window* window = context->GetWindow();
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
context->SetColor(0, 0, 1, 0);
context->Clear();

//Draw a rectangle on the screen
context->SetColor(1, 0, 0, 0);
context->DrawRect(100, 100, context->GetWidth() - 200, context->GetHeight() - 200);

context->Sync();
}
return 0;
}