• 1
  • 2
  • 3
  • 4
  • 5
  • 10
 
darthmaule2
Posts: 94
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

08 Nov 2014, 17:02

Ahh... I was looking for LocalResourceProvider here:
..\NoesisGUI-win-x86_64\Include
Rather than:
..\NoesisGUI-SDK-win\Include

...so now I can load a resource like this:
const NsChar *datapath = "C:\\XamlResources\\";
const Ptr<IResourceSystem>& resourceSystem= NsGetSystem<IResourceSystem>();
Ptr<ResourceProvider> provider = *new LocalResourceProvider(datapath);
resourceSystem->AddProvider(provider.GetPtr());
Ptr<BaseResource> comboBoxResource = resourceSystem->Load("ComboBox.xaml");
How then do I render it? The tutorial shows this code:
// Create the UI renderer
Ptr<UIElement> xaml = LoadXaml<UIElement>("Gui/Tutorials/Integration/DX9/UI.xaml");
gXamlRenderer = CreateRenderer(xaml.GetPtr());
gXamlRenderer->SetSize(640, 480);
gXamlRenderer->SetAntialiasingMode(Noesis::Gui::AntialiasingMode_PPAA);
CreateRenderer takes a UIElement* but I have a BaseResource* (my variable above "comboBoxResource"). How do I get the UIElement* from a loaded resource?
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2862
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

08 Nov 2014, 18:28

Ahh... I was looking for LocalResourceProvider here:
..\NoesisGUI-win-x86_64\Include
Rather than:
..\NoesisGUI-SDK-win\Include
You were looking at the correct folder. Problem is that the win-x86_64 binaries were not regenerated in the latest beta. I will fix it this week.
...so now I can load a resource like this:
const NsChar *datapath = "C:\\XamlResources\\";
const Ptr<IResourceSystem>& resourceSystem= NsGetSystem<IResourceSystem>();
Ptr<ResourceProvider> provider = *new LocalResourceProvider(datapath);
resourceSystem->AddProvider(provider.GetPtr());
Ptr<BaseResource> comboBoxResource = resourceSystem->Load("ComboBox.xaml");
The way to load resources is the same as before. You can use the LoadXaml<T> that will do the cast for you:
Ptr<UIElement> xaml = LoadXaml<UIElement>("ComboBox.xaml");
That way you will have the UIElement* that you needs for rendering.

Note that although you are requesting the file ComboBox.xaml, the provider you are using (LocalResourceProvider, whose code you can see in the the header) is in fact looking the preprocessed file ComboBox.xaml.nsb.
 
darthmaule2
Posts: 94
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

09 Nov 2014, 11:36

Thanks!
After figuring out I needed this line...
NsConfigValue("Render.RenderSystem", "Render", "DX11");
... I think I'm on my way to doing something useful
 
darthmaule2
Posts: 94
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

09 Nov 2014, 14:13

I'm struggling with this tutorial:

http://www.noesisengine.com/docs/Gui.Co ... orial.html

I've made a 64-bit Win32 DLL "NoesisGuiExtensions.dll" with a single cpp file that contains the tutorial code:
#include "stdafx.h"
#include "NoesisGuiExtensions.h"

#pragma warning(disable: 4275)
#pragma warning(disable: 4251)

#include <Noesis.h>
#include <NsCore/ReflectionImplement.h>
#include <NsCore/TypeId.h>
#include <NsCore/Boxing.h>
#include <NsCore/Package.h>
#include <NsCore/String.h>
#include <NsGui/BaseValueConverter.h>

using namespace Noesis;
using namespace Noesis::Core;
using namespace Noesis::Gui;
using namespace Noesis::Core::Boxing;

class UppercaseConverter: public BaseValueConverter
{
public:
	NsBool TryConvert(BaseComponent* value, const Type* targetType, BaseComponent* parameter,
		Ptr<BaseComponent>& result)
	{
		NsString text = Unbox<NsString>(NsStaticCast<BoxedValue*>(value));
		text.make_upper();
		result =  Box<NsString>(text);
		return true;
	}

private:
	NS_IMPLEMENT_INLINE_REFLECTION(UppercaseConverter, BaseValueConverter)
	{
		NsMeta<TypeId>("UppercaseConverter");
	}
};

extern "C" NS_DLL_EXPORT
void NsRegisterReflection(ComponentFactory* factory, NsBool registerComponents)
{
	NS_REGISTER_COMPONENT(UppercaseConverter)
}
I put the DLL into the NoesisGUI-SDK-win\Bin directory and ran the build tool against a file containing the XAML from the tutorial... I called that file "TextInput.xaml".

But, the build tool did not find the UppercaseConverter class even though it did load my DLL and it did find TextInput.xaml, here is a bit from the log:

x+ General - LoadLibrary NoesisGuiExtensions.dll: (#193)
00:00.3474x+ General > InitSystems
00:00.3474x+ General % > ResourceSystem (ResourceSystem)
00:00.3474x+ General < InitSystems [0.000028 sg]
00:00.3474x+ General & < NoesisApplication Init [0.037146 sg]
00:00.3474x+ General > NoesisApplication Run
00:00.3490x+ General ./TextInput.xaml
00:00.3493x+ Symbol ( Symbol added: 'Gui/Parse', Index: 1303
00:00.3493x+ Symbol $ Symbol added: 'Class', Index: 1304
00:00.3495
x+ General 3 Ignoring unknown type 'UppercaseConverter' (@5,6)
00:00.3502x+ Symbol , Symbol added: 'Gui/NameScope', Index: 1305
00:00.3504
x+ NS_ERROR Resource 'Converter' not found
00:00.3516x+ General 8 _NT_SYMBOL_PATH not set. Stack traces may be incorrect
00:00.3529 x+ General Parsing StaticResource (@9,6).
00:00.3529 x+ General Resource 'Converter' not found
00:00.3536x+ General > Kernel::Shutdown
00:00.3536x+ Kernel > Shutting down kernel systems
00:00.3536x+ Kernel ' > System Shut Down [ResourceSystem]
00:00.3536x+ Kernel > Shutting down libraries


The build tool was run from the bin directory like this:

.\Resource.BuildTool.exe .\ --outdir ..\Xaml --platform DX11

Any ideas what I could be missing?
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2862
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

09 Nov 2014, 15:44

LoadLibrary NoesisGuiExtensions.dll: (#193)
Error 193 is "%1 is not a valid Win32 application."

Problem is that, right now, BuildTool is a 32 bits executable. It cannot load 64 bits DLLs. I think the best option is having two project sharing the same extension. One that compiles a 32 bits DLL and the second one, your executable, where probably you don't need a DLL at all.
 
darthmaule2
Posts: 94
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

09 Nov 2014, 16:59

I made the DLL 32-bit and successfully compiled TextInput.xaml.nsb.

But now when I try to run my application, it throws and exception and returns this error information in the handler:
filename: \\Core\\Kernerl\\Src\\ComponentFactoryImpl.cpp
line: 121
desc: Can't create component UppercaseConverter, it is not registered

The log shows that UppercaseConvert symbol was added:

00:00.0325Ä0 General ARG1: --outdir
00:00.0325Ä0 General ARG2: ..\Xaml
00:00.0325Ä0 General ARG3: --platform
00:00.0325Ä0 General ARG4: DX11
00:00.0359Ä0 Symbol 1 Symbol added: 'UppercaseConverter', Index: 1303
00:00.0368Ä0 General > InitSystems
00:00.0368Ä0 General % > ResourceSystem (ResourceSystem)
00:00.0368Ä0 General < InitSystems [0.000017 sg]
00:00.0369Ä0 General & < NoesisApplication Init [0.004389 sg]
00:00.0369Ä0 General > NoesisApplication Run
00:00.0375Ä0 General ./ComboBox.xaml
00:00.0376Ä0 Symbol ( Symbol added: 'Gui/Parse', Index: 1304
00:00.0377Ä0 Symbol $ Symbol added: 'Class', Index: 1305
00:00.0392Ä0 Symbol 3 Symbol added: 'Gui/FrameworkElement', Index: 1306
00:00.0395Ä0 Symbol , Symbol added: 'Gui/NameScope', Index: 1307
00:00.0401Ä0
Serialization -> SerializeBegin
00:00.0411Ä0
Serialization U [0] UIResource [3756 bytes (0% metadata, 10% strings), 84 instances, 27 components]
00:00.0411Ä0
Serialization & <- SerializeEnd [3776 bytes written]
00:00.0431Ä0 General ./TextInput.xaml
00:00.0436Ä0 Symbol 5 Symbol added: 'Gui/ResourceDictionary', Index: 1308
00:00.0440Ä0
Serialization -> SerializeBegin
00:00.0442Ä0
Serialization U [0] UIResource [1054 bytes (0% metadata, 18% strings), 21 instances, 14 components]
00:00.0442Ä0
Serialization & <- SerializeEnd [1074 bytes written]


Again, thanks for all the help with this!
 
darthmaule2
Posts: 94
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

09 Nov 2014, 17:30

OK I figured it out... I had to call NsRegisterReflection. Basically this means that I need to duplicate all the code in my 32-bit DLL (my DLL that is called by the build tool) in my application (because I can't call a 32-bit dll from my 64-bit DLL). Does that sound right?
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2862
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

09 Nov 2014, 20:55

Exact, as explained in the Extending NoesisGUI Tutorial you need to manually register your classes in the factory. This is done automatically by the BuildTool when it finds plugins in the current directory.

Instead of duplicating the code, you can have two different projects sharing several files. Although in the future we will provide a 64-bits builder you probably do not want having a DLL for the extensions in your main application. So having two different projects seem like a good idea.
 
darthmaule2
Posts: 94
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

10 Nov 2014, 16:34

OK - so now I'm just trying to display the ComboBox.xaml from the samples that come with the SDK. I am rendering it and can type into the edit box with the blinking cursor.

... but, the theme is obviously not set, so I tried what the documentation says (but replaced the path with where I put NoesisStyle.xaml)

// Set default theme
IUISystem::SetTheme("Gui/Themes/NoesisStyle.xaml");
// Launch Noesis Kernel
NsGetKernel()->Init();

This results in "InitSystem" crashing with this error "Resource NoesisStyle.xaml not found". I tried building NoesisStyle.xaml (to create the nsb file) and put both files in multiple locations but haven't been able to get that to work.. I always get the same error. Has SetTheme changed any with the BETA?

Another issue I see is that clicking on the Combobox drop-downs doesn't display any visible submenu (although Ic an actually change the selection by just randomly clicking).

Any idea what I'm doing wrong here?
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2862
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

10 Nov 2014, 18:06

OK - so now I'm just trying to display the ComboBox.xaml from the samples that come with the SDK. I am rendering it and can type into the edit box with the blinking cursor.

... but, the theme is obviously not set, so I tried what the documentation says (but replaced the path with where I put NoesisStyle.xaml)

// Set default theme
IUISystem::SetTheme("Gui/Themes/NoesisStyle.xaml");
// Launch Noesis Kernel
NsGetKernel()->Init();

This results in "InitSystem" crashing with this error "Resource NoesisStyle.xaml not found". I tried building NoesisStyle.xaml (to create the nsb file) and put both files in multiple locations but haven't been able to get that to work.. I always get the same error. Has SetTheme changed any with the BETA?
If you installed a LocalResourceProvider at %ROOT and you set the theme to "Gui/Themes/NoesisStyle.xaml", the resource system expects to find the file at %ROOT/Gui/Themes/NoesisStyle.xaml.nsb. You can debug this by setting a breakpoint in LocalResourceProvider::RequestFile, whose code is included in the header.
Another issue I see is that clicking on the Combobox drop-downs doesn't display any visible submenu (although Ic an actually change the selection by just randomly clicking).

Any idea what I'm doing wrong here?
Are you rendering with a stencil surface set?
  • 1
  • 2
  • 3
  • 4
  • 5
  • 10

Who is online

Users browsing this forum: No registered users and 2 guests