it seems i cannot use glBindBuffer, glGenBuffer in the inherited-class of QQuickPaintedItem.
I already try to include , but it doesn't work and I also try to use GLEW in QQuickPaintedItem. It looks like Qt would undefined those functions in QQuickPaintedItem.
My Qt version is 5.1 msvc-opengl and the system operates on win7 desktop.
compiler msg:
fcglpanel.cpp(254): error C3861: 'glBindBuffer': identifier not found
some code
class MyQuickGLPanel :public QQuickPaintedItem
{
Q_OBJECT
//-------------------------------------------------------------------------
public:
FCGLPanel(QQuickItem * parent=0);
~FCGLPanel();
virtual void paint(QPainter * painter);
...
}
main
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
}
}
}
UPDATE
List some way to avoid this issue in Window platform.
Retrieve the entry point of OpenGL via
QOpenGLFunctions* oglEntry = window()->openglContext()->functions();
Use customized context creation in your 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