nux-1.14.0
nux::Texture2D Class Reference

General Texture. More...

#include <NuxGraphics/GLTextureResourceManager.h>

Inheritance diagram for nux::Texture2D:
nux::BaseTexture nux::ResourceData nux::Object nux::Trackable nux::Introspectable

List of all members.

Public Member Functions

 Texture2D (NUX_FILE_LINE_PROTO)
 Texture2D (const Texture2D &texture, NUX_FILE_LINE_PROTO)
 Texture2D (const NTextureData &BaseTexture, NUX_FILE_LINE_PROTO)
Texture2Doperator= (const Texture2D &texture)
virtual bool Update (const NBitmapData *BitmapData, bool UpdateAndCacheResource=true)
virtual bool Update (const TCHAR *Filename, bool UpdateAndCacheResource=true)
virtual bool IsNull () const
void GetData (void *Buffer, int MipIndex, int StrideY, int face=0)
int GetNumMipLevel () const
int GetWidth () const
int GetHeight () const
BitmapFormat GetFormat () const
bool IsPowerOfTwo () const
virtual BaseTextureClone () const

Detailed Description

General Texture.

The class of texture that cover power-of-two and non-power-of-two dimensions.

Definition at line 171 of file GLTextureResourceManager.h.


Member Function Documentation

BaseTexture * nux::Texture2D::Clone ( ) const [virtual]

Clone the texture.

Returns:
A cloned version of this texture.

Implements nux::BaseTexture.

Definition at line 349 of file GLTextureResourceManager.cpp.

  {
    Texture2D* texture = new Texture2D(*this);
    return texture;
  }
BitmapFormat nux::Texture2D::GetFormat ( ) const [inline, virtual]
Returns:
The texture data format.

Implements nux::BaseTexture.

Definition at line 238 of file GLTextureResourceManager.h.

    {
      return _image.GetFormat ();
    }
int nux::Texture2D::GetHeight ( ) const [inline, virtual]
Returns:
The texture height.

Implements nux::BaseTexture.

Definition at line 230 of file GLTextureResourceManager.h.

    {
      return _image.GetHeight ();
    }
int nux::Texture2D::GetNumMipLevel ( ) const [inline, virtual]
Returns:
The number of mip maps in the texture.

Implements nux::BaseTexture.

Definition at line 215 of file GLTextureResourceManager.h.

    {
      return _image.GetNumMipmap ();
    }
int nux::Texture2D::GetWidth ( ) const [inline, virtual]
Returns:
The texture width.

Implements nux::BaseTexture.

Definition at line 222 of file GLTextureResourceManager.h.

    {
      return _image.GetWidth ();
    }
virtual bool nux::Texture2D::IsNull ( ) const [inline, virtual]
Returns:
True if the texture storage contains valid bitmap data.

Implements nux::BaseTexture.

Definition at line 205 of file GLTextureResourceManager.h.

    {
      return _image.IsNull();
    }
bool nux::Texture2D::IsPowerOfTwo ( ) const [inline, virtual]
Returns:
True if the width and height of the texture are powers of two.

Implements nux::BaseTexture.

Definition at line 246 of file GLTextureResourceManager.h.

    {
      return IsPowerOf2 (_image.GetWidth () ) && IsPowerOf2 (_image.GetHeight () );
    }
bool nux::Texture2D::Update ( const NBitmapData BitmapData,
bool  UpdateAndCacheResource = true 
) [virtual]

Update the hardware resources associated to this with the provided texture data.

Parameters:
BitmapDataThe texture data to update into the hardware resource.
UpdateAndCacheResourceif True, then the texture data is loaded into this object, and the caching into hardware data is done right away. If false, the caching is done latter by calling GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource(this);
Returns:
True is there was not error.

Implements nux::BaseTexture.

Definition at line 302 of file GLTextureResourceManager.cpp.

References nux::GraphicsEngine::UpdateResource().

  {
    nuxAssertMsg (BitmapData, TEXT ("[Texture2D::Update] Argument BitmapData is NULL."));
    NUX_RETURN_VALUE_IF_NULL (BitmapData, false);

    if (!BitmapData->IsTextureData())
    {
      nuxAssertMsg (0, TEXT ("[Texture2D::Update] Argument BitmapData is not a 2D texture"));
      return false;
    }

    _image = *static_cast<const NTextureData *> (BitmapData);

    if (UpdateAndCacheResource)
    {
      // call the texture manager and recreate the texture (CachedTexture2D) associated with this object if any.
      GetGraphicsDisplay()->GetGraphicsEngine()->UpdateResource (this);
    }

    return true;
  }
bool nux::Texture2D::Update ( const TCHAR *  Filename,
bool  UpdateAndCacheResource = true 
) [virtual]

Update the hardware resources associated to this object with the data associated to the file name.

Parameters:
FilenameFile name of texture data to update into the hardware resource.
UpdateAndCacheResourceif True, then the texture data is loaded into this object, and the caching into hardware data is done right away. If false, the caching is done latter by calling GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource(this);
Returns:
True is there was not error.

Implements nux::BaseTexture.

Definition at line 324 of file GLTextureResourceManager.cpp.

References nux::LoadImageFile().

  {
    NBitmapData *BitmapData = LoadImageFile (filename);
    nuxAssertMsg (BitmapData, TEXT ("[Texture2D::Update] Bitmap for file (%s) is NULL."), filename);
    NUX_RETURN_VALUE_IF_NULL (BitmapData, false);
    bool ret = Update (BitmapData, UpdateAndCacheResource);
    NUX_SAFE_DELETE (BitmapData);
    return ret;
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends