[Interest] QGLWidget and OGL version 4.3 functions?

Thomas Meyer public at meyer-thomas.com
Sun Sep 29 16:12:48 CEST 2013


Hi,
thank you very much!

(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,GLuint,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.


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();'.

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).
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.


Thanks,
     Thomas


Am 29.09.2013 11:21, schrieb Sean Harmer:
> Hi,
>
> On 27/09/2013 07:35, Thomas Meyer wrote:
>> Hi,
>> is it possible to render in a QGLWidget with the OGL 4.3 functions?
> Yes but it is now recommended to use QWindow + QOpenGLContext for new
> code as QGLWidget will not see any further development.
>
>> If so, how can I call the functions?
> You need to get hold of the function entry points for the OpenGL 4.3
> functions. This can be done via the QOpenGLContext to get a pointer to a
> QOpenGLFunctions_4_3_Core or QOpenGLFunctions_4_3_Compatibility object
> depending upon which profile you are using.
>
> If using a QOpenGLContext directly you can just do something like this:
>
> QSurfaceFormat f;
> f.setVersion(4, 3);
> f.setProfile(QSurfaceFormat::CoreProfile);
>
> m_context = new QOpenGLContext( this );
> m_context->setFormat( f );
> m_context->create();
>
> QOpenGLFunctions_4_3_Core *funcs =
> m_context->versionFunctions<QOpenGLFunctions_4_3_Core>();
> if (!funcs) {
>       qDebug() << "Could not obtain OpenGL 4.3 function entry points";
>       return;
> }
> funcs->initializeOpenGLFunctions();
>
> // From here you can use funcs to call any OpenGL 4.3 function
> funcs->glTextureView(...);
>
> If you are using QGLWidget then instead of creating your own context as
> in the above code you can get hold of QGLWidget's context via:
>
> QOpenGLContext *context = m_glWidget->context()->contextHandle();
>
> then follow the above to get the QOpenGLFunctions_4_3_Core pointer. Just
> remember to ask QGLWidget to create a 4.3 context via QGLFormat
> (analogous to QSurfaceFormat above).
>
> Hope this helps,
>
> Sean
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130929/35deda4e/attachment.html>


More information about the Interest mailing list