0
votes

I am using Open GL 3.0

I am trying to update this example to modern OpenGL : http://qt-project.org/doc/qt-4.8/opengl-hellogl-es.html

I am also looking at this example: http://qt-project.org/doc/qt-5/qtopengl-cube-example.html

I am looking at the OpenGL ES examples, because they compiled and rendered easily on my machine, and the OpenGL ES 2 example uses some programmable pipelining.

I want to use the pipeline functions referenced in this tutorial: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/

For instance glGenBuffers()

However, this does not seem to come up in open Qt. If I try to compile a program that uses glGenBuffers, or glBindBuffer.

Why can I use some Open GL functions but not others?

Looking at the second example (OpenGL ES2) There is a type "QGLShaderProgram" which seems to wrap some of the shading functions, but I am at loss as to how to follow even a simple open GL tutorial with full access to the rendering functions.

For instance, the openGL tutorial references at least half a dozen functions I can't seem to use. I would be fine with this, but I can't seem to find where the Qt folks have explained what functions are wrapped, or covered up, or are absent.

Could I be missing an include or something?

I am including #QGLWidget and #QtOpenGL

1
You don't have to use the wrapper classes. Qt provides a class (e.g. QGLFunctions or QOpenGLGLFunctions) that you can inherit that will provide you with callable functions that are loaded at run-time if your platform supports them. It is a bit like GLEW, only less extensive. - Andon M. Coleman
I suspect one issue is that glGenBuffers is from OpenGLES, which isn't supported in all versions of Qt. - Jay
@Jay It's not from ES; it's from OpenGL 1.5+. I'd be very surprised if Qt didn't support something that old. - Colonel Thirty Two
@AndonM.Coleman I found that! I'm checking to see if those functions work properly before properly answering/closing. - baordog
@ColonelThirtyTwo it's listed in the opengles tree on khronos: khronos.org/opengles/sdk/docs/man/xhtml/glGenBuffers.xml Perhaps it was also adopted into version 1.5 - Jay

1 Answers

0
votes

See below for my answer to your question. However, it seems likely you are looking for a simpler OpenGL example with Qt like the triangle one you linked to. I also made an introductory post here where you can learn the basics of how Qt and OpenGL work together before you start an example.

First of all use Qt 5.5 now. It is configured with the -opengl dynamic option by default which might solve your problem. If you don't have -opengl desktop configure option set in your pre 5.5 build of Qt then you won't have access to modern OpenGL functions other than the subset of OpenGL ES 2 that is supported by all the platforms Qt supports.

Second, don't use the QGL* functions or classes as they are old/deprecated now. They were replaced by the QOpenGL* functions and classes.

As for includes, you will need a QOpenGLFunctions or QOpenGLFunctions_3_0 to know for sure which set of functions you are getting. You will also need any other classes like QOpenGLBuffer QOpenGLVertexArrayObject... or just include QtGui as that is where all the OpenGL functions and classes are now.