Jump to content

In widgets font var is nullptr


Go to solution Solved by Josh,

Recommended Posts

Posted

Also GetFont() method would be nice to have for Interface

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();
    //Create window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0]);
    //Create framebuffer
    auto framebuffer = CreateFramebuffer(window);
    //Create world
    auto world = CreateWorld();
    //Create main camera
    auto camera = CreateCamera(world);
    camera->SetPosition(0, 0, -3);
    auto font = LoadFont("Fonts/arial.ttf");
    //Create user interface with a semi-transparent background
    auto ui = CreateInterface(world, font, framebuffer->size);
    ui->background->SetColor(0, 0, 0, 0.5);
    //Create widget
    iVec2 sz = ui->background->ClientSize();
    auto button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui->background);
    //Create camera
    auto orthocamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    orthocamera->SetClearMode(CLEAR_DEPTH);
    orthocamera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0);
    //UI will only appear in orthographic camera
    orthocamera->SetRenderLayers(2);
    ui->SetRenderLayers(2);

    if (!button->GetFont())
        Notify("Font is null");
    else
    {
        Notify("Font is not null");
    }
    while (true)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

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

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

  • Solution
Posted

This is a protected member that was meant for possible future development. I am making this member private.

I also added a read-only font member to the Interface class. This will only be non-NULL when a 3D GUI is created.

  • Thanks 1

Let's build cool stuff and have fun. :)

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