[Interest] QGLWidget and OGL version 4.3 functions?

Sean Harmer sean.harmer at kdab.com
Mon Sep 30 12:51:40 CEST 2013


Hi,

On Sunday 29 September 2013 16:12:48 Thomas Meyer wrote:
> thank you very much!

You're welcome.

> (I have read your 5 parts article:
> http://www.kdab.com/opengl-in-qt-5-1-part-1/
> and tried the terrain_tessellation project
> http://www.kdab.com/~sean/terrain_tessellation.zip [awesome])
> 
> I want to use the QGLWidget, because I get 'artefacts' if
> I use QPainter's drawText in QWindow and it is possible to
> add QGLWidget as central widget in QMainWindow.
> With the QWindow I can only render something (I think) and
> found no solution to add it to something or to use buttons, sliders etc.
> 
> Before I got your answer, I found a solution:
> http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt
> https://svn.theharmers.co.uk/svn/codes/public/opengl/trunk/07-core-profile/
> and
> http://qt-project.org/forums/viewthread/16041/#90717
> 
> So, if I want to use the 'glTextureView' (Core since version 4.3,
> http://www.opengl.org/wiki/GLAPI/glTextureView) in GLWidget:
> ...
> voidGLWidget::initializeGL(void)
> 
> {
> 
> ...
> typedefvoid(APIENTRY*_glTextureView)(GLuint,GLenum,GLuint,GLenum,GLuint,GLui
> nt,GLuint,GLuint);
> 
> 
> _glTextureViewglTextureView;
> 
> glTextureView=(_glTextureView)context()->getProcAddress("glTextureView");
> 
> if(glTextureView!=NULL)
> {
> qDebug()<<Q_FUNC_INFO<<"glTextureView!=NULL";
> }
> ...
> I have not used the function, but this code works for me.

In all seriousness, unless you actually enjoy resolving function pointers I 
would just use QOpenGLFunctions_4_3_Core. It will make your life much easier.

As an aside if you are interested in OpenGL texturing, please do try out 
QOpenGLTexture which is new for the upcoming Qt 5.2:

http://doc-snapshot.qt-project.org/qt5-stable/qopengltexture.html

> If I use your solution in the 'voidGLWidget::initializeGL(void)'
> function from the
> https://svn.theharmers.co.uk/svn/codes/public/opengl/trunk/07-core-profile/
> example and add it as central widget in a QMainWindow, it will not work
> at 'm_context->create();'.

I've not tested any of that old code with Qt5. Instead prefer QGLWidget + 
QOpenGLFunctions_4_3_Core which should work perfectly fine.

> So, the idea is, to have a render surface in the center of a main window and
> have dock widgets around to manipulate the render surface. I don't want to
> render buttons, check boxes and sliders (etc.). I want to use what the Qt
> library has.
> (Ok, later perhaps in a game development, it looks like better ... :-) )
> 
> It would be nice (a wish) to have more documentation and examples about
> OGL with Qt.
> More clarity about additional libraries, which are not necessary anymore
> (i.e. glew).

I agree. Patches welcome. I'm very busy at present improving support for 
textures and other areas which we will need for a new Qt3D.

> Btw. there is no description for 'QGLContext::getProcAddress' in the
> documentation.
> 
> I don't understand:
> ...
> QGLFormatglFormat;
> glFormat.setVersion(1, 0);
> ...
> The documentation is not enough for me. I can set the version 1.0, but
> the functions
> above 1.0 works.

Check which OpenGL context version was actually created. I suspect you 
actually obtain a 1.5 context or maybe even 2.1 of which 1.0 is a subset.

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 Interest mailing list