compiler errors - invalid conversion from 'QAbstractOpenGLFunctions*' to 'QOpenGLFunctions_4_3_Core*' in Qt5.1&OpenGL -
i'm learning opengl referencing kdab's article part one. rather new , helpful. however, compile error trying code on page.
there 3 files in qt project: main.cpp, window.cpp , window.h.
window.h:
#ifndef window_h #define window_h #include <qwindow> #include <qsurfaceformat> #include <qopenglcontext> #include <qopenglfunctions_4_3_core> class window : public qwindow { q_object public: window(qscreen* screen); signals: private: qopenglcontext *m_context; qopenglfunctions_4_3_core* m_funcs; }; #endif // window_h
window.cpp:
#include "window.h" window::window(qscreen* screen) : qwindow(screen) { setsurfacetype(openglsurface); qsurfaceformat format; format.setdepthbuffersize(24); format.setmajorversion(4); format.setminorversion(3); format.setsamples(4); format.setprofile(qsurfaceformat::coreprofile); setformat(format); create(); m_context = new qopenglcontext; m_context->setformat(format); m_context->create(); // make context current on window m_context->makecurrent( ); // obtain functions object , resolve entry points // m_funcs declared as: qopenglfunctions_4_3_core* m_funcs m_funcs = m_context->versionfunctions(); if ( !m_funcs ) { qwarning( "could not obtain opengl versions object" ); exit( 1 ); } m_funcs->initializeopenglfunctions(); // m_funcs->glvertexattribdivisor(); }
main.cpp:
#include <qcoreapplication> #include <qglwidget> int main(int argc, char *argv[]) { qcoreapplication app(argc, argv); return app.exec(); }
error: invalid conversion 'qabstractopenglfunctions*' 'qopenglfunctions_4_3_core*' [-fpermissive]
i found solution in qt's document. statement should
m_funcs = m_context->versionfunctions<qopenglfunctions_4_3_core>();
then error eliminated.
Comments
Post a Comment