Jump to content

Exception when i'm trying to create ComboBox in "3D" UI


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

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;
        }
    }
}

image.thumb.png.798d8c78eb79ff9009a16b04c57c270c.png

  • Thanks 1
Link to comment
Share on other sites

  • Solution

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

 

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...