[2.2] Mac/Metal - reposition(..) and requestResolution(..)

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


fun3d
Gnoblar
Posts: 4
Joined: Sat Apr 18, 2020 7:06 pm
x 1

[2.2] Mac/Metal - reposition(..) and requestResolution(..)

Post by fun3d »

I'm rendering inside a QQuickItem which uses a single rendering context for multiple embedded items. By default, passing the QWindow::winId() and then ::renderOneFrame() causes rendering across the entire window, not just the item. I assume this is because of the single context.

RenderWindow::reposition and ::requestResolution had no effect, so I dug into the MetalRenderWindow - looks like that hadn't been implemented. Copying the IOS code for ::reposition did actually work to change the origin of the render:

Code: Select all

CGRect frame = mMetalView.frame;
frame.origin.x = left;
frame.origin.y = top;
mMetalView.frame = frame;
checkLayerSizeChanges();
The same was not true of ::requestResolution. I tried lot's of iterations of forcing the size at different stages of the rendering pipeline, but couldn't change the size of the render window. Figured there may be a back story on this since it wasn't implemented.

The only thing I can think of is that I'm fighting with Qt over control of the mMetalView.size.

Anybody got any leads?
fun3d
Gnoblar
Posts: 4
Joined: Sat Apr 18, 2020 7:06 pm
x 1

Re: [2.2] Mac/Metal - reposition(..) and requestResolution(..)

Post by fun3d »

Small update. Proofed out the support on mac by:
  • Adding Ogre::Window::resize(x,y,w,h) and Ogre::MetalWindow::resize(...)
  • Setting the mMetalLayer frame origin and size
  • Removing the position setting in OSX/OgreMetalView.mm
  • Turned off default animations to the CAMetalLayer (you see this in full window rendering as well where the layer resizes animate to the new width/height. Prefer to let Qt do the animating. (Long run it probably wants a toggle or something.)
As I mentioned, previously, QQuick using a single render buffer for the entire window, so the metal layer that Ogre renders to needs to limit rendering a certain pane (Item in QML-speak) that it contains. I'm sure manipulating the size of the CAMetalLayer will have some adverse affect on QQuick that I haven't observed yet.

Also sure that it breaks something on iOS and doesn't do anything on other platforms, yet. But fixin' it is part of the fun!

Will throw some patches up sometime soon.