Open CASCADE Technology  7.3.0
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes

OpenGl_Sampler Class Reference

Class implements OpenGL sampler object resource that stores the sampling parameters for a texture access. More...

#include <OpenGl_Sampler.hxx>

Inheritance diagram for OpenGl_Sampler:
Inheritance graph
[legend]

Public Member Functions

 OpenGl_Sampler (const Handle< Graphic3d_TextureParams > &theParams)
 Creates new sampler object. More...
 
virtual ~OpenGl_Sampler ()
 Releases resources of sampler object. More...
 
virtual void Release (OpenGl_Context *theContext) override
 Destroys object - will release GPU memory if any. More...
 
virtual Standard_Size EstimatedDataSize () const override
 Returns estimated GPU memory usage - not implemented. More...
 
Standard_Boolean Create (const Handle< OpenGl_Context > &theContext)
 Creates an uninitialized sampler object. More...
 
Standard_Boolean Init (const Handle< OpenGl_Context > &theContext, const OpenGl_Texture &theTexture)
 Creates and initializes sampler object. Existing object will be reused if possible, however if existing Sampler Object has Immutable flag and texture parameters should be re-initialized, then Sampler Object will be recreated. More...
 
Standard_Boolean IsValid () const
 Returns true if current object was initialized. More...
 
void Bind (const Handle< OpenGl_Context > &theCtx)
 Binds sampler object to texture unit specified in parameters. More...
 
void Unbind (const Handle< OpenGl_Context > &theCtx)
 Unbinds sampler object from texture unit specified in parameters. More...
 
void Bind (const Handle< OpenGl_Context > &theCtx, const Graphic3d_TextureUnit theUnit)
 Binds sampler object to the given texture unit. More...
 
void Unbind (const Handle< OpenGl_Context > &theCtx, const Graphic3d_TextureUnit theUnit)
 Unbinds sampler object from the given texture unit. More...
 
void SetParameter (const Handle< OpenGl_Context > &theCtx, GLenum theTarget, GLenum theParam, GLint theValue)
 Sets specific sampler parameter. More...
 
GLuint SamplerID () const
 Returns OpenGL sampler ID. More...
 
bool IsImmutable () const
 Return immutable flag preventing further modifications of sampler parameters, FALSE by default. Immutable flag might be set when Sampler Object is used within Bindless Texture. More...
 
void SetImmutable ()
 Setup immutable flag. It is not possible unsetting this flag without Sampler destruction. More...
 
const Handle< Graphic3d_TextureParams > & Parameters ()
 Returns texture parameters. More...
 
void SetParameters (const Handle< Graphic3d_TextureParams > &theParams)
 Sets texture parameters. More...
 
bool ToUpdateParameters () const
 Returns texture parameters initialization state. More...
 
- Public Member Functions inherited from OpenGl_Resource
 OpenGl_Resource ()
 Empty constructor. More...
 
virtual ~OpenGl_Resource ()
 Destructor. Inheritors should call Clean (NULL) within it. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Static Public Attributes

static const GLuint NO_SAMPLER = 0
 Helpful constant defining invalid sampler identifier. More...
 

Protected Member Functions

Standard_Boolean isValidSampler () const
 Checks if sampler object is valid. More...
 

Static Protected Member Functions

static void setParameter (const Handle< OpenGl_Context > &theContext, OpenGl_Sampler *theSampler, GLenum theTarget, GLenum theParam, GLint theValue)
 Sets specific sampler parameter. More...
 
static void applySamplerParams (const Handle< OpenGl_Context > &theCtx, const Handle< Graphic3d_TextureParams > &theParams, OpenGl_Sampler *theSampler, const GLenum theTarget, const bool theHasMipMaps)
 Apply sampler parameters. If Sampler Object is not NULL and valid resource, the parameters will be set to it (and it is not required Sampler Object being bound). Otherwise, parameters will be applied to currently bound Texture object. More...
 
static void applyGlobalTextureParams (const Handle< OpenGl_Context > &theCtx, const OpenGl_Texture &theTexture, const Handle< Graphic3d_TextureParams > &theParams)
 Apply global texture state for deprecated OpenGL functionality. More...
 
static void resetGlobalTextureParams (const Handle< OpenGl_Context > &theCtx, const OpenGl_Texture &theTexture, const Handle< Graphic3d_TextureParams > &theParams)
 Reset global texture state for deprecated OpenGL functionality. More...
 

Protected Attributes

Handle< Graphic3d_TextureParamsmyParams
 texture parameters More...
 
unsigned int mySamplerRevision
 modification counter of parameters related to sampler state More...
 
GLuint mySamplerID
 OpenGL sampler object ID. More...
 
bool myIsImmutable
 immutable flag preventing further modifications of sampler parameters, FALSE by default More...
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

Detailed Description

Class implements OpenGL sampler object resource that stores the sampling parameters for a texture access.

Constructor & Destructor Documentation

◆ OpenGl_Sampler()

OpenGl_Sampler::OpenGl_Sampler ( const Handle< Graphic3d_TextureParams > &  theParams)

Creates new sampler object.

◆ ~OpenGl_Sampler()

virtual OpenGl_Sampler::~OpenGl_Sampler ( )
virtual

Releases resources of sampler object.

Member Function Documentation

◆ applyGlobalTextureParams()

static void OpenGl_Sampler::applyGlobalTextureParams ( const Handle< OpenGl_Context > &  theCtx,
const OpenGl_Texture theTexture,
const Handle< Graphic3d_TextureParams > &  theParams 
)
staticprotected

Apply global texture state for deprecated OpenGL functionality.

◆ applySamplerParams()

static void OpenGl_Sampler::applySamplerParams ( const Handle< OpenGl_Context > &  theCtx,
const Handle< Graphic3d_TextureParams > &  theParams,
OpenGl_Sampler theSampler,
const GLenum  theTarget,
const bool  theHasMipMaps 
)
staticprotected

Apply sampler parameters. If Sampler Object is not NULL and valid resource, the parameters will be set to it (and it is not required Sampler Object being bound). Otherwise, parameters will be applied to currently bound Texture object.

◆ Bind() [1/2]

void OpenGl_Sampler::Bind ( const Handle< OpenGl_Context > &  theCtx)
inline

Binds sampler object to texture unit specified in parameters.

◆ Bind() [2/2]

void OpenGl_Sampler::Bind ( const Handle< OpenGl_Context > &  theCtx,
const Graphic3d_TextureUnit  theUnit 
)

Binds sampler object to the given texture unit.

◆ Create()

Standard_Boolean OpenGl_Sampler::Create ( const Handle< OpenGl_Context > &  theContext)

Creates an uninitialized sampler object.

◆ EstimatedDataSize()

virtual Standard_Size OpenGl_Sampler::EstimatedDataSize ( ) const
inlineoverridevirtual

Returns estimated GPU memory usage - not implemented.

Implements OpenGl_Resource.

◆ Init()

Standard_Boolean OpenGl_Sampler::Init ( const Handle< OpenGl_Context > &  theContext,
const OpenGl_Texture theTexture 
)

Creates and initializes sampler object. Existing object will be reused if possible, however if existing Sampler Object has Immutable flag and texture parameters should be re-initialized, then Sampler Object will be recreated.

◆ IsImmutable()

bool OpenGl_Sampler::IsImmutable ( ) const
inline

Return immutable flag preventing further modifications of sampler parameters, FALSE by default. Immutable flag might be set when Sampler Object is used within Bindless Texture.

◆ IsValid()

Standard_Boolean OpenGl_Sampler::IsValid ( ) const
inline

Returns true if current object was initialized.

◆ isValidSampler()

Standard_Boolean OpenGl_Sampler::isValidSampler ( ) const
inlineprotected

Checks if sampler object is valid.

◆ Parameters()

const Handle< Graphic3d_TextureParams >& OpenGl_Sampler::Parameters ( )
inline

Returns texture parameters.

◆ Release()

virtual void OpenGl_Sampler::Release ( OpenGl_Context theContext)
overridevirtual

Destroys object - will release GPU memory if any.

Implements OpenGl_Resource.

◆ resetGlobalTextureParams()

static void OpenGl_Sampler::resetGlobalTextureParams ( const Handle< OpenGl_Context > &  theCtx,
const OpenGl_Texture theTexture,
const Handle< Graphic3d_TextureParams > &  theParams 
)
staticprotected

Reset global texture state for deprecated OpenGL functionality.

◆ SamplerID()

GLuint OpenGl_Sampler::SamplerID ( ) const
inline

Returns OpenGL sampler ID.

◆ SetImmutable()

void OpenGl_Sampler::SetImmutable ( )
inline

Setup immutable flag. It is not possible unsetting this flag without Sampler destruction.

◆ SetParameter()

void OpenGl_Sampler::SetParameter ( const Handle< OpenGl_Context > &  theCtx,
GLenum  theTarget,
GLenum  theParam,
GLint  theValue 
)
inline

Sets specific sampler parameter.

◆ setParameter()

static void OpenGl_Sampler::setParameter ( const Handle< OpenGl_Context > &  theContext,
OpenGl_Sampler theSampler,
GLenum  theTarget,
GLenum  theParam,
GLint  theValue 
)
staticprotected

Sets specific sampler parameter.

◆ SetParameters()

void OpenGl_Sampler::SetParameters ( const Handle< Graphic3d_TextureParams > &  theParams)

Sets texture parameters.

◆ ToUpdateParameters()

bool OpenGl_Sampler::ToUpdateParameters ( ) const
inline

Returns texture parameters initialization state.

◆ Unbind() [1/2]

void OpenGl_Sampler::Unbind ( const Handle< OpenGl_Context > &  theCtx)
inline

Unbinds sampler object from texture unit specified in parameters.

◆ Unbind() [2/2]

void OpenGl_Sampler::Unbind ( const Handle< OpenGl_Context > &  theCtx,
const Graphic3d_TextureUnit  theUnit 
)

Unbinds sampler object from the given texture unit.

Field Documentation

◆ myIsImmutable

bool OpenGl_Sampler::myIsImmutable
protected

immutable flag preventing further modifications of sampler parameters, FALSE by default

◆ myParams

Handle< Graphic3d_TextureParams > OpenGl_Sampler::myParams
protected

texture parameters

◆ mySamplerID

GLuint OpenGl_Sampler::mySamplerID
protected

OpenGL sampler object ID.

◆ mySamplerRevision

unsigned int OpenGl_Sampler::mySamplerRevision
protected

modification counter of parameters related to sampler state

◆ NO_SAMPLER

const GLuint OpenGl_Sampler::NO_SAMPLER = 0
static

Helpful constant defining invalid sampler identifier.


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