NoesisGUI w/ Urho3D
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:
I have attached the result, which is incorrect. The UI should be showing on the screen but it isn't for some reason.
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:
Code: Select all
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);
}
Code: Select all
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);
}
Code: Select all
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();
}
Re: NoesisGUI w/ Urho3D
I assume you tried the IntegrationGLUT sample to see the minimal code necessary to run Noesis right? It is included in the C++ SDK
Re: NoesisGUI w/ Urho3D
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.I assume you tried the IntegrationGLUT sample to see the minimal code necessary to run Noesis right? It is included in the C++ SDK
Re: NoesisGUI w/ Urho3D
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.
Our IntegrationGLUT sample and RenderDoc are your best allies here.
Re: NoesisGUI w/ Urho3D
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.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.
Re: NoesisGUI w/ Urho3D
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.
Re: NoesisGUI w/ Urho3D
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.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.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 6 guests