libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
VertexShader Class Reference

Owns a GX2VertexShader's compiled program and uniform/attribute metadata. More...

#include <VertexShader.h>

Inheritance diagram for VertexShader:
[legend]

Public Member Functions

 VertexShader (uint32_t numAttr)
 
void setProgram (const uint32_t *program, uint32_t programSize, const uint32_t *regs, uint32_t regsSize)
 Uploads the compiled shader program.
 
void addUniformVar (const GX2UniformVar &var)
 Registers a uniform variable so it can be set by location.
 
void addAttribVar (const GX2AttribVar &var)
 Registers an input attribute variable.
 
void setShader () const
 Binds this vertex shader for subsequent draws.
 
GX2AttribStream * getAttributeBuffer (uint32_t idx=0) const
 
uint32_t getAttributesCount () const
 

Static Public Member Functions

static void setAttributeBuffer (uint32_t bufferIdx, uint32_t bufferSize, uint32_t stride, const void *buffer)
 Binds a vertex data buffer to an attribute buffer slot.
 
static void setUniformReg (uint32_t location, uint32_t size, const void *reg)
 Writes uniform registers for the bound vertex shader.
 
- Static Public Member Functions inherited from Shader
static void draw (int32_t primitive=GX2_PRIMITIVE_MODE_QUADS, uint32_t vtxCount=4)
 Issues the draw call for the currently bound shaders and attribute buffers.
 

Protected Attributes

uint32_t attributesCount
 Number of attribute streams.
 
GX2AttribStream * attributes
 Attribute stream descriptions handed to the fetch shader.
 
GX2VertexShader * vertexShader
 The GX2 vertex shader object.
 

Additional Inherited Members

- Static Public Attributes inherited from Shader
static const uint16_t cuVertexAttrSize = sizeof(float) * 3
 Size in bytes of one position vertex (3 floats)
 
static const uint16_t cuTexCoordAttrSize = sizeof(float) * 2
 Size in bytes of one texture coordinate (2 floats)
 
static const uint16_t cuColorAttrSize = sizeof(uint8_t) * 4
 Size in bytes of one vertex color (4 bytes, RGBA)
 

Detailed Description

Owns a GX2VertexShader's compiled program and uniform/attribute metadata.

setProgram() uploads the compiled bytecode; addUniformVar()/ addAttribVar() register the reflection info GX2 needs to bind it.

Definition at line 17 of file VertexShader.h.

Constructor & Destructor Documentation

◆ VertexShader()

VertexShader::VertexShader ( uint32_t numAttr)
inline
Parameters
numAttrNumber of vertex attribute streams the shader reads

Definition at line 21 of file VertexShader.h.

◆ ~VertexShader()

virtual VertexShader::~VertexShader ( )
inlinevirtual

Definition at line 33 of file VertexShader.h.

Member Function Documentation

◆ addAttribVar()

void VertexShader::addAttribVar ( const GX2AttribVar & var)
inline

Registers an input attribute variable.

Definition at line 101 of file VertexShader.h.

◆ addUniformVar()

void VertexShader::addUniformVar ( const GX2UniformVar & var)
inline

Registers a uniform variable so it can be set by location.

Definition at line 79 of file VertexShader.h.

◆ getAttributeBuffer()

GX2AttribStream * VertexShader::getAttributeBuffer ( uint32_t idx = 0) const
inline
Returns
the attribute stream description at idx

Definition at line 139 of file VertexShader.h.

◆ getAttributesCount()

uint32_t VertexShader::getAttributesCount ( ) const
inline
Returns
the number of attribute streams

Definition at line 147 of file VertexShader.h.

◆ setAttributeBuffer()

static void VertexShader::setAttributeBuffer ( uint32_t bufferIdx,
uint32_t bufferSize,
uint32_t stride,
const void * buffer )
inlinestatic

Binds a vertex data buffer to an attribute buffer slot.

Parameters
bufferIdxAttribute buffer slot
bufferSizeSize of buffer in bytes
strideBytes between consecutive vertices
bufferVertex data

Definition at line 127 of file VertexShader.h.

◆ setProgram()

void VertexShader::setProgram ( const uint32_t * program,
uint32_t programSize,
const uint32_t * regs,
uint32_t regsSize )
inline

Uploads the compiled shader program.

Parameters
programCompiled GX2 vertex shader bytecode
programSizeSize of program in bytes
regsPrecomputed shader register values
regsSizeSize of regs in bytes

Definition at line 61 of file VertexShader.h.

◆ setShader()

void VertexShader::setShader ( ) const
inline

Binds this vertex shader for subsequent draws.

Definition at line 133 of file VertexShader.h.

◆ setUniformReg()

static void VertexShader::setUniformReg ( uint32_t location,
uint32_t size,
const void * reg )
inlinestatic

Writes uniform registers for the bound vertex shader.

Parameters
locationRegister location of the uniform
sizeNumber of registers to write
regSource values

Definition at line 153 of file VertexShader.h.

Member Data Documentation

◆ attributes

GX2AttribStream* VertexShader::attributes
protected

Attribute stream descriptions handed to the fetch shader.

Definition at line 160 of file VertexShader.h.

◆ attributesCount

uint32_t VertexShader::attributesCount
protected

Number of attribute streams.

Definition at line 159 of file VertexShader.h.

◆ vertexShader

GX2VertexShader* VertexShader::vertexShader
protected

The GX2 vertex shader object.

Definition at line 161 of file VertexShader.h.


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