Dreikblack Posted May 23, 2023 Posted May 23, 2023 Painting working only before first Render() #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> menuWold; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> drawPanel; shared_ptr<Widget> btn; shared_ptr<Pixmap> px; int progress = 0; void paint() { progress++; for (int x = 0; x < progress * 10; x++) { for (int y = 0; y < 200; y++) { px->WritePixel(x, y, Rgba (20, 250, 10)); } } } void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(menuWold, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); drawPanel = CreatePanel(0, 50, 200, 200 , ui->root, PANEL_DEFAULT); drawPanel->SetColor(1, 0, 0); px = CreatePixmap(200, 200); drawPanel->SetPixmap(px); btn = CreateButton("Progress", 0, 0, 100, 20, ui->root); //works for (int i = 0; i < 5; i++) { paint(); } } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 1000, 1000, displays[0], WINDOW_DEFAULT); //Create a world menuWold = CreateWorld(); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create light auto light = CreateBoxLight(menuWold); light->SetRange(-10, 10); light->SetRotation(15, 15, 0); light->SetColor(2); //Create camera auto camera = CreateCamera(menuWold); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -3); camera->SetFov(70); //Create scenery auto box = CreateBox(menuWold); initGui(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); if (ev.source == btn && ev.id == EVENT_WIDGETACTION) { //pixmap not changes paint(); } ui->ProcessEvent(ev); } menuWold->Update(); menuWold->Render(framebuffer); } return 0; } Check out Slipgate Tactics demo, which is made with Ultra Engine: https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/
MarKli Posted May 23, 2023 Posted May 23, 2023 Hey, I think you have to use Redraw() for something like that. void paint() { progress++; for (int x = 0; x < progress * 10; x++) { for (int y = 0; y < 200; y++) { px->WritePixel(x, y, Rgba (20, 250, 10)); } } drawPanel->Redraw(); }
Dreikblack Posted May 23, 2023 Author Posted May 23, 2023 Hi! Unfortunately Redraw() changes nothing in this case. Pixmap painting worken for me in Ultra App Kit. Check out Slipgate Tactics demo, which is made with Ultra Engine: https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/
Dreikblack Posted June 4, 2023 Author Posted June 4, 2023 Similar issue with icons: #include "UltraEngine.h" using namespace UltraEngine; 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 button = CreateButton("Button", 10, 10, 120, 30, ui->root); auto icon = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/23cbb91bbaa1f22d6f3eb20cfa54a747d3062c33/Assets/Icons/help.svg"); button->SetIcon(icon); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); if (ev.source == button && ev.id == EVENT_WIDGETACTION) { button->SetIcon(LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/23cbb91bbaa1f22d6f3eb20cfa54a747d3062c33/Assets/Icons/new.svg")); } ui->ProcessEvent(ev); } world->Update(); world->Render(framebuffer); } return 0; } Check out Slipgate Tactics demo, which is made with Ultra Engine: https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/
Solution Josh Posted September 7, 2023 Solution Posted September 7, 2023 If you use this code, it will work in the next build. It is necessary to set the pixmap to NULL before resetting the original pixmap, in order to trigger a change. if (ev.source == btn && ev.id == EVENT_WIDGETACTION) { //pixmap not changes paint(); drawPanel->SetPixmap(nullptr); drawPanel->SetPixmap(px); } My job is to make tools you love, with the features you want, and performance you can't live without.
Recommended Posts