Open CASCADE Technology  7.1.0.beta
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes

OpenGl_Texture Class Reference

Texture resource. More...

#include <OpenGl_Texture.hxx>

Inheritance diagram for OpenGl_Texture:
Inheritance graph
[legend]

Public Member Functions

 OpenGl_Texture (const Handle< Graphic3d_TextureParams > &theParams=NULL)
 Create uninitialized VBO. More...
 
virtual ~OpenGl_Texture ()
 Destroy object. More...
 
bool IsValid () const
 
GLenum GetTarget () const
 
GLsizei SizeX () const
 
GLsizei SizeY () const
 
GLuint TextureId () const
 
GLenum GetFormat () const
 
bool IsAlpha () const
 Return true for GL_RED and GL_ALPHA formats. More...
 
void SetAlpha (const bool theValue)
 Setup to interprete the format as Alpha by Shader Manager (should be GL_ALPHA within compatible context or GL_RED otherwise). More...
 
bool Create (const Handle< OpenGl_Context > &theCtx)
 Creates Texture id if not yet generated. Data should be initialized by another method. More...
 
virtual void Release (OpenGl_Context *theCtx) override
 Destroy object - will release GPU memory if any. More...
 
void Bind (const Handle< OpenGl_Context > &theCtx, const GLenum theTextureUnit=GL_TEXTURE0) const
 Bind this Texture to specified unit. More...
 
void Unbind (const Handle< OpenGl_Context > &theCtx, const GLenum theTextureUnit=GL_TEXTURE0) const
 Unbind texture from specified unit. More...
 
Standard_Size Revision () const
 Revision of associated data source. More...
 
void SetRevision (const Standard_Size theRevision)
 Set revision of associated data source. More...
 
bool Init (const Handle< OpenGl_Context > &theCtx, const Image_PixMap &theImage, const Graphic3d_TypeOfTexture theType)
 Notice that texture will be unbound after this call. More...
 
bool Init (const Handle< OpenGl_Context > &theCtx, const GLint theTextFormat, const GLenum thePixelFormat, const GLenum theDataType, const GLsizei theSizeX, const GLsizei theSizeY, const Graphic3d_TypeOfTexture theType, const Image_PixMap *theImage=NULL)
 Initialize the texture with specified format, size and texture type. If theImage is empty the texture data will contain trash. Notice that texture will be unbound after this call. More...
 
bool Init2DMultisample (const Handle< OpenGl_Context > &theCtx, const GLsizei theNbSamples, const GLint theTextFormat, const GLsizei theSizeX, const GLsizei theSizeY)
 Initialize the 2D multisampling texture using glTexImage2DMultisample(). More...
 
bool InitRectangle (const Handle< OpenGl_Context > &theCtx, const Standard_Integer theSizeX, const Standard_Integer theSizeY, const OpenGl_TextureFormat &theFormat)
 Allocates texture rectangle with specified format and size. More...
 
bool Init3D (const Handle< OpenGl_Context > &theCtx, const GLint theTextFormat, const GLenum thePixelFormat, const GLenum theDataType, const Standard_Integer theSizeX, const Standard_Integer theSizeY, const Standard_Integer theSizeZ, const void *thePixels)
 Initializes 3D texture rectangle with specified format and size. More...
 
Standard_Boolean HasMipmaps () const
 
const Handle< Graphic3d_TextureParams > & GetParams () const
 
void SetParams (const Handle< Graphic3d_TextureParams > &theParams)
 
- 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 Member Functions

static bool GetDataFormat (const Handle< OpenGl_Context > &theCtx, const Image_PixMap &theData, GLint &theTextFormat, GLenum &thePixelFormat, GLenum &theDataType)
 Return texture type and format by Image_PixMap data format. 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...
 

Static Public Attributes

static const GLuint NO_TEXTURE = 0
 Helpful constants. More...
 

Protected Attributes

Standard_Size myRevision
 revision of associated data source More...
 
GLuint myTextureId
 GL resource ID. More...
 
GLenum myTarget
 GL_TEXTURE_1D/GL_TEXTURE_2D/GL_TEXTURE_3D. More...
 
GLsizei mySizeX
 texture width More...
 
GLsizei mySizeY
 texture height More...
 
GLsizei mySizeZ
 texture depth More...
 
GLenum myTextFormat
 texture format - GL_RGB, GL_RGBA,... More...
 
Standard_Boolean myHasMipmaps
 flag indicates that texture was uploaded with mipmaps More...
 
bool myIsAlpha
 indicates alpha format More...
 
Handle< Graphic3d_TextureParamsmyParams
 texture parameters More...
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 

Detailed Description

Texture resource.

Constructor & Destructor Documentation

OpenGl_Texture::OpenGl_Texture ( const Handle< Graphic3d_TextureParams > &  theParams = NULL)

Create uninitialized VBO.

virtual OpenGl_Texture::~OpenGl_Texture ( )
virtual

Destroy object.

Member Function Documentation

void OpenGl_Texture::Bind ( const Handle< OpenGl_Context > &  theCtx,
const GLenum  theTextureUnit = GL_TEXTURE0 
) const

Bind this Texture to specified unit.

bool OpenGl_Texture::Create ( const Handle< OpenGl_Context > &  theCtx)

Creates Texture id if not yet generated. Data should be initialized by another method.

static bool OpenGl_Texture::GetDataFormat ( const Handle< OpenGl_Context > &  theCtx,
const Image_PixMap theData,
GLint &  theTextFormat,
GLenum &  thePixelFormat,
GLenum &  theDataType 
)
static

Return texture type and format by Image_PixMap data format.

GLenum OpenGl_Texture::GetFormat ( ) const
inline
Returns
texture format (not sized)
const Handle< Graphic3d_TextureParams >& OpenGl_Texture::GetParams ( ) const
Returns
assigned texture parameters (not necessary applied)
GLenum OpenGl_Texture::GetTarget ( ) const
inline
Returns
target to which the texture is bound (GL_TEXTURE_1D, GL_TEXTURE_2D)
Standard_Boolean OpenGl_Texture::HasMipmaps ( ) const
Returns
true if texture was generated within mipmaps
bool OpenGl_Texture::Init ( const Handle< OpenGl_Context > &  theCtx,
const Image_PixMap theImage,
const Graphic3d_TypeOfTexture  theType 
)

Notice that texture will be unbound after this call.

bool OpenGl_Texture::Init ( const Handle< OpenGl_Context > &  theCtx,
const GLint  theTextFormat,
const GLenum  thePixelFormat,
const GLenum  theDataType,
const GLsizei  theSizeX,
const GLsizei  theSizeY,
const Graphic3d_TypeOfTexture  theType,
const Image_PixMap theImage = NULL 
)

Initialize the texture with specified format, size and texture type. If theImage is empty the texture data will contain trash. Notice that texture will be unbound after this call.

bool OpenGl_Texture::Init2DMultisample ( const Handle< OpenGl_Context > &  theCtx,
const GLsizei  theNbSamples,
const GLint  theTextFormat,
const GLsizei  theSizeX,
const GLsizei  theSizeY 
)

Initialize the 2D multisampling texture using glTexImage2DMultisample().

bool OpenGl_Texture::Init3D ( const Handle< OpenGl_Context > &  theCtx,
const GLint  theTextFormat,
const GLenum  thePixelFormat,
const GLenum  theDataType,
const Standard_Integer  theSizeX,
const Standard_Integer  theSizeY,
const Standard_Integer  theSizeZ,
const void *  thePixels 
)

Initializes 3D texture rectangle with specified format and size.

bool OpenGl_Texture::InitRectangle ( const Handle< OpenGl_Context > &  theCtx,
const Standard_Integer  theSizeX,
const Standard_Integer  theSizeY,
const OpenGl_TextureFormat theFormat 
)

Allocates texture rectangle with specified format and size.

Note
Texture data is not initialized (will contain trash).
bool OpenGl_Texture::IsAlpha ( ) const
inline

Return true for GL_RED and GL_ALPHA formats.

bool OpenGl_Texture::IsValid ( ) const
inline
Returns
true if current object was initialized
virtual void OpenGl_Texture::Release ( OpenGl_Context theCtx)
overridevirtual

Destroy object - will release GPU memory if any.

Implements OpenGl_Resource.

Reimplemented in OpenGl_PointSprite.

Standard_Size OpenGl_Texture::Revision ( ) const
inline

Revision of associated data source.

void OpenGl_Texture::SetAlpha ( const bool  theValue)
inline

Setup to interprete the format as Alpha by Shader Manager (should be GL_ALPHA within compatible context or GL_RED otherwise).

void OpenGl_Texture::SetParams ( const Handle< Graphic3d_TextureParams > &  theParams)
Parameters
textureparameters
void OpenGl_Texture::SetRevision ( const Standard_Size  theRevision)
inline

Set revision of associated data source.

GLsizei OpenGl_Texture::SizeX ( ) const
inline
Returns
texture width (0 LOD)
GLsizei OpenGl_Texture::SizeY ( ) const
inline
Returns
texture height (0 LOD)
GLuint OpenGl_Texture::TextureId ( ) const
inline
Returns
texture ID
void OpenGl_Texture::Unbind ( const Handle< OpenGl_Context > &  theCtx,
const GLenum  theTextureUnit = GL_TEXTURE0 
) const

Unbind texture from specified unit.

Field Documentation

Standard_Boolean OpenGl_Texture::myHasMipmaps
protected

flag indicates that texture was uploaded with mipmaps

bool OpenGl_Texture::myIsAlpha
protected

indicates alpha format

Handle< Graphic3d_TextureParams > OpenGl_Texture::myParams
protected

texture parameters

Standard_Size OpenGl_Texture::myRevision
protected

revision of associated data source

GLsizei OpenGl_Texture::mySizeX
protected

texture width

GLsizei OpenGl_Texture::mySizeY
protected

texture height

GLsizei OpenGl_Texture::mySizeZ
protected

texture depth

GLenum OpenGl_Texture::myTarget
protected

GL_TEXTURE_1D/GL_TEXTURE_2D/GL_TEXTURE_3D.

GLenum OpenGl_Texture::myTextFormat
protected

texture format - GL_RGB, GL_RGBA,...

GLuint OpenGl_Texture::myTextureId
protected

GL resource ID.

const GLuint OpenGl_Texture::NO_TEXTURE = 0
static

Helpful constants.


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