File indexing completed on 2026-09-11 09:18:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _OpenGl_Sampler_Header
0017 #define _OpenGl_Sampler_Header
0018
0019 #include <Graphic3d_TextureParams.hxx>
0020 #include <OpenGl_Resource.hxx>
0021
0022 class OpenGl_Texture;
0023
0024
0025
0026 class OpenGl_Sampler : public OpenGl_Resource
0027 {
0028 friend class OpenGl_Context;
0029 friend class OpenGl_Texture;
0030 friend class OpenGl_Text;
0031 DEFINE_STANDARD_RTTIEXT(OpenGl_Sampler, OpenGl_Resource)
0032 public:
0033
0034 static const unsigned int NO_SAMPLER = 0;
0035
0036 public:
0037
0038 Standard_EXPORT OpenGl_Sampler(const occ::handle<Graphic3d_TextureParams>& theParams);
0039
0040
0041 Standard_EXPORT ~OpenGl_Sampler() override;
0042
0043
0044 Standard_EXPORT void Release(OpenGl_Context* theContext) override;
0045
0046
0047 size_t EstimatedDataSize() const override { return 0; }
0048
0049
0050 Standard_EXPORT bool Create(const occ::handle<OpenGl_Context>& theContext);
0051
0052
0053
0054
0055 Standard_EXPORT bool Init(const occ::handle<OpenGl_Context>& theContext,
0056 const OpenGl_Texture& theTexture);
0057
0058
0059 bool IsValid() const { return isValidSampler(); }
0060
0061
0062 void Bind(const occ::handle<OpenGl_Context>& theCtx) { Bind(theCtx, myParams->TextureUnit()); }
0063
0064
0065 void Unbind(const occ::handle<OpenGl_Context>& theCtx)
0066 {
0067 Unbind(theCtx, myParams->TextureUnit());
0068 }
0069
0070
0071 Standard_EXPORT void Bind(const occ::handle<OpenGl_Context>& theCtx,
0072 const Graphic3d_TextureUnit theUnit);
0073
0074
0075 Standard_EXPORT void Unbind(const occ::handle<OpenGl_Context>& theCtx,
0076 const Graphic3d_TextureUnit theUnit);
0077
0078
0079 void SetParameter(const occ::handle<OpenGl_Context>& theCtx,
0080 unsigned int theTarget,
0081 unsigned int theParam,
0082 int theValue)
0083 {
0084 setParameter(theCtx, this, theTarget, theParam, theValue);
0085 }
0086
0087
0088 unsigned int SamplerID() const { return mySamplerID; }
0089
0090
0091
0092 bool IsImmutable() const { return myIsImmutable; }
0093
0094
0095 void SetImmutable() { myIsImmutable = true; }
0096
0097
0098 const occ::handle<Graphic3d_TextureParams>& Parameters() { return myParams; }
0099
0100
0101 Standard_EXPORT void SetParameters(const occ::handle<Graphic3d_TextureParams>& theParams);
0102
0103
0104 bool ToUpdateParameters() const { return mySamplerRevision != myParams->SamplerRevision(); }
0105
0106 protected:
0107
0108 bool isValidSampler() const { return mySamplerID != NO_SAMPLER; }
0109
0110
0111 Standard_EXPORT static void setParameter(const occ::handle<OpenGl_Context>& theContext,
0112 OpenGl_Sampler* theSampler,
0113 unsigned int theTarget,
0114 unsigned int theParam,
0115 int theValue);
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125 Standard_EXPORT static void applySamplerParams(
0126 const occ::handle<OpenGl_Context>& theCtx,
0127 const occ::handle<Graphic3d_TextureParams>& theParams,
0128 OpenGl_Sampler* theSampler,
0129 const unsigned int theTarget,
0130 const int theMaxMipLevel);
0131
0132
0133 Standard_EXPORT static void applyGlobalTextureParams(
0134 const occ::handle<OpenGl_Context>& theCtx,
0135 const OpenGl_Texture& theTexture,
0136 const occ::handle<Graphic3d_TextureParams>& theParams);
0137
0138
0139 Standard_EXPORT static void resetGlobalTextureParams(
0140 const occ::handle<OpenGl_Context>& theCtx,
0141 const OpenGl_Texture& theTexture,
0142 const occ::handle<Graphic3d_TextureParams>& theParams);
0143
0144 protected:
0145 occ::handle<Graphic3d_TextureParams> myParams;
0146
0147 unsigned int mySamplerRevision;
0148 unsigned int mySamplerID;
0149 bool myIsImmutable;
0150
0151 };
0152
0153 #endif