[Development] QT5 OpenGL question

Sean Harmer sean.harmer at kdab.com
Fri Aug 2 12:44:44 CEST 2013


On Friday 02 August 2013 10:05:56 Sze Howe Koh wrote:
> On 2 August 2013 08:16, Jiergir Ogoerg <f35f22fan at gmail.com> wrote:
> > Hi,
> > I'm willing to switch to QT5 with GL,
> > afaik in Qt5 the GL functions are encapsulated into a class that extends
> > QAbstractOpenGLFunctions and you can't use the GL calls outside that class
> > unless you pass each time a reference to this class.
> > 
> > Why doesn't it publish the GL functions publicly (not inside a class
> > instance) like glew and other tools do?
> > 
> > I'm asking because I have a lib of mine that uses GL calls, what should I
> > do, pass an instance of OpenGLFunctions class to each method in the lib? -
> > that's cumbersome.
> 
> Hi,
> 
> To answer your second question, you could use a global pointer to a
> QOpenGLFunctions_X object -- no need to pass it as around as an
> argument.

Or set it as a member variable in that class. Or inherit your class from 
QOpenGLFunctions_blah. Or you could resolve global functions yourself. Or 
maybe use GLEW - although I've not tried that with Qt for a while now.

The reason we have these functions on a class rather than globally is that the 
function addresses can be context-specific.

Cheers,

Sean
--
Join us in October at Qt Developer Days 2013 - https://devdays.kdab.com

Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions



More information about the Development mailing list