Skip to content

Commit

Permalink
Fix render system (#1101)
Browse files Browse the repository at this point in the history
* typedef to handle different types for window id handles

* update to follow latest recommendations

for integrating Qt5 and Ogre3D, see:

http://www.ogre3d.org/tikiwiki/tiki-
index.php?page=Integrating+Ogre+into+QT5

* restore conditional for Qt5

fixes #1100
  • Loading branch information
wjwwood authored May 6, 2017
1 parent 8119e2d commit 2801067
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
17 changes: 6 additions & 11 deletions src/rviz/ogre_helpers/render_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ int checkBadDrawable( Display* display, XErrorEvent* error )
#endif // Q_WS_X11

Ogre::RenderWindow* RenderSystem::makeRenderWindow(
unsigned long window_id,
WindowIDType window_id,
unsigned int width,
unsigned int height,
double pixel_ratio)
Expand All @@ -355,11 +355,8 @@ Ogre::RenderWindow* RenderSystem::makeRenderWindow(
Ogre::NameValuePairList params;
Ogre::RenderWindow *window = NULL;

#ifdef Q_OS_MAC
params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)window_id);
#else
params["parentWindowHandle"] = Ogre::StringConverter::toString((unsigned long)window_id);
#endif
params["externalWindowHandle"] = Ogre::StringConverter::toString(window_id);
params["parentWindowHandle"] = Ogre::StringConverter::toString(window_id);

params["externalGLControl"] = true;

Expand All @@ -369,11 +366,9 @@ Ogre::RenderWindow* RenderSystem::makeRenderWindow(
}

// Set the macAPI for Ogre based on the Qt implementation
#ifdef QT_MAC_USE_COCOA
params["macAPI"] = "cocoa";
params["macAPICocoaUseNSView"] = "true";
#else
params["macAPI"] = "carbon";
#if defined(Q_OS_MAC)
parameters["macAPI"] = "cocoa";
parameters["macAPICocoaUseNSView"] = "true";
#endif
params["contentScalingFactor"] = std::to_string(pixel_ratio);

Expand Down
11 changes: 9 additions & 2 deletions src/rviz/ogre_helpers/render_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ namespace rviz
class RenderSystem
{
public:

#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
typedef size_t WindowIDType;
#else
typedef unsigned long WindowIDType;
#endif

static RenderSystem* get();

Ogre::RenderWindow* makeRenderWindow(
unsigned long window_id,
WindowIDType window_id,
unsigned int width,
unsigned int height,
double pixel_ratio = 1.0);
Expand Down Expand Up @@ -96,7 +103,7 @@ class RenderSystem
static RenderSystem* instance_;

// ID for a dummy window of size 1x1, used to keep Ogre happy.
unsigned long dummy_window_id_;
WindowIDType dummy_window_id_;

Ogre::Root* ogre_root_;
Ogre::OverlaySystem* ogre_overlay_system_;
Expand Down
6 changes: 5 additions & 1 deletion src/rviz/ogre_helpers/render_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ RenderWidget::RenderWidget( RenderSystem* render_system, QWidget *parent )
this->setLayout(mainLayout);
#endif

WId win_id = this->renderFrame->winId();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
rviz::RenderSystem::WindowIDType win_id = this->renderFrame->winId();
#else
rviz::RenderSystem::WindowIDType win_id = this->winId();
#endif
QApplication::flush();

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Expand Down

0 comments on commit 2801067

Please sign in to comment.