CUGL 3.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cugl::graphics::SpriteVertex Class Reference

#include <CUSpriteVertex.h>

Public Member Functions

 SpriteVertex ()
 
 SpriteVertex (const std::shared_ptr< JsonValue > &json)
 
SpriteVertexset (const std::shared_ptr< JsonValue > &json)
 

Static Public Member Functions

static const GLvoid * positionOffset ()
 
static const GLvoid * colorOffset ()
 
static const GLvoid * texcoordOffset ()
 
static const GLvoid * gradcoordOffset ()
 

Public Attributes

cugl::Vec2 position
 
GLuint color
 
cugl::Vec2 texcoord
 
cugl::Vec2 gradcoord
 

Detailed Description

This class/struct is rendering information for a 2d sprite batch vertex.

The class is intended to be used as a struct. This struct has the basic rendering information required by a SpriteBatch for rendering.

Note that not all attributes of a sprite vertex are rendered. In particular, gradient coordinates are ignored if there is no gradient being applied, and texture coordinates are ignored if there is no texture being applied. See SpriteBatch for how to control these individual elements.

Constructor & Destructor Documentation

◆ SpriteVertex() [1/2]

cugl::graphics::SpriteVertex::SpriteVertex ( )
inline

Creates a new SpriteVertex

The values of this vertex will all be zeroed. That means that the color will be completely transparent.

◆ SpriteVertex() [2/2]

cugl::graphics::SpriteVertex::SpriteVertex ( const std::shared_ptr< JsonValue > &  json)

Creates a new SpriteVertex from the given JSON value.

A sprite vertex can be described as an array of floats or a JSON object. If it is a JSON object, then it supports the following attributes.

"position":  An array of float arrays of length two
"color":     Either a four-element integer array (values 0..255) or a string.
             Any string should be a web color or a Tkinter color name.
"texcoord":  An array of float arrays of length two
"gradcoord": An array of float arrays of length two

Again, all attributes are optional. The default color is 'white' and all other values resolve to the origin.

If the sprite vertex is represented as an array, then it should be an array of length no more than 10. These float are assigned to the attributes position (2), color (4), texCoord (2) and gradCoord (2) in order. Missing values are replaced with a 0 (or 255 in the case of the color attributes).

Parameters
jsonThe JSON object specifying the vertex

Member Function Documentation

◆ colorOffset()

static const GLvoid * cugl::graphics::SpriteVertex::colorOffset ( )
inlinestatic

The memory offset of the vertex color

◆ gradcoordOffset()

static const GLvoid * cugl::graphics::SpriteVertex::gradcoordOffset ( )
inlinestatic

The memory offset of the vertex texture coordinate

◆ positionOffset()

static const GLvoid * cugl::graphics::SpriteVertex::positionOffset ( )
inlinestatic

The memory offset of the vertex position

◆ set()

SpriteVertex & cugl::graphics::SpriteVertex::set ( const std::shared_ptr< JsonValue > &  json)

Sets this SpriteVertex to have the data in the given JSON value.

A sprite vertex can be described as an array of floats or a JSON object. If it is a JSON object, then it supports the following attributes.

"position":  An array of float arrays of length two
"color":     Either a four-element integer array (values 0..255) or a string.
             Any string should be a web color or a Tkinter color name.
"texcoord":  An array of float arrays of length two
"gradcoord": An array of float arrays of length two

Again, all attributes are optional. The default color is 'white' and all other values resolve to the origin.

If the sprite vertex is represented as an array, then it should be an array of length no more than 10. These float are assigned to the attributes position (2), color (4), texCoord (2) and gradCoord (2) in order. Missing values are replaced with a 0 (or 255 in the case of the color attributes).

Parameters
jsonThe JSON object specifying the vertex
Returns
a reference to this sprite vertex for chaining

◆ texcoordOffset()

static const GLvoid * cugl::graphics::SpriteVertex::texcoordOffset ( )
inlinestatic

The memory offset of the vertex texture coordinate

Member Data Documentation

◆ color

GLuint cugl::graphics::SpriteVertex::color

The vertex color

◆ gradcoord

cugl::Vec2 cugl::graphics::SpriteVertex::gradcoord

The vertex gradient coordinate

◆ position

cugl::Vec2 cugl::graphics::SpriteVertex::position

The vertex position

◆ texcoord

cugl::Vec2 cugl::graphics::SpriteVertex::texcoord

The vertex texture coordinate


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