darthmaule2
Posts: 98
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

10 Nov 2014, 19:44

I do set a LocalResourceProvider but that happens later in the code. The SetTheme call happens before Init() and way before the LocalResourceProvider is created. If I move SetTheme after the LocalResourceProvider is created, it doesn't crash, but it doesn't change the theme. If I move the LocalResourceProvider creation before SetTheme, it crashes somewhere else. Here is the initialization code:
NsConfigValue("Render.RenderSystem", "Render", "DX11");

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

// Register own classes
ComponentFactory *factory = NsGetKernel()->GetComponentFactory();
NsRegisterReflection(factory, true);

// Start Up Noesis Systems
IDX11RenderSystem::SetDevice(g_pd3dDevice);
NsGetKernel()->InitSystems();

const NsChar *datapath = "Xaml";
const Ptr<IResourceSystem>& resourceSystem = NsGetSystem<IResourceSystem>();
Ptr<ResourceProvider> provider = *new LocalResourceProvider(datapath);
ResourceSystem->AddProvider(provider.GetPtr());

g_comboBox = LoadXaml<UIElement>("ComboBox.xaml");
g_pXamlRenderer = CreateRenderer(g_comboBox.GetPtr());
RECT dimensions;
GetClientRect( g_hWnd, &dimensions );
UINT width = dimensions.right - dimensions.left;
UINT height = dimensions.bottom - dimensions.top;
g_pXamlRenderer->SetSize(width, height);
g_pXamlRenderer->SetAntialiasingMode(Noesis::Gui::AntialiasingMode_PPAA);
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: noesisGUI v1.2 BETA

10 Nov 2014, 20:06

We have to evaluate what is happening, but could you please try to set the Theme after initializing the systems, something like this:
NsConfigValue("Render.RenderSystem", "Render", "DX11");

// Launch Noesis Kernel
NsGetKernel()->Init();

// Register own classes
ComponentFactory *factory = NsGetKernel()->GetComponentFactory();
NsRegisterReflection(factory, true);

// Start Up Noesis Systems
IDX11RenderSystem::SetDevice(g_pd3dDevice);
NsGetKernel()->InitSystems();

const NsChar *datapath = "Xaml";
const Ptr<IResourceSystem>& resourceSystem = NsGetSystem<IResourceSystem>();
Ptr<ResourceProvider> provider = *new LocalResourceProvider(datapath);
ResourceSystem->AddProvider(provider.GetPtr());

const Ptr<IUISystem>& uiSystem = NsGetSystem<IUISystem>();
Ptr<ResourceDictionary> theme = LoadXaml<ResourceDictionary>("NoesisStyle.xaml");
uiSystem->SetTheme(theme.GetPtr());

g_comboBox = LoadXaml<UIElement>("ComboBox.xaml");
g_pXamlRenderer = CreateRenderer(g_comboBox.GetPtr());
RECT dimensions;
GetClientRect( g_hWnd, &dimensions );
UINT width = dimensions.right - dimensions.left;
UINT height = dimensions.bottom - dimensions.top;
g_pXamlRenderer->SetSize(width, height);
g_pXamlRenderer->SetAntialiasingMode(Noesis::Gui::AntialiasingMode_PPAA);
 
darthmaule2
Posts: 98
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

10 Nov 2014, 21:24

I made your proposed change and then I got an error that it couldn't find the FontFamily. I realized I hadn't moved the fonts over to my local directory structure. So, now I have:

\Xaml\ComboBox.xaml
\Xaml\Themes\NoesisStyle.xaml
\Xaml\Themes\Fonts\Roboto*

I rebuilt everything with the build tool and updated the code to point to Themes directory:

const Ptr<IUISystem>& uiSystem = NsGetSystem<IUISystem>();
Ptr<ResourceDictionary> theme = LoadXaml<ResourceDictionary>("Themes/NoesisStyle.xaml");
uiSystem->SetTheme(theme.GetPtr());

Now it crashes on this line and doesn't provide any error information:

uiSystem->SetTheme(theme.GetPtr());

I know it's finding the themes and the fonts because if I change the Fonts directory name, then I just get the error "Unable to locate FontFamily".

The themes and fonts were built using the DX11 platform parameter. I'm using the Themes and Fonts folders from (copied to my local "Xaml" folder):

NoesisGUI-win-x86_64\Data\Themes
NoesisGUI-win-x86_64\Data\Themes\Fonts

Could this be an issue with my application being 64-bit? Or maybe I have the directory structure wrong?
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

11 Nov 2014, 02:39

Now it crashes on this line and doesn't provide any error information:
uiSystem->SetTheme(theme.GetPtr());
Could you confirm with the debugger that theme variable is not null?

When you say "it doesn't provide error information" does it mean that your error handler is not being invoked, or that it is being invoked with an empty description? Or are you getting a native exception (like access violation) ?

Thanks for clarifying.
 
darthmaule2
Posts: 98
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

11 Nov 2014, 12:06

The theme variable is not null. I changed the code to the following and it crashes on the last line:
const Ptr<IUISystem>& uiSystem = NsGetSystem<IUISystem>();
Ptr<ResourceDictionary> theme = LoadXaml<ResourceDictionary>("Themes/NoesisStyle.xaml");
ResourceDictionary *themeResources = theme.GetPtr();
uiSystem->SetTheme(themeResources);
The exception is an Access Violation. themeResources is also not null but looks to be initialized with 0xfeeefeee...
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

11 Nov 2014, 13:55

I have updated the x86_64 distributable. The link is in the first page. Please, download and tell me if the error still happens.
 
darthmaule2
Posts: 98
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

11 Nov 2014, 14:37

It's working now... thanks!
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

11 Nov 2014, 14:58

It's working now... thanks!
Good news! What happened with the submenu issue?
 
darthmaule2
Posts: 98
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA

11 Nov 2014, 16:56

Good news! What happened with the submenu issue?
Well... I still have that problem but I'm guessing it is mostly due to my lack of DirectX11 skills :).

Basically, I'm just starting with tutorial05 here...
https://code.msdn.microsoft.com/windows ... 2-829979ef

And then trying to modify your sample DirectX9 render code for DirectX11:
// Render the scene
if( SUCCEEDED( pd3dDevice->BeginScene() ) )
{
    // Tick kernel
    NsGetKernel()->Tick();

    // Update UI
    gXamlRenderer->Update(fTime);
    RenderCommands commands = gXamlRenderer->WaitForUpdate();

    IDirect3DSurface9* color;
    DXUTGetD3D9Device()->GetRenderTarget(0, &color);
    color->Release();

    IDirect3DSurface9* depth;
    DXUTGetD3D9Device()->GetDepthStencilSurface(&depth);
    depth->Release();

    // Draw surface
    V(gStateBlock->Capture());
    gXamlRenderer->Render(commands.offscreenCommands.GetPtr());
    V(gStateBlock->Apply());

    DXUTGetD3D9Device()->SetRenderTarget(0, color);
    DXUTGetD3D9Device()->SetDepthStencilSurface(depth);

    // Clear the render target and the zbuffer
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 66, 75, 121 ), 1.0f, 0 ) );

    ...
    ///////////////////////
    // RENDER SCENE
    ///////////////////////
    ...

    // Draw GUI
    V(gStateBlock->Capture());
    gXamlRenderer->Render(commands.commands.GetPtr());
    V(gStateBlock->Apply());

    V( pd3dDevice->EndScene() );
So the render code from the tutorial that I'm starting from (without any of my modifications) is:
void Render()
{
    // Update our time
    static float t = 0.0f;
    if( g_driverType == D3D_DRIVER_TYPE_REFERENCE )
    {
        t += ( float )XM_PI * 0.0125f;
    }
    else
    {
        static ULONGLONG timeStart = 0;
        ULONGLONG timeCur = GetTickCount64();
        if( timeStart == 0 )
            timeStart = timeCur;
        t = ( timeCur - timeStart ) / 1000.0f;
    }

    // 1st Cube: Rotate around the origin
	g_World1 = XMMatrixRotationY( t );

    // 2nd Cube:  Rotate around origin
    XMMATRIX mSpin = XMMatrixRotationZ( -t );
    XMMATRIX mOrbit = XMMatrixRotationY( -t * 2.0f );
	XMMATRIX mTranslate = XMMatrixTranslation( -4.0f, 0.0f, 0.0f );
	XMMATRIX mScale = XMMatrixScaling( 0.3f, 0.3f, 0.3f );

	g_World2 = mScale * mSpin * mTranslate * mOrbit;

    //
    // Clear the back buffer
    //
    g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, DirectX::Colors::MidnightBlue );

    //
    // Clear the depth buffer to 1.0 (max depth)
    //
    g_pImmediateContext->ClearDepthStencilView( g_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0 );

    //
    // Update variables for the first cube
    //
    ConstantBuffer cb1;
	cb1.mWorld = XMMatrixTranspose( g_World1 );
	cb1.mView = XMMatrixTranspose( g_View );
	cb1.mProjection = XMMatrixTranspose( g_Projection );
	g_pImmediateContext->UpdateSubresource( g_pConstantBuffer, 0, nullptr, &cb1, 0, 0 );

    //
    // Render the first cube
    //
	g_pImmediateContext->VSSetShader( g_pVertexShader, nullptr, 0 );
	g_pImmediateContext->VSSetConstantBuffers( 0, 1, &g_pConstantBuffer );
	g_pImmediateContext->PSSetShader( g_pPixelShader, nullptr, 0 );
	g_pImmediateContext->DrawIndexed( 36, 0, 0 );

    //
    // Update variables for the second cube
    //
    ConstantBuffer cb2;
	cb2.mWorld = XMMatrixTranspose( g_World2 );
	cb2.mView = XMMatrixTranspose( g_View );
	cb2.mProjection = XMMatrixTranspose( g_Projection );
	g_pImmediateContext->UpdateSubresource( g_pConstantBuffer, 0, nullptr, &cb2, 0, 0 );

    //
    // Render the second cube
    //
	g_pImmediateContext->DrawIndexed( 36, 0, 0 );

	/////////////////////////////////////////////////////////////////////////////////////////

    //
    // Present our back buffer to our front buffer
    //
    g_pSwapChain->Present( 0, 0 );
}
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA

12 Nov 2014, 00:35

I do not see the creation code in that samples. Just make sure that you are creating a Depth surface with Stencil bits:
D3D11_TEXTURE2D_DESC desc;
desc.Width = width;
desc.Height = height;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
desc.SampleDesc = sampleDesc;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;

D3DPtr<ID3D11Texture2D> depthStencil;
V(device->CreateTexture2D(&desc, 0, depthStencil.GetPtrForInit()));
V(device->CreateDepthStencilView(depthStencil.GetPtr(), 0, &mDepthStencil));
Anyway, I am updating the integration samples these days. Please, give me a few days and I will publish the DX11 integration sample in github.

Who is online

Users browsing this forum: No registered users and 31 guests