Re: [Interest] QGLWidget and OGL version 4.3 functions?

2013-09-30 Thread Yves Bailly
Le 29/09/2013 11:21, Sean Harmer a écrit :
 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.

Will it be replaced by something just as convenient? QWindow is just not
as easy to use, moreover embedding it in the middle of a GUI full of controls
(in a QMdiSubWindow for example). QWidget::createWindowContainer() is
pretty unnatural.

Regards,

-- 
  /- Yves Bailly - Software developer   -\
  \- Sescoi RD  - http://www.sescoi.fr -/
The possible is done. The impossible is being done. For miracles,
thanks to allow a little delay.
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QGLWidget and OGL version 4.3 functions?

2013-09-30 Thread Sean Harmer
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_INFOglTextureView!=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.har...@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
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QGLWidget and OGL version 4.3 functions?

2013-09-30 Thread Sean Harmer
On Monday 30 September 2013 17:15:12 Thomas Meyer wrote:
  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.
 That's true! I have replaced the typedef's to bind a VAO with:
 ...
 uintvao;
 
 funcs-glGenVertexArrays(1,vao);
 funcs-glBindVertexArray(vao);
 ...

QOpenGLVertexArrayObject. Just sayin' :)

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

Dr Sean Harmer | sean.har...@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
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QGLWidget and OGL version 4.3 functions?

2013-09-29 Thread 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-versionFunctionsQOpenGLFunctions_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@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QGLWidget and OGL version 4.3 functions?

2013-09-29 Thread Thomas Meyer

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_INFOglTextureView!=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-versionFunctionsQOpenGLFunctions_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@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest



___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] QGLWidget and OGL version 4.3 functions?

2013-09-27 Thread Thomas Meyer
Hi,
is it possible to render in a QGLWidget with the OGL 4.3 functions?
If so, how can I call the functions?
If not, will it be in the future (is it planned)?

Thanks,
 Thomas

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest