34 #include <OgreViewport.h> 35 #include <OgreCamera.h> 36 #include <OgreRenderWindow.h> 37 #include <OgreStringConverter.h> 38 #include <OgreGpuProgramManager.h> 39 #include <OgreRenderTargetListener.h> 44 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX 57 , overlays_enabled_(true)
58 , background_color_(
Ogre::ColourValue::Black)
59 , stereo_enabled_(false)
60 , rendering_stereo_(false)
61 , left_camera_(nullptr)
62 , right_camera_(nullptr)
63 , right_viewport_(nullptr)
72 #if OGRE_STEREO_ENABLE 106 #if OGRE_STEREO_ENABLE 108 viewport_->setDrawBuffer(Ogre::CBT_BACK_LEFT);
125 #if OGRE_STEREO_ENABLE 126 viewport_->setDrawBuffer(Ogre::CBT_BACK);
141 Ogre::Viewport* viewport = evt.source;
143 const Ogre::Vector2& offset =
camera_->getFrustumOffset();
144 const Ogre::Vector3 pos =
camera_->getPosition();
145 const Ogre::Vector3 right =
camera_->getRight();
146 const Ogre::Vector3 up =
camera_->getUp();
156 Ogre::Vector3 newpos = pos + right * offset.x + up * offset.y;
171 Ogre::Vector3 newpos = pos - right * offset.x - up * offset.y;
180 ROS_WARN(
"Begin rendering to unknown viewport.");
186 Ogre::Viewport* viewport = evt.source;
198 ROS_WARN(
"End rendering to unknown viewport.");
239 viewport_->setOverlaysEnabled(overlays_enabled);
249 viewport_->setBackgroundColour(background_color);
260 camera_->setAspectRatio(Ogre::Real(width()) / Ogre::Real(height()));
263 right_camera_->setAspectRatio(Ogre::Real(width()) / Ogre::Real(height()));
266 if (
camera_->getProjectionType() == Ogre::PT_ORTHOGRAPHIC)
272 camera_->setCustomProjectionMatrix(
true, proj);
306 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
boost::function< void()> pre_render_callback_
Functor which is called before each render.
void postViewportUpdate(const Ogre::RenderTargetViewportEvent &evt) override
bool enableStereo(bool enable)
Enable or disable stereo rendering If stereo is not supported this is ignored.
static RenderSystem * get()
void paintEvent(QPaintEvent *e) override
~QtOgreRenderWindow() override
QtOgreRenderWindow(QWidget *parent=nullptr)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
void preViewportUpdate(const Ogre::RenderTargetViewportEvent &evt) override
virtual void setPreRenderCallback(boost::function< void()> func)
void setCameraAspectRatio()
Ogre::Viewport * right_viewport_
Ogre::Viewport * getViewport() const
void setBackgroundColor(Ogre::ColourValue color)
Ogre::ColourValue background_color_
boost::function< void()> post_render_callback_
Functor which is called after each render.
Ogre::Camera * right_camera_
void buildScaledOrthoMatrix(Ogre::Matrix4 &proj, float left, float right, float bottom, float top, float near, float far)
void resizeEvent(QResizeEvent *event) override
void setupStereo()
Prepare to render in stereo if enabled and supported.
void setCamera(Ogre::Camera *camera)
Ogre::Viewport * viewport_
Ogre::Camera * left_camera_
void setOverlaysEnabled(bool overlays_enabled)
virtual void setPostRenderCallback(boost::function< void()> func)
void setOrthoScale(float scale)
Set the scale of the orthographic window. Only valid for an orthographic camera.