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. display .obj file in QOpenGLWindow
Forum Updated to NodeBB v4.3 + New Features

display .obj file in QOpenGLWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 681 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.
  • C Offline
    C Offline
    cprinter
    wrote on last edited by
    #1

    Hi everyone,

    Hope this is the right subforum for my question.
    After creating an empty window with QOpenGLWindow, I want to import and display a .obj file in that window.
    In the documentation I could not find anything. Does anybody have suggestions what the general approach to this task is?

    Thanks

    W 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      IIRC, Qt3D has all you need for that.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      2
      • C cprinter

        Hi everyone,

        Hope this is the right subforum for my question.
        After creating an empty window with QOpenGLWindow, I want to import and display a .obj file in that window.
        In the documentation I could not find anything. Does anybody have suggestions what the general approach to this task is?

        Thanks

        W Offline
        W Offline
        wrosecrans
        wrote on last edited by
        #3

        @cprinter What are you actually trying to do? If you want to do it yourself, there are a couple of sub-problems.

        1 - Load an OBJ file into memory, parse it, and have some raw geometry to render. You can find documentation for the format, or various libraries that can read the format.

        2 - Use OpenGL to render some geometry in memory. The fact that the geometry originally came from an OBJ file doesn't make any difference when you are rendering it. "How to render 3D graphics with OpenGL" is a giant topic, and there are tons of approaches to writing your renderer, potentially involving all sorts of interesting decisions about how to do shading and lighting, or how to improve performance by only drawing visible parts of the scene.

        3 - Open a window to have some place for your OpenGL renderer to draw on screen. This is the only part that would be Qt specific, and it sounds like you've got that much figured out.

        If you don't want to do all that stuff yourself, like Sgaist said you can use Qt3D rather than a bare QOpenGLWindow. If you do want to do it yourself in a bare QOpenGLWindow, there isn't a ton of Qt-specific stuff to discuss. Override the methods mentioned in the QOpenGLWindow documentation and do your painting there with standard OpenGL functionality. There's a handful of helper classes like QOpenGLTexture, but they aren't doing anything you can't do other ways, and you haven't mentioned any specific problems with your OpenGL.

        1 Reply Last reply
        2
        • SGaistS SGaist

          Hi,

          IIRC, Qt3D has all you need for that.

          C Offline
          C Offline
          cprinter
          wrote on last edited by
          #4

          @SGaist
          had a quick look at qt3d as well, but I had the impression that I have more freedom using QOpenGLWindow as a "foundation".

          @wrosecrans
          thanks for the elaborate response, I plan to build an application that allows me to import a .obj file, visualize the mesh, then slice the mesh into multiple parts and visualize these slices.
          I have to add that I also have no prior experience with OpenGL, so it seems I have a lot of learning to do. I just wanted to know if there is one obvious, correct way to do this.

          W 1 Reply Last reply
          0
          • C cprinter

            @SGaist
            had a quick look at qt3d as well, but I had the impression that I have more freedom using QOpenGLWindow as a "foundation".

            @wrosecrans
            thanks for the elaborate response, I plan to build an application that allows me to import a .obj file, visualize the mesh, then slice the mesh into multiple parts and visualize these slices.
            I have to add that I also have no prior experience with OpenGL, so it seems I have a lot of learning to do. I just wanted to know if there is one obvious, correct way to do this.

            W Offline
            W Offline
            wrosecrans
            wrote on last edited by
            #5

            @cprinter There's definitely no one correct way to do it. You are 100% right that writing your own OpenGL code gives you more freedom to do whatever you want than using a higher level library like Qt3D. But that freedom means it's up to you to decide what exactly you want to do.

            At the end of the day, OpenGL is just a way to draw a triangle. It's up to you to decide what triangles, where they should be and what they should look like.

            C 1 Reply Last reply
            1
            • W wrosecrans

              @cprinter There's definitely no one correct way to do it. You are 100% right that writing your own OpenGL code gives you more freedom to do whatever you want than using a higher level library like Qt3D. But that freedom means it's up to you to decide what exactly you want to do.

              At the end of the day, OpenGL is just a way to draw a triangle. It's up to you to decide what triangles, where they should be and what they should look like.

              C Offline
              C Offline
              cprinter
              wrote on last edited by
              #6

              @wrosecrans okay, thanks again for clarifying that.

              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