render to texture in next 2.1

Problems building or running the engine, queries about how to use features etc.
Post Reply
alexwang
Gnoblar
Posts: 21
Joined: Thu Nov 04, 2021 10:17 am

render to texture in next 2.1

Post by alexwang »

Ogre Version: :ogre next 2.1
Operating System: : ubuntu 18
Render System: :opengles

Hi, i'm going to render to texture in ogre next 2.1; the code in ogre1.12.13 as follow; But in next 2.1, the function addViewport parameter doesn't contain Ogre::Camera, OgreViewPort.cpp doesn't contain setClearEveryFram, setBackGroundColor, a little functions are available in version 2.1.

Code: Select all

	TexturePtr frameBufferTex = TextureManager::getSingleton().createManual("frameBufferTex", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, 854, 480, 0, PF_R8G8B8, TU_RENDERTARGET);
	RenderTarget* renderTex = frameBufferTex->getBuffer()->getRenderTarget();
	renderTex->addViewport(scnMgr->getCamera("mainCam"));
	renderTex->getViewport(0)->setClearEveryFrame(true);
	renderTex->getViewPort(0)->setBackgroundColor(ColourValue::black);
	renderTex->getViewPort(0)->setOverlaysEnabled(true);
	renderTex->update();

then i tried exist functions in 2.1

Code: Select all

	.....
	.....
	auto vp = renderTex->addViewport(0,0,1,1);
	scnMgr->getCamera("mainCam")->_notifyViewport(vp);
	renderTex->getViewport(0)->clear(FBT_COLOUR|FBT_DEPTH, ColourValue::Black);
	

but it doesn't work; Is there an example of rendering to textures in version 2.1 ??

Post Reply