Jump to content

Ultra Engine testing


Josh
 Share

Recommended Posts

On 1/3/2023 at 7:49 AM, Dreikblack said:

If i understand correctly your case and how mouse/keys events works a callbacks triggers only for upper UI element under mouse cursor. In UAK i solved it for my custom widgets by calling parent event methods

void InnerContainer::MouseEnter(const int x, const int y) {
    GetParent()->MouseEnter(x, y);
}

I want to note that MouseEnter() etc. are now protected methods. They can be accessed from a subclass of Widget, but not from outside the class. However, you can duplicate this behavior by feeding an event into Interface::ProcessEvent.

  • Like 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

Have just noticed while the clipping of widgets is off by 1 pixel, a child of clipped widget is not clipped at all.  Here the blue panel is a child of the red, which is very large and extends well beyond the region of the green panel.  Perhaps the two clipping issues are related.

UnclippedUI.png.f6584d8e23bf559b9596e7616ed8e18d.png

#include "UltraEngine.h"
#include "ComponentSystem.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->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);
    w1->SetColor(0, 1, 0);

    auto w2 = CreatePanel(-10, 10, 1024, 64, w1);
    w2->SetColor(1, 0, 0);

    auto w3 = CreatePanel(512, 10, 32, 32, w2);
    w3->SetColor(0, 0, 1);

    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;
}

 

  • Thanks 1
Link to comment
Share on other sites

Can we get a Quote String/WString function? I made one in my core static library similar how Leadwerks would have it. I have a terrible time remembering how to format the string to show quotes and this makes it easier.

	std::string String::Quote(const std::string& s)
	{
		return "\"" + s + "\"";
	}

The usage could be something like this:

UltraEngine::String str = "Hello World!";
UltraEngine::Print(str.Quote());
Output:
"Hello World!"

 

  • Like 1

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

10 hours ago, reepblue said:

Can we get a Quote String/WString function? I made one in my core static library similar how Leadwerks would have it. I have a terrible time remembering how to format the string to show quotes and this makes it easier.

 I don't feel like the usage of this is common enough to warrant a method.

Update

  • Fixed widget clipping
  • Thanks 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

Updated my Repo here: https://github.com/klepto2/UltraEngineUtilities

Added a ShaderWatcher:

It establishes a FilesystemWatch and keeps track of all used shaders in Shaderfamilies.

- Runtime compilation of shaders

- Automatically reloading shader assets after compilation

- Error-Reports for each shader

Missing: Handling Renaming and Deletion of json files

Known issues:

Notepadd++ uses a way to save files which will trigger the FILECHANGED - EVENT multiple times. I guess i need some way to store some hashvalues for the files.

 

#include "UltraEngine.h"
#include "ComponentSystem.h"

#include "include\Utilities.h"

using namespace UltraEngine;
using namespace UltraEngine::Utilities::Shader;

int main(int argc, const char* argv[])
{
    auto watcher = CreateShaderWatcher();
    watcher->Start();
    ...
}

 

  • Like 2
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

It is a slightly modified and updated to the latest version of ultraengine of this: 

It is not rendered in Vulkan directly, so it will not work when rendered to a texture, but for general purpose ingame editors it will work as well as if it is directly attached to a window. I just needed to modify some syntax changes and change some scrolling and draw behavior.

 

 

  • Like 2
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

The escape isn't quitting the application anymore either...

#include "Engine.h"
#include "DynamicUI.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);


    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

  • Thanks 1
Link to comment
Share on other sites

I've found part (hopefully all) of the problem.  Setting the shape of the widget is not triggering a refresh of the clipping data.

I also couldn't get any key input to work.  I only tried a few keys but they're not working since the last update.

#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->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);
    w1->SetColor(0, 1, 0);

    auto w2 = CreatePanel(0, 0, 1, 1, w1);
    w2->SetColor(1, 0, 0);

    auto w3 = CreatePanel(-10, -10, 32, 32, w2);
    w3->SetColor(0, 0, 1);

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        while (PeekEvent()) {
            auto ev = WaitEvent();
            ui->ProcessEvent(ev);
        }

        if (window->MouseHit(MOUSE_RIGHT)) {
            w2->SetShape(0, 0, 256, 256);
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

3 hours ago, SpiderPig said:

I've found part (hopefully all) of the problem.  Setting the shape of the widget is not triggering a refresh of the clipping data.

When I right-click the mouse the red panel appears. Maybe your installation is not up to date?

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

10 minutes ago, Josh said:

When I right-click the mouse the red panel appears. Maybe your installation is not up to date?

That's correct but the blue panel remains at 1x1 pixels.  It is 32x32 panel and is offset by -10,-10.  So you should see a 22x22 blue square in the top left corner but it remains as a 1x1 pixel.

Link to comment
Share on other sites

Thankyou those issues are fixed.  But now there is another - when a child moves out of bounds and should be hidden completely it seems to pile up.  Here's a shot in my game of what's happening when I scroll some items on the left, and a smaller example is below.  Just move the red panel around with the arrow keys.

ScrollPileUp.gif.9915477ff3192f911dd9ec0e4b1db4d2.gif

 

#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->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);
    w1->SetColor(0, 1, 0);

    auto w2 = CreatePanel(0, 0, 1, 1, w1);
    w2->SetColor(1, 0, 0);

    auto w3 = CreatePanel(0, 0, 32, 32, w2);
    w3->SetColor(0, 0, 1);

    auto p = iVec2();
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        while (PeekEvent()) {
            auto ev = WaitEvent();
            ui->ProcessEvent(ev);
        }

        if (window->KeyDown(KEY_UP)) {
            w2->SetShape(p.x, p.y -= 1, 256, 256);
        }
        else if (window->KeyDown(KEY_DOWN)) {
            w2->SetShape(p.x, p.y += 1, 256, 256);
        }

        if (window->KeyDown(KEY_LEFT)) {
            w2->SetShape(p.x -= 1, p.y, 256, 256);
        }
        else if (window->KeyDown(KEY_RIGHT)) {
            w2->SetShape(p.x += 1, p.y, 256, 256);
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

Working pretty good now.  There is a noticeable delay (less so in release) when scrolling a lot of widgets.  I'm using SetShape() to position them as I move the wheel.    I tried a smaller example but it looked fine as it wasn't scrolling many widgets.  It looks like when the clipping region encompasses the whole widget they are then hidden?  Either way you might consider this a minor cosmetic issue but I'll mention it none the less.  If you want I can put together a larger example tonight.

ScrollDelay.gif.8fc5208f32cf6728a93a7cfc04021816.gif

 

Link to comment
Share on other sites

8 minutes ago, SpiderPig said:

Working pretty good now.  There is a noticeable delay (less so in release) when scrolling a lot of widgets.  I'm using SetShape() to position them as I move the wheel.    I tried a smaller example but it looked fine as it wasn't scrolling many widgets.  It looks like when the clipping region encompasses the whole widget they are then hidden?  Either way you might consider this a minor cosmetic issue but I'll mention it none the less.  If you want I can put together a larger example tonight.

ScrollDelay.gif.8fc5208f32cf6728a93a7cfc04021816.gif

I've been waiting for someone to mention this....

What you are seeing is happening because the culling is asynchronous. When you quickly scroll some items pop into view, but since a new visibility list has not been received from the culling thread, it does not draw the new objects that are in view yet. You can get the same effect with a listbox with many items or a treeview.

There are some different possible solutions for this. I could make the camera culling frustum bigger, or disable frustum culling on a per-object basis. It is probably best to get the engine in people's hands first, see how it gets used, and then decide on a solution.

  • Like 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

You can try to implement some kind of virtualization. If all elements in you list are of the same size, you can just create as much as is visible. If you scroll you can recycle the ones which are out of view and put them in a cache. Then you calculate which items are in view and you pop the items from the cache and update there position. If the size changes and more items are visible than are in the cache, just create new items.

  • Like 1
  • Upvote 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...