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 55 , ortho_scale_( 1.0
f )
56 , auto_render_( true )
58 , overlays_enabled_( true )
59 , background_color_(
Ogre::ColourValue::Black )
60 , stereo_enabled_( false )
61 , rendering_stereo_( false )
64 , right_viewport_( 0 )
73 #if OGRE_STEREO_ENABLE 107 #if OGRE_STEREO_ENABLE 109 viewport_->setDrawBuffer(Ogre::CBT_BACK_LEFT);
126 #if OGRE_STEREO_ENABLE 127 viewport_->setDrawBuffer(Ogre::CBT_BACK);
142 const Ogre::RenderTargetViewportEvent& evt)
144 Ogre::Viewport* viewport = evt.source;
146 const Ogre::Vector2& offset =
camera_->getFrustumOffset();
147 const Ogre::Vector3 pos =
camera_->getPosition();
148 const Ogre::Vector3 right =
camera_->getRight();
149 const Ogre::Vector3 up =
camera_->getUp();
155 viewport->setCamera(
camera_ );
159 Ogre::Vector3 newpos = pos
172 viewport->setCamera(
camera_ );
176 Ogre::Vector3 newpos = pos
187 ROS_WARN(
"Begin rendering to unknown viewport.");
192 const Ogre::RenderTargetViewportEvent& evt)
194 Ogre::Viewport* viewport = evt.source;
206 ROS_WARN(
"End rendering to unknown viewport.");
246 viewport_->setOverlaysEnabled( overlays_enabled );
256 viewport_->setBackgroundColour( background_color );
267 camera_->setAspectRatio( Ogre::Real( width() ) / Ogre::Real( height() ) );
269 right_camera_->setAspectRatio( Ogre::Real( width() ) / Ogre::Real( height() ) );
272 if (
camera_->getProjectionType() == Ogre::PT_ORTHOGRAPHIC )
279 camera_->setCustomProjectionMatrix(
true, proj);
313 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
boost::function< void()> pre_render_callback_
Functor which is called before each render.
virtual void resizeEvent(QResizeEvent *event)
bool enableStereo(bool enable)
Enable or disable stereo rendering If stereo is not supported this is ignored.
static RenderSystem * get()
QtOgreRenderWindow(QWidget *parent=0)
boost::function< void()> post_render_callback_
Functor which is called after each render.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
virtual void setPreRenderCallback(boost::function< void()> func)
void setCameraAspectRatio()
Ogre::Viewport * right_viewport_
virtual ~QtOgreRenderWindow()
void setBackgroundColor(Ogre::ColourValue color)
Ogre::ColourValue background_color_
virtual void postViewportUpdate(const Ogre::RenderTargetViewportEvent &evt)
Ogre::Viewport * getViewport() const
Ogre::Camera * right_camera_
void buildScaledOrthoMatrix(Ogre::Matrix4 &proj, float left, float right, float bottom, float top, float near, float far)
void setupStereo()
Prepare to render in stereo if enabled and supported.
virtual void preViewportUpdate(const Ogre::RenderTargetViewportEvent &evt)
virtual void paintEvent(QPaintEvent *e)
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.