Jump to content

Child Widgets visible beside parent widget area


Go to solution Solved by Josh,

Recommended Posts

Posted

In 2D seems to be still working:

image.png.2e7fac76873e4909a486049641e8da8f.png

But in 3D:

image.png.555445340afd2984d9dbd9cb1201057c.png

#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> panel1;
shared_ptr<Widget> panel2;
shared_ptr<Widget> panel3;

void initGui()
{
    auto default_font = LoadFont("Fonts\\arial.ttf");
    ui = CreateInterface(world, default_font, framebuffer->GetSize());
    ui->SetRenderLayers(2);
    ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.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);

    panel1 = CreatePanel(20, 20, 100, 100, ui->root);
    panel1->SetColor(1, 0, 0, 1, WIDGETCOLOR_BACKGROUND);
    panel2 = CreatePanel(50, 50, 100, 100, panel1);
    panel2->SetColor(0, 1, 0, 1, WIDGETCOLOR_BACKGROUND);
    panel3 = CreatePanel(25, 25, 100, 100, panel2);
    panel3->SetColor(0, 0, 1, 1, WIDGETCOLOR_BACKGROUND);
}

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();
    world->SetAmbientLight(0);

    //Create a framebuffer
    framebuffer = CreateFramebuffer(window);

    //Create a camera    
    auto camera = CreateCamera(world);
    camera->SetClearColor(0, 0, 0);

    initGui();

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

  • Confused 1

Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

  • 2 weeks later...
Posted

Well, bottom clipping was fixed but suddenly there is still an issue if child widgets are at top :lol:

image.png.5a55819efc6a7cf09cc4a8847597babb.png

#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> panel1;
shared_ptr<Widget> panel2;
shared_ptr<Widget> panel3;

void initGui()
{
    auto default_font = LoadFont("Fonts\\arial.ttf");
    ui = CreateInterface(world, default_font, framebuffer->GetSize());
    ui->SetRenderLayers(2);
    ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.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);

    panel1 = CreatePanel(20, 200, 100, 100, ui->root);
    panel1->SetColor(1, 0, 0, 1, WIDGETCOLOR_BACKGROUND);
    panel2 = CreatePanel(50, -50, 100, 100, panel1);
    panel2->SetColor(0, 1, 0, 1, WIDGETCOLOR_BACKGROUND);
    panel3 = CreatePanel(25, -25, 100, 100, panel2);
    panel3->SetColor(0, 0, 1, 1, WIDGETCOLOR_BACKGROUND);
}

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

    //Create a window
    window = CreateWindow("Ultra Engine", 0, 0, 500, 500, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    world = CreateWorld();
    world->SetAmbientLight(0);

    //Create a framebuffer
    framebuffer = CreateFramebuffer(window);

    //Create a camera    
    auto camera = CreateCamera(world);
    camera->SetClearColor(0, 0, 0);

    initGui();

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

  • Haha 1

Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

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.

×
×
  • Create New...