SpiderPig Posted January 12, 2023 Share Posted January 12, 2023 I've narrowed down a problem with loading a pixmap in the new DDS format you supported. I'm using a pixmap as an input mask and the widget should only go red when the mouse is over the white section of the image but it flickers on and off all the time. Anyway, If you assign this same pixmap to the widget the program will crash. Pretty sure both problems are one and the same. If I export my input mask with a transparent section it all works. #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Pixmap> input_mask = nullptr; bool Callback(const Event& event, shared_ptr<Object> extra) { auto process_input = true; auto target_size = event.source->As<Widget>()->ClientSize(); auto size = input_mask->size; auto sx = size.x / target_size.x; auto sy = size.y / target_size.y; auto x = Clamp(event.position.x * sx, 0, input_mask->size.x - 1); auto y = Clamp(event.position.y * sy, 0, input_mask->size.y - 1); auto value = Red(input_mask->ReadPixel(x, y)); process_input = (value == 0 ? false : true); event.source->As<Widget>()->SetColor(1, 1, 1); switch (event.id) { case EVENT_MOUSEMOVE: { if (process_input == true) { event.source->As<Widget>()->SetColor(1, 0, 0, 1); } } break; } return true; } 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->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 w1 = CreatePanel(20, 20, 128, 128, ui->root); ListenEvent(EVENT_NONE, w1, Callback); w1->SetColor(0, 1, 0); input_mask = LoadPixmap("InputMask.dds"); w1->SetPixmap(input_mask);//Crash here auto p = iVec2(); 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; } InputMask.zip Link to comment Share on other sites More sharing options...
Josh Posted January 13, 2023 Share Posted January 13, 2023 Okay, the pixmap is loading correctly, but since it is in BGR format Vulkan does not like it when you try to create a texture with it. I think technically what I should probably do is add a check in CreateTexture() that rejects unsupported formats, and then the user should have to convert a pixmap like this to RGBA format (using the Convert method). There may be legitimate reasons someone wants to work with an RGB or BGR format pixmaps, so I am reluctant to auto-correct that in the pixmap loader like I did in the texture loader. 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 More sharing options...
Josh Posted January 13, 2023 Share Posted January 13, 2023 Actually, I will make it so the Widget::SetPixmap will assign a converted RGBA pixmap automatically, if it is needed. This is already done in the windowed interface, so I don't see a problem, and the pixmap loader will still strictly load the format that actually appears in the file. CreateTexture will return NULL if the RGB/BGR format is specified. 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 More sharing options...
Solution Josh Posted January 13, 2023 Solution Share Posted January 13, 2023 These changes are now available on the 1.0.1 branch. Please reinstall the client app to be able to detect and install the update: https://ultraengine.github.io/files/UltraClient.exe 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 More sharing options...
Recommended Posts