Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Integration issues OpenSceneGraph -> QOpenGLWidget, GL context override
Forum Updated to NodeBB v4.3 + New Features

Integration issues OpenSceneGraph -> QOpenGLWidget, GL context override

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johansson_gbg
    wrote on 7 Feb 2020, 09:57 last edited by
    #1

    Hello Qt devs!

    I'm cross posting this from https://groups.google.com/forum/#!topic/osg-users/-I2wXtUFzrM where i originally discussed this issue. I am using the OpenSceneGraph library to abstract OpenGL but instanciating my viewport window through the QOpenGLWidget. This is an example code i have generated to explain my issue.

    QtOSGWidget(QWidget* parent = 0)
    
          : QOpenGLWidget(parent)
    
            , _mGraphicsWindow(new osgViewer::GraphicsWindowEmbedded( this->x(), this->y(),
    
                                                                      this->width(), this->height() ) )
    
            , _mViewer(new osgViewer::Viewer)
    
          // take care of HDPI screen, e.g. Retina display on Mac
    
          , m_scale(QApplication::desktop()->devicePixelRatio())
    
          {
    
            _mGraphicsWindow->init();
    
    
    
            osg::Group* root = new osg::Group;
    
    
    
            osg::StateSet* rootStateSet = root->getOrCreateStateSet();
    
            rootStateSet->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );
    
    
    
            osgText::Text* text = new osgText::Text();
    
            text->setText("ABRAKADABRA");
    
            text->setCharacterSize(14);
    
            text->setCharacterSizeMode(osgText::Text::CharacterSizeMode::SCREEN_COORDS);
    
            text->setAutoRotateToScreen(true);
    
            text->setColor(osg::Vec4(0,0,0,1));
    
    
    
            osg::Geode* drawableText = new osg::Geode;
    
            drawableText->addDrawable(text);
    
            root->addChild(drawableText);
    
    
    
            osg::Camera* camera = new osg::Camera;
    
            camera->setViewport( 0, 0, this->width(), this->height() );
    
            camera->setClearColor( osg::Vec4( 0.9f, 0.9f, 1.f, 1.f ) );
    
            float aspectRatio = static_cast<float>( this->width()) / static_cast<float>( this->height() );
    
            camera->setProjectionMatrixAsPerspective( 30.f, aspectRatio, 1.f, 1000.f );
    
            camera->setGraphicsContext( _mGraphicsWindow );
    
    
    
            _mViewer->setCamera(camera);
    
            _mViewer->setSceneData(root);
    
            osgGA::TrackballManipulator* manipulator = new osgGA::TrackballManipulator;
    
            manipulator->setAllowThrow( false );
    
            this->setMouseTracking(true);
    
            _mViewer->setCameraManipulator(manipulator);
    
            _mViewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
    
            _mViewer->realize();
    
            
    
    
    
          }
    
    
     virtual void paintGL() {
    
        _mViewer->frame();
    
      }
    
    
    int main(int argc, char** argv)
    
    {
    
        QSurfaceFormat glFormat;
    
        glFormat.setVersion(3, 3);
    
        glFormat.setProfile(QSurfaceFormat::CoreProfile);
    
        glFormat.setSamples(4); //anti aliasing
    
        QSurfaceFormat::setDefaultFormat(glFormat);
    
    
    
        QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
    
    
        QApplication qapp(argc, argv);
    
        QMainWindow window;
    
        QtOSGWidget* widget = new QtOSGWidget(&window);
    
    
    
        window.setCentralWidget(widget);
    
        window.show();
    
    
    
        return qapp.exec();
    
    }
    

    This causes the following effect on text outputs through the OpenGl render window : https://imgur.com/a/S7IsZs5

    Where you can see a clear pixelating issue on the text output. The main dev of OpenSceneGraph discusses in the topic that it could be related to the OpenGLWidget setting the graphics context overriding the settings OSG provides. What exactly is the OpenGLWidget doing with the GL state and what could cause such pixelation? Any leads to solve this issue is appreciated. Thanks

    Best regards Dan

    1 Reply Last reply
    0
    • J Offline
      J Offline
      johansson_gbg
      wrote on 19 Feb 2020, 07:51 last edited by
      #2

      Hello

      Perhaps i posted this in the wrong subforum. Is there a better place for this topic?

      //Regards Dan

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 19 Feb 2020, 20:43 last edited by
        #3

        Hi and welcome to devnet,

        No you did not, however you might be in a case that nobody encountered here thus the lack of answer.

        In any case, you should provide more information about your setup:

        • Qt version
        • OSG version
        • OS

        A complete minimal compilable example that shows the behaviour.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved