About integerate NoesisGUI with OGRE 2.1
Hi guys,
I have some problem with integerate NoesisGUI with Ogre 2.1.
1. As we use OGRE 2.1 we use directX 11, I found an OgreBindings project at github but it's use directX 9. I chaned some code and use the D3D11 Render from 1.3 sdk to support directX11. Because I never use Dirext api before, the Tutorial05 in the sdk said that "Restore state. This must be done per frame because NoesisGUI modifies the GPU state" and the code shown as below
g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, g_pDepthStencilView);
g_pImmediateContext->IASetInputLayout(g_pVertexLayout);
UINT stride = sizeof(SimpleVertex);
UINT offset = 0;
g_pImmediateContext->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
g_pImmediateContext->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
g_pImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
g_pImmediateContext->OMSetDepthStencilState(0, 0);
g_pImmediateContext->RSSetState(0);
g_pImmediateContext->OMSetBlendState(0, 0, 0xffffffff);
D3D11_VIEWPORT vp = { 0.0f, 0.0f, (FLOAT)g_Width, (FLOAT)g_Height, 0.0f, 1.0f};
g_pImmediateContext->RSSetViewports(1, &vp);
I'm wonder which code are store the GPU state and which are restore the GPU state. I'm sorry to ask you so basic issus.
In my project I call renderer->RenderOffscreen() when Ogre framestarted and call renderer->Render() when Ogre frameRenderingQueued as the OgreBindings sample at github.
2. In our project we support some keyboard shutcuts such as W-A-S-D to control walk. When showing a gui view with an input in the 3D scence, I want the input box to lost focus when the mouse clicked out of the gui view. I found a method UIElement::Focus but there no method called such as ReleaseFocus, how can I implement this function. I want when I press 'W' the word will not show in the input box after I clicked the mouse out of the view but walking.
3. How do I determine if an event(keyboard event, mouse event or touch event) has been handled by NoesisGUI or not? Just now I found UIElement::IsMouseOver method, is that correct?
Thanks.
I have some problem with integerate NoesisGUI with Ogre 2.1.
1. As we use OGRE 2.1 we use directX 11, I found an OgreBindings project at github but it's use directX 9. I chaned some code and use the D3D11 Render from 1.3 sdk to support directX11. Because I never use Dirext api before, the Tutorial05 in the sdk said that "Restore state. This must be done per frame because NoesisGUI modifies the GPU state" and the code shown as below
g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, g_pDepthStencilView);
g_pImmediateContext->IASetInputLayout(g_pVertexLayout);
UINT stride = sizeof(SimpleVertex);
UINT offset = 0;
g_pImmediateContext->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
g_pImmediateContext->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
g_pImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
g_pImmediateContext->OMSetDepthStencilState(0, 0);
g_pImmediateContext->RSSetState(0);
g_pImmediateContext->OMSetBlendState(0, 0, 0xffffffff);
D3D11_VIEWPORT vp = { 0.0f, 0.0f, (FLOAT)g_Width, (FLOAT)g_Height, 0.0f, 1.0f};
g_pImmediateContext->RSSetViewports(1, &vp);
I'm wonder which code are store the GPU state and which are restore the GPU state. I'm sorry to ask you so basic issus.
In my project I call renderer->RenderOffscreen() when Ogre framestarted and call renderer->Render() when Ogre frameRenderingQueued as the OgreBindings sample at github.
2. In our project we support some keyboard shutcuts such as W-A-S-D to control walk. When showing a gui view with an input in the 3D scence, I want the input box to lost focus when the mouse clicked out of the gui view. I found a method UIElement::Focus but there no method called such as ReleaseFocus, how can I implement this function. I want when I press 'W' the word will not show in the input box after I clicked the mouse out of the view but walking.
3. How do I determine if an event(keyboard event, mouse event or touch event) has been handled by NoesisGUI or not? Just now I found UIElement::IsMouseOver method, is that correct?
Thanks.
Re: About integerate NoesisGUI with OGRE 2.1
Don't worry about asking basic issues. In fact, this is not a basic issue. Whenever you call Render() or RenderOffscreen() we modify the GPU state and it must be restored at your side. The easiest and more efficient way is by setting all the changed states again in your engine.That is what is being done in the integration sample. Another alternative, easier to implement but more inefficient would be doing Gets before calling Noesis and doing Sets after that to restore the state. In D3D11 this is very easy, this is the list of states we are chaning:1. I'm wonder which code are store the GPU state and which are restore the GPU state. I'm sorry to ask you so basic issus.
In my project I call renderer->RenderOffscreen() when Ogre framestarted and call renderer->Render() when Ogre frameRenderingQueued as the OgreBindings sample at github.
Code: Select all
mContext->IASetIndexBuffer(mIndices.buffer, DXGI_FORMAT_R16_UINT, 0);
mContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
mContext->VSSetConstantBuffers(0, 1, &mConstants);
mContext->PSSetConstantBuffers(0, 1, &mConstants);
mContext->HSSetShader(0, 0, 0);
mContext->DSSetShader(0, 0, 0);
mContext->GSSetShader(0, 0, 0);
mContext->CSSetShader(0, 0, 0);
mContext->SetPredication(0, 0);
mContext->IASetInputLayout(layout);
mContext->VSSetShader(shader, 0, 0);
mContext->PSSetShader(shader, 0, 0);
mContext->RSSetState(state);
mContext->OMSetBlendState(state, 0, 0xffffffff);
mContext->OMSetDepthStencilState(state, stencilRef);
mContext->PSSetShaderResources(0-3, 1, &texture);
mContext->PSSetSamplers(0-3, 1, &sampler);
I will improve the integration sample with all this to avoid confusion.
I recommend using VisualTreeHelper::HitTest to detect if the mouse position is over a NoesisGUI element or not. Our D3D9 integration sample does it. Note that sample is using NoesisGUI 1.2.2. In our project we support some keyboard shutcuts such as W-A-S-D to control walk. When showing a gui view with an input in the 3D scence, I want the input box to lost focus when the mouse clicked out of the gui view. I found a method UIElement::Focus but there no method called such as ReleaseFocus, how can I implement this function. I want when I press 'W' the word will not show in the input box after I clicked the mouse out of the view but walking.
Using HitTest as commented above you can easily implement a keyboard focus manager between your application and NoesisGUI. Please, let me know if you need more details about it.3. How do I determine if an event(keyboard event, mouse event or touch event) has been handled by NoesisGUI or not? Just now I found UIElement::IsMouseOver method, is that correct?
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: About integerate NoesisGUI with OGRE 2.1
If you want to manually remove the focus of an element, you can do it via the Mouse class, by calling:
You can execute that code when the user clicks outside any element of the UI, and you know it by using VisualTreeHelper::HitTest() as jsantos previously indicated.
Code: Select all
Mouse* mouse = element->GetMouse();
mouse->Capture(0);
Re: About integerate NoesisGUI with OGRE 2.1
I tried you guys described above, it's works fine for me. Thank you.
Who is online
Users browsing this forum: No registered users and 6 guests