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>
20 #include <Handle_OpenGl_Sampler.hxx>
22 //! Class implements OpenGL sampler object resource that
23 //! stores the sampling parameters for a texture access.
24 class OpenGl_Sampler : public OpenGl_Resource
28 //! Helpful constant defining invalid sampler identifier
29 static const GLuint NO_SAMPLER = 0;
33 //! Creates new sampler object.
34 Standard_EXPORT OpenGl_Sampler();
36 //! Releases resources of sampler object.
37 Standard_EXPORT virtual ~OpenGl_Sampler();
39 //! Destroys object - will release GPU memory if any.
40 Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
42 //! Initializes sampler object.
43 Standard_EXPORT Standard_Boolean Init (OpenGl_Context& theContext);
45 //! Returns true if current object was initialized.
46 Standard_Boolean IsValid() const
48 return isValidSampler();
51 //! Binds sampler object to the given texture unit.
52 Standard_EXPORT void Bind (OpenGl_Context& theContext, const GLuint theUnit = 0);
54 //! Unbinds sampler object from the given texture unit.
55 Standard_EXPORT void Unbind (OpenGl_Context& theContext, const GLuint theUnit = 0);
57 //! Sets specific sampler parameter.
58 Standard_EXPORT void SetParameter (OpenGl_Context& theContext, const GLenum theParam, const GLint theValue);
60 //! Returns OpenGL sampler ID.
61 GLuint SamplerID() const
68 //! Checks if sampler object is valid.
69 Standard_Boolean isValidSampler() const
71 return mySamplerID != NO_SAMPLER;
76 GLuint mySamplerID; //!< OpenGL sampler object ID
80 DEFINE_STANDARD_RTTI(OpenGl_Sampler, OpenGl_Resource)
84 #endif // OPENGL_SAMPLER_H