Questions tagged [gl-triangle-strip]

A triangle strip is a series of connected triangles, sharing vertices, allowing for faster rendering and more efficient memory usage for computer graphics. In OpenGL implementation, GL_TRIANGLE_STRIP draws a series of triangles using vertices v0, v1, v2, then v2, v1, v3 (note the order), then v2, v3, v4, and so on. The ordering is to ensure that the triangles are all drawn with the same orientation so that the strip can correctly form part of a surface

A triangle strip is a series of connected triangles, sharing vertices, allowing for faster rendering and more efficient memory usage for computer graphics. They are optimized on most graphics cards, making them the most efficient way of describing an object. There are two primary reasons to use triangle strips:

  • Triangle strips increase code efficiency. After the first triangle is defined using three vertices, each new triangle can be defined by only one additional vertex, sharing the last two vertices defined for the previous triangle.
  • Triangle strips reduce the amount of data needed to create a series of triangles. The number of vertices stored in memory is reduced from 3N to N+2, where N is the number of triangles to be drawn. This allows for less use of disk space, as well as making them faster to load into RAM.

OpenGL implementation

OpenGL has innate support for triangle strips using the glBegin(), glVertex*(), and glEnd() functions. To draw a triangle strip, glBegin() must be passed the argument GL_TRIANGLE_STRIP, which notifies OpenGL a triangle strip is about to be drawn. The glVertex*() family of functions specify the coordinates for each vertex in the triangle strip.

//Vertices below are in Clockwise orientation
//Default setting for glFrontFace is Counter-clockwise
glFrontFace(GL_CW);

glBegin(GL_TRIANGLE_STRIP); 
glVertex3f( 0.0f, 0.0f, 0.0f ); //vertex 1
glVertex3f( 0.0f, 1.0f, 0.0f ); //vertex 2
glVertex3f( 1.0f, 0.0f, 0.0f ); //vertex 3
glVertex3f( 1.5f, 1.0f, 0.0f ); //vertex 4
glEnd();

Note that only one additional vertex is needed to draw the second triangle. In OpenGL, the order in which the vertices are specified is important so that surface normals are consistent.

Quoted directly from the OpenGL Programming Guide:

GL_TRIANGLE_STRIP Draws a series of triangles (three-sided polygons) using vertices v0, v1, v2, then v2, v1, v3 (note the order), then v2, v3, v4, and so on. The ordering is to ensure that the triangles are all drawn with the same orientation so that the strip can correctly form part of a surface.

65 questions
1
vote
2 answers

How to draw a VAO made out of 5 triangles in OpenGL?

I have recently written a program to draw a triangle with 3 different RGB values and I want to do the same with another separate VAO in the same program but I want this one composed of 5 triangles. Here is my main.cpp: void…
Garrus
  • 61
  • 7
1
vote
0 answers

Creating flat terrain with triangle strips

I am asking for some help with drawing a flat terrain using triangle strips. If this is the correct way to do it? So far i managed to create vertex and index arrays, debugged it couple of times and it seems to generate correct values. At first I…
1
vote
0 answers

WebGL triangle layout for deformation

I am implementing simple deformation in WebGL by moving vertices up or down, but stumbled upon a problem with the way the triangles are laid out. I am using the PlaneGeometry in three.js and it uses the following layout for the…
Jason
  • 4,905
  • 1
  • 30
  • 38
1
vote
1 answer

GL_TRIANGLE_STRIP and transparency problems

I want to draw transparent polygon(a pyramid for example). Some faces appear transparent where as some faces appear opaque. Im drawing using GL_TRIANGLE_STRIP. I have enabled blend mode, but no luck. Please see the attached image,
vaishak
  • 63
  • 7
1
vote
3 answers

Which triangulation algorithm creates these triangles

I can not figure it out which triangulation algorithm is used to create these triangles in the attached picture. I think it is not delanuay or ear clipping but which polygon triangulation method create these triangles? Any help?
1
vote
2 answers

Creat mesh from point cloud on a 2D grid

I am using the new Kinect v2 and I am getting the depth map of the Kinect. After I get the depth map I convert the depth data from Depth Space to Camera Space. As far as I understand this is done, by converting all the X,Y coordinate of each pixel…
Silex
  • 2,583
  • 3
  • 35
  • 59
1
vote
0 answers

Convert indexed triangle strip index array with degenerated triangles to primitive restar

This is question for Direct3D 10 or OpenGL 3.2 / GLES 3.0 and primitive restart. I'm trying to look at a way to convert an indexed array containing degenerated triangles strip to an other indexed array with degenerated indices replaced by 0xFFFF…
1
vote
2 answers

Appearance of a triangle strip. Surface normals? Or windings?

Below is a picture of what my outcome is. I am using flat shading and have put each vertex in their respectable triangle objects. Then I use these vertices to calculate the surface normals. I have been reading that because my triangles share…
1
vote
2 answers

Why is z coordinates used in a triangle strip open gl

I have just started using openGL which i am teaching myself from a book. In my book i am told to build quads using triangle strips because it is more efficient. The book uses these vertices to create the quad. vertices.push_back(-0.5f); …
Popgalop
  • 737
  • 2
  • 9
  • 26
1
vote
1 answer

OpenGL GL_TRIANGLE_STRIP; seemingly not getting the Z Coordinate to affect drawing

I'm trying to draw a line using a GL_TRIANGLE_STRIP that will go deeper or more shallow with the z coordinate, but the the z value I'm passing into glVertex3f() doesn't seem to affect the perceived width. In the code below (a modified example from…
balthatrix
  • 115
  • 6
1
vote
1 answer

Reversed triangle strip (winding issues) when drawing concatenated triangle strips (ios 6)

I am trying to send a pair of triangle strips, derived from input triangles, for rendering The strips are defined by the following vertex indices: strip 1: 0 14 16 15 1 23 30 41 8 strip 2: 31 7 17 18 16 0 14______15______23______41 7…
user236520
1
vote
1 answer

opengl es, ios and triangle fans

I am currently rendering a scene using triangles with the following code: glBindVertexArrayOES(_mVertexArrayObjectTriangles); glBindBuffer(GL_ARRAY_BUFFER, _mVertexPositionNormalTriangles); glDrawElements(GL_TRIANGLES,…
user236520
1
vote
1 answer

Display GL_TRIANGLE_STRIP as wireframe

I'm struggling to get an opengl triangle strip to display as a wireframe. My display algorithm looks something like this: // want to display by strip here to allow for quick processing of each of the polygons that we need // allow a quick strip of…
JonMorehouse
  • 1,313
  • 6
  • 14
  • 34
1
vote
2 answers

qt + open Gl= paintgl function for drawing a triangle

i have coded what i have read in previous post about a well known subject but i continue to get a green window without any triangle inside. Here is my paint function : void mGLWidget::paintGL() { glClearColor( Qt::green ); QSize viewport_size =…
gwen
  • 11
  • 1
1
vote
1 answer

How Calculate NORMAL in triangle strip

i have a problem with the lighting of my OPENGL projects. I program on c++ using ECLIPSE. I have a terrein construited by triangle strip. the code of my render is the follow: HeightMap::~HeightMap(void) { } float…
Agata
  • 3
  • 1
  • 10