klepto2 Posted March 1, 2023 Share Posted March 1, 2023 #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE); //Create User Interface auto ui = CreateInterface(window); auto sz = ui->root->ClientSize(); //Create widget auto panel = CreatePanel(50, 50, sz.x - 100, sz.y - 100, ui->root); panel->SetColor(0, 0, 0, 1); panel->SetLayout(1, 1, 1, 1); auto pixmap = CreatePixmap(256, 256); pixmap->Fill(0xFF0000FF); panel->SetPixmap(pixmap); auto btnChangeColor1 = CreateButton("Change Color without fill", 50, 10, 200, 30, ui->root); auto btnChangeColor2 = CreateButton("Change Color with fill", 260, 10, 200, 30, ui->root); while (true) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WIDGETACTION: { if (ev.source == btnChangeColor1) { int color = Rgba(Random(255), Random(255), Random(255), 255); for (int x = 0; x < pixmap->size.width; x++) for (int y = 0; y < pixmap->size.height; y++) pixmap->WritePixel(x, y, color); } else if (ev.source == btnChangeColor2) { pixmap->Fill(Rgba(Random(255), Random(255), Random(255), 255)); } panel->Paint(); break; } case EVENT_WINDOWCLOSE: return 0; break; } } return 0; } I am currently experimenting with redirecting the scintilla rendering to a pixmap and found a small bug. The pixmap is only updated, in this case on the panel, but also when using just the WidgetBlock, when you use the Fill method. any other pixel manipulation is not working when using pixmaps in the ui. I assume, that it might have to do with the underlying Bitmap object is not updated. A nice way would be to have something to mark the pixmap as dirty, as i need to use memcpy for performance reasons and then the pixmap will not know if it has chnaged or not. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted March 1, 2023 Share Posted March 1, 2023 I have not run your example yet but I think I know what you are referring to. For some reason I had this commented out in the source in WritePixel... 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...
klepto2 Posted March 1, 2023 Author Share Posted March 1, 2023 Please think about some kind of setpixels(void* buffer) which uses the update mechanic, writepixel might be much to slow for a lot of scenarios. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted March 1, 2023 Share Posted March 1, 2023 There is a pixels member that is a buffer. You can use Buffer::Poke to set all the pixel data at once. Or maybe even better, just use Pixmap->pixels->Data() to get the memory pointer and use that for whatever functions is writing to a block of memory. 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...
klepto2 Posted March 1, 2023 Author Share Posted March 1, 2023 That’s what I’m currently doing, but to have the pixmap update correctly in the ui, I needed to cheat a bit, to get access to the getbitmap method and update it myself. A method which would trigger the bitmap update would be useful. Or unify the getbitmap method on all so, withjust diefferent return types. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted March 1, 2023 Share Posted March 1, 2023 So it would be something like Pixmap::Invalidate() or Refresh()? 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...
klepto2 Posted March 1, 2023 Author Share Posted March 1, 2023 Depends. If the update is immediately, I would go with Refresh else I would use invalidate. The problem with this is that it more or less is only valid for the ui system in all other cases the pixmap works well without it. So maybe it should be named to something like RefreshUi? Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Solution Josh Posted March 4, 2023 Solution Share Posted March 4, 2023 Fixed in 1.0.2. Also added Pixmap::Invalidate(). 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.