![]() |
CUGL 4.0
Cornell University Game Library
|
Namespaces | |
| namespace | vulkan |
Classes | |
| class | AttributeDef |
| class | BlendState |
| class | ComputeShader |
| class | Font |
| class | FontLoader |
| class | FrameBuffer |
| class | GLSLConstant |
| class | GlyphRun |
| class | Gradient |
| class | GradientLoader |
| class | GraphicsShader |
| class | Image |
| class | ImageArray |
| class | IndexBuffer |
| class | Mesh |
| class | MeshExtruder |
| class | Particle3 |
| class | ParticleEmitter |
| class | ParticleInstance |
| class | ParticleLoader |
| class | ParticleShader |
| class | ParticleSystem |
| class | ParticleVertex |
| class | RenderPass |
| class | ResourceDef |
| class | Sampler |
| class | Scissor |
| class | ShaderSource |
| class | SpriteBatch |
| class | SpriteMesh |
| class | SpriteMeshLoader |
| class | SpriteSheet |
| class | SpriteVertex |
| class | StencilState |
| class | StorageBuffer |
| class | TextLayout |
| class | Texture |
| class | TextureArray |
| class | TextureLoader |
| class | TextureRenderer |
| class | UniformBuffer |
| class | UniformDef |
| class | VertexBindInfo |
| 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) |
| TextureFilter | json_filter (const std::string name) |
| TextureWrap | json_wrap (const std::string name) |
| BlendMode | json_blend_mode (std::string name) |
| Color4 | json_color (JsonValue *entry, std::string backup) |
| void | sdl_flip_vertically (SDL_Surface *surf) |
| 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. However, in the transition to Vulkan, we discovered that we need to factor this out. This allows us to provide options for OpenGL, Vulkan, and even headless clients.
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 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 |
An enum representing the color blending equation.
This enum is an abstraction of constants like GL_FUNC_ADD or the Vulkan equivalent VK_BLEND_OP_ADD.
|
strong |
An enum representing the color blending factor.
This enum is an abstraction of constants like GL_SRC_ALPHA or the Vulkan equivalent VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA. Note that blend factors have different meanings according to whether they are an RGB blend factor or an alpha blend factor.
In the documentation for each value, Rs is the red value of the source, while Rd is the red value of the destination (and similarly G green, B blue, and A alpha). Rc is the red of the constant color, which is a color set with the graphics pipeline.
|
strong |
An enum of predefined color blend models
While it is possible to define custom color blending via BlendState, there are some fairly common blend modes that most applications will use. This enum represents those modes to make it easier on the developer to use the color blending.
|
strong |
This enum represents the different buffer access types
A buffer can be any of VertexBuffer, IndexBuffer, UniformBuffer or StorageBuffer. These types are a simplification of the buffer types provided by the various graphics APIs. We find that they are sufficient for most of our purposes.
|
strong |
An enum representing comparison operators for depth and stencil tests.
This enum is an abstraction of constants like GL_NEVER or the Vulkan equivalent VK_COMPARE_OP_NEVER.
|
strong |
An enum representing the current cull mode.
Culling is used to remove non-visible triangles. This enum is an abstraction of constants like GL_BACK or the Vulkan equivalent VK_CULL_MODE_BACK_BIT. Note that culling only applies to triangles, not points or lines.
|
strong |
An enum representing the current drawing command.
We only support drawing commands supported by both OpenGL and Vulkan. This enum is an abstraction of contants like GL_TRIANGLES or the Vulkan equivalent VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST.
|
strong |
|
strong |
An enum representing the supported GLSL types.
This enum is used to connect C++ types to GLSL types. Note that not all platforms support all types (particularly the user-defined BLOCK type.
|
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 defining the access rules for and image.
Access rules apply to the methods Image#set and Image#get. They also indicate whether the image can be used in a compute shader or not. It is assumed that all images can be sampled by a shader.
| Enumerator | |
|---|---|
| SHADER_ONLY | The image can only be used in shader. The image does not support read or write access. This format is useful for images that associated with a |
| READ_ONLY | This image is read only on the CPU side. The image supports |
| WRITE_ONLY | The image is write-only on the CPU side. While the image can be accessed by a shader, no data can be loaded into the image after it is initialized. However, it is possible to add new data on the CPU side via |
| READ_WRITE | The image supports full CPU read and write access |
| COMPUTE_ONLY | The image can be accessed by a computer shader but has no CPU access. Vulkan ONLY: Neither methods |
| COMPUTE_READ | The image can be accessed by a computer shader and read from the CPU. Vulkan ONLY: The method |
| COMPUTE_ALL | The image has full compute and CPU access. Vulkan ONLY: The methods |
|
strong |
An enum representing a shader resource (buffer or texture).
Resources are any value attached to a shader that cannot be represented as GLSL primitive type. These primarily include textures and uniform buffers. However, in the case of Vulkan, there is a wider array of types supported. See the documentation for each enum value for the supported types.
| Enumerator | |
|---|---|
| MONO_BUFFER | A uniform buffer that is composed of just one block OpenGL and Vulkan: This type is supported in both APIs. It corresponds to a uniform buffer that has only one block, which cannot change during drawing. It corresponds to type uniform in GLSL. Note that this restriction is only on the number of blocks. It says nothing about the read/write access to the buffer itself. It is possible to have a dynamic (read/write) uniform buffer with just one block. |
| MULTI_BUFFER | A uniform buffer that is composed of multiple blocks OpenGL and Vulkan: This type is supported in both APIs. It corresponds to a buffer that can vary the block between drawing calls. It corresponds to type uniform in GLSL. Note that this restriction is only on the number of blocks. It says nothing about the read/write access to the buffer itself. It is possible to have a static (write-once) uniform buffer with mutliple blocks. |
| MONO_STORAGE | A storage buffer that is composed of just one block Vulkan ONLY: This type corresponds to a storage buffer that has only one block, which cannot change during shader executions. It is supported by both graphics and compute shaders in Vulkan, but attempts to use this resource with OpenGL will fail. It corresponds to type buffer in GLSL. Note that this restriction is only on the number of blocks. It says nothing about the read/write access to the buffer itself. It is possible to have a dynamic (read/write) storage buffer with just one block. |
| MULTI_STORAGE | A storage buffer that is composed of multiple blocks Vulkan ONLY: This type corresponds to a storage buffer that has only multiple blocks that can vary between shader executions. It is supported by both graphics and compute shaders in Vulkan, but attempts to use this resource with OpenGL will fail. It corresponds to type buffer in GLSL. Note that this restriction is only on the number of blocks. It says nothing about the read/write access to the buffer itself. It is possible to have a static (write-once) storage buffer with mutliple blocks. |
| TEXTURE | A (2d) texture with sampler OpenGL and Vulkan: In OpenGL, this resource is a standard GL_TEXTURE_2D object. In Vulkan, it is a combined image and sampler. It corresponds to type sampler2D in GLSL. |
| TEXTURE_ARRAY | A (2d) texture array with sampler OpenGL and Vulkan: In OpenGL, this resource is a GL_TEXTURE_2D_ARRAY object. In Vulkan, it is a combined image array and sampler (there is only one sampler for the entire array). It corresponds to sampler2DArray in GLSL. |
| SAMPLER | A sampler object Vulkan ONLY: Only Vulkan supports separating samplers from textures. Attempts to use this resource with OpenGL will fail. It corresponds to type sampler in GLSL. |
| IMAGE | An image object Vulkan ONLY: An image object is a texture without a sampler. Only Vulkan supports this separation. Attempts to use this resource with OpenGL will fail. It corresponds to type texture2D in GLSL. |
| IMAGE_ARRAY | An image array object Vulkan ONLY: An image array is a texture array without a sampler. Only Vulkan supports this separation. Attempts to use this resource with OpenGL will fail. It corresponds to type texture2DArray in GLSL. |
| COMPUTE_VERTEX | A vertex buffer that is the output to a compute shader Vulkan ONLY: This is a |
| COMPUTE_INDEX | A vertex buffer that is the output to a compute shader Vulkan ONLY: This is a |
| COMPUTE_STORAGE | A storage buffer that is the output to a compute shader Vulkan ONLY: This is a This value should only be used for outputs to a compute shader. Inputs should use type |
| COMPUTE_IMAGE | An image that is the output to a compute shader Vulkan ONLY: The is a This value should only be used for outputs to a compute shader. Inputs should use type |
|
strong |
An enum representing the various stages of the graphics pipeline.
This enum is used to refer to elements of a GLSL shader. In particular, it references which file to look for a variable. Note that only the first two stages are supported by OpenGL/OpenGLES.
|
strong |
An enum of predefined stencil tests.
While it is possible to define custom stencil tests via StencilState, there are some fairly common stencil tests that most applications will use. This enum represents those tests to make it easier on the developer to use the stencil buffer.
| Enumerator | |
|---|---|
| NONE | Disables any stencil effects. This effect directs the pipeline to ignore the stencil buffer when drawing. However, it does not clear the contents. |
| CLIP | Restricts all drawing to a stenciled region. In order for this effect to do anything, you must have created a stencil region with |
| CLIP_CLEAR | Restricts all drawing to the stenciled region. In order for this effect to do anything, you must have created a stencil region with This mode is different from |
| MASK | Prohibits all drawing to the stenciled region. In order for this effect to do anything, you must have created a stencil region with |
| MASK_CLEAR | Prohibits all drawing to the stenciled region. In order for this effect to do anything, you must have created a stencil region with This mode is different from |
| STAMP | Adds a stencil region the buffer This effect will not have any immediate visible effects. Instead it creates a stencil region for modes such as The shapes are drawn to the stencil buffer additively to the buffer. It ignores path orientation, and does not support holes. This allows the effect to implement a nonzero fill rule on the shapes. 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 |
| STAMP_EVENODD | Adds a stencil region the buffer This effect will not have any immediate visible effects. Instead it is a variation of The shapes are drawn to the stencil buffer using an even-odd fill rule. It respects orienation and can be used to draw a stencil for a polygon with holes. This has the disadvantage that stamps drawn on top of each other have an "erasing" effect. However, it does not have the polygon limitations that |
| STAMP_NONZERO | Adds a stencil region the buffer This effect will not have any immediate visible effects. Instead it is a variation of The shapes are drawn to the stencil buffer using a nonzero fill rule. It respects orienation and can be used to draw a stencil for a polygon with holes. This has the advantage that (unlike an even-odd fill rule) stamps are additive and can be drawn on top of each other. However, the size of the stencil buffer means that more than 256 overlapping polygons of the same orientation will cause unpredictable effects. |
| CLEAR | Erases pixels from the stenciled 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 modes |
|
strong |
An enum representing stencil operations.
This enum is an abstraction of constants like GL_KEEP or the Vulkan equivalent VK_STENCIL_OP_KEEP.
|
strong |
An enum listing the possible texture pixel formats.
This enum defines the texel formats supported by CUGL. As CUGL must support both OpenGLES and Vulkan, it only supports a small subset of formats. CUGL will convert these values into the format for the appropriate platform.
|
strong |
An enum representing the texture filter options.
This enum is an abstraction of constants like GL_LINEAR or the Vulkan equivalent VK_FILTER_LINEAR. We use the OpenGL naming scheme as it allows us to combine mipmap and texture filter into a single enumeration.
|
strong |
An enum represeting a texture wrap parameter.
This enum is an abstraction of constants like GL_REPEAT or the Vulkan equivalent VK_SAMPLER_ADDRESS_MODE_REPEAT.
|
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.
| BlendMode cugl::graphics::json_blend_mode | ( | std::string | name | ) |
Returns the blend mode for the given name
This function converts JSON directory entries into BlendMode values. If the name is invalid, it returns BlendMode#PREMULT.
| name | The JSON name for the blend mode |
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 |
| TextureFilter cugl::graphics::json_filter | ( | const std::string | name | ) |
Returns the texture filter for the given name
This function converts JSON directory entries into TextureFilter values. If the name is invalid, it returns TextureFilter#LINEAR.
| name | The JSON name for the texture filter |
| TextureWrap cugl::graphics::json_wrap | ( | const std::string | name | ) |
Returns the texture wrap for the given name
This function converts JSON directory entries into TextureWrap values. If the name is invalid, it returns TextureWrap#CLAMP.
| name | The JSON name for the texture wrap |
|
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 |
| void cugl::graphics::sdl_flip_vertically | ( | SDL_Surface * | surf | ) |
Flips the pixel data in an SDL surface.
This converts the SDL to OpenGL coordinates, to make it easier to use.
| surf | The SDL surface |