Jump to content

UI is broken at one of displays. Fullscreen window creates only on display 0.


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

If i drag or create window at 2nd screen ui is looks broken, button can be pressed tho.

Also if i try to create full window at non main display it's still appears on main one.

Editor UI works fine on all displays.

Main screen:

image.thumb.png.cb96a5d36e400e56adda8bb2176b3bf3.png

Second screen:

image.thumb.png.20016ff43298a442a96aaf83543e6d92.png

Third screen:

image.thumb.png.510fb1eb0446ed79a88c093b61d69faa.png

#include "UltraEngine.h"

using namespace UltraEngine;

shared_ptr<Window> window;
shared_ptr<Framebuffer> framebuffer;
shared_ptr<World> menuWold;
shared_ptr<Interface> ui;
shared_ptr<Camera> uiCamera;
shared_ptr<Widget> btn;
shared_ptr<Widget> btn2;
bool fullscreen = false;
int displayId = 0;

void initGui()
{
    auto default_font = LoadFont("Fonts\\arial.ttf");
    ui = CreateInterface(menuWold, default_font, framebuffer->GetSize());
    ui->SetRenderLayers(2);
    ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);

    uiCamera = CreateCamera(menuWold, 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("Change display", (float)framebuffer->GetSize().x / 2, framebuffer->GetSize().y / 2, 200, 200, ui->root);
    btn->SetFontScale(2.0f);

    btn2 = CreateButton("Fullscreen", (float)framebuffer->GetSize().x / 2, framebuffer->GetSize().y / 2 - 100, 120, 30, ui->root, BUTTON_CHECKBOX);
    if (fullscreen) btn2->SetState(WIDGETSTATE_SELECTED);
}

void changeDisplay()
{
    auto displays = GetDisplays();
    displayId = ++displayId;
    if (displayId == displays.size())
    {
        displayId = 0;
    }
    if (!fullscreen)
    {
        window = CreateWindow("Ultra Engine", 0, 0, 1000, 1000, GetDisplays()[displayId], WINDOW_DEFAULT);
    }
    else
    {
        window = CreateWindow("Ultra Engine", 0, 0, displays[displayId]->GetSize().width, displays[displayId]->GetSize().height, displays[displayId], WINDOW_DEFAULT | WINDOW_FULLSCREEN);
    }
    framebuffer = CreateFramebuffer(window);
    initGui();
}

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    window = CreateWindow("Ultra Engine", 0, 0, 1000, 1000, displays[0], WINDOW_DEFAULT);

    //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);

    initGui();

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        while (PeekEvent())
        {
            const Event ev = WaitEvent();
            if (ev.source == btn && ev.id == EVENT_WIDGETACTION)
            {
                changeDisplay();
            }
            if (ev.source == btn2 && ev.id == EVENT_WIDGETACTION)
            {
                fullscreen = !fullscreen;
            }
            ui->ProcessEvent(ev);
        }
        menuWold->Update();
        menuWold->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

  • 3 weeks later...
On 1/1/2024 at 7:02 PM, Dreikblack said:

Also if i try to create full window at non main display it's still appears on main one.

Can confirm:

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the display
    auto displays = GetDisplays();

    //Create a window
    auto style = WINDOW_FULLSCREEN;
    auto window = CreateWindow("Example", displays[1]->position.x, 0, displays[1]->size.x, displays[1]->size.y, displays[1], style);

    auto ui = CreateInterface(window);

    //Main loop
    while (window->Closed() == false)
    {
        if (window->KeyDown(KEY_ESCAPE)) break;
    }
    return 0;
}

 

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

On 1/1/2024 at 7:02 PM, Dreikblack said:

Also if i try to create full window at non main display it's still appears on main one.

Fixed this part.

  • Thanks 1

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

  • Solution

I am going to close this because there is no way for me to investigate this further. Please let me know if any new information arises.

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...