Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: rendering triangles, tetrahedrons, and/or lines

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2009
    Posts
    14

    rendering triangles, tetrahedrons, and/or lines

    I'm trying to render something like the attached picture with OpenGL using GLUT instead of using Matlab. I have all the vertices in a float array, but I'm not sure what's the best way of rendering the mesh. I'm thinking of using triangles or tetrahedrons for the elements in the cube, and a line for the blue line. Your opinions would be much appreciated. Thanks.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    135

    Re: rendering triangles, tetrahedrons, and/or lines

    Tetrahedra aren't OpenGL primitives, so you can't use those. Triangles or triangle strips are probably the best way to go, depending on how you have the data. Lines would be good for the outline and the blue line.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2009
    Posts
    14

    Re: rendering triangles, tetrahedrons, and/or lines

    My data looks something like this:

    [x1 y1 z1 x2 y2 z2 ... xn yn zn] for the box, and [a1 b1 c1 ... am bm cm] for the blue line.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    135

    Re: rendering triangles, tetrahedrons, and/or lines

    I'm sorry I wasn't clear there, so I'll take another go at it:
    Each 3 elements specify a vertex, but triangles and triangle strips take the vertices in a different order and use them slightly differently.
    Triangles take data (v1, v2, v3, v4, v5, v6, ...) and makes a triangle out of v1,v2,v3, and v4,v5,v6, and so on, where vn is all three components of vertex n. Triangle strips would make a triangle with v1,v2,v3, then v2,v3,v4, and so on. (If you're going to use those, check the order. I'm not sure that's exactly right, and it makes sure that all the triangles face the same way.)
    Depending on how your vertices are ordered in your array, it may be easier to use triangles or triangle strips.

  5. #5
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,370

    Re: rendering triangles, tetrahedrons, and/or lines

    Compiled display lists would be an efficient and simple way to render your data if it is static. The best way is to use vertex buffer objects or at least vertex arrays. You can find here a nice tutorial on vbos.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •