jasiuj
Topic Author
Posts: 6
Joined: 19 Jan 2018, 08:05

Unigine integration

25 Mar 2018, 14:33

Hi,

A few weeks back I was implemented NoesisGUI 2.1.0 RC3 into Unigine 2.6.1.1 engine (viewtopic.php?f=3&t=1170&p=7700&hilit=unigine#p7700).

In the middle of time I updated NoesisGUI into final 2.1 release. I created a base library project to integrate NoesisGUI 2.1 with Unigine 2.6.1.1 (it works from Starter version).

I would like to share it with you. But I hope that Noesis team will check and improve it. I give all rights for Noesis Team to use, modify and share it (just take it and make it better and share for everyone).

After update to 2.1 release version and migrate implementation from main app file to AppSystemLogic in Unigine (to work GUI in Editor2 as I described later in this topic) there is a problem that each rendered frame of NoesisGUI contains last frame too, I think soo. The problem is that transparency object of NoesisGUI is transparent just for a few first frames and then stay more opaque and full opaque at last. Also when I hide Noesis gui object it is still displayed in the GUI (as set Visibility as Collapsed for Grid object). So I need a help to resolve it as well. You will see it when you will add simple xaml file with transparent object in it.

I attach this project. Because of license agreement I do not include D3D11RenderDevice.h, D3D11RenderDevice.cpp and Render.D3D11RenderDevice.cpp files which you can add from NoesisGUI download pack (such files are not modified).

To use it just add this project to your solution in C++ of Unigine project. You have 2 option to use it:

1. in main.cpp file (but it will not work in Editor2):
#include "NoesisGUI.h"

#ifdef _WIN32
int wmain(int argc, wchar_t *argv[]) {
#else
int main(int argc, char *argv[]) {
#endif

	Unigine::Engine* pEngine = Unigine::Engine::init(UNIGINE_VERSION, argc, argv);
	...

	NoesisGUI* noesisGUI = &NoesisGUI::getInstance();
	noesisGUI->Initialize();

	while (!pEngine->isDone())
	{


		noesisGUI->Update();
		pEngine->update();

		pEngine->render();
		noesisGUI->Render();

		pEngine->swap();

		//noesisGUI->Clear();
		pEngine->swap();
	}

	noesisGUI->Shutdown();
	...

	return 0;
}


2. or in AppSystemLogic file:
#include "NoesisGUI.h"

NoesisGUI* noesisGUI;
	
int AppSystemLogic::init() {
{
	noesisGUI = &NoesisGUI::getInstance();
	noesisGUI->Initialize();
}	
	
int AppSystemLogic::update() {
	noesisGUI->Update();
	return 1;
}	

int AppSystemLogic::render() {
	noesisGUI->Render();
	return 1;
}
Example of us this library to load a new gui and implement button action:
		NoesisGUI* noesisGUI = &NoesisGUI::getInstance();
		noesisGUI->LoadUI("my_file.xaml");

		// garaz
		Noesis::Button* button1 = noesisGUI->xaml->FindName<Noesis::Button>("button_quit");
		button1->Click() += [](BaseComponent* sender, const RoutedEventArgs& args)
		{
			App::get()->exit();
		};
		
		...
Attachments
NoesisIntegration.zip
(5 KiB) Downloaded 85 times
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Unigine integration

27 Mar 2018, 10:53

Thanks for sharing this with the community! Before going on, could you please create a GitHub repository for it?
 
jasiuj
Topic Author
Posts: 6
Joined: 19 Jan 2018, 08:05

Re: Unigine integration

27 Mar 2018, 15:53

Thanks for sharing this with the community! Before going on, could you please create a GitHub repository for it?
Do I can/should create Public repository for it ? Do I can include Shaders.h, D3D11RenderDevice.h, D3D11RenderDevice.cpp and Render.D3D11RenderDevice.cpp Noesis files with the project ?
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Unigine integration

28 Mar 2018, 14:33

Do I can/should create Public repository for it ? Do I can include Shaders.h, D3D11RenderDevice.h, D3D11RenderDevice.cpp and Render.D3D11RenderDevice.cpp Noesis files with the project ?
Yes, you can include them. Please do not include the binaries (Noesis.dll)
 
jasiuj
Topic Author
Posts: 6
Joined: 19 Jan 2018, 08:05

Re: Unigine integration

28 Mar 2018, 16:58

Do I can/should create Public repository for it ? Do I can include Shaders.h, D3D11RenderDevice.h, D3D11RenderDevice.cpp and Render.D3D11RenderDevice.cpp Noesis files with the project ?
Yes, you can include them. Please do not include the binaries (Noesis.dll)
I already created Git repository at: https://github.com/researchdeveloping/N ... I-Unigine/ :)
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Unigine integration

28 Mar 2018, 20:02

Thank you!

Did you follow the integration guide? Because, this is the recommended way to implement the rendering (code taken from the GLUT integration sample)
// Offscreen rendering phase populates textures needed by the on-screen rendering
_view->GetRenderer()->UpdateRenderTree();
_view->GetRenderer()->RenderOffscreen();

// If you are going to render here with your own engine you need to restore the GPU state
// because noesis changes it. The framebuffer and viewport are restored here
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));

glClearColor(0.0f, 0.0f, 0.25f, 0.0f);
glClearStencil(0);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

// Rendering is done in the active framebuffer
_view->GetRenderer()->Render();
You are instead doing:
ID3D11RenderTargetView* pTexNoesisRTV = static_cast<ID3D11RenderTargetView*>(my_texture->getD3D11RenderTargetView());
pContext->OMSetRenderTargets(1, &pTexNoesisRTV, nullptr);

view->GetRenderer()->UpdateRenderTree();
view->GetRenderer()->RenderOffscreen();

view->GetRenderer()->Render();
That's not correct. You need to render the offscreen phase before setting the main render target and rendering the 3D scene.
 
jasiuj
Topic Author
Posts: 6
Joined: 19 Jan 2018, 08:05

Re: Unigine integration

29 Mar 2018, 08:52

I follow integration guide but for mistake I do it in a wrong way. As you write this fix the issue with transparency. This fix set to render NoesisGUI on top of Unigine (so it will be necessary to hide NoesisGUI to see Unigine console, to add Unigine cursor, etc.). I push this fix to GitHub.

By the way. Please correct me if I should choose other license than GPL 3 at GitHub ? Also I added notice there that D3D11RenderDevice.h, D3D11RenderDevice.cpp, Render.D3D11RenderDevice.cpp, Shaders.h filkes are licensed by Noesis with all rights and point everybody to Noesis website to check license.

Thanks!

Edit:
With the fix provided integration works well only within main.cpp. To work in AppSystemLogic you have to move pContext->OMSetRenderTargets line from render() at the top of the render() function. Then it will works in Editor2 as well but it will be broken transparency, etc. Also then NoesisGUI will be below Unigine GUI layer.

This may be related to different work main loop in the Unigine engine. I ask Unigine about it: https://developer.unigine.com/forum/top ... ui-sample/
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Unigine integration

29 Mar 2018, 15:28

By the way. Please correct me if I should choose other license than GPL 3 at GitHub ? Also I added notice there that D3D11RenderDevice.h, D3D11RenderDevice.cpp, Render.D3D11RenderDevice.cpp, Shaders.h filkes are licensed by Noesis with all rights and point everybody to Noesis website to check license.
That license is correct. Thanks for taking care!

Who is online

Users browsing this forum: No registered users and 1 guest