SetCurrent

This function sets the current world. The current world is the world used when a new entity is created or loaded from a file.

Syntax

Parameters

Example

#include "Leadwerks.h"

using namespace Leadwerks;

World* myworld[2] = { NULL };

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

for (int i = 0; i < 2; i++)
{
//Create a world
myworld[i] = World::Create();

//Create a camera
Camera* camera = Camera::Create();
camera->Turn(35, 0, 0);
camera->Move(0, 0, -3);

//Create a directional light
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);

//Create a model
Model* model = NULL;
if (i == 0)
{
model = Model::Box();
}
else
{
model = Model::Cylinder();
}
model->SetColor(0.0, 0.0, 1.0);
}



while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

//Press space key to switch between worlds
if (window->KeyHit(Key::Space))
{
if (World::GetCurrent() == myworld[0])
{
World::SetCurrent(myworld[1]);
}
else
{
World::SetCurrent(myworld[0]);
}
}

Leadwerks::Time::Update();
World::GetCurrent()->Update();
World::GetCurrent()->Render();
context->Sync(false);

}
return 0;
}