How to load and bind a texture with Qt's OpenGL classes? -
i'm working on simple opengl application using qt5, , i've used new qopengl classes handle vertex buffers, index buffers , shaders. i'm little stuck on textures, though.
i have qopenglbuffer , qopenglshaderprogram... where's qopengltexture? no such class seems exist in qt5 class list. have resort direct opengl calls managing textures?
that right: no such class exists in qtgui module of qt5. , yes, have resort plain opengl calls handle textures if don't want pull in widget library.
that beingness said, current (let's non-optimal , inconsistent) situation recognized , actively beingness discussed qt developers. see sean harmer's opengl in qt 5.1 , onwards mail, point 7. next thread , having @ current dev tree, uncertainty going land in 5.1.
edit: looking @ other answers , recent comments i'd add together regarding options have standard qt 5.0:
is main goal to:
get pointer can passglteximage2d(..., gl_unsigned_byte, gl_rgba, pointer)
potentially 'weird' formatted qimage? or use helper class spares dealing gltex*()
related functions? if first , linking (old) opengl module (which part of qt 5.0) alternative (and apart 'esthetically' reasons, don't see why not be), utilize static qglwidget::converttoglformat(qimage)
victor hinting at. if not, doing function 'by hand' (along lines of xīcò suggested) should work: first calling qimage::converttoformat(qimage::format_argb32)
, add together platform dependent byte swizzeling , mirroring (see converttoglformathelper(...) in the source). although, if happen utilize own shaders, doing on gpu way faster.
if want have both and linking mentioned opengl qt 5.0 add-on module alternative might able utilize qglwidget::bindtexture(...)
equivalent in qquickview class:
gluint texid = qglcontext::fromopenglcontext( this->openglcontext())->bindtexture(...)
where this
qquickview*. see qglcontext help. (disclaimer: have not tried myself.)
qt opengl qt5
No comments:
Post a Comment