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. Implementing rectangle using gl_triangle_strip
QtWS25 Last Chance

Implementing rectangle using gl_triangle_strip

Scheduled Pinned Locked Moved General and Desktop
opengl es2.0rectanglesbarchart
8 Posts 3 Posters 4.3k Views
  • 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.
  • Q Offline
    Q Offline
    qtEnthusiast
    wrote on last edited by
    #1

    I am trying to implement a rectangle (bar) for every data point using opengl gl_triangle_strip.
    the problem i am facing is after the first four points, a new triangle is getting drawn with every new point.
    How do i solve this issue?

    Please help.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qtEnthusiast
      wrote on last edited by
      #2

      Main reason why I am using triangle_strip is that it should be filled.

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

        Hi and welcome to devnet,

        That's rather on OpenGL than a Qt question. You should check the OpenGL forums for that one.

        But basically, that's how triangle strip is working. Each points lead to a new triangle.

        What technique are you currently using to build your rectangle ?

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

        Q 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          That's rather on OpenGL than a Qt question. You should check the OpenGL forums for that one.

          But basically, that's how triangle strip is working. Each points lead to a new triangle.

          What technique are you currently using to build your rectangle ?

          Q Offline
          Q Offline
          qtEnthusiast
          wrote on last edited by
          #4

          @SGaist Hi and thanks for your immediate response.
          I have an incoming set of points. And i need to draw bars for each of them.
          With a single point i am creating 4 points around it, giving it some width and height.
          As i mentioned earlier, i want filled rectangles. so i was suggested to use triangle strips.

          but that has a drawback which i mentioned above. so looking for a solution.
          my very little knowledge on opengl is adding to the agony.

          1 Reply Last reply
          0
          • Chris KawaC Online
            Chris KawaC Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            If you generate vertices for each point then you have a couple of options:

            • create two triangles (6 vertices) and use triangles instead of triangle strips
            • create 4 vertices for each point and do draw call for each two triangles as a separate triangle strip
            • create 4 vertices for each point and insert two dummy vertices between each group. First dummy should have the same coords as last vertex in the previous group and second should have coords of the first vertex in following group. The duplicated vertices will produce a degenerate triangles that GPU will skip over.
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Chris-Kawa What about VAO + VBO ? Wouldn't it be simpler ?

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

              1 Reply Last reply
              0
              • Chris KawaC Online
                Chris KawaC Online
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @SGaist VBO is just a way of storing data (an array basically). What I was talking about can (and should) of course use that but the question is how do you actually interpret (draw) the data from the VBO, ie. how the data is organized (buffer layout) and what draw call to use (i.g. GL_TRIANGLES or GL_TRIANGLE_STRIP as the mode param in the glDrawArrays/Elements call). Storage and rendering are kinda orthogonal topics.

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

                  Good point, I've read your post with glBegin and glEnd in mind.

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

                  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