Back to index

nux  3.0.0
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
nux::NTextureData Class Reference

#include <ImageSurface.h>

Inheritance diagram for nux::NTextureData:
Inheritance graph
[legend]
Collaboration diagram for nux::NTextureData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NTextureData (BitmapFormat f=BITFMT_R8G8B8A8, int width=16, int height=16, int NumMipmap=1)
virtual ~NTextureData ()
 NTextureData (const NTextureData &)
 Copy constructor.
NTextureDataoperator= (const NTextureData &)
 Assignment constructor.
virtual void Allocate (BitmapFormat f, int width, int height, int NumMipmap=1)
virtual void AllocateCheckBoardTexture (int width, int height, int NumMipmap, Color color0, Color color1, int TileWidth=4, int TileHeight=4)
virtual void AllocateColorTexture (int width, int height, int NumMipmap, Color color0=Color(0xFFFFFFF))
virtual const ImageSurfaceGetSurface (int MipLevel) const
virtual ImageSurfaceGetSurface (int MipLevel)
virtual const ImageSurfaceGetSurface (int face, int MipLevel) const
virtual ImageSurfaceGetSurface (int face, int MipLevel)
bool SetSurface (int MipLevel, const ImageSurface &object)
virtual bool IsTextureData () const
virtual int GetNumMipmap () const
virtual int GetWidth () const
virtual int GetHeight () const
virtual BitmapFormat GetFormat () const
virtual bool IsNull () const
virtual bool IsCubemapTextureData () const
virtual bool IsVolumeTextureData () const
virtual bool IsAnimatedTextureData () const
virtual int GetDepth () const
virtual int GetMemorySize () const

Protected Attributes

unsigned int m_TotalMemorySize

Private Member Functions

void ClearData ()

Private Attributes

int m_NumMipmap
std::vector< ImageSurface * > m_MipSurfaceArray

Detailed Description

Definition at line 223 of file ImageSurface.h.


Constructor & Destructor Documentation

nux::NTextureData::NTextureData ( BitmapFormat  f = BITFMT_R8G8B8A8,
int  width = 16,
int  height = 16,
int  NumMipmap = 1 
)

Definition at line 889 of file ImageSurface.cpp.

    :   m_NumMipmap(0)
  {
    Allocate(f, width, height, NumMipmap);
  }

Here is the call graph for this function:

Definition at line 895 of file ImageSurface.cpp.

  {
    ClearData();
  }

Here is the call graph for this function:

Copy constructor.

Definition at line 909 of file ImageSurface.cpp.

  {
    for (int i = 0; i < object.GetNumMipmap(); i++)
      m_MipSurfaceArray.push_back(new ImageSurface(object.GetSurface(i)));
  }

Here is the call graph for this function:


Member Function Documentation

void nux::NTextureData::Allocate ( BitmapFormat  f,
int  width,
int  height,
int  NumMipmap = 1 
) [virtual]

Definition at line 928 of file ImageSurface.cpp.

  {
    nuxAssertMsg(width >= 0, "[NTextureData::Allocate] Error: Negative texture width.");
    nuxAssertMsg(height >= 0, "[NTextureData::Allocate] Error: Negative texture height.");
    nuxAssert(NumMipmapRequested >= 0);

    int NumTotalMipLevel    = 1 + (int) Floor(Log2(Max(width, height)));
    m_NumMipmap = NumMipmapRequested;

    if (NumMipmapRequested == 0)
      m_NumMipmap = NumTotalMipLevel ? NumTotalMipLevel : 1;

    if (NumMipmapRequested > NumTotalMipLevel)
      m_NumMipmap = NumTotalMipLevel ? NumTotalMipLevel : 1;

    m_TotalMemorySize = 0;
    ClearData();

    for (int i = 0; i < m_NumMipmap; i++)
    {
      int w = width >> i;
      int h = height >> i;
      m_MipSurfaceArray.push_back(new ImageSurface(format, w, h));
      m_TotalMemorySize += m_MipSurfaceArray[i]->GetSize();
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::NTextureData::AllocateCheckBoardTexture ( int  width,
int  height,
int  NumMipmap,
Color  color0,
Color  color1,
int  TileWidth = 4,
int  TileHeight = 4 
) [virtual]

Definition at line 955 of file ImageSurface.cpp.

  {
    Allocate(BITFMT_R8G8B8A8, width, height, NumMipmap);

    for (int i = 0; i < m_NumMipmap; i++)
    {
      int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
      int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
      MakeCheckBoardImage(*m_MipSurfaceArray[i], w, h, color0, color1, TileWidth, TileHeight);
    }
  }

Here is the call graph for this function:

void nux::NTextureData::AllocateColorTexture ( int  width,
int  height,
int  NumMipmap,
Color  color0 = Color(0xFFFFFFF) 
) [virtual]

Definition at line 967 of file ImageSurface.cpp.

  {
    Allocate(BITFMT_R8G8B8A8, width, height, NumMipmap);

    for (int i = 0; i < m_NumMipmap; i++)
    {
      int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
      int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
      MakeCheckBoardImage(*m_MipSurfaceArray[i], w, h, color0, color0);
    }
  }

Here is the call graph for this function:

void nux::NTextureData::ClearData ( ) [private]

Definition at line 900 of file ImageSurface.cpp.

  {
    for (int i = 0; i < (int) m_MipSurfaceArray.size(); i++)
      delete m_MipSurfaceArray[i];

    m_MipSurfaceArray.clear();
  }

Here is the caller graph for this function:

virtual int nux::NBitmapData::GetDepth ( ) const [inline, virtual, inherited]

Reimplemented in nux::NAnimatedTextureData, and nux::NVolumeData.

Definition at line 204 of file ImageSurface.h.

    {
      return 0;
    }
virtual BitmapFormat nux::NTextureData::GetFormat ( ) const [inline, virtual]

Implements nux::NBitmapData.

Definition at line 272 of file ImageSurface.h.

    {
      return m_MipSurfaceArray[0]->GetFormat();
    }

Here is the caller graph for this function:

virtual int nux::NTextureData::GetHeight ( ) const [inline, virtual]

Implements nux::NBitmapData.

Definition at line 268 of file ImageSurface.h.

    {
      return m_MipSurfaceArray[0]->GetHeight();
    }

Here is the caller graph for this function:

virtual int nux::NBitmapData::GetMemorySize ( ) const [inline, virtual, inherited]

Definition at line 210 of file ImageSurface.h.

    {
      return m_TotalMemorySize;
    }
int nux::NTextureData::GetNumMipmap ( ) const [virtual]

Implements nux::NBitmapData.

Definition at line 979 of file ImageSurface.cpp.

  {
    return m_MipSurfaceArray.size();
  }

Here is the caller graph for this function:

virtual const ImageSurface& nux::NTextureData::GetSurface ( int  MipLevel) const [inline, virtual]

Implements nux::NBitmapData.

Definition at line 237 of file ImageSurface.h.

    {
      return *m_MipSurfaceArray[MipLevel];
    };

Here is the caller graph for this function:

virtual ImageSurface& nux::NTextureData::GetSurface ( int  MipLevel) [inline, virtual]

Implements nux::NBitmapData.

Definition at line 241 of file ImageSurface.h.

    {
      return const_cast<ImageSurface &> ((const_cast< const NTextureData * > (this))->GetSurface(MipLevel));
    }
virtual const ImageSurface& nux::NTextureData::GetSurface ( int  face,
int  MipLevel 
) const [inline, virtual]

Implements nux::NBitmapData.

Definition at line 245 of file ImageSurface.h.

    {
      //nuxAssertMsg(0, "[NTextureData::GetSurface] Use GetSurface(unsigned int MipLevel) for NTextureData.");
      return GetSurface(MipLevel);
    }

Here is the call graph for this function:

virtual ImageSurface& nux::NTextureData::GetSurface ( int  face,
int  MipLevel 
) [inline, virtual]

Implements nux::NBitmapData.

Definition at line 250 of file ImageSurface.h.

    {
      //nuxAssertMsg(0, "[NTextureData::GetSurface] Use GetSurface(unsigned int MipLevel) for NTextureData.");
      return GetSurface(MipLevel);
    }

Here is the call graph for this function:

virtual int nux::NTextureData::GetWidth ( ) const [inline, virtual]

Implements nux::NBitmapData.

Definition at line 264 of file ImageSurface.h.

    {
      return m_MipSurfaceArray[0]->GetWidth();
    }

Here is the caller graph for this function:

virtual bool nux::NBitmapData::IsAnimatedTextureData ( ) const [inline, virtual, inherited]

Reimplemented in nux::NAnimatedTextureData.

Definition at line 196 of file ImageSurface.h.

    {
      return false;
    }

Here is the caller graph for this function:

virtual bool nux::NBitmapData::IsCubemapTextureData ( ) const [inline, virtual, inherited]

Reimplemented in nux::NCubemapData.

Definition at line 188 of file ImageSurface.h.

    {
      return false;
    }

Here is the caller graph for this function:

virtual bool nux::NTextureData::IsNull ( ) const [inline, virtual]

Implements nux::NBitmapData.

Definition at line 276 of file ImageSurface.h.

    {
      return m_MipSurfaceArray[0]->IsNull();
    }

Here is the caller graph for this function:

virtual bool nux::NTextureData::IsTextureData ( ) const [inline, virtual]

Reimplemented from nux::NBitmapData.

Definition at line 258 of file ImageSurface.h.

    {
      return true;
    }
virtual bool nux::NBitmapData::IsVolumeTextureData ( ) const [inline, virtual, inherited]

Reimplemented in nux::NVolumeData.

Definition at line 192 of file ImageSurface.h.

    {
      return false;
    }

Here is the caller graph for this function:

NTextureData & nux::NTextureData::operator= ( const NTextureData copy)

Assignment constructor.

Definition at line 916 of file ImageSurface.cpp.

  {
    ClearData();
    m_NumMipmap = copy.m_NumMipmap;
    m_TotalMemorySize = copy.m_TotalMemorySize;

    for (int i = 0; i < copy.GetNumMipmap(); i++)
      m_MipSurfaceArray.push_back(new ImageSurface(copy.GetSurface(i)));

    return *this;
  }

Here is the call graph for this function:

bool nux::NTextureData::SetSurface ( int  MipLevel,
const ImageSurface object 
)

Definition at line 984 of file ImageSurface.cpp.

  {
    nuxAssert(MipLevel >= 0);
    nuxAssert(MipLevel < m_NumMipmap);

    ImageSurface &surface = GetSurface(MipLevel);

    if (surface.GetFormat() != targetsurface.GetFormat())
      return false;

    if (surface.GetWidth() != targetsurface.GetWidth())
      return false;

    if (surface.GetHeight() != targetsurface.GetHeight())
      return false;

    surface = targetsurface;
    return true;
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 283 of file ImageSurface.h.

Definition at line 282 of file ImageSurface.h.

unsigned int nux::NBitmapData::m_TotalMemorySize [protected, inherited]

Definition at line 216 of file ImageSurface.h.


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