Page 1 of 1

GraphicsSystem into QWidget?

Posted: Fri Aug 17, 2018 3:42 am
by srd
Trying to get GraphicsSystem (Ogre 2.1) into the main window of a Qt app. I added QWindow to GraphicsSystem as a class to inherit from, hoping to then upcast in the call to createWindowContainer. Can someone take a look and maybe offer a few comments on this, or enough to get past this error which I thought should work.

Code: Select all

// --- graphicssystem.h
    class GraphicsSystem : public BaseSystem, public QWindow,
        public Ogre::UniformScalableTask
    {
    protected:
        Ogre::RenderWindow *mRenderWindow;

// --- mainwindow.h
class MainWindow : public QMainWindow
{
    private:
        QWidget* renderWidget;
        Ogre::RenderWindow* renderWindow;

// mainwindow.cpp
MainWindow::MainWindow())
{
    // ...
    renderWindow = graphicsSystem.getRenderWindow();

    // ...
    renderWidget = QWidget::createWindowContainer(
        static_cast<QWindow*>(renderWindow));

              
mainwindow.cpp: In constructor ‘MainWindow::MainWindow()’:                                                              
mainwindow.cpp:89:35: error: invalid static_cast from type ‘Ogre::RenderWindow*’ to type ‘QWindow*’                     
   static_cast<QWindow*>(renderWindow));
                                     ^
make[4]: *** [Makefile:668: mainwindow.o] Error 1

Or if anyone knows of any examples around that do this (Ogre 2.1 w/ Qt)?

Re: GraphicsSystem into QWidget?

Posted: Fri Aug 17, 2018 10:20 am
by dermont
It looks like you are casting against the wrong window i.e the render window. You should be casting against the derived class GraphicsSystem pointer ( &graphicsSystem ?? ) since it has a base class QWindow.

Re: GraphicsSystem into QWidget?

Posted: Fri Aug 17, 2018 12:19 pm
by al2950
Take a look at Spookyboo's HLMS Editor and Magus

More specifically Ogre3_widget.h and Ogre3_widget.cpp

Re: GraphicsSystem into QWidget?

Posted: Sat Aug 18, 2018 2:48 am
by srd
Thanks, but this confirmed my suspicions. I had already been looking at HLMSEditor, which is based off of Magnus making them one in the same. They do not work with the current Samples framework. In fact, they're very different. OgreManager and QOgreWidget are complete rewrites of GraphicsSystem, making the reasoning I keep hearing for using the Samples framework completely useless. This is why I absolutely hate that Samples framework, it's unusable for anything but those tutorials.