C# Class Sparrow.Utils.VertexData

The VertexData class manages a raw list of vertex information, allowing direct upload to OpenGL vertex buffers. _You only have to work with this class if you create display objects with a custom render function. If you don't plan to do that, you can safely ignore it._ To render objects with OpenGL, you have to organize vertex data in so-called vertex buffers. Those buffers reside in graphics memory and can be accessed very efficiently by the GPU. Before you can move data into vertex buffers, you have to set it up in conventional memory - that is, in a byte array. That array contains all vertex information (the coordinates, color, and texture coordinates) - one vertex after the other. To simplify creating and working with such a bulky list, the VertexData class was created. It contains methods to specify and modify vertex data. The raw array managed by the class can then easily be uploaded to a vertex buffer. **Premultiplied Alpha** The color values of texture files may contain premultiplied alpha values, which means that the 'RGB' values were multiplied with the 'alpha' value before saving them. On rendering, it makes a difference in which way the alpha value is saved; for that reason, the VertexData class mimics this behavior. You can choose how the alpha values should be handled via the 'premultipliedAlpha' property.
Afficher le fichier Open project: fmotagarcia/sparrow-sharp Class Usage Examples

Méthodes publiques

Méthode Description
AlphaAt ( int index ) : float

Returns the alpha value of a vertex.

BoundsAfterTransformation ( Matrix matrix ) : Rectangle

Calculates the bounding rectangle of all vertices after being transformed by a matrix.

BoundsAfterTransformation ( Matrix matrix, int atIndex, int numVertices ) : Rectangle

Calculates the bounding rectangle of subsequent vertices after being transformed by a matrix.

ColorAt ( int index ) : uint

Returns the RGB color of a vertex (without premultiplied alpha).

CopyToVertexData ( VertexData target, bool copyColor, int atIndex ) : void

Copies the vertex data of this instance to another vertex data object, starting at a certain index.

CopyToVertexData ( VertexData target, bool copyColor, int atIndex, int numVertices ) : void

Copies a range of vertices of this instance to another vertex data object.

PositionAt ( int index ) : Point

Returns the position of a vertex.

ScaleAlphaBy ( float factor ) : void

Multiplies all alpha values with a certain factor.

ScaleAlphaBy ( float factor, int index, int numVertices ) : void

Multiplies a range of alpha values with a certain factor.

SetAlpha ( float alpha ) : void

Updates the alpha value of all vertices.

SetAlpha ( float alpha, int atIndex ) : void

Updates the alpha value of a vertex.

SetColor ( uint color ) : void

Updates the color of all vertexes. The method always expects non-premultiplied alpha values.

SetColor ( uint color, float alpha ) : void

Updates the color of all vertexes. The method always expects non-premultiplied alpha values.

SetColor ( uint color, float alpha, int atIndex ) : void

Updates the color of a vertex. The method always expects non-premultiplied alpha values.

SetColor ( uint color, int atIndex ) : void

Updates the color of a vertex. The method always expects non-premultiplied alpha values.

SetPosition ( Point position, int atIndex ) : void

Updates the position of a vertex.

SetPosition ( float x, float y, int atIndex ) : void

Updates the position of a vertex.

SetPremultipliedAlpha ( bool value, bool updateVertices ) : void

Changes the way alpha and color values are stored. Optionally, all exisiting vertices are updated.

SetTexCoords ( Point texCoords, int atIndex ) : void

Updates the texture coordinates of a vertex.

SetTexCoords ( float x, float y, int atIndex ) : void

Updates the texture coordinates of a vertex.

TexCoordsAt ( int index ) : Point

Returns the texture coordinates of a vertex.

TransformVertices ( Matrix matrix, int atIndex, int numVertices ) : void

Transforms the positions of subsequent vertices by multiplication with a transformation matrix

VertexData ( int numVertices, bool premultipliedAlpha = false ) : System

Initializes a VertexData instance with a certain size.

Method Details

AlphaAt() public méthode

Returns the alpha value of a vertex.
public AlphaAt ( int index ) : float
index int
Résultat float

BoundsAfterTransformation() public méthode

Calculates the bounding rectangle of all vertices after being transformed by a matrix.
public BoundsAfterTransformation ( Matrix matrix ) : Rectangle
matrix Matrix
Résultat Sparrow.Geom.Rectangle

BoundsAfterTransformation() public méthode

Calculates the bounding rectangle of subsequent vertices after being transformed by a matrix.
public BoundsAfterTransformation ( Matrix matrix, int atIndex, int numVertices ) : Rectangle
matrix Matrix
atIndex int
numVertices int
Résultat Sparrow.Geom.Rectangle

ColorAt() public méthode

Returns the RGB color of a vertex (without premultiplied alpha).
public ColorAt ( int index ) : uint
index int
Résultat uint

CopyToVertexData() public méthode

Copies the vertex data of this instance to another vertex data object, starting at a certain index.
public CopyToVertexData ( VertexData target, bool copyColor, int atIndex ) : void
target VertexData
copyColor bool
atIndex int
Résultat void

CopyToVertexData() public méthode

Copies a range of vertices of this instance to another vertex data object.
public CopyToVertexData ( VertexData target, bool copyColor, int atIndex, int numVertices ) : void
target VertexData
copyColor bool
atIndex int
numVertices int
Résultat void

PositionAt() public méthode

Returns the position of a vertex.
public PositionAt ( int index ) : Point
index int
Résultat Point

ScaleAlphaBy() public méthode

Multiplies all alpha values with a certain factor.
public ScaleAlphaBy ( float factor ) : void
factor float
Résultat void

ScaleAlphaBy() public méthode

Multiplies a range of alpha values with a certain factor.
public ScaleAlphaBy ( float factor, int index, int numVertices ) : void
factor float
index int
numVertices int
Résultat void

SetAlpha() public méthode

Updates the alpha value of all vertices.
public SetAlpha ( float alpha ) : void
alpha float
Résultat void

SetAlpha() public méthode

Updates the alpha value of a vertex.
public SetAlpha ( float alpha, int atIndex ) : void
alpha float
atIndex int
Résultat void

SetColor() public méthode

Updates the color of all vertexes. The method always expects non-premultiplied alpha values.
public SetColor ( uint color ) : void
color uint
Résultat void

SetColor() public méthode

Updates the color of all vertexes. The method always expects non-premultiplied alpha values.
public SetColor ( uint color, float alpha ) : void
color uint
alpha float
Résultat void

SetColor() public méthode

Updates the color of a vertex. The method always expects non-premultiplied alpha values.
public SetColor ( uint color, float alpha, int atIndex ) : void
color uint
alpha float
atIndex int
Résultat void

SetColor() public méthode

Updates the color of a vertex. The method always expects non-premultiplied alpha values.
public SetColor ( uint color, int atIndex ) : void
color uint
atIndex int
Résultat void

SetPosition() public méthode

Updates the position of a vertex.
public SetPosition ( Point position, int atIndex ) : void
position Point
atIndex int
Résultat void

SetPosition() public méthode

Updates the position of a vertex.
public SetPosition ( float x, float y, int atIndex ) : void
x float
y float
atIndex int
Résultat void

SetPremultipliedAlpha() public méthode

Changes the way alpha and color values are stored. Optionally, all exisiting vertices are updated.
public SetPremultipliedAlpha ( bool value, bool updateVertices ) : void
value bool
updateVertices bool
Résultat void

SetTexCoords() public méthode

Updates the texture coordinates of a vertex.
public SetTexCoords ( Point texCoords, int atIndex ) : void
texCoords Point
atIndex int
Résultat void

SetTexCoords() public méthode

Updates the texture coordinates of a vertex.
public SetTexCoords ( float x, float y, int atIndex ) : void
x float
y float
atIndex int
Résultat void

TexCoordsAt() public méthode

Returns the texture coordinates of a vertex.
public TexCoordsAt ( int index ) : Point
index int
Résultat Point

TransformVertices() public méthode

Transforms the positions of subsequent vertices by multiplication with a transformation matrix
public TransformVertices ( Matrix matrix, int atIndex, int numVertices ) : void
matrix Matrix
atIndex int
numVertices int
Résultat void

VertexData() public méthode

Initializes a VertexData instance with a certain size.
public VertexData ( int numVertices, bool premultipliedAlpha = false ) : System
numVertices int
premultipliedAlpha bool
Résultat System