Jump to content

Widget with Pixmap does not change colour


SpiderPig
 Share

Go to solution Solved by Josh,

Recommended Posts

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;
}

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 2 weeks later...
  • Solution

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

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

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