Question

il semble que je ne puisse pas utiliser glBindBuffer, glGenBuffer dans la classe héritée de QQuickPaintedItem.

J'essaie déjà d'inclure , mais cela ne fonctionne pas et j'essaie également d'utiliser GLEW dans QQuickPaintedItem.Il semble que Qt ne définirait pas ces fonctions dans QQuickPaintedItem.

Ma version de Qt est la 5.1 msvc-opengl et le système fonctionne sur le bureau Win7.

msg du compilateur :

fcglpanel.cpp(254): error C3861: 'glBindBuffer': identifier not found

du code

class MyQuickGLPanel :public QQuickPaintedItem 
{

Q_OBJECT

    //-------------------------------------------------------------------------
    public: 
        FCGLPanel(QQuickItem  * parent=0);
        ~FCGLPanel(); 
        virtual void paint(QPainter * painter);
    ...
}

principal

int main(int argc, char *argv[])
{
    QApplication app(argc, argv); 

    qmlRegisterType<MyQucikGLPanel>("MyQucikGLPanel", 1, 0, "MyPanel"); 

    QQmlApplicationEngine engine(QUrl::fromLocalFile("../qml/main.qml")); 

    QObject *topLevel = engine.rootObjects().value(0);
    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
    return qmlMode(argc, argv);
}

main.qml

import QtQuick 2.1
import QtQuick.Controls 1.0 
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import QtQuick.Window 2.1

import "./MyUI" 1.0 as MyUI
import MyQucikGLPanel 1.0

ApplicationWindow {
    id: appwindow

    property int zGLPanel : 4;

    SplitView {

        x: 32
        y: 8
        anchors.rightMargin: 5
        anchors.bottomMargin: 5
        anchors.leftMargin: 0
        anchors.topMargin: 0
        anchors.fill: parent

        // [EMBEDDING C++ object]
        MyPanel{
            id: mylogicPanel
            anchors.fill: parent
            width: 640
            height: 480
            z : appwindow.zGLPanel
        }
    }           
}

MISE À JOUR

Énumérez un moyen d'éviter ce problème sur la plate-forme Windows.

  1. Récupérer le point d'entrée d'OpenGL via

    QOpenGLFunctions* oglEntry = window()->openglContext()->functions();

  2. Utilisez la création de contexte personnalisé dans votre QWindow.

    
    Window::Window( QScreen* screen )
    : QWindow( screen ){
    // Tell Qt we will use OpenGL for this window
    setSurfaceType( OpenGLSurface );
    
    // Specify the format and create platform-specific surface
    QSurfaceFormat format; 
    format.setMajorVersion( 4 );
    format.setMinorVersion( 3 ); 
    format.setProfile( QSurfaceFormat::CoreProfile );
    setFormat( format );
    create();
    
    // Create an OpenGL context
    m_context = new QOpenGLContext;
    m_context->setFormat( format );
    m_context->create();
      ....
    }
    

    RÉF

    http://www.kdab.com/opengl-in-qt-5-1-part-1/

    Différence de vitesse d'ouverture entre Qt 4/5 et l'API Opengl

Était-ce utile?

La solution

Qt essaie de regrouper de nombreuses fonctionnalités OpenGL dans une seule classe contenant toutes les fonctions partagées (étendues) entre GL et GL ES 2.0, appelée QGLFunctions.

Plutôt que d'utiliser GLEW, vous devriez envisager QGLFunctions::glBindBuffer (...).Si tu appelles QGLFunctions::initializeGLFunctions (...) ça fait un parcelle des mêmes choses que GLEW.

En fait, vous hériterez probablement de cette classe afin que tout appel à glBindBuffer (...) est automatiquement géré via l'héritage de QGLFunctions.


La description suivante est tirée de la documentation du SDK Qt pour QGLFunctions:

QGLFonctions fournit un garanti API disponible sur tous les systèmes OpenGL et prenant en charge la résolution des fonctions sur les systèmes qui en ont besoin.La manière recommandée d'utiliser QGLFunctions est par héritage direct :

class MyGLWidget : public QGLWidget, protected QGLFunctions
{
  Q_OBJECT
public:
  MyGLWidget(QWidget *parent = 0) : QGLWidget(parent) {}

protected:
  void initializeGL();
  void paintGL();
};

void MyGLWidget::initializeGL()
{
  initializeGLFunctions();
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top