GraphicsSystem into QWidget?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
srd
Gnoblar
Posts: 21
Joined: Sun Jan 14, 2018 6:12 am

GraphicsSystem into QWidget?

Post 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)?
dermont
Bugbear
Posts: 812
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: GraphicsSystem into QWidget?

Post 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.
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: GraphicsSystem into QWidget?

Post by al2950 »

Take a look at Spookyboo's HLMS Editor and Magus

More specifically Ogre3_widget.h and Ogre3_widget.cpp
srd
Gnoblar
Posts: 21
Joined: Sun Jan 14, 2018 6:12 am

Re: GraphicsSystem into QWidget?

Post 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.
Post Reply