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: 18
Joined: Sun Jan 14, 2018 6:12 am

GraphicsSystem into QWidget?

Post by srd » Fri Aug 17, 2018 3:42 am

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)?
0 x

dermont
Orc Shaman
Posts: 768
Joined: Thu Dec 09, 2004 2:51 am
x 8

Re: GraphicsSystem into QWidget?

Post by dermont » Fri Aug 17, 2018 10:20 am

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.
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1133
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 51

Re: GraphicsSystem into QWidget?

Post by al2950 » Fri Aug 17, 2018 12:19 pm

Take a look at Spookyboo's HLMS Editor and Magus

More specifically Ogre3_widget.h and Ogre3_widget.cpp
1 x

srd
Gnoblar
Posts: 18
Joined: Sun Jan 14, 2018 6:12 am

Re: GraphicsSystem into QWidget?

Post by srd » Sat Aug 18, 2018 2:48 am

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.
0 x

Post Reply