In my current build this code is working correctly. Please let me know if you have problems after today's update.
Two things to remember:
A window with a framebuffer will not be deleted until after two calls to World::Render with a different framebuffer, because it has to make a round-trip to the rendering thread and back to delete the window's graphics context before the window is deleted.
You don't have this problem in your code, but remember to clear out events to prevent windows from being stuck in memory.
#include "UltraEngine.h"
using namespace UltraEngine;
int main(int argc, const char* argv[])
{
//Get the displays
auto displays = GetDisplays();
shared_ptr<Window> window;
shared_ptr<Framebuffer> framebuffer;
shared_ptr<World> menuWold;
//Create a window
window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR);
//Create a world
menuWold = CreateWorld();
//Create a framebuffer
framebuffer = CreateFramebuffer(window);
//Create light
auto light = CreateBoxLight(menuWold);
light->SetRange(-10, 10);
light->SetRotation(15, 15, 0);
light->SetColor(2);
//Create camera
auto camera = CreateCamera(menuWold);
camera->SetClearColor(0.125);
camera->SetPosition(0, 0, -3);
camera->SetFov(70);
//Create scenery
auto box = CreateBox(menuWold);
int x = 0;
//Main loop
while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
{
while (PeekEvent()) WaitEvent();
if (window->KeyHit(KEY_SPACE))
{
x += 100;
window = CreateWindow("Ultra Engine", x, x, 800, 600, displays[0], WINDOW_TITLEBAR);
framebuffer = CreateFramebuffer(window);
}
menuWold->Update();
menuWold->Render(framebuffer);
}
return 0;
}