Pregunta

parece que no puedo utilizar glBindBuffer, glGenBuffer en el heredado de la clase de QQuickPaintedItem.

Yo ya intente incluir , pero no funciona y yo también trate de usar GLEW en QQuickPaintedItem.Parece Qt sería indefinido esas funciones en QQuickPaintedItem.

Mi versión de Qt es 5.1 msvc-opengl y el sistema funciona en win7 de escritorio.

compilador de error:

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

código

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);
}

principal.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
        }
    }           
}

ACTUALIZACIÓN

Lista de alguna manera para evitar este problema en la Ventana de la plataforma.

  1. Recuperar el punto de entrada de OpenGL a través de

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

  2. Personalizar contexto de creación en su 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();
      ....
    }
    

    REF

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

    Diferencia en opengl velocidad entre Qt 4/5 y Opengl API

¿Fue útil?

Solución

Qt se intenta ajustar un montón de OpenGL funcionalidad en una sola clase que contiene todos los (extended) funciones compartidas entre GL y GL ES 2.0, llamado QGLFunctions.

En lugar de utilizar GLEW, usted debe considerar QGLFunctions::glBindBuffer (...).Si usted llame QGLFunctions::initializeGLFunctions (...) hace un mucho de la misma cosas como GLEW.

De hecho, usted probablemente va a seguir adelante y heredar esta clase, así que cualquier llamada a glBindBuffer (...) es manejado automáticamente a través de la herencia de QGLFunctions.


La siguiente descripción está tomada de la documentación del SDK de Qt QGLFunctions:

QGLFunctions proporciona un garantizado API que está disponible en todos OpenGL sistemas y se ocupa de la resolución de la función en los sistemas que necesitan.La forma recomendada de uso QGLFunctions es por herencia directa:

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

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

void MyGLWidget::initializeGL()
{
  initializeGLFunctions();
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top