Jump to content

silageman

Members
  • Posts

    21
  • Joined

  • Last visited

Posts posted by silageman

  1. spent a few hours on this and said i would post about it since it could be usefull to others here:

    #include "UltraEngine.h"
    #define SDL_MAIN_HANDLED
    #include <SDL.h>
    #include <SDL_image.h>
    using namespace UltraEngine;
    
    void clear(SDL_Renderer* renderer) {
        SDL_RenderClear(renderer);
        SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); 
    }
    
    void draw(SDL_Renderer* renderer, SDL_Rect* rectangle) {
        SDL_Surface* surface = SDL_LoadBMP("test.bmp");
        SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
        SDL_FreeSurface(surface);
        SDL_RenderCopy(renderer, texture, NULL, rectangle);
        SDL_RenderPresent(renderer);
    }
    
    int main(int argc, const char* argv[])
    {
    
        //Get the available displays
        auto displays = GetDisplays();
        //Create a window
        auto window = CreateWindow("SDL2 Example with Ultra App Kit", 0, 0, 1920, 1080, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE);
        auto ui = CreateInterface(window);
        iVec2 sz = ui->root->ClientSize();
        auto viewport = CreateWindow("", 200, 8, sz.x - 200 - 8, sz.y - 16, window, WINDOW_CHILD);
        auto btnW = CreateButton("W", 0, 0, 200, 200, ui->root);
        auto btnS = CreateButton("S", 0, 200, 200, 200, ui->root);
        auto btnA = CreateButton("A", 0, 400, 200, 200, ui->root);
        auto btnD = CreateButton("D", 0,600, 200, 200, ui->root);
        SDL_Renderer* renderer;
        SDL_SetMainReady();
        SDL_Init(SDL_INIT_EVERYTHING);
        auto getwindow = SDL_CreateWindowFrom(viewport->GetHandle());
        renderer = SDL_CreateRenderer(getwindow, -1, SDL_RENDERER_ACCELERATED);
    
       SDL_Rect rectangle = {
       rectangle.x = 40,
       rectangle.y = 40,
       rectangle.w = 40,
       rectangle.h = 40
        };
    
    
       bool running = true;
        while (running)
        {
    
            clear(renderer);
            
            while (PeekEvent())
            {
                const Event ev = WaitEvent();
                switch (ev.id)
                {
                case EVENT_WINDOWCLOSE:
                    if (ev.source == window)
                    {
                        return 0;
                    }
                    break;
                case EVENT_WIDGETACTION:
                    if (ev.source == btnW)
                    {
    
                        rectangle.y -=10;
    
                    }
                    else if (ev.source == btnS)
                    {
    
                        rectangle.y += 10;
    
                    }
                    else if (ev.source == btnA)
                    {
    
                        rectangle.x -= 10;
    
                    }
                    else if (ev.source == btnD)
                    {
    
                        rectangle.x += 10;
    
                    }
                    break;
                }
    
            }
            draw(renderer, &rectangle);
        }
        SDL_DestroyWindow(getwindow);
        SDL_Quit();
        return 0;
    }

     

     

  2. #include "UltraEngine.h"

     

    using namespace UltraEngine;

     

     

    int main(int argc, const char* argv[])

    {

     

        auto displays = GetDisplays();

        auto window = CreateWindow("Add Buttons", 0, 0, 640, 480, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE);

        auto ui = CreateInterface(window);

        auto sz = ui->root->ClientSize();

        array<shared_ptr<Widget>, 10> btn;

        int inc = 0;

        int space = 0;

        btn[0] = CreateButton("add", 0, 0, 100, 100, ui->root);

        while (true)

        {

            const Event ev = WaitEvent();

            switch (ev.id)

            {

            case EVENT_WIDGETACTION:

                    if(ev.source == btn[inc]){

                        space=space+100;

                        btn[inc+1] = CreateButton("+", 0,space, 100, 100, ui->root);

                        Print(inc);

                        inc= inc+1;

                        break;

                    }

                break;

            case EVENT_WINDOWCLOSE:

                return 0;

                break;

            }

        }

    }

    • Like 1
  3. on kubuntu latest using the official install of steam the auto generated makefile wont build because of file structure changes.

    take a look at the screenshots below for fix. it's '/Release/AppKit.o'  - this was the only way i could build for linux can you push out a fix for this as it will pee people off and is an easy fix. or at least mention somewhere how to build this with configname

    Thanks.

     

    Screenshot_20220103_211951.png

    Screenshot_20220103_211924.png

    • Thanks 1
  4. #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, 640, 480, displays[0], WINDOW_TITLEBAR | WINDOW_CENTER);
    
        //Create User Interface
        auto ui = CreateInterface(window);
    
        //Create buttons
        int x = (window->ClientSize().x - 120) / 2;
        int y = 350;
        int sep = 0;
    
        auto button = CreateButton("CONVERT", x, y, 300, 60, ui->root);
        y += sep;
    
       
        while (true)
        {
            const Event ev = WaitEvent();
            switch (ev.id)
            {
                case EVENT_WIDGETACTION:
                    if (ev.source->As<Widget>()->text == "CONVERT") {
                 
                        WString file = RequestFile("Open File", "", "All Files:*", 0, false);
                        
                        Print(file);
                        return 0;
                        //Print(Command("./ffmpeg -h"));
                    }
                    break;
                case EVENT_WINDOWCLOSE:
                    return 0;
                    break;
            }
        }
        return 0;
    }

    here just to make easier, latest Xcode and app kit from the App Store on big sur. it's hardly a permission thing?

  5. 16 minutes ago, Josh said:

    You start with a Leadwerks project, not with an Ultra App Kit project. The pre-made project here is updated:

    This expects you to have Steam installed at "C:\Program Files (x86)\Steam" and Ultra App Kit and Leadwerks installed in the default locations.

    If Leadwerks or Steam is installed in another location you can edit the file "Projects\Windows\PropertySheet.props" to indicate the new paths.

    everything is default both leadwerk and steam are in default steam locations

    Capture123.PNG

×
×
  • Create New...