Dreikblack Posted March 11, 2024 Share Posted March 11, 2024 Normal look On my 2nd screen. Normal on 3rd one tho. Also UI mouse input works like if no offset happen #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> world; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> btn; shared_ptr<Widget> btn2; static bool EventCallback(const Event& e, shared_ptr<Object> extra) { Print("Callback"); return true; } void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(world, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.2f, 0.1f, 0.1f, 1.0f); 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); btn = CreateButton("Btn", 20, 20, 100, 100, ui->root); btn2 = CreateButton("Btn", 20, 150, 100, 100, ui->root); } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 300, 300, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world world = CreateWorld(); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0, 0, 0); initGui(); ListenEvent(EVENT_DATA, NULL, EventCallback, btn); auto color = Vec4(0.5, 0, 1, 0.5f); btn->SetColor(color); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); ui->ProcessEvent(ev); } world->Update(); world->Render(framebuffer); } return 0; } Quote Link to comment Share on other sites More sharing options...
Josh Posted March 11, 2024 Share Posted March 11, 2024 This requires two monitors to test? Do I just move the window from one to another? 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...
Josh Posted March 11, 2024 Share Posted March 11, 2024 The titlebars in your screenshots are a different size. It looks like the monitors are using a different display scale, which will give them a different framebuffer size. 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...
Dreikblack Posted March 11, 2024 Author Share Posted March 11, 2024 You are right. 2nd screen different display scale. Tried same - works as intended but impossible to use this screen because everything is too big then Quote Link to comment Share on other sites More sharing options...
Josh Posted March 11, 2024 Share Posted March 11, 2024 Is that the solution then? 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...
Dreikblack Posted March 11, 2024 Author Share Posted March 11, 2024 idk, such things should not happens no matter what dpi user have on screens imho Quote Link to comment Share on other sites More sharing options...
Josh Posted March 11, 2024 Share Posted March 11, 2024 It seems that your framebuffer size is changing if you move a window in between two screens with a different display scale, so you would need to reposition your 2D camera. 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...
Dreikblack Posted March 11, 2024 Author Share Posted March 11, 2024 Problem is a same with full GUI recreation when display changes including camera with code from another thread So probably Ultra takes DPI from first created window? Quote Link to comment Share on other sites More sharing options...
Josh Posted March 12, 2024 Share Posted March 12, 2024 I am mostly concerned at the prospect of the window client area changing size while rendering is happening on another thread. Will need to get out another monitor and test this some more... 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...
Dreikblack Posted May 5, 2024 Author Share Posted May 5, 2024 Is there a way to disable any dependency for UI from DPI scale and stuff? Even if i create app initionally on 2nd screen with 100% scale it's still have wrong offset if 1st had 125%. ui->SetScale(1.0f); does not help Quote Link to comment Share on other sites More sharing options...
Josh Posted October 31, 2024 Share Posted October 31, 2024 I can see this happening on my second screen. 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...
Josh Posted October 31, 2024 Share Posted October 31, 2024 Although the window size stays constant, the client size changes when moving in between displays with two different DPI scales: #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> world; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> btn; shared_ptr<Widget> btn2; static bool EventCallback(const Event& e, shared_ptr<Object> extra) { Print("Callback"); return true; } void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(world, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.2f, 0.1f, 0.1f, 1.0f); 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); btn = CreateButton("Btn", 20, 20, 100, 100, ui->root); btn2 = CreateButton("Btn", 20, 150, 100, 100, ui->root); } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 300, 300, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world world = CreateWorld(); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0, 0, 0); initGui(); ListenEvent(EVENT_DATA, NULL, EventCallback, btn); auto color = Vec4(0.5, 0, 1, 0.5f); btn->SetColor(color); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); ui->ProcessEvent(ev); } world->Update(); world->Render(framebuffer); Print(window->ClientSize().x); } return 0; } 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...
Josh Posted October 31, 2024 Share Posted October 31, 2024 When combined with the next update I will post, this code that adjusts the interface size and camera position will fix the problem. //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); ui->ProcessEvent(ev); if (ev.id == EVENT_WINDOWSIZE) { ui->SetSize(framebuffer->size); uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); } } world->Update(); world->Render(framebuffer); } 1 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...
Dreikblack Posted November 1, 2024 Author Share Posted November 1, 2024 Just in case, next update after last one (3h ago) or it was supposed to be fixed in latest beta? atm it's not working: #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> world; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> btn; shared_ptr<Widget> btn2; static bool EventCallback(const Event& e, shared_ptr<Object> extra) { Print("Callback"); return true; } void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(world, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.2f, 0.1f, 0.1f, 1.0f); 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); btn = CreateButton("Btn", 20, 20, 100, 100, ui->root); btn2 = CreateButton("Btn", 20, 150, 100, 100, ui->root); } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 300, 300, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world world = CreateWorld(); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0, 0, 0); initGui(); ListenEvent(EVENT_DATA, NULL, EventCallback, btn); auto color = Vec4(0.5, 0, 1, 0.5f); btn->SetColor(color); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); ui->ProcessEvent(ev); if (ev.id == EVENT_WINDOWSIZE) { ui->SetSize(framebuffer->size); uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); } } world->Update(); world->Render(framebuffer); } return 0; } Quote Link to comment Share on other sites More sharing options...
Josh Posted November 1, 2024 Share Posted November 1, 2024 Yes, it is working on my setup. Primary display: Second display: 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...
Dreikblack Posted November 1, 2024 Author Share Posted November 1, 2024 Primary 2k 125 scale, second 1080p 100% scale. On my second screen. Quote Link to comment Share on other sites More sharing options...
Josh Posted November 1, 2024 Share Posted November 1, 2024 Hmmm, I am getting a different result when I compile from the library and the source... 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 November 1, 2024 Solution Share Posted November 1, 2024 Change this setting in the project properties and it will work: 1 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.