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

#include <CUSampler.h>

Public Member Functions

 Sampler ()
 
 ~Sampler ()
 
void dispose ()
 
bool init ()
 
bool initWithWrap (TextureWrap wrapS, TextureWrap wrapT)
 
bool initWithFilters (TextureFilter magFilter, TextureFilter minFilter)
 
bool init (TextureWrap wrapS, TextureWrap wrapT, TextureFilter magFilter, TextureFilter minFilter)
 
size_t id () const
 
SamplerData * getImplementation ()
 
TextureFilter getMagFilter () const
 
void setMagFilter (TextureFilter filter)
 
TextureFilter getMinFilter () const
 
void setMinFilter (TextureFilter filter)
 
TextureWrap getWrapS () const
 
void setWrapS (TextureWrap wrap)
 
TextureWrap getWrapT () const
 
void setWrapT (TextureWrap wrap)
 

Static Public Member Functions

static std::shared_ptr< Sampleralloc ()
 
static std::shared_ptr< SamplerallocWithWrap (TextureWrap wrapS, TextureWrap wrapT)
 
static std::shared_ptr< SamplerallocWithFilters (TextureFilter magFilter, TextureFilter minFilter)
 
static std::shared_ptr< Sampleralloc (TextureWrap wrapS, TextureWrap wrapT, TextureFilter magFilter, TextureFilter minFilter)
 

Detailed Description

This is a class representing a sampler.

A sampler is second part of a Texture. It is used to to instruct the texture how it should read and filter data from the underlying image. In OpenGL, this is a simple struct. However, its allocation is a little more involved in Vulkan and Metal.

Constructor & Destructor Documentation

◆ Sampler()

cugl::graphics::Sampler::Sampler ( )
inline

Creates a new empty sampler with no filter or wrap-style.

This method performs no allocations. You must call init to generate a proper sampler.

◆ ~Sampler()

cugl::graphics::Sampler::~Sampler ( )
inline

Deletes this sampler, disposing all resources

Member Function Documentation

◆ alloc() [1/2]

static std::shared_ptr< Sampler > cugl::graphics::Sampler::alloc ( )
inlinestatic

Returns a newly allocated a default sampler.

The sampler will use a TextureFilter#LINEAR filter. It will also use TextureWrap#CLAMP on both axes.

Returns
a newly allocated a default sampler.

◆ alloc() [2/2]

static std::shared_ptr< Sampler > cugl::graphics::Sampler::alloc ( TextureWrap  wrapS,
TextureWrap  wrapT,
TextureFilter  magFilter,
TextureFilter  minFilter 
)
inlinestatic

Returns a newly allocated a sampler with the given wrap and filter values

Parameters
wrapSThe horizontal wrap
wrapTThe vertical wrap
magFilterThe filter for magnifying an image
minFilterThe filter for shrinking an image
Returns
a newly allocated a sampler with the given wrap and filter values

◆ allocWithFilters()

static std::shared_ptr< Sampler > cugl::graphics::Sampler::allocWithFilters ( TextureFilter  magFilter,
TextureFilter  minFilter 
)
inlinestatic

Returns a newly allocated sampler with the given filter values

The sampler will use TextureWrap#CLAMP on both axes.

Parameters
magFilterThe filter for magnifying an image
minFilterThe filter for shrinking an image
Returns
a newly allocated sampler with the given filter values

◆ allocWithWrap()

static std::shared_ptr< Sampler > cugl::graphics::Sampler::allocWithWrap ( TextureWrap  wrapS,
TextureWrap  wrapT 
)
inlinestatic

Returns a newly allocated sampler with the given wrap values

The sampler will use a TextureFilter#LINEAR filter.

Parameters
wrapSThe horizontal wrap
wrapTThe vertical wrap
Returns
a newly allocated sampler with the given wrap values

◆ dispose()

void cugl::graphics::Sampler::dispose ( )

Deletes the sampler and resets all attributes.

You must reinitialize the sampler to use it.

◆ getImplementation()

SamplerData * cugl::graphics::Sampler::getImplementation ( )
inline

Returns the platform-specific implementation for this sampler

The value returned is an opaque type encapsulating the information for either OpenGL or Vulkan.

Returns
the platform-specific implementation for this sampler

◆ getMagFilter()

TextureFilter cugl::graphics::Sampler::getMagFilter ( ) const
inline

Returns the magnification filter of this sampler.

The magnification filter is the algorithm hint that the graphics card uses to make an image larger. The default is LINEAR.

Returns
the magnification filter of this sampler.

◆ getMinFilter()

TextureFilter cugl::graphics::Sampler::getMinFilter ( ) const
inline

Returns the minimization filter of this sampler.

The minimization filter is the algorithm hint that the graphics card uses to make an image smaller. The default is LINEAR.

Returns
the minimization filter of this sampler.

◆ getWrapS()

TextureWrap cugl::graphics::Sampler::getWrapS ( ) const
inline

Returns the horizontal wrap of this sampler.

The default is CLAMP.

Returns
the horizontal wrap of this sampler.

◆ getWrapT()

TextureWrap cugl::graphics::Sampler::getWrapT ( ) const
inline

Returns the vertical wrap of this sampler.

The default is CLAMP.

Returns
the vertical wrap of this sampler.

◆ id()

size_t cugl::graphics::Sampler::id ( ) const

Returns a unique identifier for this sampler

This value can be used in memory-based hashes.

Returns
a unique identifier for this sampler

◆ init() [1/2]

bool cugl::graphics::Sampler::init ( )
inline

Initializes a default sampler.

The sampler will use a TextureFilter#LINEAR filter. It will also use TextureWrap#CLAMP on both axes.

Returns
true if initialization was successful.

◆ init() [2/2]

bool cugl::graphics::Sampler::init ( TextureWrap  wrapS,
TextureWrap  wrapT,
TextureFilter  magFilter,
TextureFilter  minFilter 
)

Initializes a sampler with the given wrap and filter values

Parameters
wrapSThe horizontal wrap
wrapTThe vertical wrap
magFilterThe filter for magnifying an image
minFilterThe filter for shrinking an image
Returns
true if initialization was successful.

◆ initWithFilters()

bool cugl::graphics::Sampler::initWithFilters ( TextureFilter  magFilter,
TextureFilter  minFilter 
)
inline

Initializes a sampler with the given filter values

The sampler will use TextureWrap#CLAMP on both axes.

Parameters
magFilterThe filter for magnifying an image
minFilterThe filter for shrinking an image
Returns
true if initialization was successful.

◆ initWithWrap()

bool cugl::graphics::Sampler::initWithWrap ( TextureWrap  wrapS,
TextureWrap  wrapT 
)
inline

Initializes a sampler with the given wrap values

The sampler will use a TextureFilter#LINEAR filter.

Parameters
wrapSThe horizontal wrap
wrapTThe vertical wrap
Returns
true if initialization was successful.

◆ setMagFilter()

void cugl::graphics::Sampler::setMagFilter ( TextureFilter  filter)

Sets the magnification filter of this sampler.

The magnification filter is the algorithm hint that the graphics card uses to make an image larger. The default is LINEAR.

When this value is changed, the value will be pushed to the implementation and all subsequent drawing commands will use the new value. Previous drawing commands (including those in flight) are unaffected.

Parameters
filterThe magnification filter of this sampler.

◆ setMinFilter()

void cugl::graphics::Sampler::setMinFilter ( TextureFilter  filter)

Sets the minimization filter of this sampler.

The minimization filter is the algorithm hint that the graphics card uses to make an image smaller. The default is LINEAR.

When this value is changed, the value will be pushed to the implementation and all subsequent drawing commands will use the new value. Previous drawing commands (including those in flight) are unaffected.

Parameters
filterThe min filter of this sampler.

◆ setWrapS()

void cugl::graphics::Sampler::setWrapS ( TextureWrap  wrap)

Sets the horizontal wrap of this sampler.

The default is CLAMP.

When this value is changed, the value will be pushed to the implementation and all subsequent drawing commands will use the new value. Previous drawing commands (including those in flight) are unaffected.

Parameters
wrapThe horizontal wrap setting of this sampler

◆ setWrapT()

void cugl::graphics::Sampler::setWrapT ( TextureWrap  wrap)

Sets the vertical wrap of this sampler.

The default is CLAMP.

When this value is changed, the value will be pushed to the implementation and all subsequent drawing commands will use the new value. Previous drawing commands (including those in flight) are unaffected.

Parameters
wrapThe vertical wrap setting of this sampler

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