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
0
votes
1 answer

Textured triangle strips - rows beyond first row gives garbled output

I'm drawing some "simple" 2D graphics using OpenGL ES, glDrawArrays and GL_TRIANGLE_STRIP. I'm writing a function whose purpose is to take one 13x13 point (or other arbitrarily sized) texture and output it in specified number of columns and rows. So…
Jonny
  • 15,955
  • 18
  • 111
  • 232
0
votes
1 answer

How to draw a line using GL_TRIANGLE_STRIP in OpenGLES?

Currently i am working in simple game app using openGLES, draw a line using GL_Lines mode and working fine, i want to draw a line using GL_TRIANGLE_STRIP, is it possible to draw a line using GL_TRIANGLE_STRIP? Thanks in Advance I tried the source…
Sampath
  • 117
  • 1
  • 9
0
votes
2 answers

Draw quad elements using GL_Trianglestrip OpenGL ES 2.0

I want to parse a model and render 4-vertex polygons (rectangles) in OpenGL ES 2.0, and instead of using two triangles I thought of using one triangle strip for each quad/rectangle. The problem is my rectangles are not connected throughout the…
ChrHansen
  • 1,502
  • 1
  • 14
  • 22
-1
votes
1 answer

Converting from triangle strip to polygon

I've some areas which contains 1 or more polygons. Each polygon is represented in GL_TRIANGLE_STRIP format, where each vertex is a pair of (lat, long). Is there any way to get the contours of the area? Some specs: Contours must be in counter…
-2
votes
2 answers

Getting the triangles within a tringle strip?

I am having issues with finding the vertices that make up all the triangles within a given opengl triangle strip. I was wondering if anyone could help with ways of approaching that with some pseudo code or examples. Here is an example of me drawing…
1 2 3 4
5