We use the code we just created, and as always, simply add the code we need for this new feature:
We need a new member variable in the
framelistener
to save the current render mode:Ogre::PolygonMode _PolyMode;
Init the value in the constructor with
PM_SOLID:
_PolyMode = Ogre::PolygonMode::PM_SOLID;
We then add a new
if
condition in theframeStarted()
function, which tests if the R key is pressed. If this is the case, we can change the render mode. If the current mode is solid, and we want it to be wireframe:if(_key->isKeyDown(OIS::KC_R)) { if(_PolyMode == PM_SOLID) { _PolyMode = Ogre::PolygonMode::PM_WIREFRAME; }
If it is wireframe, and we want it to change to point mode:
else if(_PolyMode == PM_WIREFRAME) { _PolyMode = Ogre::PolygonMode::PM_POINTS; }
And from point mode, back again to solid:
else if(_PolyMode == PM_POINTS) { _PolyMode = Ogre::PolygonMode::PM_SOLID; }
Now that we have calculated the new render mode, we can apply...