MagnetarX10
-
Posts
10 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by MagnetarX10
-
-
@Drew_Benton Thanks. Makes sense.
-
I have the same issue with your EXE.
Video link: https://drive.google.com/file/d/1VxprAr7jaH9Ne5sWD-Ecmea1TBPF3Rp4/view?usp=share_link
Something about my system, I guess. I could have some weird version issue with drivers or libs. I have two monitors. One is a wide screen monitor. I have seen other issues in the past that were particular to a wide monitor, but this happens on both of my screens.
Not sure if any of this information is useful, but here it is:
-
-
I may have done this incorrectly, but I updated my Ultra Engine Client to 1.0.1. Then I created a new project. Then I copied and pasted the code from example 3 in Create Instance into main.cpp and rebuilt the project, but I am getting the same behavior as before.
I tried it twice and restarted the Ultra Engine Client in case that is a requirement after an update.
-
Here is a video. I think it is when I click outside of the Viewport region. I think I was doing this accidently initially and did not notice. My assumption is that the viewport is getting invalidated but it does not seem to be sent a render message. I added a little bit of code to track which render event was being sent so I could easily tell when a new render message we sent:
case EVENT_VIEWPORTRENDER: world->Render(framebuffer); dirty = false; std::stringstream sstm; sstm << "Viewport render (count=" << ++renderCount << ")"; Print(sstm.str()); break;
-
@Josh Thanks.
On my machine (RTX3080, Windows 11 Pro, AMD CPU), every once in a while the viewport does not paint. I think it is writing a ViewPort Render, but the ViewPort is blank. Tends to happen when I am resizing or moving the window. I have not figure out exactly what causes it.
-
@reepblue I looked at your code again. I am trying to figure out why it does not work the same as the ListenEvent() callback version I have. I assume that WaitEvent() returns an EVENT_WINDOWSIZE event on a different frequency than the ListenEvent() gets called. Your loop drops down to the Update() and Render() calls which seems like it should be functionally equivalent, but I see a dark window during the resize in your version. This means there is a difference.
It has been a very long time since I did Windows programming but maybe the WaitEvent() triggers in the messages that signal a begin and end to the sizing rather than getting message for WM_SIZING which (I think) happens continuously as the user is resizing the window.
-
@reepblue Thanks! This is very, very helpful.
I had worked on this a bit and got it largely working based on @Josh's info.
The nice thing about using the ListenEvent() callback is that the 3D Scene will remain visible while the Application Window is resized. I also called Update() to keep it rotating, but I am not sure if that is a bad idea.
I added some buttons to change the rotation of the cube, but I do not understand is why it can take a few clicks to get the buttons to work. I assume there is a better way to get the button click or I need to select it based on mouse over?
Also, it has been a while since I have programmed C++ ( over a decade), so I don't remember if there is a way to cast the "shared_ptr<Object> extra" parameter in the ListenEvent() callback to a struct or class of objects instead of the single pointer so I don't need to setup the panels and world objects as globals.
#include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; const int WIN_WIDTH = 1000; const int WIN_HEIGHT = 1000; const int PANEL_WIDTH = 200; const int PADDING = 10; //global "cheats" to pass more data into the resize callback shared_ptr<Window> viewport; shared_ptr<World> world; shared_ptr<Framebuffer> framebuffer; shared_ptr<Widget> left_panel; shared_ptr<Widget> right_panel; //------------------------------------------------------- // Callback to handle dynamic resizing of the Viewport // and panels //------------------------------------------------------- bool ResizeViewport(const Event& ev, shared_ptr<Object> extra) { // If the window resize event is captured auto window = ev.source->As<Window>(); // Get the new size of the applications window iVec2 win_sz = window->ClientSize(); auto viewport = extra->As<Window>(); // Set the position and size of the viewport window AND the panels viewport->SetShape(PANEL_WIDTH + PADDING, PADDING, win_sz.x - (PANEL_WIDTH*2) - (PADDING * 2), win_sz.y - PADDING); if (left_panel != NULL) left_panel->SetShape(0, 0, PANEL_WIDTH, win_sz.y - PADDING); if (right_panel != NULL) right_panel->SetShape(win_sz.x - PANEL_WIDTH, 0, PANEL_WIDTH, win_sz.y - PADDING); //Render the Viewport to keep the 3D scene drawing during the resize world->Update(); world->Render(framebuffer); return true; } int main(int argc, const char* argv[]) { //Disable multithreaded rendering for RESIZABLE Windows AsyncRender(false); auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine Test", 0, 0, WIN_WIDTH, WIN_HEIGHT, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE); auto font = LoadFont("Fonts/Arial.ttf"); //------------------------------------------------------- // Create 2D User Interface //------------------------------------------------------- auto ui = CreateInterface(window); iVec2 win_sz = ui->root->ClientSize(); left_panel = CreatePanel(0, 0, PANEL_WIDTH, win_sz.y - PADDING, ui->root); left_panel->SetColor(0.20f, 0.20f, 0.20f, 1); left_panel->SetLayout(1, 1, 1, 1); right_panel = CreatePanel(win_sz.x - PANEL_WIDTH, 0, PANEL_WIDTH, win_sz.y - PADDING, ui->root); right_panel->SetColor(0.20f, 0.20f, 0.20f, 1); right_panel->SetLayout(1, 1, 1, 1); //Add Buttons iVec2 left_sz = left_panel->ClientSize(); iVec2 right_sz = right_panel->ClientSize(); auto rotate_left_btn = CreateButton("Rotate Left", left_sz.x / 2 - 75, left_sz.y / 2 - 15, 150, 30, left_panel); auto rotate_right_btn = CreateButton("Rotate Right", right_sz.x / 2 - 75, right_sz.y / 2 - 15, 150, 30, right_panel); //------------------------------------------------------- // Create 3D Viewport //------------------------------------------------------- viewport = CreateWindow("", PANEL_WIDTH + PADDING, PADDING, win_sz.x - (PANEL_WIDTH*2) - (PADDING*2), win_sz.y - PADDING, window, WINDOW_CHILD); framebuffer = CreateFramebuffer(viewport); world = CreateWorld(); // Adjust the size of the viewport when the applications window is resized (this will callback to the ResizeViewport() function) ListenEvent(EVENT_WINDOWSIZE, window, ResizeViewport, viewport); //------------------------------------------------------- // Setup 3D Scene //------------------------------------------------------- //Setup Camera auto camera_3D = CreateCamera(world); camera_3D->SetClearColor(0.125); camera_3D->SetFov(50); camera_3D->SetPosition(0, 0, -3); //Create a light auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); //Create a box auto box = CreateBox(world); box->SetColor(0, 0, 1); //Entity component system auto actor = CreateActor(box); auto component = actor->AddComponent<Mover>(); //Rotate the Box component->rotation.y = 45; //------------------------------------------------------- // Main Loop //------------------------------------------------------- while (true) { while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WIDGETACTION: //Set the rotation based on the button click if (ev.source == rotate_right_btn) component->rotation.y = -45; else if (ev.source == rotate_left_btn) component->rotation.y = +45; break; case EVENT_WINDOWCLOSE: if (ev.source == window) return 0; break; default: ui->ProcessEvent(ev); break; } } world->Update(); world->Render(framebuffer); } return 0; }
-
I am new to Ultra Engine and never used Leadworks and have only a little bit of 3D programming experience. I looked as some youtube examples and read what I think are the relevant portions of the programming reference, but I am not 100% sure what to do.
I am trying to build something similar to the Editor interface I saw in the Gallery. I want a main window that has a left panel and a right panel with UI controls and a center panel that renders a 3D viewport.
- I have created the Window, FrameBuffer, World, and Interface Objects.
- I have a Left and Right Panel on the Interface.
- I setup 2 cameras, one for the 2D and one for the 3D Objects.
- I turned off the real-time rendering for the 2D camera.
I am sure this is simple, I don't know how to setup the 3D world for only that middle space inside the main window. Currently, the 3D world draws over the 2D UI and I get a lot of flashing.
General Approach for a Desktop GUI with a sub-panel that renders 3D objects
in Programming
Posted
@Josh Thanks for the help. Here is a version that combines the OpenGL example. This seems to be working fine. This is exactly what I need.