Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Not able to Draw using QOpenGLWidget

    General and Desktop
    2
    2
    30
    Loading More Posts
    • 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.
    • S
      summit last edited by

      I have upgraded my project from QGLWidget to QOpenglWidget.

      The project worked fine using QGL widget but now i am not able to see the rendered output.

      class GLWidget : public  QOpenGLWidget
      {
      	Q_OBJECT;
      public:
      	explicit GLWidget(QWidget *parent = 0);
      //	~GLWidget();
      	void initializeGL() override;
      	void paintGL() override;
      	void resizeGL(int w, int h) override;
      	QTimer timer;
      	QElapsedTimer elapsedtimer;
      	
      
      private:
      	int width;
      	int height;
      
      };
      
      ///////////////////////////////////////////////////////////////////////////////////
      GLWidget::GLWidget(QWidget *parent) : QOpenGLWidget(parent)
      {
      	
      }
      
      //////////////////////////////////////////////////////////////////////////////////////////
      void GLWidget::initializeGL() 
      {
      	GLenum GlewInitResult;
      	glewExperimental = GL_TRUE;
      	GlewInitResult = glewInit();
      	if (GLEW_OK != GlewInitResult)   // Check if glew is initialized properly
      	{
      		QMessageBox msgBox;
      		msgBox.setText("Not able to Initialize Glew");
      		msgBox.exec();
      	}
      
      }
      /////////////////////////////////////////////////////////////////////////////////////////////
      void GLWidget::paintGL() 
      {
        // Painting commands here which are opengl commands using GLEW.
           glBindFramebuffer(GL_FRAMEBUFFER, 0);	// Render in default framebuffer
           glClear(GL_COLOR_BUFFER_BIT);
           RenderCube();	
      
         
      }
      ///////////////////////////////////////////////////////////////////////////////////////////
      
      IN the Main function
      
      QApplication application(argc, argv);
      
      QSurfaceFormat format;
      format.setDepthBufferSize(24);
      format.setStencilBufferSize(8);
      format.setVersion(3, 2);
      format.setProfile(QSurfaceFormat::CoreProfile);
      QSurfaceFormat::setDefaultFormat(format);
      
      return application.exec();
      
      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Please provide a complete minimal compilable example that shows your issue.

        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 Reply Quote 0
        • First post
          Last post