CUGL 3.0
Cornell University Game Library
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions
cugl::graphics Namespace Reference

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
 

Enumerations

enum class  StencilEffect : int {
  NATIVE = 0 , NONE = 1 , CLIP = 2 , MASK = 3 ,
  FILL = 4 , WIPE = 5 , STAMP = 6 , CARVE = 7 ,
  CLAMP = 8 , NONE_CLIP = 9 , NONE_MASK = 10 , NONE_FILL = 11 ,
  NONE_WIPE = 12 , NONE_STAMP = 13 , NONE_CARVE = 14 , NONE_CLAMP = 15 ,
  CLIP_JOIN = 16 , CLIP_MEET = 17 , CLIP_NONE = 18 , CLIP_MASK = 19 ,
  CLIP_FILL = 20 , CLIP_WIPE = 21 , CLIP_STAMP = 22 , CLIP_CARVE = 23 ,
  CLIP_CLAMP = 24 , MASK_JOIN = 25 , MASK_MEET = 26 , MASK_NONE = 27 ,
  MASK_CLIP = 28 , MASK_FILL = 29 , MASK_WIPE = 30 , MASK_STAMP = 31 ,
  MASK_CARVE = 32 , MASK_CLAMP = 33 , FILL_JOIN = 34 , FILL_MEET = 35 ,
  FILL_NONE = 36 , FILL_MASK = 37 , FILL_CLIP = 38 , WIPE_NONE = 39 ,
  WIPE_MASK = 40 , WIPE_CLIP = 41 , STAMP_NONE = 42 , STAMP_CLIP = 43 ,
  STAMP_MASK = 44 , STAMP_BOTH = 45 , CARVE_NONE = 46 , CARVE_CLIP = 47 ,
  CARVE_MASK = 48 , CARVE_BOTH = 49 , CLAMP_NONE = 50 , CLAMP_CLIP = 51 ,
  CLAMP_MASK = 52
}
 
enum class  HorizontalAlign : int {
  LEFT = 0 , CENTER = 1 , RIGHT = 2 , JUSTIFY = 3 ,
  HARD_LEFT = 4 , TRUE_CENTER = 5 , HARD_RIGHT = 6
}
 
enum class  VerticalAlign {
  BASELINE = 0 , BOTTOM = 1 , MIDDLE = 2 , TOP = 3 ,
  HARD_BOTTOM = 4 , TRUE_MIDDLE = 5 , HARD_TOP = 6
}
 

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)
 

Detailed Description

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

Typedef Documentation

◆ ParticleAllocator

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)>
Parameters
sourceThe particle emitter
partThe particle to update

◆ ParticleDeallocator

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)>
Parameters
partThe particle to recycle

◆ ParticleUpdater

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)>
Parameters
deltaThe time passed since the last call to update
partThe particle to simulate
instThe object to hold the simulation results

Enumeration Type Documentation

◆ HorizontalAlign

enum class cugl::graphics::HorizontalAlign : int
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 Font#getStretchLimit is non-zero. When this option is chosen, the x-coordinate origin is on the natural left side.

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.

◆ StencilEffect

enum class cugl::graphics::StencilEffect : int
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 SpriteBatch to ignore the stencil buffer (both halves) when drawing. However, it does not clear the contents of the stencil buffer. To clear the stencil buffer, you will need to call cugl::graphics::stencil::clearBuffer.

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 StencilEffect#STAMP or one of its variants. This effect will process the drawing commands normally, but restrict all drawing to the stencil region. This can be used to quickly draw non-convex shapes by making a stencil and drawing a rectangle over the stencil.

This effect is the same as StencilEffect#CLIP_JOIN in that it respects the union of the two halves of the stencil buffer.

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 StencilEffect#STAMP or one of its variants. This effect will process the drawing commands normally, but reject any attempts to draw to the stencil region. This can be used to quickly draw shape borders on top of a solid shape.

This effect is the same as StencilEffect#MASK_JOIN in that it respects the union of the two halves of the stencil buffer.

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 StencilEffect#STAMP or one of its variants. This effect will process the drawing commands normally, but restrict all drawing to the stencil region. This can be used to quickly draw non-convex shapes by making a stencil and drawing a rectangle over the stencil.

This effect is different from StencilEffect#CLIP in that it will zero out the pixels it draws in the stencil buffer, effectively removing them from the stencil region. In many applications, this is a fast way to clear the stencil buffer once it is no longer needed.

This effect is the same as StencilEffect#FILL_JOIN in that it respects the union of the two halves of the stencil buffer.

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 StencilEffect#FILL is a combination of this and StencilEffect#CLIP. Again, this is a potential optimization for clearing the stencil buffer. However, on most tiled-based GPUs, it is probably faster to simply clear the whole buffer.

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 StencilEffect#CLIP, StencilEffect#MASK, and the like.

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 StencilEffect#STAMP_NONE (which has no such limitations).

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 StencilEffect#CLIP, StencilEffect#MASK, and the like.

Like StencilEffect#STAMP, shapes are drawn to the stencil buffer instead of the screen. But unlike stamp, this effect is always additive. It ignores path orientation, and does not support holes. This allows the effect to implement a nonzero fill rule while using only half of the buffer. This effect is equivalent to StencilEffect#CARVE_NONE in that it uses only the lower half.

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 StencilEffect#CARVE that also draws as it writes to the stencil buffer. This guarantees that each pixel is updated exactly once. This is used by extruded paths so that overlapping sections are not drawn twice (which has negative effects on alpha blending).

This effect is equivalent to StencilEffect#CLAMP_NONE in that it uses only the lower half.

NONE_CLIP 

Applies StencilEffect#CLIP using the upper stencil buffer only.

As with StencilEffect#CLIP, this effect restricts drawing to the stencil region. However, this effect only uses the stencil region present in the upper stencil buffer.

This effect is designed to be used with stencil regions created by StencilEffect#NONE_STAMP. While it can be used by a stencil region created by StencilEffect#STAMP, the lower stencil buffer is ignored, and hence the results are unpredictable.

NONE_MASK 

Applies StencilEffect#MASK using the upper stencil buffer only.

As with StencilEffect#MASK, this effect prohibits drawing to the stencil region. However, this effect only uses the stencil region present in the upper stencil buffer.

This effect is designed to be used with stencil regions created by StencilEffect#NONE_STAMP. While it can be used by a stencil region created by StencilEffect#STAMP, the lower stencil buffer is ignored, and hence the results are unpredictable.

NONE_FILL 

Applies StencilEffect#FILL using the upper stencil buffer only.

As with StencilEffect#FILL, this effect limits drawing to the stencil region. However, this effect only uses the stencil region present in the upper stencil buffer. It also only zeroes out the upper stencil buffer.

This effect is designed to be used with stencil regions created by StencilEffect#NONE_STAMP. While it can be used by a stencil region created by StencilEffect#STAMP, the lower stencil buffer is ignored, and hence the results are unpredictable.

NONE_WIPE 

Applies StencilEffect#WIPE using the upper stencil buffer only.

As with StencilEffect#WIPE, this effect zeroes out the stencil region, erasing parts of it. However, its effects are limited to the upper stencil region.

This effect is designed to be used with stencil regions created by StencilEffect#NONE_STAMP. While it can be used by a stencil region created by StencilEffect#STAMP, the lower stencil buffer is ignored, and hence the results are unpredictable.

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 StencilEffect#CLIP, StencilEffect#MASK, and the like.

Unlike StencilEffect#STAMP, the region created is limited to the upper half of the stencil buffer. That is because the shapes are drawn to the buffer with an even-odd fill rule (which does not require the full stencil buffer to implement). This has the disadvantage that stamps drawn on top of each other have an "erasing" effect. However, it has the advantage that the this stamp supports a wider array of effects than the simple stamp effect.

Use StencilEffect#NONE_CLAMP if you have an simple stencil with no holes that you wish to write to the upper half of the buffer.

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 StencilEffect#CLIP, StencilEffect#MASK, and the like.

Like StencilEffect#STAMP, shapes are drawn to the stencil buffer instead of the screen. But unlike stamp, this effect is always additive. It ignores path orientation, and does not support holes. This allows the effect to implement a nonzero fill rule while using only the upper half of the buffer.

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 StencilEffect#NONE_CARVE that also draws as it writes to the upper stencil buffer. This guarantees that each pixel is updated exactly once. This is used by extruded paths so that overlapping sections are not drawn twice (which has negative effects on alpha blending).

CLIP_JOIN 

Restrict all drawing to the unified stencil region.

This effect is the same as StencilEffect#CLIP in that it respects the union of the two halves of the stencil buffer.

CLIP_MEET 

Restrict all drawing to the intersecting stencil region.

This effect is the same as StencilEffect#CLIP, except that it limits drawing to the intersection of the stencil regions in the two halves of the stencil buffer. If a unified stencil region was created by StencilEffect#STAMP, then the results of this effect are unpredictable.

CLIP_NONE 

Applies StencilEffect#CLIP using the lower stencil buffer only.

As with StencilEffect#CLIP, this effect restricts drawing to the stencil region. However, this effect only uses the stencil region present in the lower stencil buffer.

This effect is designed to be used with stencil regions created by StencilEffect#NONE_STAMP. While it can be used by a stencil region created by StencilEffect#STAMP, the lower stencil buffer is ignored, and hence the results are unpredictable.

CLIP_MASK 

Applies a lower buffer StencilEffect#CLIP with an upper StencilEffect#MASK.

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 StencilEffect#STAMP, then the results are unpredictable.

CLIP_FILL 

Applies a lower buffer StencilEffect#CLIP with an upper StencilEffect#FILL.

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 StencilEffect#STAMP, then the results are unpredictable.

CLIP_WIPE 

Applies a lower buffer StencilEffect#CLIP with an upper StencilEffect#WIPE.

As with StencilEffect#WIPE, this command does not do any drawing on screen. Instead, it zeroes out the upper stencil buffer. However, it is clipped by the stencil region in the lower buffer, so that it does not zero out any pixel outside this region. Hence this is a way to erase the lower buffer stencil region from the upper buffer stencil region.

CLIP_STAMP 

Applies a lower buffer StencilEffect#CLIP with an upper StencilEffect#STAMP.

As with StencilEffect#NONE_CLAMP, this writes a shape to the upper stencil buffer using an even-odd fill rule. This means that adding a shape on top of existing shape has an erasing effect. However, it also restricts its operation to the stencil region in the lower stencil buffer. Note that if a pixel is clipped while drawing, it will not be added the stencil region in the upper buffer.

CLIP_CARVE 

Applies a lower buffer StencilEffect#CLIP with an upper StencilEffect#CARVE.

As with StencilEffect#NONE_CARVE, this writes an additive shape to the upper stencil buffer. However, it also restricts its operation to the stencil region in the lower stencil buffer. Note that if a pixel is clipped while drawing, it will not be added the stencil region in the upper buffer. Hence this is a way to copy the lower buffer stencil region into the upper buffer.

CLIP_CLAMP 

Applies a lower buffer StencilEffect#CLIP with an upper StencilEffect#CLAMP.

As with StencilEffect#NONE_CLAMP, this draws a nonoverlapping shape using the upper stencil buffer. However, it also restricts its operation to the stencil region in the lower stencil buffer. Note that if a pixel is clipped while drawing, it will not be added the stencil region in the upper buffer.

MASK_JOIN 

Prohibits all drawing to the unified stencil region.

This effect is the same as StencilEffect#MASK in that it respects the union of the two halves of the stencil buffer.

MASK_MEET 

Prohibits all drawing to the intersecting stencil region.

This effect is the same as StencilEffect#MASK, except that it limits drawing to the intersection of the stencil regions in the two halves of the stencil buffer. If a unified stencil region was created by StencilEffect#STAMP, then the results of this effect are unpredictable.

MASK_NONE 

Applies StencilEffect#MASK using the lower stencil buffer only.

As with StencilEffect#MASK, this effect prohibits drawing to the stencil region. However, this effect only uses the stencil region present in the lower stencil buffer.

This effect is designed to be used with stencil regions created by StencilEffect#STAMP_NONE. While it can be used by a stencil region created by StencilEffect#STAMP, the upper stencil buffer is ignored, and hence the results are unpredictable.

MASK_CLIP 

Applies a lower buffer StencilEffect#MASK with an upper StencilEffect#CLIP.

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 StencilEffect#STAMP, then the results are unpredictable.

MASK_FILL 

Applies a lower buffer StencilEffect#MASK with an upper StencilEffect#FILL.

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 StencilEffect#STAMP, then the results are unpredictable.

MASK_WIPE 

Applies a lower buffer StencilEffect#MASK with an upper StencilEffect#WIPE.

As with StencilEffect#WIPE, this command does not do any drawing on screen. Instead, it zeroes out the upper stencil buffer. However, it is masked by the stencil region in the lower buffer, so that it does not zero out any pixel inside this region.

MASK_STAMP 

Applies a lower buffer StencilEffect#MASK with an upper StencilEffect#STAMP.

As with StencilEffect#NONE_STAMP, this writes a shape to the upper stencil buffer using an even-odd fill rule. This means that adding a shape on top of existing shape has an erasing effect. However, it also masks its operation by the stencil region in the lower stencil buffer. Note that if a pixel is masked while drawing, it will not be added the stencil region in the upper buffer.

MASK_CARVE 

Applies a lower buffer StencilEffect#MASK with an upper StencilEffect#CARVE.

As with StencilEffect#NONE_CARVE, this writes an additive shape to the upper stencil buffer. However, it also prohibits any drawing to the stencil region in the lower stencil buffer. Note that if a pixel is masked while drawing, it will not be added the stencil region in the upper buffer.

MASK_CLAMP 

Applies a lower buffer StencilEffect#MASK with an upper StencilEffect#CLAMP.

As with StencilEffect#NONE_CLAMP, this draws a nonoverlapping shape using the upper stencil buffer. However, it also prohibits any drawing to the stencil region in the lower stencil buffer. Note that if a pixel is masked while drawing, it will not be added the stencil region in the upper buffer.

FILL_JOIN 

Restrict all drawing to the unified stencil region.

This effect is the same as StencilEffect#FILL in that it respects the union of the two halves of the stencil buffer.

FILL_MEET 

Restrict all drawing to the intersecting stencil region.

This effect is the same as StencilEffect#FILL, except that it limits drawing to the intersection of the stencil regions in the two halves of the stencil buffer.

When zeroing out pixels, this operation zeroes out both halves of the stencil buffer. If a unified stencil region was created by StencilEffect#STAMP, the results of this effect are unpredictable.

FILL_NONE 

Applies StencilEffect#FILL using the lower stencil buffer only.

As with StencilEffect#FILL, this effect restricts drawing to the stencil region. However, this effect only uses the stencil region present in the lower stencil buffer. It also only zeroes the stencil region in this lower buffer.

This effect is designed to be used with stencil regions created by StencilEffect#NONE_STAMP. While it can be used by a stencil region created by StencilEffect#STAMP, the lower stencil buffer is ignored, and hence the results are unpredictable.

FILL_MASK 

Applies a lower buffer StencilEffect#FILL with an upper StencilEffect#MASK.

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 StencilEffect#STAMP, then the results are unpredictable.

FILL_CLIP 

Applies a lower buffer StencilEffect#FILL with an upper StencilEffect#CLIP.

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 StencilEffect#STAMP, then the results are unpredictable.

WIPE_NONE 

Applies StencilEffect#WIPE using the lower stencil buffer only.

As with StencilEffect#WIPE, this effect zeroes out the stencil region, erasing parts of it. However, its effects are limited to the lower stencil region.

This effect is designed to be used with stencil regions created by StencilEffect#NONE_STAMP. While it can be used by a stencil region created by StencilEffect#STAMP, the lower stencil buffer is ignored, and hence the results are unpredictable.

WIPE_MASK 

Applies a lower buffer StencilEffect#WIPE with an upper StencilEffect#MASK.

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 StencilEffect#STAMP, the results are unpredictable.

WIPE_CLIP 

Applies a lower buffer StencilEffect#WIPE with an upper StencilEffect#CLIP.

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 StencilEffect#STAMP, the results are unpredictable.

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 StencilEffect#CLIP, StencilEffect#MASK, and the like.

Unlike StencilEffect#STAMP, the region created is limited to the lower half of the stencil buffer. That is because the shapes are drawn to the buffer with an even-odd fill rule (which does not require the full stencil buffer to implement). This has the disadvantage that stamps drawn on top of each other have an "erasing" effect. However, it has the advantage that the this stamp supports a wider array of effects than the simple stamp effect.

STAMP_CLIP 

Applies a lower buffer StencilEffect#STAMP with an upper StencilEffect#CLIP.

As with StencilEffect#STAMP_NONE, this writes a shape to the lower stencil buffer using an even-odd fill rule. This means that adding a shape on top of existing shape has an erasing effect. However, it also restricts its operation to the stencil region in the upper stencil buffer. Note that if a pixel is clipped while drawing, it will not be added the stencil region in the lower buffer.

STAMP_MASK 

Applies a lower buffer StencilEffect#STAMP with an upper StencilEffect#MASK.

As with StencilEffect#STAMP_NONE, this writes a shape to the lower stencil buffer using an even-odd fill rule. This means that adding a shape on top of existing shape has an erasing effect. However, it also masks its operation by the stencil region in the upper stencil buffer. Note that if a pixel is masked while drawing, it will not be added the stencil region in the lower buffer.

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 StencilEffect#CLIP, StencilEffect#MASK, and the like.

Unlike StencilEffect#STAMP, the region is create twice and put in both the upper and the lower stencil buffer. That is because the shapes are drawn to the buffer with an even-odd fill rule (which does not require the full stencil buffer to implement). This has the disadvantage that stamps drawn on top of each other have an "erasing" effect. However, it has the advantage that the this stamp supports a wider array of effects than the simple stamp effect.

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 StencilEffect#CARVE, since it only uses half of the stencil buffer.

CARVE_CLIP 

Applies a lower buffer StencilEffect#CARVE with an upper StencilEffect#CLIP.

As with StencilEffect#CARVE_NONE, this writes an additive shape to the lower stencil buffer. However, it also restricts its operation to the stencil region in the upper stencil buffer. Note that if a pixel is clipped while drawing, it will not be added the stencil region in the lower buffer. Hence this is a way to copy the upper buffer stencil region into the lower buffer.

CARVE_MASK 

Applies a lower buffer StencilEffect#CARVE with an upper StencilEffect#MASK.

As with StencilEffect#CARVE_NONE, this writes an additive shape to the lower stencil buffer. However, it also prohibits any drawing to the stencil region in the upper stencil buffer. Note that if a pixel is masked while drawing, it will not be added the stencil region in the lower buffer.

CARVE_BOTH 

Adds a stencil region to both the lower and upper buffer

This effect is similar to StencilEffect#CARVE, except that it uses both buffers. This is to give a wider degree of flexibility.

CLAMP_NONE 

Uses the lower buffer to limit each pixel to single update.

This effect is equivalent to StencilEffect#CLAMP, since it only uses half of the stencil buffer.

CLAMP_CLIP 

Applies a lower buffer StencilEffect#CLAMP with an upper StencilEffect#CLIP.

As with StencilEffect#CLAMP_NONE, this draws a nonoverlapping shape using the lower stencil buffer. However, it also restricts its operation to the stencil region in the upper stencil buffer. Note that if a pixel is clipped while drawing, it will not be added the stencil region in the lower buffer.

CLAMP_MASK 

Applies a lower buffer StencilEffect#CLAMP with an upper StencilEffect#MASK.

As with StencilEffect#CLAMP_NONE, this draws a nonoverlapping shape using the lower stencil buffer. However, it also prohibits any drawing to the stencil region in the upper stencil buffer. Note that if a pixel is masked while drawing, it will not be added the stencil region in the lower buffer.

◆ VerticalAlign

enum class cugl::graphics::VerticalAlign
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.

Enumerator
BASELINE 

Anchors the block according to the text baseline (DEFAULT)

In the case of a multi-line block, the y-origin is the baseline of the first (top) line, assuming that text reads top-to-bottom.

BOTTOM 

Anchors the block at the bottom, as defined by the font descent

The descent is the amount space below the baseline that the font reserves for its characters. This space will be included even if no character in the block is below the baseline.

In the case of a multi-line block, the y-origin is the bottom of the last line.

MIDDLE 

Anchors the block at the natural center.

This option uses the font height when computing the center. This means including the descent below the bottom line and the ascent above the top line, even if no characters use that space.

In the case of a multi-line block, the y-origin is computed as the center of the ascent of the first line to the descent of the last line.

TOP 

Anchors the block at the top, as defined by the font ascent

The ascent is the amount space above the baseline that the font reserves for its characters. This space will be included even if no character in the block uses the full ascent.

In the case of a multi-line block, the y-origin is the top of the first line.

HARD_BOTTOM 

Anchors the block at the visible bottom

This option ignores the font descent when computing the y-origin. To the y-coordinate origin is placed so that the it touches the character with the greatest extent below the baseline. If no characters are below the baseline, it uses the baseline as the bottom.

In the case of a multi-line block, the y-origin is the bottom of the last line.

TRUE_MIDDLE 

Anchors the block at the visible middle

This option ignores the font height when computing the y-origin. It measures the center from the top of the highest character to the bottom of the character with greatest extent below the baseline. If no characters are below the baseline, it uses the baseline as the bottom.

In the case of a multi-line block, the y-origin is centered between the highest character of the first line, and the visible bottom of the last line.

HARD_TOP 

Anchors the block at the visible top

This option ignores the font ascent when computing the y-origin. To the y-coordinate origin is placed so that the it touches the the top of the highest character above the baseline.

In the case of a multi-line block, the y-origin is the top of the first line.

Function Documentation

◆ gl_blend_eq()

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.

Parameters
nameThe JSON name for the blend equation
Returns
the OpenGL blend equation for the given name

◆ gl_blend_func()

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.

Parameters
nameThe JSON name for the blend function
Returns
the OpenGL blend function for the given name

◆ gl_error_name()

std::string cugl::graphics::gl_error_name ( GLenum  error)

Returns a string description of an OpenGL error type

Parameters
errorThe OpenGL error type
Returns
a string description of an OpenGL error type

◆ gl_filter()

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.

Parameters
nameThe JSON name for the texture filter
Returns
the OpenGL enum for the given texture filter name

◆ gl_type_name()

std::string cugl::graphics::gl_type_name ( GLenum  error)

Returns a string description of an OpenGL data type

Parameters
errorThe OpenGL error type
Returns
a string description of an OpenGL data type

◆ gl_wrap()

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.

Parameters
nameThe JSON name for the texture wrap
Returns
the OpenGL enum for the given texture wrap name

◆ json_color()

Color4 cugl::graphics::json_color ( JsonValue entry,
std::string  backup 
)

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.

Parameters
entryThe JSON entry for the color
backupDefault color to use on failure
Returns
the color value for the given JSON entry

◆ operator&()

Font::Style cugl::graphics::operator& ( Font::Style  lhs,
Font::Style  rhs 
)
inline

Returns the bitwise and of two font styles.

Returns
the bitwise and of two font styles.

◆ operator*()

int cugl::graphics::operator* ( Font::Style  value)
inline

Returns the int equivalent of a font style.

Returns
the int equivalent of a font style.

◆ operator^()

Font::Style cugl::graphics::operator^ ( Font::Style  lhs,
Font::Style  rhs 
)
inline

Returns the bitwise exclusive or of two font styles.

Returns
the bitwise exclusive or of two font styles.

◆ operator|()

Font::Style cugl::graphics::operator| ( Font::Style  lhs,
Font::Style  rhs 
)
inline

Returns the bitwise or of two font styles.

Returns
the bitwise or of two font styles.

◆ operator~()

Font::Style cugl::graphics::operator~ ( Font::Style  lhs)
inline

Returns the bitwise complement of a font style.

Returns
the bitwise complement of a font style.

◆ parse_mesh()

template<typename T >
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.

Template Parameters
TThe vertex type
Parameters
meshThe mesh to populate
jsonThe JSON object specifying the mesh