OCCT3D OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    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:

    Public Member Functions

     OpenGl_Sampler (const occ::handle< Graphic3d_TextureParams > &theParams)
     Creates new sampler object.
     ~OpenGl_Sampler () override
     Releases resources of sampler object.
    void Release (OpenGl_Context *theContext) override
     Destroys object - will release GPU memory if any.
    size_t EstimatedDataSize () const override
     Returns estimated GPU memory usage - not implemented.
    bool Create (const occ::handle< OpenGl_Context > &theContext)
     Creates an uninitialized sampler object.
    bool Init (const occ::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.
    bool IsValid () const
     Returns true if current object was initialized.
    void Bind (const occ::handle< OpenGl_Context > &theCtx)
     Binds sampler object to texture unit specified in parameters.
    void Unbind (const occ::handle< OpenGl_Context > &theCtx)
     Unbinds sampler object from texture unit specified in parameters.
    void Bind (const occ::handle< OpenGl_Context > &theCtx, const Graphic3d_TextureUnit theUnit)
     Binds sampler object to the given texture unit.
    void Unbind (const occ::handle< OpenGl_Context > &theCtx, const Graphic3d_TextureUnit theUnit)
     Unbinds sampler object from the given texture unit.
    void SetParameter (const occ::handle< OpenGl_Context > &theCtx, unsigned int theTarget, unsigned int theParam, int theValue)
     Sets specific sampler parameter.
    unsigned int SamplerID () const
     Returns OpenGL sampler ID.
    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.
    void SetImmutable ()
     Setup immutable flag. It is not possible unsetting this flag without Sampler destruction.
    const occ::handle< Graphic3d_TextureParams > & Parameters ()
     Returns texture parameters.
    void SetParameters (const occ::handle< Graphic3d_TextureParams > &theParams)
     Sets texture parameters.
    bool ToUpdateParameters () const
     Returns texture parameters initialization state.
    Public Member Functions inherited from OpenGl_Resource
     OpenGl_Resource ()
     Empty constructor.
     ~OpenGl_Resource () override
     Destructor. Inheritors should call Clean (NULL) within it.
    virtual void DumpJson (Standard_OStream &theOStream, int theDepth=-1) const
     Dumps the content of me into the stream.
    Public Member Functions inherited from Standard_Transient
     Standard_Transient ()
     Empty constructor.
     Standard_Transient (const Standard_Transient &)
     Copy constructor – does nothing.
    Standard_Transientoperator= (const Standard_Transient &)
     Assignment operator, needed to avoid copying reference counter.
    virtual ~Standard_Transient ()=default
     Destructor must be virtual.
    virtual const opencascade::handle< Standard_Type > & DynamicType () const
     Returns a type descriptor about this object.
    bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
     Returns a true value if this is an instance of Type.
    bool IsInstance (const char *const theTypeName) const
     Returns a true value if this is an instance of TypeName.
    bool 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.
    bool IsKind (const char *const 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.
    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.
    int GetRefCount () const noexcept
     Get the reference counter of this object.
    void IncrementRefCounter () noexcept
     Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
    int DecrementRefCounter () noexcept
     Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
    virtual void Delete () const
     Memory deallocator for transient classes.

    Static Public Attributes

    static const unsigned int NO_SAMPLER = 0
     Helpful constant defining invalid sampler identifier.

    Protected Member Functions

    bool isValidSampler () const
     Checks if sampler object is valid.

    Static Protected Member Functions

    static void setParameter (const occ::handle< OpenGl_Context > &theContext, OpenGl_Sampler *theSampler, unsigned int theTarget, unsigned int theParam, int theValue)
     Sets specific sampler parameter.
    static void applySamplerParams (const occ::handle< OpenGl_Context > &theCtx, const occ::handle< Graphic3d_TextureParams > &theParams, OpenGl_Sampler *theSampler, const unsigned int theTarget, const int theMaxMipLevel)
     Apply sampler parameters.
    static void applyGlobalTextureParams (const occ::handle< OpenGl_Context > &theCtx, const OpenGl_Texture &theTexture, const occ::handle< Graphic3d_TextureParams > &theParams)
     Apply global texture state for deprecated OpenGL functionality.
    static void resetGlobalTextureParams (const occ::handle< OpenGl_Context > &theCtx, const OpenGl_Texture &theTexture, const occ::handle< Graphic3d_TextureParams > &theParams)
     Reset global texture state for deprecated OpenGL functionality.

    Protected Attributes

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

    Additional Inherited Members

    typedef void base_type
     Returns a type descriptor about this object.
    static constexpr const char * get_type_name ()
     Returns a type descriptor about this object.
    static const opencascade::handle< Standard_Type > & get_type_descriptor ()
     Returns type descriptor of Standard_Transient class.

    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 occ::handle< Graphic3d_TextureParams > & theParams)

    Creates new sampler object.

    ◆ ~OpenGl_Sampler()

    OpenGl_Sampler::~OpenGl_Sampler ( )
    override

    Releases resources of sampler object.

    Member Function Documentation

    ◆ applyGlobalTextureParams()

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

    Apply global texture state for deprecated OpenGL functionality.

    ◆ applySamplerParams()

    void OpenGl_Sampler::applySamplerParams ( const occ::handle< OpenGl_Context > & theCtx,
    const occ::handle< Graphic3d_TextureParams > & theParams,
    OpenGl_Sampler * theSampler,
    const unsigned int theTarget,
    const int theMaxMipLevel )
    staticprotected

    Apply sampler parameters.

    Parameters
    [in]theCtxactive OpenGL context
    [in]theParamstexture parameters to apply
    [in]theSamplerapply parameters to Texture object (NULL) or to specified Sampler object (non-NULL, sampler is not required to be bound)
    [in]theTargetOpenGL texture target
    [in]theMaxMipLevelmaximum mipmap level defined within the texture

    ◆ Bind() [1/2]

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

    Binds sampler object to texture unit specified in parameters.

    ◆ Bind() [2/2]

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

    Binds sampler object to the given texture unit.

    ◆ Create()

    bool OpenGl_Sampler::Create ( const occ::handle< OpenGl_Context > & theContext)

    Creates an uninitialized sampler object.

    ◆ EstimatedDataSize()

    size_t OpenGl_Sampler::EstimatedDataSize ( ) const
    inlineoverridevirtual

    Returns estimated GPU memory usage - not implemented.

    Implements OpenGl_Resource.

    ◆ Init()

    bool OpenGl_Sampler::Init ( const occ::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()

    bool OpenGl_Sampler::IsValid ( ) const
    inline

    Returns true if current object was initialized.

    ◆ isValidSampler()

    bool OpenGl_Sampler::isValidSampler ( ) const
    inlineprotected

    Checks if sampler object is valid.

    ◆ Parameters()

    const occ::handle< Graphic3d_TextureParams > & OpenGl_Sampler::Parameters ( )
    inline

    Returns texture parameters.

    ◆ Release()

    void OpenGl_Sampler::Release ( OpenGl_Context * theContext)
    overridevirtual

    Destroys object - will release GPU memory if any.

    Implements OpenGl_Resource.

    ◆ resetGlobalTextureParams()

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

    Reset global texture state for deprecated OpenGL functionality.

    ◆ SamplerID()

    unsigned int 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 occ::handle< OpenGl_Context > & theCtx,
    unsigned int theTarget,
    unsigned int theParam,
    int theValue )
    inline

    Sets specific sampler parameter.

    ◆ setParameter()

    void OpenGl_Sampler::setParameter ( const occ::handle< OpenGl_Context > & theContext,
    OpenGl_Sampler * theSampler,
    unsigned int theTarget,
    unsigned int theParam,
    int theValue )
    staticprotected

    Sets specific sampler parameter.

    ◆ SetParameters()

    void OpenGl_Sampler::SetParameters ( const occ::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 occ::handle< OpenGl_Context > & theCtx)
    inline

    Unbinds sampler object from texture unit specified in parameters.

    ◆ Unbind() [2/2]

    void OpenGl_Sampler::Unbind ( const occ::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

    occ::handle<Graphic3d_TextureParams> OpenGl_Sampler::myParams
    protected

    texture parameters

    ◆ mySamplerID

    unsigned int 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 unsigned int OpenGl_Sampler::NO_SAMPLER = 0
    static

    Helpful constant defining invalid sampler identifier.


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