Why is it impossible to use OpenGL in Qt 5?

0

Probably OpenGL is the only thing I can not use in Qt, Maya and 3Ds and another autodesk program pa uses opengl in qt, but no tutorial or example that works.

I have already created a class for the widget based on QOpenGLWidget (Since QGLWidget is obsolete), then in the Ui editor I add a widget and promote it to the class I created.

Result, when I compile a white screen without menus or anything with the frozen screen, then the crash application.

Several tutorials do this way and it works, but with me it always gives the same result, crash application.

link link

They all work on video, less in practice.

glpanel.h code

#include <QtOpenGL>

class GLPanel : public QOpenGLWidget, protected QOpenGLFunctions{

    Q_OBJECT

public:

    explicit GLPanel(QWidget *parent = 0);

protected:

    void initializeGL() Q_DECL_OVERRIDE;
    void resizeGL(int w, int h) Q_DECL_OVERRIDE;
    void paintGL() Q_DECL_OVERRIDE;

};

glpanel.cpp code

#include "glpanel.h"

GLPanel::GLPanel(QWidget *parent) :
    QOpenGLWidget(parent)
{

}

void GLPanel::initializeGL()
{
    initializeOpenGLFunctions();
}

void GLPanel::resizeGL(int w, int h)
{

}

void GLPanel::paintGL()
{

}

ui code

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>400</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Ives 3D</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QGridLayout" name="gridLayout_2">
    <item row="0" column="0">
     <widget class="GLPanel" name="Viewport" native="true"/>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>400</width>
     <height>21</height>
    </rect>
   </property>
   <widget class="QMenu" name="menuFile">
    <property name="title">
     <string>File</string>
    </property>
    <addaction name="action_Exit"/>
   </widget>
   <addaction name="menuFile"/>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
  <widget class="QToolBar" name="toolBar">
   <property name="windowTitle">
    <string>toolBar</string>
   </property>
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <action name="action_Exit">
   <property name="text">
    <string>&amp;Exit</string>
   </property>
  </action>
 </widget>
 <customwidgets>
  <customwidget>
   <class>GLPanel</class>
   <extends>QWidget</extends>
   <header>glpanel.h</header>
   <container>1</container>
  </customwidget>
 </customwidgets>
 <resources/>
 <connections/>
</ui>

Can someone give me a light? !!

    
asked by anonymous 29.01.2018 / 14:24

1 answer

0

In relation to the comment of paulocanedo the version of openGL he posted is using shaders, this version is the latest version. The advantages are the speed of rendering and quality. The downside is the complexity and the need for a compatible video card.

Your project ran right here on Ubuntu. I made some modifications to your project and added the glut library to have an example on the screen. Link is also in the description ( link ). As for its error may be the lack of a video drive installed or something relative to the lack of the opengl library. If you continue with an error in your project, try removing the initializeOpenGLFunctions (). Here I used QT 5.5.1 to compile.

    
30.01.2018 / 18:57