Jump to content
  • entries
    2
  • comments
    11
  • views
    139

UltraEngine Utilities


klepto2

256 views

 Share

In this post, I want to introduce you to my GitHub repository: https://github.com/klepto2/UltraEngineUtilities

Currently, there is not that much available, but I am working on adding more utilities and helper classes, which will help to work with UltraEngine.  I had the privilege to be one of the first users of UltraEngine and was able to see the enormous amount of potential right from the beginning. So with the repo, I want to give some of the small or bigger helpers I have developed or made compatible for UltraEngine to the public. 

  • Available Features:
    • namepace UltraEngine::Utilities::Shader
      • ShaderCompiler
        • A class which allows you to compile UltraEngines glsl-shaders to SPIRV format from code.
      • ShaderWatcher
        • This class uses the UltraEngine::FileSystemWatcher to watch changes for all available shaders used by your program
        • It parses the ShaderFamilies
        • Keeps track of includes
        • Recompilation of shaders as soon as the shader file changes
        • Automatically reloads shaders when the compilation was succesfully

Sample code:

How To use the Shadercompiler:

#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 compiler = CreateShaderCompiler();
    auto result = compiler->Compile("Shaders/GUI/WidgetBlock.frag", "Shaders/GUI/WidgetBlock.frag.spv");
    if (result->IsSuccesfull())
    {
        Print("Shader compiled succesfully!");
        for (auto f : result->GetIncludedFiles())
        {
            Print("Shader includes: " + f);
        }
    }
    else
    {
        Print("Shader compilation failed!");
        Print(result->GetError());
    }
    ...
}

How to use the ShaderWatcher:

#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();
    ...
}

 

  • Future Features:
    • Multiple Widgets 

I am as well working on some more advanced stuff, but there i have to decide how to publish them.

  1. ComputeShader-Integration
  2. Real-time PBR-Environment-Calculations
  3. Atmospheric scattering
  4. Ocean and Water rendering

 

Here are some Screens and Animations showing some of the above Features:

 

image.thumb.gif.eabb6f2458e74474c697e953961dc72c.gif

image.thumb.gif.e9a4da76f9ef4906ba3eb8a9f1c7a641.gif

image.thumb.gif.66e4e0295aaee86457d84473e30d62e2.gif

 

  • Like 3
 Share

11 Comments


Recommended Comments

Just added: 

shared_ptr<SyntaxEditor> CreateSyntaxEditor(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent)

This will create a scintilla component. It works both for 3d Interfaces and Window-Interfaces, But in 3d it is just an overlay on the topwindow, so it is not available for render to texture targets. For Details on how to use the Control: https://www.scintilla.org/ScintillaDoc.html 

I have seperated the Scintilla Function calls from the base Widget. You need to call: syntaxEditor->GetCall()->CurrentPos() for exsample. It is more oriented the way it is used by the original author in his Scite project.

Link to comment

Do you think Scintilla can be compiled as a DLL module for Lua to call? It would be interesting to see if we can add a script editor tool as an extension:

local function hook(event, scripteditor)

    --Catch menu event to open script editor
    if event.id == EVENT_WIDGETACTION then
        if event.source == scripteditor.menuitem then
            scripteditor.window:SetHidden(false)
            scripteditor.window:Activate()
        end

    --Intercept asset browser open asset event
    else if event.id == EVENT_OPENASSET then
        ext = string.lower(ExtractExt(event.text))
      
        --If it's a code file let's steal the event
        if ext == "vert" or ext == "frag" or ext == "lua" then
            local code = LoadString(event.text)
            scripteditor.codearea:SetText(code)
            scripteditor.window:SetHidden(false)
            scripteditor.window:Activate()        
            return false --the rest of the program will never see the event! ha-ha 
        end
      
    end
end

local menu = program.menu:FindChild("Tools")

local scripteditor = {}
scripteditor.window = CreateWindow("Script Editor", 0,0,800,600,program.window, WINDOW_TITLEBAR + WINDOW_RESIZABLE)
scripteditor.ui = CreateInterface(scripteditor.window)
scripteditor.codearea = CreateCodeArea()---TODO!
scripteditor.menuitem = CreateMenu("Script Editor", menu)

--Listen for events
ListenEvent(EVENT_WIDGETACTION, scripteditor.menuitem, hook, scripteditor)
ListenEvent(EVENT_OPENASSET, program.assetbrowser, hook, scripteditor)

 

Link to comment

The original design of scintilla on win32 is based on dll usage,  but I have decided to use the lib approach because this will make it much easier to make it crossplatform, and it is much easier to debug. Nevertheless this will not limit you to create a DLL plugin using scintilla. If I think about it it is much better than the original scintilla way, as you don’t need any 3rd party dlls and you can create a shared lib for Linux or macOS the same way on all platforms.

  • Like 1
Link to comment
3 hours ago, klepto2 said:

The original design of scintilla on win32 is based on dll usage,  but I have decided to use the lib approach because this will make it much easier to make it crossplatform, and it is much easier to debug. Nevertheless this will not limit you to create a DLL plugin using scintilla. If I think about it it is much better than the original scintilla way, as you don’t need any 3rd party dlls and you can create a shared lib for Linux or macOS the same way on all platforms.

If you have any insight in getting static libraries to link with Ultra Engine, let me know. I couldn't seem to get it to work due to how the engine is compiled.

Link to comment

What errors do you get? I only got problems, when i tried to link libs which where not exported for the correct project configuration.

You need to reference the debug libs or release libs depending on you current build configuration. Otherwise you only have the option to use dlls together with the small lib files. For Scintilla i do something like this in my header:

#if _DEBUG
#pragma comment(lib, "Scintilla_d.lib")
#pragma comment(lib, "Lexilla_d.lib")
#else
#pragma comment(lib, "Scintilla.lib")
#pragma comment(lib, "Lexilla.lib")
#endif

 

Link to comment
On 1/16/2023 at 6:12 PM, Josh said:

Do you think Scintilla can be compiled as a DLL module for Lua to call? It would be interesting to see if we can add a script editor tool as an extension:

local function hook(event, scripteditor)

    --Catch menu event to open script editor
    if event.id == EVENT_WIDGETACTION then
        if event.source == scripteditor.menuitem then
            scripteditor.window:SetHidden(false)
            scripteditor.window:Activate()
        end

    --Intercept asset browser open asset event
    else if event.id == EVENT_OPENASSET then
        ext = string.lower(ExtractExt(event.text))
      
        --If it's a code file let's steal the event
        if ext == "vert" or ext == "frag" or ext == "lua" then
            local code = LoadString(event.text)
            scripteditor.codearea:SetText(code)
            scripteditor.window:SetHidden(false)
            scripteditor.window:Activate()        
            return false --the rest of the program will never see the event! ha-ha 
        end
      
    end
end

local menu = program.menu:FindChild("Tools")

local scripteditor = {}
scripteditor.window = CreateWindow("Script Editor", 0,0,800,600,program.window, WINDOW_TITLEBAR + WINDOW_RESIZABLE)
scripteditor.ui = CreateInterface(scripteditor.window)
scripteditor.codearea = CreateCodeArea()---TODO!
scripteditor.menuitem = CreateMenu("Script Editor", menu)

--Listen for events
ListenEvent(EVENT_WIDGETACTION, scripteditor.menuitem, hook, scripteditor)
ListenEvent(EVENT_OPENASSET, program.assetbrowser, hook, scripteditor)

Some ideas which you might consider. The createcodearea should be extended to get the filepath ( for parsing includes or imports) . A way to configure the required highlighting. Instead of pass these things one by one I would create a table ( maybe Document) containing all the infos required by the codearea. 

Link to comment
20 hours ago, klepto2 said:

What errors do you get? I only got problems, when i tried to link libs which where not exported for the correct project configuration.

It's only one library and I have everything as a premake script. I was getting errors which at the time thought were related to the runtime setting, but now looking back at it, the library and project files were not a perfect match. I think I need to look at this again. 

Link to comment

I've include Utilities.h in my project but am getting errors on these lines because the files do not exist in those folders?

#include "../external/submodules/scintilla/include/ScintillaTypes.h"
#include "../external/submodules/scintilla/include/ScintillaMessages.h"
#include "../external/submodules/scintilla/include/ScintillaStructures.h"
#include "../external/submodules/scintilla/include/ScintillaCall.h"
#include "../external/submodules/scintilla/include/Scintilla.h"

#include "../external/submodules/scintilla/include/ILexer.h"
#include "../external/submodules/lexilla/include/Lexilla.h"
#include "../external/submodules/lexilla/include/SciLexer.h"

 

Link to comment

Hi, i just came back from vacation. Normally if you cloned the repo you just need to run this from cmdline in the main folder:

 

git submodule update --init
On 1/26/2023 at 2:27 PM, Josh said:

Same here. I can't even see the missing headers in the Scintilla repository here:
https://github.com/mirror/scintilla/search?q=ScintillaStructures.h

this mirror is out of date for a long time I use this one: 

https://github.com/missdeer/scintilla

but I will remove the scintilla submodule and just try to include all relevant files in the repo.

 

Edited by klepto2
  • Thanks 1
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...