Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QOpenGLWidget - Rotation and Zoom in and Out
Forum Updated to NodeBB v4.3 + New Features

QOpenGLWidget - Rotation and Zoom in and Out

Scheduled Pinned Locked Moved General and Desktop
qt5.5opengl
3 Posts 3 Posters 6.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Lays147L Offline
    Lays147L Offline
    Lays147
    wrote on last edited by
    #1

    Hello guys!
    I managed to create a cube in 3D with the widget, but now I need to do their rotation and zoom. I've read the examples hellogl2 and cube, but did not help me much. Like that with the right and left mouse buttons to rotate power projection and scroll to zoom in and out.
    The examples I have seen on the internet are with glut, but the qt is supported so I do not use this library.
    Can anyone give me a hand?
    thanks!

    For example, i already try do this, but not change.
    QMatrix4x4 camera;
    void GLWidget::mousePressEvent(QMouseEvent *event)
    {
    if(event->button() == Qt::RightButton)
    {
    qDebug() <<"HERE!";
    camera.translate(0, 0, -1);
    update();

    }
    

    Lays Rodrigues
    Newby on Qt - Learning always!
    Using QT 5.7
    ArchLinux

    timdayT 1 Reply Last reply
    0
    • Lays147L Lays147

      Hello guys!
      I managed to create a cube in 3D with the widget, but now I need to do their rotation and zoom. I've read the examples hellogl2 and cube, but did not help me much. Like that with the right and left mouse buttons to rotate power projection and scroll to zoom in and out.
      The examples I have seen on the internet are with glut, but the qt is supported so I do not use this library.
      Can anyone give me a hand?
      thanks!

      For example, i already try do this, but not change.
      QMatrix4x4 camera;
      void GLWidget::mousePressEvent(QMouseEvent *event)
      {
      if(event->button() == Qt::RightButton)
      {
      qDebug() <<"HERE!";
      camera.translate(0, 0, -1);
      update();

      }
      
      timdayT Offline
      timdayT Offline
      timday
      wrote on last edited by
      #2

      @Lays147 How much do you know about vectors, matrices and basic linear algebra type things? In my day, everyone learned computer graphics geometry, homogeneous coordinates etc from a book called Foley & van Damme; but it's probably a bit out of date now and been replaced by something else as the standard undergrad graphics text. If your program has a vertex shader, and you can pass a transform matrix to it, and the shader multiplies vertex coordinates by the matrix... then you can just multiply the transforms you want together and pass them as a single transform.

      The earlier bits of ftp://ftp.informatik.hu-berlin.de/pub/Linux/Qt/QT/developerguides/qtopengltutorial/OpenGLTutorial.pdf is pretty good QMatrix4x4-friendly intro, even if the OpenGL (and the Qt) is old-school (although it does use shaders, and VBOs later on).

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stephane78
        wrote on last edited by
        #3

        Hi,
        for the rotation, you should look at this example :http://doc.qt.io/qt-5/qtgui-openglwindow-example.html.
        and for the knowledge of modern Opengl(>=3.3) you should read http://learnopengl.com/ and you can read http://learnopengl.com/#!Getting-started/Hello-Triangle to understand VAO and VBO...
        regards

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved