Dreikblack Posted July 12, 2023 Share Posted July 12, 2023 I think block.SetPixmap work fine if a pixmap as member set in but with if it's another pixmap (to make few different icons for different blocks) i have an exception at Render(). An example: #include "UltraEngine.h" using namespace UltraEngine; class NewWidget : public Widget { protected: virtual void Draw(const int x, const int y, const int width, const int height) { for (int i = 0; i < 4; i++) { blocks[i].hidden = false; blocks[i].position = iVec2(i * 64, 0); blocks[i].size = iVec2(64, 64); blocks[i].filter = pixmapfilter; blocks[i].color = Vec4(1); auto px = LoadPixmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/dirt01.dds"); blocks[i].SetPixmap(px); } } public: static shared_ptr<NewWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style = 0) { struct Struct : public NewWidget { }; auto instance = std::make_shared<Struct>(); instance->Initialize("", x, y, width, height, parent, style); return instance; } NewWidget() { blocks.resize(4); } }; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1920, 1080, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a world auto world = CreateWorld(); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.6); camera->SetFov(90); camera->SetRotation(54.736f, 45, 0); camera->SetPosition(0, 4, 0); auto sz = framebuffer->GetSize(); // Load a font auto font = LoadFont("Fonts/arial.ttf"); // Create user interface auto ui = CreateInterface(world, font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); // Create ui camera auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); auto widget = NewWidget::create(0, 0, 64 * 4, 64, ui->root, 0); //Create light auto light = CreateBoxLight(world); light->SetRange(-100, 100); light->SetArea(100, 100); light->SetRotation(35, 35, 0); light->SetColor(2); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer, false); } return 0; } Quote Link to comment Share on other sites More sharing options...
klepto2 Posted July 12, 2023 Share Posted July 12, 2023 Try it like this: class NewWidget : public Widget { protected: virtual void Draw(const int x, const int y, const int width, const int height) { if (blocks.size() < 4) { for (int i = 0; i < 4; i++) { auto px = LoadPixmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/dirt01.dds"); int block = AddBlock(px, iVec2(i * 64, 0), Vec4(1)); blocks[block].size = iVec2(64, 64); } } } public: static shared_ptr<NewWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style = 0) { struct Struct : public NewWidget { }; auto instance = std::make_shared<Struct>(); instance->Initialize("", x, y, width, height, parent, style); return instance; } NewWidget() { } }; 1 1 Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Dreikblack Posted July 12, 2023 Author Share Posted July 12, 2023 Thanks! It works and even alpha channel working! Maybe i should try to rework other widgets like that for temp fix of black background 2 Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted July 19, 2023 Solution Share Posted July 19, 2023 OP did in fact find a bug. Fixed in next build. 1 Quote 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
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.