CUGL 4.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
cugl::graphics::AttributeDef Class Reference

#include <CUGraphicsBase.h>

Public Member Functions

 AttributeDef ()
 
 AttributeDef (const AttributeDef &def)
 
AttributeDefoperator= (const AttributeDef &def)
 

Public Attributes

GLSLType type
 
Uint32 group
 
Sint32 location
 
size_t offset
 

Detailed Description

This class represents a shader attribute variable.

Attributes must be declared before the shader is compiled. The shader will validate the GLSL code against declared attributes. Note that not all GLSL types are supported on all platforms.

Note that while GLSL supports the binding keyword for uniform buffers and textures, there is no binding keyword for attributes. However, when we specify an attribute, we still have to give it an binding value. The purpose of this is for the organizing VertexBuffer objects. All attributes in the same vertex buffer must share the same binding. Conversely, attributes in distinct vertex buffers must have distinct bindings.

In this class, we refer to this concept as a vertex group instead of a binding, in order to make the difference clear. Technically, the group number can be anything we choose. However, for performance reasons, we prefer to start at 0 and assigning groups consecutively.

Constructor & Destructor Documentation

◆ AttributeDef() [1/2]

cugl::graphics::AttributeDef::AttributeDef ( )

Creates a default attribute definition.

◆ AttributeDef() [2/2]

cugl::graphics::AttributeDef::AttributeDef ( const AttributeDef def)

Creates a copy of the given attribute definition

Parameters
defThe attribute definition to copy

Member Function Documentation

◆ operator=()

AttributeDef & cugl::graphics::AttributeDef::operator= ( const AttributeDef def)

Assigns this object to be a copy of the given attribute definition.

Parameters
defThe attribute definition to copy
Returns
a reference to this object for chaining

Member Data Documentation

◆ group

Uint32 cugl::graphics::AttributeDef::group

The vertex group for this attribute

This is a user-defined value for grouping attributes that should be stored in the same VertexBuffer.

◆ location

Sint32 cugl::graphics::AttributeDef::location

The attribute location

In OpenGL, setting this value to -1 causes the shader to determine this location automatically. Vulkan requires that this value be set explicitly.

◆ offset

size_t cugl::graphics::AttributeDef::offset

The stride offset of this attribute

◆ type

GLSLType cugl::graphics::AttributeDef::type

The GLSL type of this attribute


The documentation for this class was generated from the following file: