1 // Created on: 2014-10-08
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef OPENGL_SAMPLER_H
17 #define OPENGL_SAMPLER_H
19 #include <OpenGl_Context.hxx>
22 DEFINE_STANDARD_HANDLE(OpenGl_Sampler, OpenGl_Resource)
24 //! Class implements OpenGL sampler object resource that
25 //! stores the sampling parameters for a texture access.
26 class OpenGl_Sampler : public OpenGl_Resource
30 //! Helpful constant defining invalid sampler identifier
31 static const GLuint NO_SAMPLER = 0;
35 //! Creates new sampler object.
36 Standard_EXPORT OpenGl_Sampler();
38 //! Releases resources of sampler object.
39 Standard_EXPORT virtual ~OpenGl_Sampler();
41 //! Destroys object - will release GPU memory if any.
42 Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
44 //! Initializes sampler object.
45 Standard_EXPORT Standard_Boolean Init (OpenGl_Context& theContext);
47 //! Returns true if current object was initialized.
48 Standard_Boolean IsValid() const
50 return isValidSampler();
53 //! Binds sampler object to the given texture unit.
54 Standard_EXPORT void Bind (OpenGl_Context& theContext, const GLuint theUnit = 0);
56 //! Unbinds sampler object from the given texture unit.
57 Standard_EXPORT void Unbind (OpenGl_Context& theContext, const GLuint theUnit = 0);
59 //! Sets specific sampler parameter.
60 Standard_EXPORT void SetParameter (OpenGl_Context& theContext, const GLenum theParam, const GLint theValue);
62 //! Returns OpenGL sampler ID.
63 GLuint SamplerID() const
70 //! Checks if sampler object is valid.
71 Standard_Boolean isValidSampler() const
73 return mySamplerID != NO_SAMPLER;
78 GLuint mySamplerID; //!< OpenGL sampler object ID
82 DEFINE_STANDARD_RTTI(OpenGl_Sampler, OpenGl_Resource)
86 #endif // OPENGL_SAMPLER_H