[2.1] Rendering Ogre 2.1 in a Qt widget using SDL
Posted: Wed Sep 21, 2016 4:35 am
I am trying to render Ogre 2.1 in a Qt widget using SDL. My project builds upon one of the examples provided in Ogre 2.1.
My problem is that the widget does not render Ogre, although mRoot->renderOneFrame() is called.
The original example contains the following lines in GraphicsSystem.cpp.
Then, the widget is initialised as follows.
OgreRenderer is responsible to render the Ogre scene. ui.centralwidget is a QFrame. I also implemented the resizeEvent and showEvent functions.
This renders an empty Ogre scene with a blue skybox in a separate window, as shown below.
Now I want to render the scene in the same window. Based on this tutorial, I changed those lines to the following.
As shown below, this doesn't render anything in the top widget. After resizing the window, some parts of the bottom widget is also rendered in the top widget.
So is there any way I can debug this to find what is wrong with the code? Please let me know if I need to give more information. If there is another way to render Ogre 2.1 in Qt, I am also happy to hear.
I use Qt 5.7, Visual Studio 2015, Windows 8.1.
Thank you.
My problem is that the widget does not render Ogre, although mRoot->renderOneFrame() is called.
The original example contains the following lines in GraphicsSystem.cpp.
Code: Select all
mSdlWindow = SDL_CreateWindow(
windowTitle.c_str(), // window title
posX, // initial x position
posY, // initial y position
width, // width, in pixels
height, // height, in pixels
SDL_WINDOW_SHOWN
| (fullscreen ? SDL_WINDOW_FULLSCREEN : 0) | SDL_WINDOW_RESIZABLE );
Code: Select all
m_pRenderer = new OgreRenderer(ui.centralwidget);
m_pRendererWidget = QWidget::createWindowContainer(
m_pRenderer,
ui.centralwidget);
m_pRendererWidget->resize(ui.centralwidget->size());
m_pRenderer->Initialize();
This renders an empty Ogre scene with a blue skybox in a separate window, as shown below.
Now I want to render the scene in the same window. Based on this tutorial, I changed those lines to the following.
Code: Select all
mSdlWindow = SDL_CreateWindowFrom((void*)widget->winId());
So is there any way I can debug this to find what is wrong with the code? Please let me know if I need to give more information. If there is another way to render Ogre 2.1 in Qt, I am also happy to hear.
I use Qt 5.7, Visual Studio 2015, Windows 8.1.
Thank you.