Jump to content

Exception thrown at Render() if CustomWidget has blocks[i].SetPixmap(not member pixmap) in Draw()


Go to solution Solved by Josh,

Recommended Posts

Posted

I think block.SetPixmap work fine if a pixmap as member set in but with if it's another pixmap (to make few different icons for different blocks) i have an exception at Render(). An example:

#include "UltraEngine.h"

using namespace UltraEngine;

class NewWidget : public Widget
{
protected:
    virtual void Draw(const int x, const int y, const int width, const int height)
    {
        for (int i = 0; i < 4; i++)
        {

            blocks[i].hidden = false;
            blocks[i].position = iVec2(i * 64, 0);
            blocks[i].size = iVec2(64, 64);
            blocks[i].filter = pixmapfilter;
            blocks[i].color = Vec4(1);
            auto px = LoadPixmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/dirt01.dds");
            blocks[i].SetPixmap(px);
        }
    }

public:
    static shared_ptr<NewWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style = 0)
    {
        struct Struct : public NewWidget {
        };
        auto instance = std::make_shared<Struct>();
        instance->Initialize("", x, y, width, height, parent, style);
        return instance;
    }

    NewWidget()
    {
        blocks.resize(4);
    }
};

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

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

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

    //Create a world
    auto world = CreateWorld();

    //Create a camera    
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.6);
    camera->SetFov(90);
    camera->SetRotation(54.736f, 45, 0);
    camera->SetPosition(0, 4, 0);

    auto sz = framebuffer->GetSize();

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

    auto widget = NewWidget::create(0, 0, 64 * 4, 64, ui->root, 0);

    //Create light
    auto light = CreateBoxLight(world);
    light->SetRange(-100, 100);
    light->SetArea(100, 100);
    light->SetRotation(35, 35, 0);
    light->SetColor(2);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer, false);
    }
    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/

Posted

Try it like this:

class NewWidget : public Widget
{
protected:
    virtual void Draw(const int x, const int y, const int width, const int height)
    {
        if (blocks.size() < 4)
        {
            for (int i = 0; i < 4; i++)
            {
                auto px = LoadPixmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/dirt01.dds");
                int block = AddBlock(px, iVec2(i * 64, 0), Vec4(1));
                blocks[block].size = iVec2(64, 64);
            }
        }
    }

public:
    static shared_ptr<NewWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style = 0)
    {
        struct Struct : public NewWidget {
        };
        auto instance = std::make_shared<Struct>();
        instance->Initialize("", x, y, width, height, parent, style);
        return instance;
    }

    NewWidget()
    {
        
        
    }
};

 

  • Like 1
  • Thanks 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
  • Solution
Posted

OP did in fact find a bug. Fixed in next build.

Jonah Ray Franks 2Ktv GIF by Burger Records

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

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