LxrdKxnny
Topic Author
Posts: 5
Joined: 19 Jan 2024, 21:46

NoesisGUI w/ Urho3D

21 Jan 2024, 17:02

Hello,

I am attempting to integrate NoesisGUI with my Urho3D project with the Rebel Fork Framework (rbfx) but I'm having issues setting it up. There are no errors when launching my Urho3D game, but the UI created using XAML is not showing in the window at all.

Here are the relevant parts of my code:
void ZeroStrike::Setup()
{
    engineParameters_[EP_ORGANIZATION_NAME] = "";
    engineParameters_[EP_APPLICATION_NAME] = "";
    engineParameters_[EP_LOG_NAME] = "conf://GameLog.log";
    engineParameters_[EP_RENDER_BACKEND] = static_cast<int>(RenderBackend::OpenGL);
}
void ZeroStrike::Start()
{
    Noesis::SetLogHandler([](const char*, uint32_t, uint32_t level, const char*, const char* message)
    {
        const char* prefixes[] = { "T", "D", "I", "W", "E" };
        URHO3D_LOGINFOF("Noesis (%s): %s", prefixes[level], message);
    });
    
    Noesis::GUI::SetLicense(NS_LICENSE_NAME, NS_LICENSE_KEY);
    
    Noesis::GUI::Init();

    NoesisApp::SetThemeProviders();
    Noesis::GUI::LoadApplicationResources("Theme/NoesisTheme.DarkBlue.xaml");

    Noesis::Ptr<Noesis::Grid> xaml(Noesis::GUI::ParseXaml<Noesis::Grid>(R"(
        <Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
            <Grid.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Offset="0" Color="#FF123F61"/>
                    <GradientStop Offset="0.6" Color="#FF0E4B79"/>
                    <GradientStop Offset="0.7" Color="#FF106097"/>
                </LinearGradientBrush>
            </Grid.Background>
            <Viewbox>
                <StackPanel Margin="50">
                    <Button Content="Hello World!" Margin="0,30,0,0"/>
                    <Rectangle Height="5" Margin="-10,20,-10,0">
                        <Rectangle.Fill>
                            <RadialGradientBrush>
                                <GradientStop Offset="0" Color="#40000000"/>
                                <GradientStop Offset="1" Color="#00000000"/>
                            </RadialGradientBrush>
                        </Rectangle.Fill>
                    </Rectangle>
                </StackPanel>
            </Viewbox>
        </Grid>
    )"));

    m_NoesisView = Noesis::GUI::CreateView(xaml).GiveOwnership();
    m_NoesisView->SetFlags(Noesis::RenderFlags_PPAA | Noesis::RenderFlags_LCD);
    m_NoesisView->SetSize(GetSubsystem<Graphics>()->GetWidth(), GetSubsystem<Graphics>()->GetHeight());

    m_NoesisView->GetRenderer()->Init(NoesisApp::GLFactory::CreateDevice(false));
    
    auto cache = GetSubsystem<ResourceCache>();
    auto renderer = GetSubsystem<Renderer>();

    m_Scene = MakeShared<Scene>(context_);
    m_Scene->CreateComponent<Octree>();

    Node* cameraNode = m_Scene->CreateChild("Camera");
    Camera* camera = cameraNode->CreateComponent<Camera>();

    Zone* zone = m_Scene->CreateComponent<Zone>();
    zone->SetFogColor(0xC9C0BB_rgb);

    m_GeometryNode = m_Scene->CreateChild("Box");
    m_GeometryNode->SetPosition(Vector3{0.0f, 0.0f, 5.0f});
    m_GeometryNode->SetRotation(Quaternion{-30.0f, 60.0f, 50.0f});
    StaticModel* geometry = m_GeometryNode->CreateComponent<StaticModel>();
    geometry->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
    geometry->SetMaterial(cache->GetResource<Material>("Materials/DefaultGrey.xml"));

    Node* lightNode = m_Scene->CreateChild("Light");
    lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);

    const auto viewport = MakeShared<Viewport>(context_, m_Scene, camera);
    renderer->SetViewport(0, viewport);

    SubscribeToEvent(E_UPDATE, &ZeroStrike::Update);
}
void ZeroStrike::Stop()
{
    Noesis::GUI::Shutdown();
}

void ZeroStrike::Update(VariantMap& eventData)
{
    const float timeStep = eventData[Update::P_TIMESTEP].GetFloat();
    m_GeometryNode->Rotate(Quaternion{10 * timeStep, Vector3::UP}, TS_WORLD);

    auto input = GetSubsystem<Input>();
    if (input->GetKeyPress(KEY_ESCAPE))
        SendEvent(E_EXITREQUESTED);

    m_NoesisView->GetRenderer()->UpdateRenderTree();
    m_NoesisView->GetRenderer()->RenderOffscreen();

    m_NoesisView->GetRenderer()->Render();
}
I have attached the result, which is incorrect. The UI should be showing on the screen but it isn't for some reason.
Attachments
Urho3D-NoesisGUI-Result.png
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: NoesisGUI w/ Urho3D

22 Jan 2024, 23:03

I assume you tried the IntegrationGLUT sample to see the minimal code necessary to run Noesis right? It is included in the C++ SDK
 
LxrdKxnny
Topic Author
Posts: 5
Joined: 19 Jan 2024, 21:46

Re: NoesisGUI w/ Urho3D

22 Jan 2024, 23:54

I assume you tried the IntegrationGLUT sample to see the minimal code necessary to run Noesis right? It is included in the C++ SDK
That is initially what I was following when attempting to implement NoesisGUI with Urho3D. I've compared the code I have with that and don't seem to see a problem, apart from the fact that in the example, _view->Update() is being used but isn't being used in my project. I've since added that with no luck. I also noticed there that before called GetRenderer()->Render(), the example is binding a framebuffer, setting up a viewport, and clearing the screen, etc. I can't really do that from within my Urho3D project considering that stuff is obviously done in the engine code itself.
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: NoesisGUI w/ Urho3D

31 Jan 2024, 12:24

Sorry for the late reply. Unfortunately, we can't help you here, we don't have experience with Urho3D.

Our IntegrationGLUT sample and RenderDoc are your best allies here.
 
LxrdKxnny
Topic Author
Posts: 5
Joined: 19 Jan 2024, 21:46

Re: NoesisGUI w/ Urho3D

03 Feb 2024, 01:54

Sorry for the late reply. Unfortunately, we can't help you here, we don't have experience with Urho3D.

Our IntegrationGLUT sample and RenderDoc are your best allies here.
Thanks for the response! I'm actually stepping away from Urho3D and going back to my own OpenGL game engine I've been working on so I can properly follow the IntegrationGLUT tutorial for integrating NoesisGUI into my own game engine.
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: NoesisGUI w/ Urho3D

05 Feb 2024, 15:47

Great, appreciate the feedback. I was also going to mention that, in many cases, views may not render properly due to a missing call to SetSize.
 
LxrdKxnny
Topic Author
Posts: 5
Joined: 19 Jan 2024, 21:46

Re: NoesisGUI w/ Urho3D

09 Feb 2024, 16:03

Great, appreciate the feedback. I was also going to mention that, in many cases, views may not render properly due to a missing call to SetSize.
I've successfully integrated NoesisGUI into my own game engine and did notice I was missing the 'SetSize' and wondered why the GUI wasn't rendering.

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest