Jump to content

Panel texture not showing with 3D cam


SpiderPig
 Share

Go to solution Solved by SpiderPig,

Recommended Posts

While the example here works, it seems if you are overlaying an interface over a 3D environment the panel won't show the assigned texture.  I first noticed this in my project where I wanted to show the real-time render of a 2nd camera on the panel.

749502057_PanelTexture.jpg.0e47287fb18646db4db474dda0fc511c.jpg

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0]);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();
    auto font = LoadFont("Fonts/arial.ttf");

    auto ui = CreateInterface(world, font, framebuffer->size);
    ui->background->SetColor(0, 0, 0, 0);

    //Create and position camera
    auto camera = CreateCamera(world);
    camera->SetPosition(0, 1, -2);

    int RENDERLAYER_1 = 2;
    auto ui_camera = CreateCamera(world, UltraEngine::PROJECTION_ORTHOGRAPHIC);
    ui_camera->SetRenderLayers(RENDERLAYER_1);
    ui_camera->SetPosition(framebuffer->size.x / 2.0f, framebuffer->size.y / 2.0f);
    ui_camera->SetClearMode(UltraEngine::CLEAR_DEPTH);

    auto panel = CreatePanel(0, 0, 512, 512, ui->root);
    auto tex = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_diff_4k.dds");
    panel->SetTexture(tex);

    auto box = CreateBox(world);
    box->SetColor(1, 0, 0);

    while (true)
    {
        while (UltraEngine::PeekEvent()) {
            auto event = UltraEngine::WaitEvent();
            switch (event.id) {
            case UltraEngine::EVENT_WINDOWCLOSE:
                if (event.source == window) {
                    return 0;
                }
                break;
            }

            ui->ProcessEvent(event);
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

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