Jump to content

[SOLVED] 2.16 CustomSystemProxy link to External Window


photo

Recommended Posts

Hello.

We are migrating from version 2.14 to version 2.16.

I am making a window using MFC of Visual Studio 2019, and I am rendering by putting Unigine Engine in the View Window.

I am trying to render the view window by treating it as an extenal window, but only a black screen is continuously output.

CustomSystemProxy( SYSTEM_PROXY_MOUSE | SYSTEM_PROXY_KEYBOARD) 

I wonder if it is right to initialize without SYSTEM_PROXY_WINDOWS to render in extern window.

https://developer.unigine.com/en/docs/2.16/code/cpp/usage/unigine_app/proxy?rlang=cpp&words=customsystemproxy%2Ccustomsystemproxi#external_window

And I implemented it by referring to the link above, but the desired result does not come out continuously.

 

A simple winapi source is attached.

I think the changed structure is a really convenient structure, but it's difficult because it's the first time I'm used to it. Please help.

thank you

 

 

source (2).zip log.txt

Edited by KOVIAHN
Link to comment

Hello,

I looked at your code and you are doing everything right. But the problem is that the doRender() method isn't implemented for ExternalWindow. The empty implementation is called every frame, so we see a black background. For testing, you can try changing the code like this:

#include <UnigineViewport.h>
#include <UnigineGame.h>
  
using namespace Unigine;

class ExternalWindow
{
public:
	virtual ~ExternalWindow() = default;

	virtual void doRender()
	{
		PlayerPtr player = Game::getPlayer();
		if (!player)
			return;

		CameraPtr camera = player->getCamera();
		if (!camera)
			return;

		if (!viewport)
			viewport = Viewport::create();

		RenderState::saveState();
		RenderState::clearStates();

		// set your window size, for test 1600x900
		RenderState::setViewport(0, 0, 1600, 900);
		viewport->renderEngine(camera);

		RenderState::restoreState();
	}

	virtual void doUpdate() {}
	virtual void doSwap() {}
	virtual bool isRendering() const { return true; }

private:
	ViewportPtr viewport;
};

 As a result, we get the following image:

image.png

  • Thanks 1
Link to comment
  • silent changed the title to [SOLVED] 2.16 CustomSystemProxy link to External Window
×
×
  • Create New...