OGRECave / ogre-next

aka ogre v2 - scene-oriented, flexible 3D C++ engine
https://ogrecave.github.io/ogre-next/api/latest
Other
977 stars 221 forks source link

Multi window rendering of different texts? #446

Open ChenTianSky opened 1 month ago

ChenTianSky commented 1 month ago

I use Ogre:: v1:: Overlay as a container to add Ogre:: v1:: TextAreaOverlayElement to different windows, but the text from multiple windows will be stacked together and rendered on each window. How can I achieve rendering different text on different windows? For example, rendering hello in window A and world in window B

darksylinc commented 1 month ago

Hi!

You have multiple ways (assuming two windows, but it extends to N windows):

If interactions only happen in one window and the other windows just show data:

  1. Use two root windows and everything is derived from those windows. One root window for each Window.
  2. Use a CompositorWorkspaceListener::passPreExecute to identify your pass (use CompositorPassDef::mIdentifier for that) and...
  3. Set all root windows to hidden (via setHidden( true )) except the one belonging to the root window.

If each window needs full functionality:

You'll need the very recent OffScreenCanvas (needs OgreNext >= 3.0). See OffScreenCanvas2D and OffScreenCanvas3D samples.

Rather than using OffScreenCanvas::createTexture you can create the workspace externally (one for each Window) and use OffScreenCanvas::setWorkspace directly.

You'll get multiple secondary ColibriManagers (one OffScreenCanvas and ColibriManager per window) that are independent (you can't migrate widgets from one window to another though).