Jump to content

Pixmap has no transparency in UI above 3D


Go to solution Solved by Josh,

Recommended Posts

Posted

In full 2D works fine but in 3D it's a black background in Pixmap area where should be transparent pixels.

Probably Vulkan things this time too? Just want to be sure if it will be fixed later in Ultra or i'm missing something.

image.png.c1f4e83ce38bafb453b72d0345f308dc.png

 

#include "UltraEngine.h"

using namespace UltraEngine;

void drawPixel(shared_ptr<Pixmap> pixmap, const int x, const int y, unsigned int color)
{
    if (pixmap && x >= 0 && x < pixmap->size.width && y >= 0 && y < pixmap->size.height) {
        pixmap->WritePixel(x, y, color);
    }
}

void drawCircle(shared_ptr<Pixmap> pixmap, const int centerX, const int centerY, const int radius, unsigned int color) {
    int x = 0;
    int y = radius;
    int delta = 1 - 2 * radius;
    int error = 0;
    while (y >= 0) {
        drawPixel(pixmap, centerX + x, centerY + y, color);
        drawPixel(pixmap, centerX + x, centerY - y, color);
        drawPixel(pixmap, centerX - x, centerY + y, color);
        drawPixel(pixmap, centerX - x, centerY - y, color);
        error = 2 * (delta + y) - 1;
        if (delta < 0 && error <= 0) {
            ++x;
            delta += 2 * x + 1;
            continue;
        }
        error = 2 * (delta - x) - 1;
        if (delta > 0 && error > 0) {
            --y;
            delta += 1 - 2 * y;
            continue;
        }
        ++x;
        delta += 2 * (x - y);
        --y;
    }
}

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto world = CreateWorld();
    auto framebuffer = CreateFramebuffer(window);

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(0, 0, -3);

    auto default_font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(world, default_font, framebuffer->GetSize());
    ui->SetRenderLayers(2);
    ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);

    auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    ui_camera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
    ui_camera->SetRenderLayers(2);
    ui_camera->SetClearMode(CLEAR_DEPTH);


    auto panel = CreatePanel(0, 0, 200, 200, ui->root);
    auto pixmap = UltraEngine::CreatePixmap(100, 100);
    drawCircle(pixmap, 50, 50, 25, Rgba(100, 50, 150, 255));
    panel->SetPixmap(pixmap);
    panel->SetColor(0.1f, 0.15f, 0.1f, 1);

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        while (PeekEvent()) {
            auto ev = WaitEvent();
            ui->ProcessEvent(ev);
        }

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

 

Posted

I think this is something I just never programmed in the behavior for...

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

Posted

Pixmap seems to ignores alpha chanal at all:

    drawCircle(pixmap, 50, 50, 25, Rgba(100, 50, 150, 255));
    drawCircle(pixmap, 50, 50, 30, Rgba(100, 50, 150, 0));
    drawCircle(pixmap, 50, 50, 35, Rgba(100, 50, 150, 133));

image.png.0a18005aade2456f917c508b959fd149.png

btw slider has issue in fisrt and last position. Also i wonder how triangles button are made, no problem with their background. No source here: here https://github.com/Leadwerks/UltraEngine/tree/main/Source/Classes/GUI

Same 3 circles with no 3D World behind UI for comparison:

image.thumb.png.2a5c69eda672ee7d6584e3618cdd5dde.png

  • 4 months later...
  • Josh locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...