Jump to content

Widget with Pixmap does not change colour


Go to solution Solved by Josh,

Recommended Posts

Posted

A panel with a pixmap does not change colour or alpha.  I've tried WIDGETCOLOR_BACKGROUND and WIDGETCOLOR_FORGROUND.

#include "UltraEngine.h"
#include "ComponentSystem.h"
using namespace UltraEngine;

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

    auto camera = CreateCamera(world);
    camera->Move(0, 2, -3);
    camera->SetClearColor(1, 0, 0);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 35, 35);

    auto floor = CreateBox(world, 100.0f, 0.5f, 100.0f);

    auto default_font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(world, default_font, framebuffer->size);
    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->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
    ui_camera->SetRenderLayers(2);
    ui_camera->SetClearMode(CLEAR_DEPTH);

    auto panel = CreatePanel(0, 0, 512, 512, ui->root);
    panel->SetPixmap(LoadPixmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/dirt01.dds"));
    panel->SetColor(1.0f, 0.0f, 1.0f, 0.5f);

    while (window->KeyHit(KEY_ESCAPE) == false && window->Closed() == false)
    {
        while (PeekEvent()) {
            ui->ProcessEvent(WaitEvent());
        }

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

 

Posted

The pixmap and texture block uses the alpha value of the pixmap or texture itself.  I do something like this to render alpha based pixmaps:

auto data = _scintillaRenderTarget->pixels->Data();

				for (i = 0; i < _scintillaRenderTarget->pixels->GetSize(); i += 4)
				{
					index = i;
					B = data[index]; G = data[index + 1]; R = data[index + 2];
					data[index] = R; data[index + 1] = G; data[index + 2] = B;
					data[index + 3] = char(color[WIDGETCOLOR_BACKGROUND].a * 255);
				}

but i agree, the source alpha should be mulitplied with the destination alpha in the case of widget usage.

  • Upvote 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Posted

Note: The code above converts a deviceindependent bitmap into RGBA format, so you would just need this part in the loop:

 

data[index + 3] = char(color[WIDGETCOLOR_BACKGROUND].a * 255);

 

  • Like 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
  • 2 weeks later...
  • Solution
Posted

So currently this is a design decision, not a bug. As long as I say this is the way it is supposed to be, it it not a bug. If I say that color should affect images, then there is a bug on Linux, which can't really be fixed due to the limitations of the platform.

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