reepblue Posted March 12, 2023 Share Posted March 12, 2023 Running through old samples we were testing during the beta and noticed that this example doesn't have the framebuffer fill the window anymore after it's been "resized". #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine - Normal", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); camera->SetViewport(200, 0, framebuffer->size.x - 200, framebuffer->size.y); auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); uiCamera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), iVec2(200, framebuffer->size.y)); ui->SetRenderLayers(2); auto sz = ui->root->ClientSize(); auto listbox = CreateListBox(5, 5, sz.x - 10, 200, ui->root, LISTBOX_DEFAULT)->As<ListBox>(); auto tabber = CreateTabber(5, 205, sz.x - 10, sz.y - 205, ui->root)->As<Tabber>(); tabber->AddItem("Settings", true); tabber->AddItem("Output"); tabber->SetLayout(1, 0, 1, 1); for (int i = 0; i < 100; i++) { listbox->AddItem("Item " + String(i)); } //Create a light auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); //Create a box auto box = CreateBox(world); box->SetColor(0, 0, 1); //Entity component system auto actor = CreateActor(box); auto component = actor->AddComponent<Mover>(); component->rotation.y = 45; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); ui->ProcessEvent(ev); switch (ev.id) { case UltraEngine::EVENT_WINDOWCLOSE: if (ev.source == window) exit(0); break; default: break; } } // Rebuild the window. if (window->KeyDown(KEY_SPACE)) { static bool bSwapped = false; framebuffer = NULL; window = NULL; if (!bSwapped) { // Make it a tad bigger window = CreateWindow("Ultra Engine - Resized", 0, 0, 1400, 800, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); framebuffer = CreateFramebuffer(window); } else { window = CreateWindow("Ultra Engine - Normal", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); framebuffer = CreateFramebuffer(window); } // Reposition the camera. uiCamera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); //Resize the interface ui->SetSize(iVec2(200, framebuffer->size.y)); bSwapped = !bSwapped; } world->Update(); if (framebuffer) world->Render(framebuffer); } return 0; } Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted March 15, 2023 Share Posted March 15, 2023 Confirmed... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted March 15, 2023 Solution Share Posted March 15, 2023 camera->SetViewport(200, 0, framebuffer->size.x - 200, framebuffer->size.y); If you call that code again after the new framebuffer is created, it works perfectly. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted March 17, 2023 Author Share Posted March 17, 2023 Ok, now there's an extra step but it makes sense. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.