![]() |
CUGL 3.0
Cornell University Game Library
|
Namespaces | |
namespace | stencil |
Classes | |
class | Font |
class | FontLoader |
class | GlyphRun |
class | Gradient |
class | GradientLoader |
class | InstanceBuffer |
class | Mesh |
class | MeshExtruder |
class | Particle3 |
class | ParticleEmitter |
class | ParticleInstance |
class | ParticleLoader |
class | ParticleShader |
class | ParticleSystem |
class | ParticleVertex |
class | RenderTarget |
class | Scissor |
class | Shader |
class | SpriteBatch |
class | SpriteMesh |
class | SpriteMeshLoader |
class | SpriteSheet |
class | SpriteVertex |
class | TextLayout |
class | Texture |
class | TextureLoader |
class | TextureRenderer |
class | UniformBuffer |
class | VertexBuffer |
Typedefs | |
typedef std::function< void(const ParticleEmitter &source, Particle3 *part)> | ParticleAllocator |
typedef std::function< void(Particle3 *part)> | ParticleDeallocator |
typedef std::function< bool(float delta, Particle3 *part, ParticleInstance *inst)> | ParticleUpdater |
Functions | |
int | operator* (Font::Style value) |
Font::Style | operator| (Font::Style lhs, Font::Style rhs) |
Font::Style | operator& (Font::Style lhs, Font::Style rhs) |
Font::Style | operator^ (Font::Style lhs, Font::Style rhs) |
Font::Style | operator~ (Font::Style lhs) |
std::string | gl_error_name (GLenum error) |
std::string | gl_type_name (GLenum error) |
GLuint | gl_filter (const std::string name) |
GLuint | gl_wrap (const std::string name) |
GLenum | gl_blend_eq (std::string name) |
GLenum | gl_blend_func (std::string name) |
Color4 | json_color (JsonValue *entry, std::string backup) |
template<typename T > | |
void | parse_mesh (Mesh< T > &mesh, const std::shared_ptr< JsonValue > &json) |
The classes and functions needed to construct a graphics pipeline.
Initially these were part of the core CUGL module (everyone wants graphics, right). However, after student demand for a headless option that did not have so many OpenGL dependencies, this was factored out.
Forward reference for fonts
Forward reference for now
This type represents a function to allocate a Particle3
object.
Particle systems recycle their particle objects, so allocation simply means assigning attributes after they have been recycled. That is the purpose of this function. It takes a ParticleEmitter
object and uses that to reassign the attributes of a Particle3
object.
This function is allowed to allocate and assign custom data to the userdata attribute in a particle. However, if it does so, the user should also create a ParticleDeallocator
function to reclaim this memory as nessary.
The allocator should set all attributes except for distance
and delay
. Those attributes are managed by the ParticleSystem
and any values set here will be overwritten.
This function type is equivalent to
std::function<void(const ParticleEmitter& source, Particle3* part)>
source | The particle emitter |
part | The particle to update |
This type represents a function to deallocate a Particle3
object.
Particle systems recycle their particle objects, and we need to be clean up any allocated memory when they are recycled. That is the purpose of this function. Note that this this function is only necessary is the ParticleAllocator
allocated memory to the userdata attribute of a Particle3
object. Otherwise, it can be ignored.
The function type is equivalent to
std::function<void(Particle3* part)>
part | The particle to recycle |
This type represents a function to update a Particle3
object.
This function provides the user-defined simulation for the particle system. It takes a Particle3
object and defines a ParticleInstance
for rendering.
While this function should update the attributes of the Particle3
, it is not necessary to update the life
attribute, as that value is managed by the system. Any changes to that attribute will unnaturally shorten or lengthen the lifespan of the particle. In addition, any values set to distance
and delay
will be overwritten.
This function should return true if the update was successful. It should return false if the update failed and the particle should be deleted.
This function type is equivalent to
std::function<bool(float delta, Particle3* part, ParticleInstance* inst)>
delta | The time passed since the last call to update |
part | The particle to simulate |
inst | The object to hold the simulation results |
|
strong |
This enumeration represents the horizontal alignment of each line of text.
The horizontal alignment has two meanings. First, it is the relationship of the relative alignment of multiple lines. In addition, it defines the x-coordinate origin of the text layout. The later is relevant even when the text layout is a single line.
Enumerator | |
---|---|
LEFT | Anchors the each line on the natural left side (DEFAULT) The x-coordinate origin will be the left side of each line of text, and all lines of text will be aligned at this point. If the initial character of a line of text has any natural spacing on the left-hand side (e.g the character width is less than the advance), this will be included. |
CENTER | Anchors each line of text in the natural center. The x-coordinate origin with the be the center of each line of text, and lines of text will all be centered at this point. Centering will include any natural spacing (e.g the character width is less than the advance) around the first and last character. |
RIGHT | Anchors each line of text on the natural right side The x-coordinate origin will be the right side of each line of text, and all lines of text will be aligned at this point. If the final character of a line of text has any natural spacing on the right-hand side (e.g the character width is less than the advance), this will be included. |
JUSTIFY | Justifies each line of text. Justification means that each line of text is flush on both the left and right sides (including any natural spacing around the first and last character of each line). This will involve introducing additional white space, as well as spaces between characters if the attribute |
HARD_LEFT | Anchors the each line on the visible left side The x-coordinate origin will be the left side of each line of text, and all lines of text will be aligned at this point. If the initial character of a line of text has any natural spacing on the left-hand side (e.g the character width is less than the advance), this will be ignored. Hence the left edge of the first character of each line will visibly align. |
TRUE_CENTER | Anchors each line of text in the visible center. The x-coordinate origin with the be the center of each line of text, and lines of text will all be centered at this point. Centering will ignore any natural spacing (e.g the character width is less than the advance) around the first and last character. Hence the text will be measured from the left edge of the first character to the right edge of the second. |
HARD_RIGHT | Anchors the each line on the visible right side The x-coordinate origin will be the right side of each line of text, and all lines of text will be aligned at this point. If the final character of a line of text has any natural spacing on the right-hand side (e.g the character width is less than the advance), this will be ignored. Hence the right edge of the last character of each line will visibly align. |
|
strong |
An enum to support stenciling effects.
A SpriteBatch
can support many types of stencil effects. Classic stencil effects including clipping (limiting drawing to a specific region) or masking (prohibiting drawing to a specific region). The stencil effects supported are designed with scene2::CanvasNode
in mind as the primary use case.
In particular, stencil effects are designed to support simple constructive area geometry operations. You can union, intersect, or subtract stencil regions to produce the relevant effects. However, this is only used for drawing and does not actually construct the associated geometries.
To support the CAG operations, the sprite batch stencil buffer has two areas: low and high. Operations can be applied to one or both of these regions. All binary operations are operations between these two regions. For example, StencilEffect#CLIP_MASK
will restrict all drawing to the stencil region defined in the low buffer, while also prohibiting any drawing to the stencil region in the high buffer. This has the visible effect of "subtracting" the high buffer from the low buffer.
The CAG operations are only supported at the binary level, as we only have two halves of the stencil buffer. However, using non-drawing effects like StencilEffect#CLIP_WIPE
or StencilEffect#CLIP_CARVE
, it is possible to produce more interesting nested expressions.
Note that when using split-buffer operations, only one of the operations will modify the stencil buffer. That is why there no effects such as FILL_WIPE
or CLAMP_STAMP
.
Enumerator | |
---|---|
NATIVE | Differs the to the existing OpenGL stencil settings. (DEFAULT) This effect neither enables nor disables the stencil buffer. Instead it uses the existing OpenGL settings. This is the effect that you should use when you need to manipulate the stencil buffer directly. |
NONE | Disables any stencil effects. This effect directs a |
CLIP | Restrict all drawing to the unified stencil region. In order for this effect to do anything, you must have created a stencil region with This effect is the same as |
MASK | Prohibits all drawing to the unified stencil region. In order for this effect to do anything, you must have created a stencil region with This effect is the same as |
FILL | Restrict all drawing to the unified stencil region. In order for this effect to do anything, you must have created a stencil region with This effect is different from This effect is the same as |
WIPE | Erases from the unified stencil region. This effect will not draw anything to the screen. Instead, it will only draw to the stencil buffer directly. Any pixel drawn will be zeroed in the buffer, removing it from the stencil region. The effect |
STAMP | Adds a stencil region the unified buffer This effect will not have any immediate visible effects. Instead it creates a stencil region for the effects such as The shapes are drawn to the stencil buffer using a nonzero fill rule. This has the advantage that (unlike an even-odd fill rule) stamps are additive and can be drawn on top of each other. However, it has the disadvantage that it requires both halves of the stencil buffer to store the stamp (which part of the stamp is in which half is undefined). While this effect implements a nonzero fill rule faithfully, there are technical limitations. The size of the stencil buffer means that more than 256 overlapping polygons of the same orientation will cause unpredictable effects. If this is a problem, use an even odd fill rule instead like |
CARVE | Adds a stencil region the lower buffer This effect will not have any immediate visible effects. Instead it creates a stencil region for the effects such as Like The primary application of this effect is to create stencils from extruded paths so that overlapping sections are not drawn twice (which has negative effects on alpha blending). |
CLAMP | Limits drawing so that each pixel is updated once. This effect is a variation of This effect is equivalent to |
NONE_CLIP | Applies As with This effect is designed to be used with stencil regions created by |
NONE_MASK | Applies As with This effect is designed to be used with stencil regions created by |
NONE_FILL | Applies As with This effect is designed to be used with stencil regions created by |
NONE_WIPE | Applies As with This effect is designed to be used with stencil regions created by |
NONE_STAMP | Adds a stencil region to the upper buffer This effect will not have any immediate visible effect on the screen screen. Instead, it creates a stencil region for the effects such as Unlike Use |
NONE_CARVE | Adds a stencil region to the upper buffer This value will not have any immediate visible effect on the screen. Instead, it creates a stencil region for the effects such as Like The primary application of this effect is to create stencils from extruded paths so that overlapping sections are not drawn twice (which has negative effects on alpha blending). |
NONE_CLAMP | Uses the upper buffer to limit each pixel to single update. This effect is a variation of |
CLIP_JOIN | Restrict all drawing to the unified stencil region. This effect is the same as |
CLIP_MEET | Restrict all drawing to the intersecting stencil region. This effect is the same as |
CLIP_NONE | Applies As with This effect is designed to be used with stencil regions created by |
CLIP_MASK | Applies a lower buffer This command restricts drawing to the stencil region in the lower buffer while prohibiting any drawing to the stencil region in the upper buffer. If this effect is applied to a unified stencil region created by |
CLIP_FILL | Applies a lower buffer This command restricts drawing to the stencil region in the unified stencil region of the two buffers. However, it only zeroes pixels in the stencil region of the upper buffer; the lower buffer is untouched. If this effect is applied to a unified stencil region created by |
CLIP_WIPE | Applies a lower buffer As with |
CLIP_STAMP | Applies a lower buffer As with |
CLIP_CARVE | Applies a lower buffer As with |
CLIP_CLAMP | Applies a lower buffer As with |
MASK_JOIN | Prohibits all drawing to the unified stencil region. This effect is the same as |
MASK_MEET | Prohibits all drawing to the intersecting stencil region. This effect is the same as |
MASK_NONE | Applies As with This effect is designed to be used with stencil regions created by |
MASK_CLIP | Applies a lower buffer This command restricts drawing to the stencil region in the upper buffer while prohibiting any drawing to the stencil region in the lower buffer. If this effect is applied to a unified stencil region created by |
MASK_FILL | Applies a lower buffer This command restricts drawing to the stencil region in the upper buffer while prohibiting any drawing to the stencil region in the lower buffer. However, it only zeroes the stencil region in the upper buffer; the lower buffer is untouched. In addition, it will only zero those pixels that were drawn. If this effect is applied to a unified stencil region created by |
MASK_WIPE | Applies a lower buffer As with |
MASK_STAMP | Applies a lower buffer As with |
MASK_CARVE | Applies a lower buffer As with |
MASK_CLAMP | Applies a lower buffer As with |
FILL_JOIN | Restrict all drawing to the unified stencil region. This effect is the same as |
FILL_MEET | Restrict all drawing to the intersecting stencil region. This effect is the same as When zeroing out pixels, this operation zeroes out both halves of the stencil buffer. If a unified stencil region was created by |
FILL_NONE | Applies As with This effect is designed to be used with stencil regions created by |
FILL_MASK | Applies a lower buffer This command restricts drawing to the stencil region in the lower buffer while prohibiting any drawing to the stencil region in the upper buffer. When zeroing out the stencil region, this part of the effect is only applied to the lower buffer. If this effect is applied to a unified stencil region created by |
FILL_CLIP | Applies a lower buffer This command restricts drawing to the stencil region in the unified stencil region of the two buffers. However, it only zeroes pixels in the stencil region of the lower buffer; the lower buffer is untouched. If this effect is applied to a unified stencil region created by |
WIPE_NONE | Applies As with This effect is designed to be used with stencil regions created by |
WIPE_MASK | Applies a lower buffer This command erases from the stencil region in the lower buffer. However, it limits its erasing to locations that are not masked by the stencil region in the upper buffer. If this effect is applied to a unified stencil region created by |
WIPE_CLIP | Applies a lower buffer This command erases from the stencil region in the lower buffer. However, it limits its erasing to locations that are contained in the stencil region in the upper buffer. If this effect is applied to a unified stencil region created by |
STAMP_NONE | Adds a stencil region to the lower buffer This effect will not have any immediate visible effect on the screen screen. Instead, it creates a stencil region for the effects such as Unlike |
STAMP_CLIP | Applies a lower buffer As with |
STAMP_MASK | Applies a lower buffer As with |
STAMP_BOTH | Adds a stencil region to both the lower and the upper buffer This effect will not have any immediate visible effect on the screen screen. Instead, it creates a stencil region for the effects such as Unlike The use of both buffers to provide a greater degree of flexibility. |
CARVE_NONE | Adds a stencil region to the lower buffer This effect is equivalent to |
CARVE_CLIP | Applies a lower buffer As with |
CARVE_MASK | Applies a lower buffer As with |
CARVE_BOTH | Adds a stencil region to both the lower and upper buffer This effect is similar to |
CLAMP_NONE | Uses the lower buffer to limit each pixel to single update. This effect is equivalent to |
CLAMP_CLIP | Applies a lower buffer As with |
CLAMP_MASK | Applies a lower buffer As with |
|
strong |
This enumeration represents the vertical alignment of each line of text.
The vertical defines the y-coordinate origin of this text layout. In the case of multiple lines, the alignment is (often) with respect to the entire block of text, not just the first line.
GLenum cugl::graphics::gl_blend_eq | ( | std::string | name | ) |
Returns the OpenGL blend equation for the given name
This function converts JSON directory entries into OpenGL values. If the name is invalid, it returns GL_FUNC_ADD.
name | The JSON name for the blend equation |
GLenum cugl::graphics::gl_blend_func | ( | std::string | name | ) |
Returns the OpenGL blend function for the given name
This function converts JSON directory entries into OpenGL values. If the name is invalid, it returns GL_ZERO.
name | The JSON name for the blend function |
std::string cugl::graphics::gl_error_name | ( | GLenum | error | ) |
Returns a string description of an OpenGL error type
error | The OpenGL error type |
GLuint cugl::graphics::gl_filter | ( | const std::string | name | ) |
Returns the OpenGL enum for the given texture filter name
This function converts JSON directory entries into OpenGL values. If the name is invalid, it returns GL_LINEAR.
name | The JSON name for the texture filter |
std::string cugl::graphics::gl_type_name | ( | GLenum | error | ) |
Returns a string description of an OpenGL data type
error | The OpenGL error type |
GLuint cugl::graphics::gl_wrap | ( | const std::string | name | ) |
Returns the OpenGL enum for the given texture wrap name
This function converts JSON directory entries into OpenGL values. If the name is invalid, it returns GL_CLAMP_TO_EDGE.
name | The JSON name for the texture wrap |
Returns the color value for the given JSON entry
A color entry is either a four-element integer array (values 0..255) or a string. Any string should be a web color or a Tkinter color name.
entry | The JSON entry for the color |
backup | Default color to use on failure |
|
inline |
Returns the bitwise and of two font styles.
|
inline |
Returns the int equivalent of a font style.
|
inline |
Returns the bitwise exclusive or of two font styles.
|
inline |
Returns the bitwise or of two font styles.
|
inline |
Returns the bitwise complement of a font style.
void cugl::graphics::parse_mesh | ( | Mesh< T > & | mesh, |
const std::shared_ptr< JsonValue > & | json | ||
) |
Populates a the mesh with the date in the given JsonValue.
For this template function to work, the type T must have a constructor that takes a JsonValue to initialize an individual vertex. Note that SpriteVertex
has such a constructor.
The mesh can be represented as either an array or JSON object. If it is an array, it then it should contain JSON values compatible with the constructor for that type. If it is a JSON object, then it supports the following attributes:
"vertices": An array vertex specific descriptions "indices": An intenger list of triangle indices (in multiples of 3) "triangulator": One of 'monotone', 'earclip', 'delaunay', 'fan', or 'strip'
All attributes are optional. If "vertices" are missing, the mesh will be empty. If both "indices" and "triangulator" are missing, the mesh will use a triangle fan. The "triangulator" choice will only be applied if the "indices" are missing.
T | The vertex type |
mesh | The mesh to populate |
json | The JSON object specifying the mesh |