| GL Studio C++ Runtime API

Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
GlsTriangleStrip2D Class Reference

`#include <gls_triangle_storage.h>`

Inheritance diagram for GlsTriangleStrip2D:

## Public Member Functions
| GlsTriangleStrip2D ()
virtual | ~GlsTriangleStrip2D ()
void | StartBuildingStrip ()
void | SetTexture (Image *image)
void | SetTexCoords (const float x1, const float y1, const float x2, const float y2, const float x3, const float y3)
void | AddTriangle2D (const float x1, const float y1, const float x2, const float y2, const float x3, const float y3)
void | Bake (IGlsStateManager *stateManager)
void | Draw (IGlsStateManager *stateManager, const bool enableTexture)
unsigned int | GetNumTriangles ()

## Static Public Attributes
static const GLuint | VERT_SIZE = sizeof( V2f )
| Size of a vertex in bytes.
static const GLuint | TEX_SIZE = sizeof( V2f )
| Size of a texture coordinate in bytes.
static const void *const | VERT_OFFSET
static const void *const | TEX_COORD_OFFSET

## Protected Member Functions
void | AllocateNextTriangle ()
void | Stripify ()

## Protected Attributes
unsigned int | _numTriangles
unsigned int | _stripSize
DynamicArray< V2f_T2f, true > | _vertData
V2f | _currentTex [3]
Image * | _texture
unsigned int | _vboHandle
unsigned int | _vboBufferSize
bool | _stripified

## Detailed Description

The GlsTriangleStrip2D class. Wraps an OpenGL triangle strip drawable.

## Constructor & Destructor Documentation

## ◆ GlsTriangleStrip2D()

GlsTriangleStrip2D | ( |  | ) |

Default constructor

## ◆ ~GlsTriangleStrip2D()

virtual ~GlsTriangleStrip2D | ( |  | ) |
| virtual

Destructor

## Member Function Documentation

## ◆ AddTriangle2D()

void AddTriangle2D | ( | const float | x1,
|  | const float | y1,
|  | const float | x2,
|  | const float | y2,
|  | const float | x3,
|  | const float | y3
| ) |  |

Add the next triangle to the strip. Must be connected using previous two vertices of strip or be degenerate

Parameters

  x1 | X coord of vertex 1
  y1 | Y coord of vertex 1
  x2 | X coord of vertex 2
  y2 | Y coord of vertex 2
  x3 | X coord of vertex 3
  y3 | Y coord of vertex 3

Precondition
  _stripified == false

Postcondition
  _numTriangles++, triangle is added to strip

## ◆ AllocateNextTriangle()

void AllocateNextTriangle | ( |  | ) |
| protected

Allocate the next triangle in the set of ordered, connected triangles

## ◆ Bake()

void Bake | ( | IGlsStateManager * | stateManager | ) |

Finish building strip and bake it to a VBO

Parameters

  stateManager | StateManager object to issue GL commands to

Precondition
  _stripified == false
  _stripified == true

## ◆ Draw()

void Draw | ( | IGlsStateManager * | stateManager,
|  | const bool | enableTexture
| ) |  |

Draw the triangle strip

Parameters

  stateManager | StateManager object to issue GL commands to
  enableTexture | True if strip will be drawn textured

Precondition
  _stripified == true

Postcondition
  The strip is drawn

## ◆ GetNumTriangles()

unsigned int GetNumTriangles | ( |  | ) |
| inline

Returns
  The number of triangles in this strip.

## ◆ SetTexCoords()

void SetTexCoords | ( | const float | x1,
|  | const float | y1,
|  | const float | x2,
|  | const float | y2,
|  | const float | x3,
|  | const float | y3
| ) |  |

Set the texture coordinates to be used for the next triangle that is added (or subsequent triangles if this is not called again

Parameters

  x1 | X coord of vertex 1
  y1 | Y coord of vertex 1
  x2 | X coord of vertex 2
  y2 | Y coord of vertex 2
  x3 | X coord of vertex 3
  y3 | Y coord of vertex 3

Precondition
  _texture != NULL && _stripified == false

Postcondition
  _currentTex contains input values

## ◆ SetTexture()

void SetTexture | ( | Image * | image | ) |

Set the texture to be used for this triangle strip. The triangle strip may only have one texture, so it is an error to call this more than once after StartBuildingStrip() has been called.

Precondition
  _texture == NULL && _stripified == false

Postcondition
  _texture == img

Parameters

  image | The texture to assign, or NULL if no texture

## ◆ StartBuildingStrip()

void StartBuildingStrip | ( |  | ) |

Sets this object into strip building mode. During strip building mode the user adds individual triangles to the strip When strip building mode is finished, the object will create a triangle strip from the individual triangles

Precondition
  none

Postcondition
  _stripified == false

## ◆ Stripify()

void Stripify | ( |  | ) |
| protected

Convert the set of ordered, connected triangles in this object into tristrip

Precondition
  _stripified == false
  _stripified == true

## Member Data Documentation

## ◆ _currentTex

V2f _currentTex[3]
| protected

Current texture coordinates supplied for current triangle (Texture coordinates are not required to change per triangle) Used only while building list.

## ◆ _numTriangles

unsigned int _numTriangles
| protected

The number of triangles in the strip

## ◆ _stripified

bool _stripified
| protected

True if triangles have been created into a strip

## ◆ _stripSize

unsigned int _stripSize
| protected

The number of vertices in the strip

## ◆ _texture

Image* _texture
| protected

Texture to use when drawing strip. NULL if untextured

## ◆ _vboBufferSize

unsigned int _vboBufferSize
| protected

Size of the VBO buffer. Cached to so that when a strip is cleared and reset we will only reallocate the VBO when its size changes.

## ◆ _vboHandle

unsigned int _vboHandle
| protected

VBO Handle for this triangle strip

## ◆ _vertData

DynamicArray<V2f_T2f, true> _vertData
| protected

DynamicArray to store vertex and texture coordinates

## ◆ TEX_COORD_OFFSET

const void* const TEX_COORD_OFFSET
| static

Constant offsets to the primitive texture coordinate attribute.

Note
  Theoretically should be GLuints, but OpenGL's functions to pass integer offsets as pointers.

## ◆ VERT_OFFSET

const void* const VERT_OFFSET
| static

Constant offsets to the primitive vertex attribute.

Note
  Theoretically should be GLuints, but OpenGL's functions to pass integer offsets as pointers.

The documentation for this class was generated from the following file:

- gls_triangle_storage.h