Jump to content

Dreikblack

Members
  • Posts

    364
  • Joined

  • Last visited

Posts posted by Dreikblack

  1. One crash fixed and 2nd still happens if you comment out one line that i mentioned in first post. Just to make sure you know what i mean i post code it again with commented line

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
    
        RegisterComponents();
        auto fiplugin = LoadPlugin("Plugins/FITextureLoader");
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto framebuffer = CreateFramebuffer(window);
        auto world = CreateWorld();
    
        WString mapname = "Maps/start.ultra";
        auto scene = LoadMap(world, mapname);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
    
            if (window->KeyDown(KEY_ENTER))
            {
               // world = CreateWorld();
                scene = LoadMap(world, mapname);
            }
            world->Update();
            world->Render(framebuffer);
    
        }
        return 0;
    }

     

  2. Template map.

    If you hit Enter before activating doors SlidingDoor count will be zero but if you do it after triggering a doors a count will be few dozens.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
    
        RegisterComponents();
        auto fiplugin = LoadPlugin("Plugins/FITextureLoader");
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto framebuffer = CreateFramebuffer(window);
        auto world = CreateWorld();
    
        WString mapname = "Maps/start.ultra";
        auto scene = LoadMap(world, mapname);
    
        std::weak_ptr<SlidingDoor> slidingDoor;
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
    
            if (window->KeyDown(KEY_ENTER)) 
            {
                for (auto& entity : scene->entities)
                {
                    if (entity && entity->GetComponent<SlidingDoor>())
                    {
                        slidingDoor = entity->GetComponent<SlidingDoor>();
                        scene->RemoveEntity(entity);
                        Print(slidingDoor.use_count());
                        break;
                    }
                }
            }
            world->Update();
            world->Render(framebuffer);
    
        }
        return 0;
    }

     

  3. Default start map from template

    Happens after first enter press:

    image.thumb.png.9924bf4480f3c4f3b5c7b2f9abdb6d68.png

    Comment in loop "world = CreateWorld();" to get another render crash (RecordDraw) but it's not consistent and may take several attempts (Andy have this issue i believe):

    image.thumb.png.93acc1bea7b92a7e6af4b803a5cb61e4.png

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
    
        RegisterComponents();
        auto fiplugin = LoadPlugin("Plugins/FITextureLoader");
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto framebuffer = CreateFramebuffer(window);
        auto world = CreateWorld();
    
        WString mapname = "Maps/start.ultra";
        auto scene = LoadMap(world, mapname);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
    
            if (window->KeyDown(KEY_ENTER)) 
            {
                world = CreateWorld();
                scene = LoadMap(world, mapname);
            }
            world->Update();
            world->Render(framebuffer);
    
        }
        return 0;
    }

     

    • Thanks 1
  4. Reproduced it even with one loop in one main.cpp file. Not creating game gui in callback this time. Have no idea what causing an issue now beside switching between worlds which is somehow working in my Quake Tactics project. btw you mentioned that no issue happens with other map - could be a problem related to player controller or something like that?

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    
    shared_ptr<World> gameWorld;
    shared_ptr<Interface> gameUi;
    
    shared_ptr<Camera> uiCamera;
    shared_ptr<Map> gameScene;
    
    shared_ptr<Window> window;
    shared_ptr<Framebuffer> framebuffer;
    
    shared_ptr<Widget> menuPanel;
    bool isMenuOn = false;
    bool isMainMenuOn = true;
    
    bool resumeGameButtonCallback(const Event& ev, shared_ptr<Object> extra)
    {
        menuPanel->SetHidden(true);
        isMenuOn = false;
        return true;
    
    }
    
    bool mainMenuButtonCallback(const Event& ev, shared_ptr<Object> extra)
    {
        isMainMenuOn = true;
        return true;
    }
    
    
    bool newGameButtonCallback(const Event& ev, shared_ptr<Object> extra)
    {
        isMainMenuOn = false;
        return true;
    }
    
    bool exitButtonCallback(const Event& ev, shared_ptr<Object> extra)
    {
        exit(0);
        return true;
    }
    
    void guiInit()
    {
        // Load a font
        auto font = LoadFont("Fonts/arial.ttf");
    
        // Create user interface
        gameUi = CreateInterface(gameWorld, font, framebuffer->GetSize());
        gameUi->SetRenderLayers(2);
        gameUi->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
        gameUi->LoadColorScheme("Resources/configs/Style.json");
    
        // Create ui camera
        uiCamera = CreateCamera(gameWorld, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0);
        uiCamera->SetRenderLayers(2);
        uiCamera->SetClearMode(CLEAR_DEPTH);
    
        int menuWidth = 200;
        int menuHeight = 200;
        int indent = 25;
    
        menuPanel = CreatePanel(framebuffer->size.x * 0.5 - menuWidth / 2, framebuffer->size.y * 0.5 - menuHeight / 2, menuWidth, menuHeight, gameUi->root);
        menuPanel->SetColor(0.2, 0.2, 0.2, 1);
        menuPanel->SetLayout(1, 1, 1, 1);
        menuPanel->SetHidden(true);
    
        int buttonWidth = menuWidth - indent * 2;
        int buttonHeight = 50;
        int posIter = 0;
        int buttonY = indent + posIter * (buttonHeight + indent);
        auto resumeButton = CreateButton("Resume", indent, buttonY, buttonWidth, buttonHeight, menuPanel);
        ListenEvent(EVENT_WIDGETACTION, resumeButton, resumeGameButtonCallback);
        posIter = posIter + 1;
        buttonY = indent + posIter * (buttonHeight + indent);
        auto mainMenuButton = CreateButton("Main Menu", indent, buttonY, buttonWidth, buttonHeight, menuPanel);
        ListenEvent(EVENT_WIDGETACTION, mainMenuButton, mainMenuButtonCallback);
    }
    
    int main(int argc, const char* argv[])
    {
        RegisterComponents();
        //Load FreeImage plugin (optional)
        auto fiplugin = LoadPlugin("Plugins/FITextureLoader");
        //Get the displays
        auto displays = GetDisplays();
        //Create a window
        window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        //Create a framebuffer
        framebuffer = CreateFramebuffer(window);
        //Create a world
        auto world = CreateWorld();
    
        //Load a font
        auto font = LoadFont("Fonts/arial.ttf");
    
        //Create user interface
        auto ui = CreateInterface(world, font, framebuffer->GetSize());
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.2f, 0.2f, 0.2f, 1.0f);
        ui->LoadColorScheme("Resources/configs/Style.json");
    
        //Create ui camera
        auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0);
        uiCamera->SetRenderLayers(2);
        uiCamera->SetClearMode(CLEAR_DEPTH);
    
        auto newGameButton = CreateButton("New game", 200, 125, 200, 50, ui->root);
        ListenEvent(EVENT_WIDGETACTION, newGameButton, newGameButtonCallback);
    
        auto exitButton = CreateButton("Exit", 200, 200, 200, 50, ui->root);
        ListenEvent(EVENT_WIDGETACTION, exitButton, exitButtonCallback);
    
        gameWorld = CreateWorld();
        gameWorld->RecordStats();
        WString mapName = "Maps/start.ultra";
        gameScene = LoadMap(gameWorld, mapName);
        guiInit();
    
        shared_ptr<World> currentWorld = world;
        shared_ptr<Interface> currentUI = ui;
    
        while (window->Closed() == false)
        {
            if (isMainMenuOn) currentWorld = world; else currentWorld = gameWorld;
            if (isMainMenuOn) currentUI = ui; else currentUI = gameUi;
    
            if (window->KeyDown(KEY_ESCAPE) == true)
            {
                menuPanel->SetHidden(false);
                isMenuOn = true;
                window->SetMousePosition(framebuffer->size.x * 0.5, framebuffer->size.y * 0.5);
            }
            while (PeekEvent())
            {
                const Event ev = WaitEvent();
                switch (ev.id)
                {
                case EVENT_WINDOWCLOSE:
                    if (ev.source == window)
                    {
                        exit(0);
                        break;
                    }
                    break;
                default:
                    currentUI->ProcessEvent(ev);
                    break;
                }
            }
            currentWorld->Update();
            currentWorld->Render(framebuffer);
        }
        return 0;
    }

     

    • Confused 1
  5. 7 hours ago, reepblue said:

    I've noticed this issue too. Compiling the application not as a console application usually solves the issue.

    What was structure of app?

     

    8 hours ago, Josh said:

    Do you have a C++ program that produces this error?

    I can try to replicate exactly same app in C++.

     

    8 hours ago, Josh said:

    The fact that you are creating a new GUI inside an event callback really does not make me feel good.

    Why tho? Maybe this is a reason why i have no problem with similar structure in main project, i'm using lambdas instead of events for by buttons there.

     

    8 hours ago, Josh said:

    Bro, you got loops within loops.

    I have two loops for two worlds. Loop inside of loop is just side effect of it :D

    What should be approach for few worlds?

    I will also to try do it with same loop for this case but i fail to see a problem beside issue that could be related to something else like ui created in event callback.

  6. 1. Apply texture to brush

    2, Select faces of brush and do auto UV with enabled Unity faces

    3. In .ultra file path looks like "texture0": "./Test Project/gfx/all.wad/crate0_top" and after restarting editor (and game) can't load this texture

    If i fix it manually to "/gfx/all.wad/crate0_top" textures loads correctly

    I'm using own extension to apply textures from all.wad from rerelase pak0. Textures names "city4_2", "crate0_top". Same happens with usual applied textures from default folders.

    Extension code:

    local extension = {}
    extension.textureField = nil
    extension.setTextureButton = nil
    extension.fixModelButton = nil
    extension.fixYField = nil
    extension.modelScale = 4.68042326
    
    function extension.hook(event, extension)
    
        if event.id == EVENT_WIDGETACTION then
            if event.source == extension.setTextureButton then
                if (extension.textureField.text == "") then return end
                local texture = LoadTexture("/gfx/all.wad/" .. extension.textureField.text)
                --local texture = LoadTexture("/Materials/Developer/trigger.dds")
                local material = CreateMaterial()
                material:SetTexture(texture)
                local selected = program:GetSelection()
                for n = 1, #selected do
                    local currentBrush = Brush(selected[n].entity)
                    if currentBrush ~= nil then
    		            currentBrush:SetMaterial(material)
                        currentBrush:Build()
                        Print("Seted texture to selected brush "..extension.textureField.text)
                    end           
                end
            elseif event.source == extension.fixModelButton then
                local selected = program:GetSelection()
                for n = 1, #selected do
                    local currentModel = Model(selected[n].entity)
                    if currentModel ~= nil then
                        local entityName = currentModel.name
                        Print("Fixed Quake model: " ..entityName)
                        local fixY = extension.fixYField.text
                        if fixY == "" then fixY = 0.02 end
                        if (entityName == "Marine" or entityName == "Grunt") then fixY = 0.02
                        elseif (entityName == "Rottweiler") then fixY = 0.1 end
    		            currentModel = fixQuakeModelCenter(currentModel, fixY)
                    end           
                end
            end
        end
    end
    
    --------------------------------------------------------------------
    -- Add extension tab
    --------------------------------------------------------------------
    
    local sidePanel = program.sidepanel
    if sidePanel ~= nil then
        sidePanel:AddItem("QtExt")
        local sz = program.sidepanel:ClientSize()
        local panel = CreatePanel(0, 0, sz.x, sz.y, program.sidepanel)
        local uiY = 20;
        local label1 = CreateLabel("Wad texture name", 32, uiY, 120, 30, panel)
        uiY = uiY + 32;
        extension.textureField = CreateTextField(20, uiY, sz.x - 40, 32, panel)
        uiY = uiY + 20 + 32;
        extension.setTextureButton = CreateButton("Set a wad texture to selected brush", 20, uiY, sz.x - 40, 32, panel)
        uiY = uiY + 20 + 32;
        local label2 = CreateLabel("Height offset", 32, uiY, 120, 30, panel)
        uiY = uiY + 32;
        extension.fixYField = CreateTextField(20, uiY, sz.x - 40, 32, panel)
        uiY = uiY + 20 + 32;
        extension.fixModelButton = CreateButton("Fix selected Quake models", 20, uiY, sz.x - 40, 32, panel)
    end
    
    ListenEvent(EVENT_WIDGETACTION, extension.setTextureButton, extension.hook, extension)
    ListenEvent(EVENT_WIDGETACTION, extension.fixModelButton, extension.hook, extension)
    
    
    function fixQuakeModelCenter(model, fixY)
        for i = 1, #model.lods do
            local lod = model.lods[i]
            for j = 1, #lod.meshes do
                local currentMesh = lod.meshes[j]
                currentMesh:Translate(-1 * currentMesh.bounds.center.x, -1 * currentMesh.bounds.center.y - fixY, -1 * currentMesh.bounds.center.z)
            end
        end
        model:UpdateBounds();
        model:SetScale(extension.modelScale);
        return model;
    end

     

  7. When i'm trying to create Sprite with Pixmap texture it's invisible. Label and usual Sprites can be seen

    image.thumb.png.44ff1017bcd348c9fc92d6f55f20fb2a.png

    #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, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a world
        auto world = CreateWorld();
    
    	auto light = CreateBoxLight(world);
    	light->SetRange(-10, 10);
    	light->SetRotation(15, 15, 0);
    	light->SetColor(2);
    
    	//Create camera
    	auto camera = CreateCamera(world);
    	camera->SetClearColor(0.125);
    	camera->SetPosition(0, 0, -3);
    	camera->SetFov(70);
    
    	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 uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    	uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
    	uiCamera->SetRenderLayers(2);
    	uiCamera->SetClearMode(CLEAR_DEPTH);
    
    	auto label = CreateLabel("TEST GUI LABEL", 100, 100, 100, 50, ui->root);
    
    	auto pixmap = CreatePixmap(iVec2(100, 100)); 
    	pixmap->Fill(Vec4(0.5f, 0.5f, 1, 1));
    	auto tex = CreateTexture(TEXTURE_2D, 100, 100, TEXTURE_RGBA, { pixmap }, 1, TEXTURE_CLAMP_UV);
    	auto mtl = CreateMaterial();
    	mtl->SetTexture(tex);
    	mtl->SetShadow(false);
    	mtl->SetTransparent(true);
    	mtl->SetShaderFamily(LoadShaderFamily("Shaders/WidgetBlock.fam"));
    
        //Create pixmap sprite
        auto sprite = CreateSprite(world, 0, 0);
        sprite->SetPosition(0, 0);
      //  sprite->SetViewMode(SPRITEVIEW_BILLBOARD);
    	sprite->SetMaterial(mtl);
    	sprite->SetText("Test");
    	sprite->SetRenderLayers(2);
    	//Create usual sprite
        auto sprite2 = CreateSprite(world, 2, 2);
        sprite2->SetPosition(2, 0, 0);
        sprite2->SetViewMode(SPRITEVIEW_BILLBOARD);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
    
        return 0;
    }

     

  8. Well, bottom clipping was fixed but suddenly there is still an issue if child widgets are at top :lol:

    image.png.5a55819efc6a7cf09cc4a8847597babb.png

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    shared_ptr<Window> window;
    shared_ptr<Framebuffer> framebuffer;
    shared_ptr<World> world;
    shared_ptr<Interface> ui;
    shared_ptr<Camera> uiCamera;
    
    shared_ptr<Widget> panel1;
    shared_ptr<Widget> panel2;
    shared_ptr<Widget> panel3;
    
    void initGui()
    {
        auto default_font = LoadFont("Fonts\\arial.ttf");
        ui = CreateInterface(world, default_font, framebuffer->GetSize());
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
        uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
        uiCamera->SetRenderLayers(2);
        uiCamera->SetClearMode(CLEAR_DEPTH);
    
        panel1 = CreatePanel(20, 200, 100, 100, ui->root);
        panel1->SetColor(1, 0, 0, 1, WIDGETCOLOR_BACKGROUND);
        panel2 = CreatePanel(50, -50, 100, 100, panel1);
        panel2->SetColor(0, 1, 0, 1, WIDGETCOLOR_BACKGROUND);
        panel3 = CreatePanel(25, -25, 100, 100, panel2);
        panel3->SetColor(0, 0, 1, 1, WIDGETCOLOR_BACKGROUND);
    }
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        window = CreateWindow("Ultra Engine", 0, 0, 500, 500, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        world = CreateWorld();
        world->SetAmbientLight(0);
    
        //Create a framebuffer
        framebuffer = CreateFramebuffer(window);
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0, 0, 0);
    
        initGui();
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

    • Haha 1
  9. Made an example without extra classes that imitate first version of inventory that Andy had when i looked into this case.

    2 issues:

    1. After Redraw() in real time top block overlap a block under it even if top is transparent or blue border in this example.

    2. Some blocks change positions and sizes after Redraw() if those blocks were drawn initially, in this example it's text and background for text.

    First row is a widget with items and it looks fine until you hit space.

    Second initially without items.

    Space clears make two items for both widgets. After pressing Space:

    Second widget looks fine beside blue borders being filled square (issue 1).

    But first widget totally broken and have both issues.

    image.png.7c3e0f04e075678c31ae734745ef99da.png

    After redrawing with Space button:

    image.png.d534ba35e5efc8c744e44596df8ed9b5.png


        itemCount - to set how many items (red squares) suppose to show
        doHideBgId - hide text background for specific item. For some reason without it second issue does not happens. Maybe i missing something in a code.

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    class CustomWidget : public Panel
    {
    
        CustomWidget::CustomWidget()
        {
            cornerradius = 8;
        }
    
    protected:
    
    	virtual bool Initialize(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent)
    	{
    		return Widget::Initialize(text, x, y, width, height, parent, style);
    	}
    
    	void Draw(const int x, const int y, const int width, const int height)
    	{
    		blocks.clear();
    		Vec4 color = Vec4(0.9, 0.9, 0.9, 0.3);
            int blockWidth = 100;
    
    		for (int i = 0; i < 4; i++)
    		{
    			iVec2 pos;
    			pos.x = i * blockWidth + i * 10;
    			pos.y = 0;
    
    			iVec2 blockSize(blockWidth);
    
    			AddBlock(pos, blockSize, color);
    
                if (i < itemCount) {
                    auto pm = CreatePixmap(50, 50);
                    pm->Fill(Vec4(1, 0, 0, 1));
                    int block = AddBlock(pm, pos, Vec4(1));
                    blocks[block].size = blockSize;
                    if (doHideBgId != i) AddBlock(iVec2(pos.x, pos.y + (blockSize.height - 18)), iVec2(blockSize.width, 18), Vec4(0.2f, 0.2f, 0.2f, 1));
                    AddBlock("item", iVec2(pos.x, pos.y + (blockSize.height - 15)), iVec2(blockSize.width, 15), Vec4(1));
                }
    
    			if (i != 0) {
    			    int block = AddBlock(pos, iVec2(blockSize.x, blockSize.y), Vec4(0, 0, 0, 1), true);
    			    blocks[block].wireframe = true;
    			}
    			else {
    				int block = AddBlock(pos, iVec2(blockSize.x, blockSize.y), Vec4(0.16, 0.47, 1, 1), true);
    				blocks[block].wireframe = true;
    			}		
    		}
    	}
    
    public:
    
        int itemCount = 0;
        int doHideBgId = 0;
    
        static shared_ptr<CustomWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent)
        {
            struct Struct : public CustomWidget {
            };
            auto instance = std::make_shared<Struct>();
            instance->Initialize(x, y, width, height, parent);
            instance->SetColor(0, 1, 0, 1, WIDGETCOLOR_BACKGROUND);
            return instance;
        }
    
    };
    
    shared_ptr<Window> window;
    shared_ptr<Framebuffer> framebuffer;
    shared_ptr<World> menuWold;
    shared_ptr<Interface> ui;
    shared_ptr<Camera> uiCamera;
    
    shared_ptr<CustomWidget> customWidget;
    shared_ptr<CustomWidget> customWidget2;
    
    void initGui()
    {
        auto default_font = LoadFont("Fonts\\arial.ttf");
        ui = CreateInterface(menuWold, default_font, framebuffer->GetSize());
        ui->SetRenderLayers(2);
        ui->root->SetColor(1.0f, 1.0f, 1.0f, 1.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);
        customWidget = CustomWidget::create(10, 10, 500, 120, ui->root);
        customWidget->itemCount = 2;
        customWidget2 = CustomWidget::create(10, 150, 500, 120, ui->root);
    }
    
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        window = CreateWindow("Ultra Engine", 0, 0, 500, 300, displays[0], WINDOW_DEFAULT);
    
        //Create a world
        menuWold = CreateWorld();
    
        //Create a framebuffer
        framebuffer = CreateFramebuffer(window);
    
        auto textureLoaderPlugin = LoadPlugin("Plugins/FITextureLoader");
    
        initGui();
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            if (window->KeyHit(KEY_SPACE))
            {
                customWidget->itemCount = 2;
                customWidget->doHideBgId = -1;
                customWidget->Redraw();
                customWidget2->itemCount = 2;
                customWidget2->doHideBgId = -1;
                customWidget2->Redraw();
            }
            menuWold->Update();
            menuWold->Render(framebuffer);
        }
        return 0;
    }

     

    • Like 1
    • Thanks 1
  10. In 2D seems to be still working:

    image.png.2e7fac76873e4909a486049641e8da8f.png

    But in 3D:

    image.png.555445340afd2984d9dbd9cb1201057c.png

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    shared_ptr<Window> window;
    shared_ptr<Framebuffer> framebuffer;
    shared_ptr<World> world;
    shared_ptr<Interface> ui;
    shared_ptr<Camera> uiCamera;
    
    shared_ptr<Widget> panel1;
    shared_ptr<Widget> panel2;
    shared_ptr<Widget> panel3;
    
    void initGui()
    {
        auto default_font = LoadFont("Fonts\\arial.ttf");
        ui = CreateInterface(world, default_font, framebuffer->GetSize());
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
        uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
        uiCamera->SetRenderLayers(2);
        uiCamera->SetClearMode(CLEAR_DEPTH);
    
        panel1 = CreatePanel(20, 20, 100, 100, ui->root);
        panel1->SetColor(1, 0, 0, 1, WIDGETCOLOR_BACKGROUND);
        panel2 = CreatePanel(50, 50, 100, 100, panel1);
        panel2->SetColor(0, 1, 0, 1, WIDGETCOLOR_BACKGROUND);
        panel3 = CreatePanel(25, 25, 100, 100, panel2);
        panel3->SetColor(0, 0, 1, 1, WIDGETCOLOR_BACKGROUND);
    }
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        window = CreateWindow("Ultra Engine", 0, 0, 300, 300, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        world = CreateWorld();
        world->SetAmbientLight(0);
    
        //Create a framebuffer
        framebuffer = CreateFramebuffer(window);
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0, 0, 0);
    
        initGui();
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

    • Confused 1
  11. If i drag or create window at 2nd screen ui is looks broken, button can be pressed tho.

    Also if i try to create full window at non main display it's still appears on main one.

    Editor UI works fine on all displays.

    Main screen:

    image.thumb.png.cb96a5d36e400e56adda8bb2176b3bf3.png

    Second screen:

    image.thumb.png.20016ff43298a442a96aaf83543e6d92.png

    Third screen:

    image.thumb.png.510fb1eb0446ed79a88c093b61d69faa.png

    #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> btn;
    shared_ptr<Widget> btn2;
    bool fullscreen = false;
    int displayId = 0;
    
    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);
    
        btn = CreateButton("Change display", (float)framebuffer->GetSize().x / 2, framebuffer->GetSize().y / 2, 200, 200, ui->root);
        btn->SetFontScale(2.0f);
    
        btn2 = CreateButton("Fullscreen", (float)framebuffer->GetSize().x / 2, framebuffer->GetSize().y / 2 - 100, 120, 30, ui->root, BUTTON_CHECKBOX);
        if (fullscreen) btn2->SetState(WIDGETSTATE_SELECTED);
    }
    
    void changeDisplay()
    {
        auto displays = GetDisplays();
        displayId = ++displayId;
        if (displayId == displays.size())
        {
            displayId = 0;
        }
        if (!fullscreen)
        {
            window = CreateWindow("Ultra Engine", 0, 0, 1000, 1000, GetDisplays()[displayId], WINDOW_DEFAULT);
        }
        else
        {
            window = CreateWindow("Ultra Engine", 0, 0, displays[displayId]->GetSize().width, displays[displayId]->GetSize().height, displays[displayId], WINDOW_DEFAULT | WINDOW_FULLSCREEN);
        }
        framebuffer = CreateFramebuffer(window);
        initGui();
    }
    
    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)
                {
                    changeDisplay();
                }
                if (ev.source == btn2 && ev.id == EVENT_WIDGETACTION)
                {
                    fullscreen = !fullscreen;
                }
                ui->ProcessEvent(ev);
            }
            menuWold->Update();
            menuWold->Render(framebuffer);
        }
        return 0;
    }

     

  12. After resizing icon of yellow armor becomes a blue one. Red also becomes blue. Green stays green. Used to be fine several months ago.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    
    shared_ptr<Window> window;
    shared_ptr<Framebuffer> framebuffer;
    shared_ptr<World> world;
    shared_ptr<Interface> ui;
    shared_ptr<Camera> uiCamera;
    
    shared_ptr<Widget> panel;
    shared_ptr<Widget> panel2;
    
    bool isFirst = true;
    
    void initGui()
    {
        auto default_font = LoadFont("Fonts\\arial.ttf");
        ui = CreateInterface(world, default_font, framebuffer->GetSize());
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
        uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
        uiCamera->SetRenderLayers(2);
        uiCamera->SetClearMode(CLEAR_DEPTH);
    
        panel = CreatePanel(10, 10, 50, 50, ui->root, PANEL_DEFAULT);
        panel2 = CreatePanel(10, 70, 100, 100, ui->root, PANEL_DEFAULT);
    
        auto pixmap = LoadPixmap("/gfx/items.wad/armor2");//yellow armor
        panel->SetPixmap(pixmap);
        auto pixmap2 = pixmap->Resize(pixmap->size.x * 1.5f, pixmap->size.y * 1.5f);//blue now O_o
        panel2->SetPixmap(pixmap2);
    }
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        window = CreateWindow("Ultra Engine", 0, 0, 300, 300, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        world = CreateWorld();
        world->SetAmbientLight(0);
    
        //Create a framebuffer
        framebuffer = CreateFramebuffer(window);
    
        //Load FreeImage plugin
        auto plg = LoadPlugin("Plugins/FITextureLoader");
        auto quakeLoaderPlugin = LoadPlugin("Plugins/QuakeLoader");
    
        //Load model
        WString path = AppDir();
        auto pak = LoadPackage(path + "/PAK0.PAK");
        ChangeDir(path);
    
    
        //Create a camera    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0, 0, 0);
        camera->Move(0, 0, -0.3);
        camera->SetRange(0.01, 100);
        camera->SetFov(70);
    
        initGui();
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

    • Thanks 1
×
×
  • Create New...