Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "rve_render_server/render_window.h"
00031
00032 #include <OGRE/OgreRenderWindow.h>
00033 #include <OGRE/OgreRenderSystem.h>
00034 #include <OGRE/OgreRoot.h>
00035
00036 #include <ros/assert.h>
00037
00038 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
00039 #include <GL/glx.h>
00040 #endif
00041
00042 namespace rve_render_server
00043 {
00044
00045 RenderWindow::RenderWindow(const rve_common::UUID& id, Renderer* rend, const std::string& parent_window_handle, uint32_t width, uint32_t height)
00046 : RenderTarget(id, rend, width, height)
00047 , render_window_(0)
00048 {
00049 Ogre::Root* root = Ogre::Root::getSingletonPtr();
00050 Ogre::NameValuePairList params;
00051 params["parentWindowHandle"] = parent_window_handle;
00052
00053
00054 std::stringstream id_str;
00055 id_str << id;
00056 Ogre::RenderWindow* win = root->createRenderWindow(id_str.str(), width, height, false, ¶ms);
00057
00058 win->setActive(true);
00059 win->setVisible(true);
00060 win->setAutoUpdated(false);
00061 render_window_ = win;
00062
00063 setTarget(render_window_);
00064 }
00065
00066 RenderWindow::~RenderWindow()
00067 {
00068 Ogre::Root* root = Ogre::Root::getSingletonPtr();
00069
00070 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
00071 Display* disp = 0;
00072 render_window_->getCustomAttribute("XDISPLAY", &disp);
00073 #endif
00074
00075 root->getRenderSystem()->destroyRenderWindow(render_window_->getName());
00076
00077 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
00078
00079 XSync(disp, False);
00080 #endif
00081 }
00082
00083 void RenderWindow::resize(uint32_t width, uint32_t height)
00084 {
00085 RenderTarget::resize(width, height);
00086
00087
00088 #if !defined(__APPLE__)
00089 render_window_->resize(width, height);
00090 #endif
00091
00092 render_window_->windowMovedOrResized();
00093 }
00094
00095 }