ZanAlex
Topic Author
Posts: 66
Joined: 16 Jan 2015, 17:46

A few questions about some features

23 Jan 2015, 21:31

Hi,

As a UI developper in an indie team, I am considering using Noesis GUI for our game project. I've been testing the trial version for a couple of hours now and I have a few questions.

We would like to display UI in 3D scenes (like in the plane demo). It seems quite straightforward in Unity, but I cannot find a tutorial to use the feature using the native SDK. Could you tell me more about it? How does the XamlRenderer fit into the application? Is it possible to make it render to a texture for instance? The integration samples does not show how it works.

Also, we would like to reproduce the behaviour of a window in our game, like an inventory screen we could size and move anywhere on screen. Is there natively a widget performing such operation or would we have to develop it ourselves?

Thank you,
Alexandre.
Last edited by ZanAlex on 02 Feb 2015, 15:44, edited 1 time in total.
 
User avatar
jsantos
Site Admin
Posts: 3917
Joined: 20 Jan 2012, 17:18
Contact:

Re: A few questions about some features

26 Jan 2015, 12:01

Hi!

Yes, with the Native SDK you can render to texture. You are in charge of binding the target surface before calling us, so you can bind whatever kind of surface, being it the screen, an offscreen-surface, a texture render-target, etc. This is the idea shown in our integration tutorial:
d3dDevice->SetRenderTarget(0, color);
gXamlRenderer->Render(commands.GetPtr());
Regarding the draggable window you have a small example in our ShowCase section, it is in C# but the idea is the same for C++, you have to implement the feature yourself although it is straightforward. If you need help just ask for it here.
 
ZanAlex
Topic Author
Posts: 66
Joined: 16 Jan 2015, 17:46

Re: A few questions about some features

02 Feb 2015, 09:28

Hi,

You're right Locationeebr, I had other things in mind at the moment, I should have checked out, sorry about that.

Thank you for your answers jsantos.

Regards,
Last edited by ZanAlex on 02 Feb 2015, 17:06, edited 1 time in total.
 
User avatar
jsantos
Site Admin
Posts: 3917
Joined: 20 Jan 2012, 17:18
Contact:

Re: A few questions about some features

02 Feb 2015, 14:53

Hi Zan,

Do not worry about the comments from Locationeebr, it is a spam account. I just disabled it.
 
ZanAlex
Topic Author
Posts: 66
Joined: 16 Jan 2015, 17:46

Re: A few questions about some features

02 Feb 2015, 15:17

Alright, no problem.

In fact I have another question. I'm trying to create my own UserControl and to use the object in another project. My goal is to encapsulate all the UI-only operation in the dll (called Code-Behind in Noesis documentation if I'm right) and to plug it to the main project. But I keep getting linking error when trying to call CustomControl's method in my main project. I put the .dll next to the .exe, linked the .lib and include the header.

I'm still discovering the API, therefore, I'm probably doing something wrong but I thought maybe you could see what's wrong with my structure. Here is most of the code I wrote for this.

CustomControl.h
class CustomControl: public Noesis::Gui::UserControl
{
public:
    void SetOnRequest(std::function<void(std::string, std::string, std::string)> inCallback);
    void DisplayErrorMsg(const std::string& inError);
    void ClearErrorMsg();

    void OnClicked(Noesis::Core::BaseComponent* sender, const Noesis::Gui::RoutedEventArgs& e);

private:
    
    std::function<void(std::string, std::string, std::string)> _onRequest;

    NS_IMPLEMENT_INLINE_REFLECTION(CustomControl, Noesis::Gui::UserControl)
    {
        NsMeta<Noesis::Core::TypeId>("CustomControl");

        NsString source = "Xaml/CustomControl.xaml";

        Noesis::Ptr<Noesis::Gui::UIElementData> data = NsMeta<Noesis::Gui::UIElementData>(Noesis::Core::TypeOf<SelfClass>());
        data->OverrideMetadata<NsString>(Noesis::Gui::UserControl::SourceProperty, "Source",
                                         Noesis::Gui::FrameworkPropertyMetadata::Create(source, Noesis::Gui::FrameworkOptions_None));

        NsFunc("OnClicked", &CustomControl::OnClicked);
    }
}
Export.cpp
extern "C" NS_DLL_EXPORT
void NsRegisterReflection(Noesis::Core::ComponentFactory* factory, NsBool registerComponents)
{
    NS_REGISTER_COMPONENT(CustomControl)
}
MainProject
#include "CustomControl.h"

Noesis::Ptr<Noesis::FrameworkElement> pXaml = Noesis::GUI::LoadXaml<Noesis::FrameworkElement>("UI.xaml");
Noesis::Ptr<Noesis::IRenderer> pRenderer = Noesis::GUI::CreateRenderer(pXaml .GetPtr());
CustomControl* pCustomC = NsStaticCast<CustomControl*>(pXaml ->FindName("CustomControl"));
if (pCustomC != nullptr)
{
    pCustomC ->DisplayErrorMsg(std::string("Test"));
}
Thank you,
Alexandre.

EDIT:
In fact it's even worst than what I thought, I cannot load a xaml file referencing my CustomControl. It crashes and tells me the control is not registered. After a few researches, I realized I forgot to call NsRegisterReflection in my application. But this function is not recognized and I cannot find it anywhere in the headers. Am I missing something?
 
User avatar
jsantos
Site Admin
Posts: 3917
Joined: 20 Jan 2012, 17:18
Contact:

Re: A few questions about some features

02 Feb 2015, 20:31

Alright, no problem.
In fact it's even worst than what I thought, I cannot load a xaml file referencing my CustomControl. It crashes and tells me the control is not registered. After a few researches, I realized I forgot to call NsRegisterReflection in my application. But this function is not recognized and I cannot find it anywhere in the headers. Am I missing something?
Yes, you must call this function manually. As explained in the Extending Tutorial:

Note that this function is only invoked automatically by NoesisGUI SDK tools, like BuildTool or XamlPlayer. If you are inside your own application you must manually invoke this function after invoking kernel Init() and before InitSystems().
// Register own classes
NsRegisterReflection(NsGetKernel()->GetComponentFactory(), true);
So, you no longer have linker issues?
 
ZanAlex
Topic Author
Posts: 66
Joined: 16 Jan 2015, 17:46

Re: A few questions about some features

03 Feb 2015, 09:01

In fact I cannot call NsRegisterReflection, the compiler does not find it. I cannot find this function in the headers I have. Where is it declared? Its only appearance seems to be NsCore/Package.h but including it does not solve the problem.
 
User avatar
jsantos
Site Admin
Posts: 3917
Joined: 20 Jan 2012, 17:18
Contact:

Re: A few questions about some features

03 Feb 2015, 13:29

That function is for yourself, noesisGUI does not need it because it loads dynamically the method. So basically you must include it in your own headers and export the function from the dynamic library.
extern "C" __declspec(dllexport) void NsRegisterReflection(ComponentFactory*, NsBool)
{
   /// Register your own components here
}
 
ZanAlex
Topic Author
Posts: 66
Joined: 16 Jan 2015, 17:46

Re: A few questions about some features

03 Feb 2015, 15:07

Alright, everything is working as expected, I needed to refresh my memory about dynamic linkage.

Thank you for your help.
 
User avatar
jsantos
Site Admin
Posts: 3917
Joined: 20 Jan 2012, 17:18
Contact:

Re: A few questions about some features

03 Feb 2015, 15:44

I am updating the extending tutorial to v1.2 these days. As soon as I have it I will provide you a link to our github repository.

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 8 guests