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. Not able to Draw using QOpenGLWidget
Forum Updated to NodeBB v4.3 + New Features

Not able to Draw using QOpenGLWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 83 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.
  • S Offline
    S Offline
    summit
    wrote on 20 Jul 2021, 05:20 last edited by
    #1

    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
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Jul 2021, 19:28 last edited by
      #2

      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
      0

      1/2

      20 Jul 2021, 05:20

      • Login

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