![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CUSpriteVertex.h>
Public Member Functions | |
SpriteVertex () | |
SpriteVertex (const std::shared_ptr< JsonValue > &json) | |
SpriteVertex & | set (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 |
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.
|
inline |
Creates a new SpriteVertex
The values of this vertex will all be zeroed. That means that the color will be completely transparent.
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).
json | The JSON object specifying the vertex |
|
inlinestatic |
The memory offset of the vertex color
|
inlinestatic |
The memory offset of the vertex texture coordinate
|
inlinestatic |
The memory offset of the vertex position
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).
json | The JSON object specifying the vertex |
|
inlinestatic |
The memory offset of the vertex texture coordinate
GLuint cugl::graphics::SpriteVertex::color |
The vertex color
cugl::Vec2 cugl::graphics::SpriteVertex::gradcoord |
The vertex gradient coordinate
cugl::Vec2 cugl::graphics::SpriteVertex::position |
The vertex position
cugl::Vec2 cugl::graphics::SpriteVertex::texcoord |
The vertex texture coordinate