Dreikblack Posted May 6, 2023 Share Posted May 6, 2023 Works fine in usual interface but throws an exception in case of UI in 3D rendering viewport. #include "UltraEngine.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", 0, 0, 640, 480, displays[0]); // Create a world auto world = CreateWorld(); // Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create ui camera auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); //Load a font auto font = LoadFont("Fonts/arial.ttf"); //Create user interface auto ui = CreateInterface(world, font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); //Create widget auto sz = ui->root->ClientSize(); auto combobox = CreateComboBox((sz.x - 300) / 2, (sz.y - 30) / 2, 300, 30, ui->root); for (int n = 0; n < 20; ++n) { combobox->AddItem("Item " + String(n), n == 0); } while (true) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WIDGETSELECT: Print("Item " + String(ev.data) + " selected"); break; case EVENT_WINDOWCLOSE: return 0; break; } } } 1 Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted May 12, 2023 Solution Share Posted May 12, 2023 The fix is incoming. Example for testing: #include "UltraEngine.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", 0, 0, 640, 480, displays[0]); // Create a world auto world = CreateWorld(); // Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create ui camera auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); //Load a font auto font = LoadFont("Fonts/arial.ttf"); //Create user interface auto ui = CreateInterface(world, font, framebuffer->GetSize()); ui->SetRenderLayers(2); auto button = CreateButton("TEST", 20, 20, 400, 30, ui->background); //Create widget auto sz = ui->root->ClientSize(); auto combobox = CreateComboBox((sz.x - 300) / 2, (sz.y - 30) / 2 + 100, 300, 30, ui->root); for (int n = 0; n < 20; ++n) { combobox->AddItem("Item " + String(n), n == 0); } while (true) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WIDGETSELECT: Print("Item " + String(ev.data) + " selected"); break; case EVENT_WINDOWCLOSE: return 0; break; default: ui->ProcessEvent(ev); break; } world->Update(); world->Render(framebuffer); } } 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...
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.