Starting OpenGL with Qt



  • I need to start learning OpenGL now and the book I read (C++-GUI-Programming-with-Qt-4-2nd Edition) covers it in chapter 20 while I'm now reading chapter 5!

    1- What are the benefits of learning OpenGL "with" Qt?
    2- What should I read to be familiar with Qt OpenGl? Preferably a step-by-step book/tut.
    Docs haven't helped me so far except for seeing a function of a given class. So if there is a good tut apart from docs, I will be very happy to have that.

    3- What's your opinion about this tut? Would you agree if I continue reading the book and starting it at the same time.

    Overall, what would your suggestions be for a C++/Qt programmer that likes to start OpenGL?

    Thanks.


  • Qt Champions 2016

    Hi
    1: It wraps openGl calls into a more convenient class and supply integration to Qt windows etc.
    Not sure i think it's a 100% benefit while learning openGL as it also hide a bit how it really works

    2: You also need to be able to do vector math. It will be far more about openGl than Qt so
    any good reference on openGL will help.
    https://www.thoughtco.com/introduction-to-vector-mathematics-2699043

    3: Its nice site. Also it uses so called modern openGL which you should
    learn and not look at older tuts
    with old stuff in.
    https://kos.gd/posts/dont-use-old-opengl/

    • Overall, what would your suggestions be for a C++/Qt programmer that likes to start OpenGL?
      Patience and more patience. openGL is hard to start with. its a raw c API and its very easy to makes mistakes. Just to simply show something on screen,
      multiple topics must be touched and some of it is frankly very techincal.
      like a shader from http://openglbook.com/
    const GLchar* VertexShader =
    {
      "#version 400\n"\
    
      "layout(location=0) in vec4 in_Position;\n"\
      "layout(location=1) in vec4 in_Color;\n"\
      "out vec4 ex_Color;\n"\
    
      "void main(void)\n"\
      "{\n"\
      "  gl_Position = in_Position;\n"\
      "  ex_Color = in_Color;\n"\
      "}\n"
    };
    

    So most important is that you really want to learn it. Much to study and understand.
    Also, im not sure C++-GUI-Programming-with-Qt-4-2nd Edition is a good read for openGL as
    QGLwidget was replaced (http://doc.qt.io/qt-5/qglwidget.html)
    and the code might have issue in newer Qt and hence i cant really recommend it in this case.



  • @mrjj

    So most important is that you really want to learn it

    It's a great sentence that I like it so much. :)

    I gained much benefits from your talks and your sites are also very useful. Thanks.

    So I need to start and the first step is to read this page, right?

    And I think you didn't have the idea of a good tut/manual on learning OpenGl with Qt. This tut is nice but I don't think it takes advantages of Qt for teaching OpenGl. So do you still recommend me start the second step by that?

    What if I find a good tut/manual (by chance) teaching OpenGl with Qt and choose that as the second step?


  • Qt Champions 2016

    Hi :)
    It not be bad to read about vectors to start with but you can
    put that off a bit until you want to turn
    or move object.
    The first part when starting with openGl
    is about vertices and setting up shader (texture) and windows.
    The site https://learnopengl.com/ do not use Qt features at all so some of it is different from
    what you would do in Qt. Its very good openGL wise though.
    But some of the context stuff etc is wrapped into
    QOpenGLWidget and mixing the two might be confusing.
    Also it does not show how to get up and running with openGL.

    But i cant find anything that teaches the new QOpenGLWidget

    Hopefully other have some links or info to get going with openGL and Qt



  • @mrjj

    Hi :)

    Your saying hi in each reply impresses me showing your kindness, gentleness and tenderness.
    Hi

    It not be bad to read about vectors to start with but you can
    put that off a bit until you want to turn
    or move object.
    The first part when starting with openGl
    is about vertices and setting up shader (texture) and windows.
    The site https://learnopengl.com/ do not use Qt features at all so some of it is different from
    what you would do in Qt. Its very good openGL wise though.
    But some of the context stuff etc is wrapped into
    QOpenGLWidget and mixing the two might be confusing.
    Also it does not show how to get up and running with openGL.
    But i cant find anything that teaches the new QOpenGLWidget
    Hopefully other have some links or info to get going with openGL and Qt

    So I stop for now.
    Thanks.


  • Qt Champions 2016

    @tomy
    Thank you for your kind words.
    Well openGl is very isolated part of Qt/huge topic on its own
    so you can safe skip it without loosing any
    abilities Qt application wise.
    Also QML is also accelerated and much faster to play with if you want to
    just want to explore 3d
    https://doc.qt.io/qt-5/qt3d-examples.html



  • @mrjj s

    Well openGl is very isolated part of Qt/huge topic on its own
    so you can safe skip it without loosing any
    abilities Qt application wise.

    I'm not sure I understood this well. Do you mean I can skip openGl without loosing any ability about Qr applications?

    Yes, maybe, but I think I still need it.

    Also QML is also accelerated and much faster to play with if you want to
    just want to explore 3d

    I'm reading a QML book right now at the same time with reading the Qt book and I'm in this section. And it was my today's question on QML.

    One subtle question here:
    Do you mean while I'm reading QML, it's better and I don't need openGl? Or Do you mean openGl is explained in QML well and I don't need to read a another manual on openGl?


  • Qt Champions 2016

    Hi
    Yes, for normal Qt applications, often there is no need for openGL.
    Use cases are for example very heavy plotting or ultra fast (real time) plotting but
    you get very far without.

    No, QML is not better than openGL and have very different target.
    QML is for modern/mobile/speciel interfaces and also offer accelerated
    graphics. OpenGl is completely other API/focus. QML will not explain
    openGL as such . It simply offer ways to draw 3D also. Based on openGL underneath.
    But like the Simple Transformations section you are reading, QML does introduce key topics
    for 3D in general, which also applies to openGL. But the way you do in QML is related to
    how it looks in GL. You can just say triangle.rotation = 0 where in raw GL, you would apply
    vector/matrix math.



  • @mrjj
    Hi,
    Thank you very much.

    I wish there were good manuals/books or even complete tutorials covering OpenGl within the framework of Qt. I think you too agree that it's better for me as a learner/programmer of Qt.
    A side question: Does Qt offer all of what OpenGl offers?

    I found these on the web (which are based on Qt):
    1- http://doc.qt.io/qt-4.8/examples-opengl.html
    2- http://www.bogotobogo.com/Qt/Qt5_OpenGL_QGLWidget.php
    3- http://www.kdab.com/opengl-in-qt-5-1-part-1/
    4- https://steventaitinger.wordpress.com/2015/11/24/part-1-modern-opengl-using-qt-5-5-tutorial/
    5- http://www.trentreed.net/blog/qt5-opengl-part-1-basic-rendering/

    And these two are apart from Qt:
    http://openglbook.com/the-book.html
    https://learnopengl.com/

    I'm able to pick any of these and I think I've reached a conclusion point. If possible help me on choosing one of these tutorials as a first step to learn OpenGl.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.