Jump to content

Ultra Engine testing


Josh
 Share

Recommended Posts

This requires a keen eye - with a transparent shader there is a hint of transparency even with alpha set to 1.  Very hard to see the edge of the cube in this shot but you will notice it more when the cube is spinning.  There's a faint hint of the cube behind the green sphere.

TransparencyIssue.png.829a1e4b9405a2aa5f44b207c18ffd02.png

#include "UltraEngine.h"
#include "ComponentSystem.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, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->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>();
    component->rotation.y = 45;

    auto material = CreateMaterial();
    material->SetTransparent(true);

    auto s1 = CreateSphere(world);
    s1->SetPosition(-0.5f, 0.0f, -1.0f);
    s1->SetMaterial(material);
    s1->SetColor(1.0f, 0.0f, 0.0f, 0.5f);

    auto s2 = CreateSphere(world);
    s2->SetPosition(0.5f, 0.0f, -1.0f);
    s2->SetMaterial(material);
    s2->SetColor(0.0f, 1.0f, 0.0f, 1.0f);

    //Main loop
    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

On the topic of transparency, that reminds me that in this example, you can notice a ghosting effect if the alpha is set to 0.0f

#include "UltraEngine.h"
#include "ComponentSystem.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, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->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);

    auto material = CreateMaterial();
    if (material)
    {
        material->SetColor(0.0f, 0.0f, 1.0f, 1.0f);
        material->SetTransparent(true);
        box->SetMaterial(material);
        material = NULL;
    }

    //Entity component system
    auto actor = CreateActor(box);
    auto component = actor->AddComponent<Mover>();
    component->rotation.y = 45;

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        // Adjust the alpha of the sprite.
        float alpha = box->GetColor().a;
        if (window->KeyDown(KEY_UP))
        {
            alpha = Clamp((alpha + 0.01f), 0.0f, 1.0f);
            box->SetColor(1.0f, 1.0f, 1.0f, alpha);
        }

        if (window->KeyDown(KEY_DOWN))
        {
            alpha = Clamp((alpha - 0.01f), 0.0f, 1.0f);
            box->SetColor(1.0f, 1.0f, 1.0f, alpha);
        }

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

image.thumb.png.4874dc980f1c1da28f582aed08a63761.png

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

Creating a text sprite for the first time is slow and is slower the bigger the text size is.  Unsure if this one is "just the way it is" or it can be made faster?  Slower in debug mode of course but still noticeable in release.

#include "UltraEngine.h"
#include "ComponentSystem.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, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(0, 0, -3);

    auto font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(world, font, framebuffer->size);
    ui->SetRenderLayers(RENDERLAYER_1);
    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(RENDERLAYER_1);
    ui_camera->SetClearMode(CLEAR_DEPTH);

    //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>();
    component->rotation.y = 45;

    shared_ptr<Sprite> sprite;

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_C)) { sprite = CreateSprite(world, font, "Hello", 128, TEXT_CENTER);
        sprite->SetRenderLayers(RENDERLAYER_1); }
        if (window->KeyHit(KEY_D)) { sprite = nullptr; }

        camera->Move(0, 0, 0.001);

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

 

Link to comment
Share on other sites

33 minutes ago, SpiderPig said:

Creating a text sprite for the first time is slow and is slower the bigger the text size is.  Unsure if this one is "just the way it is" or it can be made faster?

When a new font size is used, every character in the font gets rasterized to an image. However, probably 99% of those characters are never used. It would make sense to only rasterize them as they are used, but it will make things a bit more complicated and require a lot of testing before it works perfectly. Maybe I can add this in a future update?

  • 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

Can't seem to get the panel to display this pixmap.  Just shows up as solid white.

#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 font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(world, font, framebuffer->size);
    ui->SetRenderLayers(RENDERLAYER_1);
    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(RENDERLAYER_1);
    ui_camera->SetClearMode(CLEAR_DEPTH);

    auto light = CreateBoxLight(world);
    light->SetRotation(35, 45, 0);
    light->SetRange(-10, 10);

    auto box = CreateBox(world);
    box->SetColor(0, 0, 1);

    auto actor = CreateActor(box);
    auto component = actor->AddComponent<Mover>();
    component->rotation.y = 45;

    auto widget = CreatePanel(0, 0, 128, 128, ui->root);
    widget->SetPixmap(LoadPixmap("Background.dds"));

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

Background.zip

 

Also .dds is not an allowed file type to upload here?

Link to comment
Share on other sites

MOUSE_ENTER event not working either.  Everything else here seems okay.

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

using namespace UltraEngine;

bool EventCallback(const Event& event, shared_ptr<Object> extra) {
    switch (event.id) {
    case EVENT_MOUSEENTER:
        Print("MOUSE_ENTER");//Not working
        break;
    case EVENT_MOUSELEAVE:
        Print("MOUSE_LEAVE");
        break;
    case EVENT_MOUSEDOWN:
        Print("MOUSE_DOWN");
        break;
    case EVENT_MOUSEMOVE:
        //Print("MOUSE_MOVE");//Works disabled to see other stuff
        break;
    case EVENT_MOUSEUP:
        Print("MOUSE_UP");
        break;
    case EVENT_MOUSEWHEEL:
        Print("MOUSE_WHEEL");
        break;
    }

    return true;
}

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 font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(world, font, framebuffer->size);
    ui->SetRenderLayers(RENDERLAYER_1);
    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(RENDERLAYER_1);
    ui_camera->SetClearMode(CLEAR_DEPTH);

    auto light = CreateBoxLight(world);
    light->SetRotation(35, 45, 0);
    light->SetRange(-10, 10);

    auto box = CreateBox(world);
    box->SetColor(0, 0, 1);

    auto actor = CreateActor(box);
    auto component = actor->AddComponent<Mover>();
    component->rotation.y = 45;

    auto widget = CreatePanel(0, 0, 128, 128, ui->root);
    ListenEvent(EVENT_NONE, widget, EventCallback);

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

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

 

Link to comment
Share on other sites

11 minutes ago, SpiderPig said:

I don't think ListenEvent is always working either.  I have a lot of widgets parented to each other and little to no events are being received in the callback.

It doesn't work recursively. You need to listen for each widget.

  • 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

Update

  • Fixed pixmap not appearing in 3D GUI
  • Fixed MOUSEENTER events not occurring
  • Entity::GetValue<T> changed to GetField<T>, but you should not use this anyway
  • RENDERLAYER_N constants are removed. You can declare your own if you want to use these:
	enum RenderLayer
	{
		RENDERLAYER_NONE = 0,
		RENDERLAYER_0 = 1,
		RENDERLAYER_1 = 2,
		RENDERLAYER_2 = 4,
		RENDERLAYER_3 = 8,
		RENDERLAYER_4 = 16,
		RENDERLAYER_5 = 32,
		RENDERLAYER_6 = 64,
		RENDERLAYER_7 = 128,
		RENDERLAYER_ALL = 255
	};
	inline RenderLayer operator|(RenderLayer a, RenderLayer b)
	{
		return static_cast<RenderLayer>(static_cast<int>(a) | static_cast<int>(b));
	};

 

  • 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

17 hours ago, SpiderPig said:

Just thought I'd mention that very rarely I get errors thrown from the thread manager.  They aren't random, they occur seemingly for stupid reasons - for instance this works fine...

This indicates a serious problem, but I am unable to produce any error with this code:

#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);

    vector<shared_ptr<Entity>> entities;
    Vec3 offset = Vec3(10.0f, 1.0f, 5.0f);
    float scale = 2.0f;
    for (int z = 0; z < 10; z++) {
        for (int x = 0; x < 10; x++) {
            auto e = CreateSphere(world);
            e->SetColor(Random(), Random(), Random());
            e->SetPosition(Vec3((float)x * scale + Random() - 0.5f, 0.0f, (float)z * scale + Random() - 0.5f) + offset, true);
            e->SetMass(1.0f);
            entities.push_back(e);
        }
    }

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

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 see the transparency issue a bit more clearly like this:

#include "UltraEngine.h"
#include "ComponentSystem.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, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->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, 8);

    //Entity component system
    auto actor = CreateActor(box);
    auto component = actor->AddComponent<Mover>();
    component->rotation.y = 45;

    auto material = CreateMaterial();
    material->SetTransparent(true);

    auto s1 = CreateSphere(world);
    s1->SetPosition(-0.5f, 0.0f, -1.0f);
    s1->SetMaterial(material);
    s1->SetColor(1.0f, 0.0f, 0.0f, 0.5f);

    auto s2 = CreateSphere(world);
    s2->SetPosition(0.5f, 0.0f, -1.0f);
    s2->SetMaterial(material);
    s2->SetColor(0.0f, 0.0f, 0.0f, 1.0f);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

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

18 hours ago, reepblue said:

On the topic of transparency, that reminds me that in this example, you can notice a ghosting effect if the alpha is set to 0.0f

Thanks for the example, I just had to move the pre-multiply alpha multiplication to come after the dither step.

  • 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

How should we get the screen position of an object on a texture?  Should the result be scaled down to the size of the texture and then reposition based on the panel position?  I am not sure how to achieve this.

ProjectIssue.thumb.png.c5cbfffe1c6583ab10926155aed5485b.png

 

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, 2, -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 buffer = CreateTextureBuffer(256, 256);

    auto cam3 = CreateCamera(world);
    cam3->SetClearColor(1, 0, 0);
    cam3->SetRenderLayers(4);
    cam3->Move(0, 0, -2);
    cam3->SetRenderTarget(buffer);



    auto w1 = CreatePanel(0, 0, 256, 256, ui->root);
    w1->SetColor(1, 1, 1);
    w1->blocks[0].texture = buffer->GetColorAttachment();

    //Create a box
    auto box = CreateBox(world);
    box->SetRenderLayers(1 | 4);
    box->SetColor(0, 0, 1);

    //Entity component system
    auto actor = CreateActor(box);
    auto component = actor->AddComponent<Mover>();
    component->rotation.y = 45;

    auto sprite = CreateSprite(world, 16, 16);
    sprite->SetRenderLayers(2);

    auto text = CreateSprite(world, default_font, "", 12);
    text->SetRenderLayers(2);

    vector<shared_ptr<Widget>> widgets;
    widgets.push_back(ui->root);

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

        auto screen_pos = cam3->Project(box->GetPosition(true), framebuffer);
        sprite->SetPosition(screen_pos.x, screen_pos.y);
        text->SetText("ScreenPos : " + String(screen_pos.x) + ", " + String(screen_pos.y));

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

 

Link to comment
Share on other sites

5 hours ago, SpiderPig said:

No mouse events for tabber or button (disable the panel creating in the loop to see this)

These widgets do not emit mouse events.

  • 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

9 hours ago, SpiderPig said:

How should we get the screen position of an object on a texture?  Should the result be scaled down to the size of the texture and then reposition based on the panel position?  I am not sure how to achieve this.

Just use the correct camera and the correct render buffer, and everything works out:

auto screen_pos = cam3->Project(box->position, buffer);

 

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

Josh, after all these bug reports you have solved recently ,and I just want to say: 

Thank you. 

UltraEngine is coming along very nice, and it is much better than I ever have thought it will be. The speed is really incredible, and the API is nice and smooth (of course there is space for improvements, but this will always be the case). Just a small sample:

In one of my researches (I posted it earlier in this thread), I started rendering a scene with a large terrain and a pseudo water plane (all tessellated).  To test a feature I wanted to implement, I needed some kind of cascade rendering of the scene from multiple viewports (in this case 3). So I rendered the complete scene with lights terrain etc. 4 times, 1 time for the main viewport and 3 times for the cascades to a viewport (512,512) with an attached pfx shader with around 10-12 subpasses. And long story short: the speed was nearly the same as if I would render just the normal viewport. Of course there is some impact, but the same scene in Leadwerks would make it slow down to maybe 5 fps, if not less. In UltraEngine this still runs at 60fps.

This is amazing !!!  

 

 

  • Like 1
  • Upvote 3
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

I agree, thank you Josh for making a great engine!

 

30 minutes ago, Josh said:

Just use the correct camera and the correct render buffer, and everything works out:

auto screen_pos = cam3->Project(box->position, buffer);

So I can pass the TextureBuffer object to it? :huh:

Got it to work, Thankyou.  Should the sprites follow the same position system as the GUI?  I mean 0,0 at the top left?

Link to comment
Share on other sites

28 minutes ago, SpiderPig said:

I agree, thank you Josh for making a great engine!

So I can pass the TextureBuffer object to it? :huh:

Yes

  • 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

12 hours ago, SpiderPig said:

I made this example in an effort to get things to crash but have noted a few other issues in the process.  Please excuses the size the example.

What am I looking at???

Untitled.thumb.jpg.101cd171f164ee01b54bbf1ccf9ff0b2.jpg

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

When I run it I get to about 2300. Each update gets slower and slower. I don't have an explanation right now why new panels stop appearing though. The render stats say more instances are being drawn.

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

using namespace UltraEngine;

bool EventCallback(const Event& event, shared_ptr<Object> extra) {
    switch (event.id) {
    case EVENT_MOUSEENTER:
        Print("MOUSE_ENTER");
        break;
    case EVENT_MOUSELEAVE:
        Print("MOUSE_LEAVE");
        break;
    case EVENT_MOUSEDOWN:
        Print("MOUSE_DOWN");
        break;
    case EVENT_MOUSEMOVE:
        //Print("MOUSE_MOVE");
        break;
    case EVENT_MOUSEUP:
        Print("MOUSE_UP");
        break;
    case EVENT_MOUSEWHEEL:
        Print("MOUSE_WHEEL");
        break;
    }

    return true;
}

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, 2, -3);

    auto default_font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(world, default_font, framebuffer->size);
    ui->SetRenderLayers(1);
    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(1);
    ui_camera->SetClearMode(CLEAR_DEPTH);

    auto w1 = CreatePanel(0, 0, 1, 1, ui->root);
    ListenEvent(EVENT_NONE, w1, EventCallback);

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

    auto w3 = CreateTabber(10, 10, 1, 1, ui->root);
    w3->SetShape(25, 25, 256, 256);
    w3->AddItem("Page1");
    w3->AddItem("Page2");

    auto w4 = CreateButton("Test", 0, 0, 32, 32, w3);
    w4->SetShape(5, 5, 100, 50);

    auto terrain = CreateTerrain(world, 512, 512);
    terrain->SetMaterial(LoadMaterial("Data\\bluegrid.mat"));

    auto c = CreateCylinder(world);
    c->SetPhysicsMode(PHYSICS_PLAYER);

    vector<shared_ptr<Entity>> entities;
    Vec3 offset = Vec3(10.0f, 1.0f, 5.0f);
    float scale = 2.0f;
    for (int z = 0; z < 10; z++) {
        for (int x = 0; x < 10; x++) {
            auto e = CreateSphere(world);
            e->SetColor(Random(), Random(), Random());
            e->SetPosition(Vec3((float)x * scale + Random() - 0.5f, 0.0f, (float)z * scale + Random() - 0.5f) + offset, true);
            e->SetMass(1.0f);
            entities.push_back(e);
        }
    }

    auto sprite = CreateSprite(world, default_font, "", 12);
    sprite->SetRenderLayers(1);//Still on layer 0?


    vector<shared_ptr<Widget>> widgets;
    widgets.push_back(ui->root);

    world->RecordStats(true);

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_SPACE)) {
            w1->SetShape(Random(0, 512), Random(0, 512), Random(64, 128), Random(64, 128));
            w2->SetShape(Random(0, 10), Random(0, 10), Random(16, 128), Random(16, 32));
        }

        if (!window->KeyDown(KEY_H))
        {
            auto w = CreatePanel(Random(0, 512), Random(0, 512), Random(64, 128), Random(64, 128), ui->root);// widgets[(int)Random(0.0f, (float)widgets.size() - 0.1f)]);
            w->SetColor(Random(), Random(), Random());
            ListenEvent(EVENT_NONE, w, EventCallback);
            widgets.push_back(w);
        }

        sprite->SetText(String(widgets.size()));

        while (PeekEvent()) {
            auto event = WaitEvent();
            ui->ProcessEvent(event);
        }

        window->SetText(world->renderstats.instances);

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

 

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

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

×
×
  • Create New...