Back to index

nux  3.0.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
nux::IOpenGLVolumeTexture Class Reference

#include <IOpenGLVolumeTexture.h>

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

List of all members.

Public Member Functions

virtual ~IOpenGLVolumeTexture ()
int GetVolumeLevel (int Level, IOpenGLVolume **ppVolumeLevel)
int LockRect (int Slice, int Level, SURFACE_LOCKED_RECT *pLockedRect, const SURFACE_RECT *pRect)
int UnlockRect (int Slice, int Level)
int LockBox (int Level, VOLUME_LOCKED_BOX *pLockedVolume, const VOLUME_BOX *pBox)
int UnlockBox (int Level)
int GetLevelDepth (int MipLevel) const
int GetLevelDesc (int Level, VOLUME_DESC *pDesc)
 NUX_DECLARE_OBJECT_TYPE (BaseObject, Trackable)
BitmapFormat GetPixelFormat () const
int GetNumMipLevel () const
bool IsPowerOfTwo () const
int GetWidth () const
int GetHeight () const
int GetDepth () const
int GetFormatRowMemoryAlignment () const
void SetRenderStates ()
void SetFiltering (unsigned int MIN=GL_NEAREST, unsigned int MAG=GL_NEAREST)
void SetWrap (unsigned int U=GL_REPEAT, unsigned int V=GL_REPEAT, unsigned int W=GL_REPEAT)
void SetLOD (float MinLod=-1000.0f, float MaxLod=+1000.0f)
void SetMipLevel (unsigned int MinMip=0, unsigned int MaxMip=1000)
void SetBorderColor (float R, float G, float B, float A)
int BindTexture ()
int BindTextureToUnit (int TextureUnitIndex)
virtual void GetSurfaceLevel (int Level, ObjectPtr< IOpenGLSurface > &surface)
virtual ObjectPtr< IOpenGLSurfaceGetSurfaceLevel (int Level)
virtual int LockRect (int Level, SURFACE_LOCKED_RECT *pLockedRect, const SURFACE_RECT *pRect)
virtual int UnlockRect (int Level)
virtual unsigned char * GetSurfaceData (int level, int &width, int &height, int &stride)
 Return a pointer to a mipmap level data.
virtual int RefCount () const
OpenGLResourceType GetResourceType () const
int GetOpenGLID () const
bool Reference ()
 Increase reference count.
bool UnReference ()
 Decrease reference count.
virtual bool SinkReference ()
 Mark the object as owned.
virtual bool Dispose ()
 Destroy and object that has a floating reference.
int GetReferenceCount () const
 Get the reference count of this object.
std::string GetAllocationLoation () const
 NUX_DECLARE_ROOT_OBJECT_TYPE (Trackable)
bool OwnsTheReference ()
 Test if object reference is owned.
bool IsHeapAllocated ()
 Test if object was allocated dynamically.
bool IsDynamic () const
 Test if object was allocated dynamically.
virtual int GetObjectSize ()
 Return the size of allocated for this object.
bool SetProperty (std::string const &name, const char *value)
 If the property was not able to be set with the value, the method returns false.
template<typename T >
bool SetProperty (std::string const &name, T const &value)
template<typename T >
GetProperty (std::string const &name, T *foo=0)
void AddProperty (std::string const &name, PropertyBase *property)

Static Public Member Functions

static std::new_handler set_new_handler (std::new_handler handler)
static void * operator new (size_t size)
static void * operator new (size_t size, void *ptr)
static void operator delete (void *ptr)

Public Attributes

sigc::signal< void, Object * > object_destroyed
 Signal emitted immediately before the object is destroyed.

Protected Member Functions

void SetOwnedReference (bool b)

Protected Attributes

GLTextureStates _TextureStates
bool _IsPOT
int _NumMipLevel
BitmapFormat _PixelFormat
int _Width
int _Height
int _Depth
int _RowMemoryAlignment
int _heap_allocated

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (IOpenGLVolumeTexture, IOpenGLBaseTexture)
 IOpenGLVolumeTexture (int Width, int Height, int Depth, int Levels, BitmapFormat PixelFormat)

Private Attributes

std::vector< ObjectPtr
< IOpenGLSurface > > * 
_VolumeSurfaceArray
std::vector< ObjectPtr
< IOpenGLVolume > > 
_VolumeArray

Friends

class GpuDevice
class IOpenGLSurface
class IOpenGLVolume
void GetTextureDesc (IOpenGLBaseTexture *pTexture, unsigned int Level, TEXTURE_DESC *pDesc)
int GetTextureSize (IOpenGLBaseTexture *pTexture)

Detailed Description

Definition at line 30 of file IOpenGLVolumeTexture.h.


Constructor & Destructor Documentation

Definition at line 72 of file IOpenGLVolumeTexture.cpp.

  {

    for (int mip = 0; mip < _NumMipLevel; mip++)
    {
      for (int slice = 0; slice < ImageSurface::GetLevelDim(_PixelFormat, _Depth, mip); slice++)
      {
        // destroying a surface
        _VolumeSurfaceArray[mip][slice] = ObjectPtr<IOpenGLSurface> (0);
      }

      _VolumeSurfaceArray[mip].clear();
    }

    NUX_SAFE_DELETE_ARRAY(_VolumeSurfaceArray);


    for (int mip = 0; mip < _NumMipLevel; mip++)
    {
      // destroying a IOpenGLVolume
      _VolumeArray[mip] = ObjectPtr<IOpenGLVolume> (0);
    }

    CHECKGL(glDeleteTextures(1, &_OpenGLID));
    _OpenGLID = 0;
    GRunTimeStats.UnRegister(this);
  }

Here is the call graph for this function:

nux::IOpenGLVolumeTexture::IOpenGLVolumeTexture ( int  Width,
int  Height,
int  Depth,
int  Levels,
BitmapFormat  PixelFormat 
) [private]

Definition at line 31 of file IOpenGLVolumeTexture.cpp.

    : IOpenGLBaseTexture(RTVOLUMETEXTURE, Width, Height, Depth, Levels, PixelFormat)
  {
#ifndef NUX_OPENGLES_20
    CHECKGL(glGenTextures(1, &_OpenGLID));
    CHECKGL(glBindTexture(GL_TEXTURE_3D, _OpenGLID));

    _VolumeSurfaceArray = new std::vector< ObjectPtr<IOpenGLSurface> >[_NumMipLevel];

    for (int mip = 0; mip < _NumMipLevel; mip++)
    {
      for (int slice = 0; slice < ImageSurface::GetLevelDim(_PixelFormat, _Depth, mip); slice++)
      {
        //IOpenGLSurface* surface = new IOpenGLSurface(this, _OpenGLID, GL_TEXTURE_3D, GL_TEXTURE_3D, mip, slice);
        //surface->InitializeLevel();
        IOpenGLSurface* surface = new IOpenGLSurface(this, _OpenGLID, GL_TEXTURE_3D, GL_TEXTURE_3D, mip, slice);
        _VolumeSurfaceArray[mip].push_back(ObjectPtr<IOpenGLSurface> (surface));
        surface->UnReference();
      }
    }

    for (int mip = 0; mip < _NumMipLevel; mip++)
    {
      IOpenGLVolume *volume = new IOpenGLVolume(this, _OpenGLID, GL_TEXTURE_3D, GL_TEXTURE_3D, mip);
      volume->InitializeLevel();
      _VolumeArray.push_back(ObjectPtr<IOpenGLVolume> (volume));
    }

    CHECKGL(glBindTexture(GL_TEXTURE_3D, _OpenGLID));
    SetFiltering(GL_NEAREST, GL_NEAREST);
    SetWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
    SetRenderStates();
    GRunTimeStats.Register(this);
#endif
  }

Here is the call graph for this function:


Member Function Documentation

void nux::Introspectable::AddProperty ( std::string const &  name,
PropertyBase property 
) [inline, inherited]

Definition at line 254 of file Property-inl.h.

{
  // check to see if it exists and if it does barf horribly as we can't
  // have two properties with the same name;
  properties_[name] = property;
}

Here is the caller graph for this function:

Definition at line 146 of file IOpenGLBaseTexture.cpp.

  {
    if (_OpenGLID == 0)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_2D, 0));
    }
    else if (_ResourceType == RTTEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_2D, _OpenGLID));
    }
#ifndef NUX_OPENGLES_20
    else if (_ResourceType == RTTEXTURERECTANGLE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _OpenGLID));
    }
    else if (_ResourceType == RTCUBETEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_CUBE_MAP, _OpenGLID));
    }
    else if (_ResourceType == RTVOLUMETEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_3D, _OpenGLID));
    }
    else if (_ResourceType == RTANIMATEDTEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _OpenGLID));
    }
#endif
    else
    {
      nuxError("[GpuDevice::BindTexture] Unknown texture type.");
      return OGL_INVALID_TEXTURE;
    }

    _TextureStates.SetRenderStates();
    return OGL_OK;
  }

Here is the call graph for this function:

int nux::IOpenGLBaseTexture::BindTextureToUnit ( int  TextureUnitIndex) [inherited]

Definition at line 184 of file IOpenGLBaseTexture.cpp.

  {
    CHECKGL(glActiveTextureARB(TextureUnitIndex));
    CHECKGL(glBindTexture(GL_TEXTURE_2D, 0));
#ifndef NUX_OPENGLES_20
    CHECKGL(glBindTexture(GL_TEXTURE_3D, 0));
    CHECKGL(glBindTexture(GL_TEXTURE_CUBE_MAP, 0));
    CHECKGL(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
    CHECKGL(glDisable(GL_TEXTURE_2D));
    CHECKGL(glDisable(GL_TEXTURE_3D));
    CHECKGL(glDisable(GL_TEXTURE_RECTANGLE_ARB));
    CHECKGL(glDisable(GL_TEXTURE_CUBE_MAP));
#endif

    if (_ResourceType == RTTEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_2D, _OpenGLID));
#ifndef NUX_OPENGLES_20
      CHECKGL(glEnable(GL_TEXTURE_2D));
#endif
    }
#ifndef NUX_OPENGLES_20
    else if (_ResourceType == RTTEXTURERECTANGLE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _OpenGLID));
      CHECKGL(glEnable(GL_TEXTURE_RECTANGLE_ARB));
    }
    else if (_ResourceType == RTCUBETEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_CUBE_MAP, _OpenGLID));
      CHECKGL(glEnable(GL_TEXTURE_CUBE_MAP));
    }
    else if (_ResourceType == RTVOLUMETEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_3D, _OpenGLID));
      CHECKGL(glEnable(GL_TEXTURE_3D));
    }
    else if (_ResourceType == RTANIMATEDTEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _OpenGLID));
      CHECKGL(glEnable(GL_TEXTURE_RECTANGLE_ARB));
    }
#endif
    else
    {
      nuxError("[IOpenGLBaseTexture::BindTexture] unknown texture type.");
      return OGL_ERROR;
    }

    _TextureStates.SetRenderStates();
    return OGL_OK;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::Object::Dispose ( ) [virtual, inherited]

Destroy and object that has a floating reference.

Returns:
True is the object has been destroyed

Reimplemented from nux::Trackable.

Definition at line 311 of file Object.cpp.

  {
    // The intent of the Dispose call is to destroy objects with a float
    // reference (reference count is equal to 1 and the '_owns_the_reference'
    // flag is set to false). In Nux, only widgets object can have a floating
    // reference.  And widgets are only visible if added to the widget tree.
    // When an object with a floating reference is added to the widget tree,
    // it becomes "owned'. It looses it floating reference status but it still
    // has a reference count number of 1.  In practice, since widgets must be
    // added to the widget tree, there should never be a need to call Dispose
    // (except in a few cases).

    // Dispose() was designed to only destroy objects with floating
    // references, while UnReference() destroys objects that are "owned".
    // That is now relaxed. Dispose() calls UnReference().
    return UnReference();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string nux::Object::GetAllocationLoation ( ) const [inherited]

Definition at line 348 of file Object.cpp.

{
  std::ostringstream sout;
  sout << allocation_file_name_ << ":" << allocation_line_number_;
  return sout.str();
}

Here is the caller graph for this function:

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

Definition at line 96 of file IOpenGLBaseTexture.h.

    {
      if (_ResourceType == RTTEXTURE)
        return 1;

      if (_ResourceType == RTTEXTURERECTANGLE)
        return 1;

      if (_ResourceType == RTCUBETEXTURE)
        return 1;

      if (_ResourceType == RTVOLUMETEXTURE)
        return _Depth;

      if (_ResourceType == RTANIMATEDTEXTURE)
        return _Depth;

      return 0;
    }

Here is the caller graph for this function:

int nux::IOpenGLBaseTexture::GetFormatRowMemoryAlignment ( ) const [inline, inherited]

Definition at line 116 of file IOpenGLBaseTexture.h.

    {
      return _RowMemoryAlignment;
    }

Here is the caller graph for this function:

int nux::IOpenGLBaseTexture::GetHeight ( ) const [inline, inherited]

Definition at line 82 of file IOpenGLBaseTexture.h.

    {
      if (_ResourceType == RTTEXTURE)
        return _Height;

      if (_ResourceType == RTTEXTURERECTANGLE)
        return _Height;

      if (_ResourceType == RTCUBETEXTURE)
        return _Width;

      return 0;
    }

Here is the caller graph for this function:

int nux::IOpenGLVolumeTexture::GetLevelDepth ( int  MipLevel) const [inline]

Definition at line 62 of file IOpenGLVolumeTexture.h.

Here is the call graph for this function:

int nux::IOpenGLVolumeTexture::GetLevelDesc ( int  Level,
VOLUME_DESC pDesc 
) [inline]

Definition at line 67 of file IOpenGLVolumeTexture.h.

    {
      nuxAssert(Level >= 0 );
      nuxAssert(Level < _NumMipLevel);

      if ((Level < 0) || (Level > _NumMipLevel))
      {
        pDesc->Width    = 0;
        pDesc->Height   = 0;
        pDesc->Depth    = 0;
        pDesc->PixelFormat   = BITFMT_UNKNOWN;
        pDesc->Type     = _ResourceType;
      }
      else
      {
        pDesc->Width    = Max<int> (1, _Width >> Level);
        pDesc->Height   = Max<int> (1, _Height >> Level);
        pDesc->Depth    = _Depth;
        pDesc->PixelFormat   = _PixelFormat;
        pDesc->Type     = _ResourceType;
      }

      return OGL_OK;
    }
int nux::IOpenGLBaseTexture::GetNumMipLevel ( ) const [inline, inherited]

Definition at line 59 of file IOpenGLBaseTexture.h.

    {
      return _NumMipLevel;
    }

Here is the caller graph for this function:

int nux::Trackable::GetObjectSize ( ) [virtual, inherited]

Return the size of allocated for this object.

Returns:
The size allocated for this object.

Definition at line 217 of file Object.cpp.

  {
    return _size_of_this_object;
  }
int nux::IOpenGLResource::GetOpenGLID ( ) const [inline, inherited]

Definition at line 101 of file IOpenGLResource.h.

    {
      return _OpenGLID;
    }

Here is the caller graph for this function:

Definition at line 55 of file IOpenGLBaseTexture.h.

    {
      return _PixelFormat;
    }

Here is the caller graph for this function:

template<typename T >
T nux::Introspectable::GetProperty ( std::string const &  name,
T *  foo = 0 
) [inherited]

Definition at line 285 of file Property-inl.h.

{
  PropertyContainer::iterator i = properties_.find(name);
  if (i == properties_.end())
    return T();

  std::string s = i->second->GetSerializedValue();
  std::pair<T, bool> result = type::PropertyTrait<T>::from_string(s);
  // If this is called with a template type that the property does not
  // support nice conversion to, you'll get no error, but will get
  // a default constructed T.  We could use an exception here.
  return result.first;
}
int nux::Object::GetReferenceCount ( ) const [inherited]

Get the reference count of this object.

Returns:
The reference count of this object.

Definition at line 343 of file Object.cpp.

  {
    return reference_count_->GetValue();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 96 of file IOpenGLResource.h.

    {
      return _ResourceType;
    }

Here is the caller graph for this function:

unsigned char * nux::IOpenGLBaseTexture::GetSurfaceData ( int  level,
int &  width,
int &  height,
int &  stride 
) [virtual, inherited]

Return a pointer to a mipmap level data.

Return a pointer to a mipmap level data. The data is in the RGBA format.

Parameters:
levelThe requested texture mipmap level data.
widthReturns the width in pixel of the image data.
heightReturns the height in pixel of the image data.
strideReturns the row stride of the image data.
Returns:
A pointer to RGBA data. The caller must delete the data by calling delete [].

Reimplemented in nux::IOpenGLRectangleTexture, and nux::IOpenGLTexture2D.

Definition at line 257 of file IOpenGLBaseTexture.cpp.

  {
    // Make this call a pure virtual once it has been implemented for IOpenGLCubeTexture,
    // IOpenGLVolumeTexture and IOpenGLAnimatedTexture.
    width = 0;
    height = 0;
    stride = 0;
    return 0;
  }
void nux::IOpenGLBaseTexture::GetSurfaceLevel ( int  Level,
ObjectPtr< IOpenGLSurface > &  surface 
) [virtual, inherited]

Reimplemented in nux::IOpenGLRectangleTexture, and nux::IOpenGLTexture2D.

Definition at line 237 of file IOpenGLBaseTexture.cpp.

  {

  }

Here is the caller graph for this function:

ObjectPtr< IOpenGLSurface > nux::IOpenGLBaseTexture::GetSurfaceLevel ( int  Level) [virtual, inherited]

Reimplemented in nux::IOpenGLRectangleTexture, and nux::IOpenGLTexture2D.

Definition at line 242 of file IOpenGLBaseTexture.cpp.

  {
    return ObjectPtr<IOpenGLSurface> (0);
  }
int nux::IOpenGLVolumeTexture::GetVolumeLevel ( int  Level,
IOpenGLVolume **  ppVolumeLevel 
)
int nux::IOpenGLBaseTexture::GetWidth ( ) const [inline, inherited]

Definition at line 68 of file IOpenGLBaseTexture.h.

    {
      if (_ResourceType == RTTEXTURE)
        return _Width;

      if (_ResourceType == RTTEXTURERECTANGLE)
        return _Width;

      if (_ResourceType == RTCUBETEXTURE)
        return _Width;

      return 0;
    }

Here is the caller graph for this function:

bool nux::Trackable::IsDynamic ( ) const [inherited]

Test if object was allocated dynamically.

Definition at line 201 of file Object.cpp.

  {
    // Get pointer to beginning of the memory occupied by this.
    const void *ptr = dynamic_cast<const void *> (this);

    // Search for ptr in allocation_list
#if defined(NUX_OS_WINDOWS) && !defined(NUX_VISUAL_STUDIO_2010)
    std::list<void*>::iterator i = std::find(GObjectStats._allocation_list.begin(),
      GObjectStats._allocation_list.end(), ptr);
#else
    auto i = std::find(GObjectStats._allocation_list.begin(),
                       GObjectStats._allocation_list.end(), ptr);
#endif
    return i != GObjectStats._allocation_list.end();
  }

Here is the caller graph for this function:

bool nux::Trackable::IsHeapAllocated ( ) [inherited]

Test if object was allocated dynamically.

Definition at line 191 of file Object.cpp.

  {
    if (_heap_allocated == -1)
    {
      _heap_allocated = (IsDynamic () ? 1 : 0);
    }

    return (_heap_allocated == 1 ? true : false);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::IOpenGLBaseTexture::IsPowerOfTwo ( ) const [inline, inherited]

Definition at line 63 of file IOpenGLBaseTexture.h.

    {
      return _IsPOT;
    }

Here is the caller graph for this function:

int nux::IOpenGLVolumeTexture::LockBox ( int  Level,
VOLUME_LOCKED_BOX pLockedVolume,
const VOLUME_BOX pBox 
)

Definition at line 154 of file IOpenGLVolumeTexture.cpp.

  {
    nuxAssertMsg(pLockedVolume, "[IOpenGLVolumeTexture::LockBox] Invalid parameter 'pLockedRect'.");
    nuxAssertMsg(Level >= 0, "[IOpenGLVolumeTexture::LockBox] Invalid mipmap level.");
    nuxAssertMsg(Level < _NumMipLevel, "[IOpenGLVolumeTexture::LockBox] Invalid mipmap level.");

    if (pBox)
    {
      nuxAssertMsg(pBox->Front >= 0, "[IOpenGLVolumeTexture::LockBox] Invalid slice index.");
      nuxAssertMsg(pBox->Front < pBox->Back, "[IOpenGLVolumeTexture::LockBox] Invalid slice index.");
      nuxAssertMsg(pBox->Back <= ImageSurface::GetLevelDim(_PixelFormat, _Depth, Level),
                    "[IOpenGLVolumeTexture::LockBox] Invalid slice index.");
    }

    return _VolumeArray[Level]->LockBox(pLockedVolume, pBox);
  }

Here is the call graph for this function:

int nux::IOpenGLVolumeTexture::LockRect ( int  Slice,
int  Level,
SURFACE_LOCKED_RECT pLockedRect,
const SURFACE_RECT pRect 
)

Definition at line 100 of file IOpenGLVolumeTexture.cpp.

  {
    nuxAssertMsg(pLockedRect, "[IOpenGLVolumeTexture::LockRect] Invalid parameter 'pLockedRect'.");
    nuxAssertMsg(Level >= 0, "[IOpenGLVolumeTexture::LockRect] Invalid mipmap level.");
    nuxAssertMsg(Level < _NumMipLevel, "[IOpenGLVolumeTexture::LockRect] Invalid mipmap level.");
    nuxAssertMsg(Slice >= 0, "[IOpenGLVolumeTexture::LockRect] Invalid slice index.");
    nuxAssertMsg(Slice < ImageSurface::GetLevelDim(_PixelFormat, _Depth, Level), "[IOpenGLVolumeTexture::LockRect] Invalid slice index.");

    if (Slice < 0)
      Slice = 0;

    if (Slice >= _Depth)
      Slice = _Depth - 1;

    if (Level < _NumMipLevel)
    {
      ObjectPtr<IOpenGLSurface> pVolumeSurfaceLevel = _VolumeSurfaceArray[Level][Slice];
      return pVolumeSurfaceLevel->LockRect(pLockedRect, pRect);
    }
    else
    {
      pLockedRect->pBits = 0;
      pLockedRect->Pitch = 0;
      return OGL_INVALID_SURFACE_LEVEL;
    }

    return OGL_OK;
  }

Here is the call graph for this function:

int nux::IOpenGLBaseTexture::LockRect ( int  Level,
SURFACE_LOCKED_RECT pLockedRect,
const SURFACE_RECT pRect 
) [virtual, inherited]

Reimplemented in nux::IOpenGLAnimatedTexture, nux::IOpenGLRectangleTexture, and nux::IOpenGLTexture2D.

Definition at line 247 of file IOpenGLBaseTexture.cpp.

  {
    return 0;
  }
nux::Object::NUX_DECLARE_OBJECT_TYPE ( BaseObject  ,
Trackable   
) [inherited]
void nux::Trackable::operator delete ( void *  ptr) [static, inherited]

Definition at line 178 of file Object.cpp.

  {
    ObjectStats::AllocationList::iterator i = std::find (GObjectStats._allocation_list.begin(), GObjectStats._allocation_list.end(), ptr);

    if (i != GObjectStats._allocation_list.end() )
    {
      GObjectStats._total_allocated_size -= NUX_STATIC_CAST (Trackable *, ptr)->_size_of_this_object;
      --GObjectStats._number_of_objects;
      GObjectStats._allocation_list.erase (i);
      ::operator delete (ptr);
    }
  }
void * nux::Trackable::operator new ( size_t  size) [static, inherited]

Definition at line 140 of file Object.cpp.

  {
    // Set the new_handler for this call
    std::new_handler global_handler  = std::set_new_handler (_new_current_handler);

    // If allocation fails _new_current_handler is called, if specified,
    // otherwise the global new_handler is called.
    void *ptr;

    try
    {
      ptr = ::operator new (size);

      GObjectStats._allocation_list.push_front (ptr);
      NUX_STATIC_CAST (Trackable *, ptr)->_size_of_this_object = size;
      GObjectStats._total_allocated_size += size;
      ++GObjectStats._number_of_objects;
    }
    catch (std::bad_alloc &)
    {
      std::set_new_handler (global_handler);
      throw;
    }

    //  Reset gloabal new_handler
    std::set_new_handler (global_handler);
    return ptr;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void * nux::Trackable::operator new ( size_t  size,
void *  ptr 
) [static, inherited]

Definition at line 171 of file Object.cpp.

  {
    return ::operator new (size, ptr);
  }

Here is the call graph for this function:

bool nux::Trackable::OwnsTheReference ( ) [inherited]

Test if object reference is owned.

Definition at line 117 of file Object.cpp.

  {
    return _owns_the_reference;
  }

Here is the caller graph for this function:

virtual int nux::IOpenGLResource::RefCount ( ) const [inline, virtual, inherited]

Reimplemented in nux::IOpenGLVolume, and nux::IOpenGLSurface.

Definition at line 91 of file IOpenGLResource.h.

    {
      return GetReferenceCount();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::Object::Reference ( ) [virtual, inherited]

Increase reference count.

Returns:
True if the object has successfully referenced.

Reimplemented from nux::Trackable.

Definition at line 254 of file Object.cpp.

  {
    if (!IsHeapAllocated())
    {
      LOG_WARN(logger) << "Trying to reference an object that was not heap allocated."
                       << "\nObject allocated at: " << GetAllocationLoation() << "\n";
      return false;
    }

    if (!OwnsTheReference())
    {
      SetOwnedReference(true);
      // The ref count remains at 1. Exit the method.
      return true;
    }

    reference_count_->Increment();
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

std::new_handler nux::Trackable::set_new_handler ( std::new_handler  handler) [static, inherited]

Definition at line 133 of file Object.cpp.

  {
    std::new_handler old_handler = _new_current_handler;
    _new_current_handler = handler;
    return old_handler;
  }

Here is the caller graph for this function:

void nux::IOpenGLBaseTexture::SetBorderColor ( float  R,
float  G,
float  B,
float  A 
) [inherited]

Definition at line 141 of file IOpenGLBaseTexture.cpp.

  {
    _TextureStates.SetBorderColor(R, G, B, A);
  }

Here is the call graph for this function:

void nux::IOpenGLBaseTexture::SetFiltering ( unsigned int  MIN = GL_NEAREST,
unsigned int  MAG = GL_NEAREST 
) [inherited]

Definition at line 121 of file IOpenGLBaseTexture.cpp.

  {
    _TextureStates.SetFiltering(MinFilter, MagFilter);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::IOpenGLBaseTexture::SetLOD ( float  MinLod = -1000.0f,
float  MaxLod = +1000.0f 
) [inherited]

Definition at line 131 of file IOpenGLBaseTexture.cpp.

  {
    _TextureStates.SetLOD(MinLod, MaxLod);
  }

Here is the call graph for this function:

void nux::IOpenGLBaseTexture::SetMipLevel ( unsigned int  MinMip = 0,
unsigned int  MaxMip = 1000 
) [inherited]

Definition at line 136 of file IOpenGLBaseTexture.cpp.

  {
    _TextureStates.SetMipLevel(MinMip, MaxMip);
  }

Here is the call graph for this function:

void nux::Trackable::SetOwnedReference ( bool  b) [protected, inherited]

Definition at line 122 of file Object.cpp.

  {
    if (_owns_the_reference == true)
    {
      LOG_DEBUG(logger) << "Do not change the ownership if is already set to true!" << "\n";
      return;
    }

    _owns_the_reference = b;
  }

Here is the caller graph for this function:

bool nux::Introspectable::SetProperty ( std::string const &  name,
const char *  value 
) [inline, inherited]

If the property was not able to be set with the value, the method returns false.

Definition at line 262 of file Property-inl.h.

{
  PropertyContainer::iterator i = properties_.find(name);
  if (i == properties_.end())
    return false;
  else
    return i->second->SetValue(value);
}
template<typename T >
bool nux::Introspectable::SetProperty ( std::string const &  name,
T const &  value 
) [inherited]

Definition at line 273 of file Property-inl.h.

{
  PropertyContainer::iterator i = properties_.find(name);
  if (i == properties_.end())
    return false;
  else
  {
    return i->second->SetValue(type::PropertyTrait<T>::to_string(value));
  }
}

Definition at line 89 of file IOpenGLBaseTexture.cpp.

  {
    if (_ResourceType == RTTEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_2D, _OpenGLID));
    }
#ifndef NUX_OPENGLES_20
    else if (_ResourceType == RTTEXTURERECTANGLE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _OpenGLID));
    }
    else if (_ResourceType == RTCUBETEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_CUBE_MAP, _OpenGLID));
    }
    else if (_ResourceType == RTVOLUMETEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_3D, _OpenGLID));
    }
    else if (_ResourceType == RTANIMATEDTEXTURE)
    {
      CHECKGL(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _OpenGLID));
    }
#endif
    else
    {
      nuxError("[IOpenGLBaseTexture::SetRenderStates] Incorrect texture resource type.");
    }

    _TextureStates.SetRenderStates();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::IOpenGLBaseTexture::SetWrap ( unsigned int  U = GL_REPEAT,
unsigned int  V = GL_REPEAT,
unsigned int  W = GL_REPEAT 
) [inherited]

Definition at line 126 of file IOpenGLBaseTexture.cpp.

  {
    _TextureStates.SetWrap(U, V, W);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::Object::SinkReference ( ) [virtual, inherited]

Mark the object as owned.

If this object is not owned, calling SinkReference() as the same effect as calling Reference().

Returns:
True if the object was not owned previously

Reimplemented from nux::Trackable.

Definition at line 306 of file Object.cpp.

  {
    return Reference();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file IOpenGLVolumeTexture.cpp.

  {
    nuxAssertMsg(Level >= 0, "[IOpenGLVolumeTexture::LockBox] Invalid mipmap level.");
    nuxAssertMsg(Level < _NumMipLevel, "[IOpenGLVolumeTexture::LockBox] Invalid mipmap level.");

    return _VolumeArray[Level]->UnlockBox();
  }
int nux::IOpenGLVolumeTexture::UnlockRect ( int  Slice,
int  Level 
)

Definition at line 133 of file IOpenGLVolumeTexture.cpp.

  {
    nuxAssertMsg(Level >= 0, "[IOpenGLVolumeTexture::LockRect] Invalid mipmap level.");
    nuxAssertMsg(Level < _NumMipLevel, "[IOpenGLVolumeTexture::LockRect] Invalid mipmap level.");

    if (Level < _NumMipLevel)
    {
      ObjectPtr<IOpenGLSurface> pVolumeSurfaceLevel = _VolumeSurfaceArray[Level][Slice];
      return pVolumeSurfaceLevel->UnlockRect();
    }
    else
    {
      return OGL_INVALID_SURFACE_LEVEL;
    }

    return OGL_OK;
  }

Here is the call graph for this function:

int nux::IOpenGLBaseTexture::UnlockRect ( int  Level) [virtual, inherited]

Reimplemented in nux::IOpenGLAnimatedTexture, nux::IOpenGLRectangleTexture, and nux::IOpenGLTexture2D.

Definition at line 252 of file IOpenGLBaseTexture.cpp.

  {
    return 0;
  }
bool nux::Object::UnReference ( ) [virtual, inherited]

Decrease reference count.

Returns:
True if the object reference count has reached 0 and the object has been destroyed.

Reimplemented from nux::Trackable.

Definition at line 274 of file Object.cpp.

  {
    if (!IsHeapAllocated())
    {
      LOG_WARN(logger) << "Trying to un-reference an object that was not heap allocated."
                       << "\nObject allocated at: " << GetAllocationLoation() << "\n";
      return false;
    }

    if (objectptr_count_->GetValue() == reference_count_->GetValue())
    {
      // There are ObjectPtr's hosting this object. Release all of them to
      // destroy this object.  This prevent from calling UnReference () many
      // times and destroying the object when there are ObjectPtr's hosting
      // it.  This method should not be called directly in that case.
      LOG_WARN(logger) << "There are ObjectPtr hosting this object. "
                       << "Release all of them to destroy this object. "
                       << "\nObject allocated at: " << GetAllocationLoation() << "\n";
      return false;
    }

    reference_count_->Decrement();

    if (reference_count_->GetValue() == 0)
    {
      Destroy();
      return true;
    }

    return false;
  }

Here is the call graph for this function:


Friends And Related Function Documentation

void GetTextureDesc ( IOpenGLBaseTexture pTexture,
unsigned int  Level,
TEXTURE_DESC pDesc 
) [friend, inherited]

Definition at line 320 of file IOpenGLBaseTexture.cpp.

  {
    GLint unpack_alignment = GPixelFormats[pTexture->_PixelFormat].RowMemoryAlignment;
    unsigned int halfUnpack = Log2(unpack_alignment);

    unsigned int BytePerPixel = 0;

    pDesc->PixelFormat = pTexture->_PixelFormat;

    if ( /*pTexture->_Format  == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||*/
      pTexture->_PixelFormat == BITFMT_DXT1 ||
      pTexture->_PixelFormat == BITFMT_DXT2 ||
      pTexture->_PixelFormat == BITFMT_DXT3 ||
      pTexture->_PixelFormat == BITFMT_DXT4 ||
      pTexture->_PixelFormat == BITFMT_DXT5)
    {
      pDesc->Width            = Max<unsigned int> (1, pTexture->_Width >> Level);
      pDesc->Height           = Max<unsigned int> (1, pTexture->_Height >> Level);
      pDesc->WidthInBlocks    = Max<unsigned int> ((pDesc->Width + 3) / 4, 1); // round the width to the upper multiple of 4. DXT blocks are 4x4 texels.
      pDesc->HeightInBlocks   = Max<unsigned int> ((pDesc->Height + 3) / 4, 1); // round the height to the upper multiple of 4. DXT blocks are 4x4 texels.

      if ( /*pTexture->_Format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||*/
        pTexture->_PixelFormat == BITFMT_DXT1)
      {
        // We can conceive a 4x4 DXT1 block as if each texel uses 4 bits.
        // Actually, for DXT, we have 2 16-bits colors(5:6:5), and each texel uses 2 bits to interpolate
        // between the 2 colors.
        //    ---------------------
        //    |      COLOR0       | 16 bits
        //    ---------------------
        //    |      COLOR1       | 16 bits
        //    ---------------------
        //    | xx | xx | xx | xx | xx = 2 bits
        //    ---------------------
        //    | xx | xx | xx | xx |
        //    ---------------------
        //    | xx | xx | xx | xx |
        //    ---------------------
        //    | xx | xx | xx | xx |
        //    ---------------------

        // A line of n texel DXT1 data uses n/2 bytes(4 bits/texel). So the number of bytes used for a
        // texwidth texel, is texwidth/2 bytes.
        // Note that texwidth is divisible by 4(to to the upper rounding to 4), therefore, it is also divisible
        // by 2.

        // glCompressedTexImage2DARB, glCompressedTexImage3DARB,
        // glCompressedTexSubImage2DARB, glCompressedTexSubImage3DARB are not affected by glPixelStorei.

        pDesc->RowPitch = pDesc->WidthInBlocks * 8;
        pDesc->SlicePitch = pDesc->WidthInBlocks * pDesc->HeightInBlocks * 8;
        pDesc->BitsPerPixel     = 0; // compressed
        pDesc->BytesPerBlock    = 8;
      }
      else
      {
        // A line of n texel DXT3/5 data uses n bytes(1 byte/texel). So the number of bytes used for a
        // texwidth texels, is texwidth bytes.

        // glCompressedTexImage2DARB, glCompressedTexImage3DARB,
        // glCompressedTexSubImage2DARB, glCompressedTexSubImage3DARB are not affected by glPixelStorei.
        pDesc->RowPitch = pDesc->WidthInBlocks * 16;
        pDesc->SlicePitch = pDesc->WidthInBlocks * pDesc->HeightInBlocks * 16;
        pDesc->BitsPerPixel     = 0; // compressed
        pDesc->BytesPerBlock    = 16;
      }
    }
    else
    {
      pDesc->Width            = Max<unsigned int> (1, pTexture->_Width >> Level);
      pDesc->Height           = Max<unsigned int> (1, pTexture->_Height >> Level);
      pDesc->WidthInBlocks    = pDesc->Width;
      pDesc->HeightInBlocks   = pDesc->Height;
      BytePerPixel            = GPixelFormats[pTexture->_PixelFormat].BlockBytes;
      pDesc->BitsPerPixel     = BytePerPixel * 8;
      pDesc->BytesPerBlock    = BytePerPixel; // a block is a 1x1 pixel ie. 1 pixel.
      pDesc->RowPitch = (((pDesc->Width * BytePerPixel + (unpack_alignment - 1)) >> (halfUnpack)) << (halfUnpack));
      pDesc->SlicePitch = (((pDesc->Width * BytePerPixel + (unpack_alignment - 1)) >> (halfUnpack)) << (halfUnpack)) * pDesc->Height;
    }
  }
int GetTextureSize ( IOpenGLBaseTexture pTexture) [friend, inherited]

Definition at line 268 of file IOpenGLBaseTexture.cpp.

  {
    GLint unpack_alignment = GPixelFormats[pTexture->_PixelFormat].RowMemoryAlignment;
    unsigned int halfUnpack = Log2(unpack_alignment);

    unsigned int TextureSize = 0;

    if (
      pTexture->_PixelFormat == BITFMT_DXT1 ||
      pTexture->_PixelFormat == BITFMT_DXT2 ||
      pTexture->_PixelFormat == BITFMT_DXT3 ||
      pTexture->_PixelFormat == BITFMT_DXT4 ||
      pTexture->_PixelFormat == BITFMT_DXT5)
    {
      for (int Level = 0; Level < pTexture->GetNumMipLevel(); Level++)
      {
        unsigned int Width            = Max<unsigned int> (1, pTexture->_Width >> Level);
        unsigned int Height           = Max<unsigned int> (1, pTexture->_Height >> Level);
        unsigned int WidthInBlocks    = Max<unsigned int> ((Width + 3) / 4, 1); // round the width to the upper multiple of 4. DXT blocks are 4x4 texels.
        unsigned int HeightInBlocks   = Max<unsigned int> ((Height + 3) / 4, 1); // round the height to the upper multiple of 4. DXT blocks are 4x4 texels.

        if (pTexture->_PixelFormat == BITFMT_DXT1)
        {
          TextureSize += WidthInBlocks * HeightInBlocks * 8;;
        }
        else
        {
          TextureSize += WidthInBlocks * HeightInBlocks * 16;
        }
      }
    }
    else
    {
      for (int Level = 0; Level < pTexture->GetNumMipLevel(); Level++)
      {
        unsigned int Width             = Max<unsigned int> (1, pTexture->_Width >> Level);
        unsigned int Height            = Max<unsigned int> (1, pTexture->_Height >> Level);
        unsigned int BytePerPixel      = GPixelFormats[pTexture->_PixelFormat].BlockBytes;
        unsigned int SlicePitch        = (((Width * BytePerPixel + (unpack_alignment - 1)) >> (halfUnpack)) << (halfUnpack)) * Height;

        TextureSize += SlicePitch;
      }
    }

    if (pTexture->GetResourceType() == RTANIMATEDTEXTURE)
    {
      return TextureSize * pTexture->GetDepth();
    }

    return TextureSize;
  }
friend class GpuDevice [friend]

Reimplemented from nux::IOpenGLResource.

Definition at line 107 of file IOpenGLVolumeTexture.h.

friend class IOpenGLSurface [friend]

Reimplemented from nux::IOpenGLBaseTexture.

Definition at line 108 of file IOpenGLVolumeTexture.h.

friend class IOpenGLVolume [friend, inherited]

Reimplemented from nux::IOpenGLResource.

Definition at line 169 of file IOpenGLBaseTexture.h.


Member Data Documentation

int nux::IOpenGLBaseTexture::_Depth [protected, inherited]

Definition at line 165 of file IOpenGLBaseTexture.h.

int nux::Trackable::_heap_allocated [protected, inherited]

Definition at line 158 of file Object.h.

int nux::IOpenGLBaseTexture::_Height [protected, inherited]

Definition at line 164 of file IOpenGLBaseTexture.h.

bool nux::IOpenGLBaseTexture::_IsPOT [protected, inherited]

Definition at line 156 of file IOpenGLBaseTexture.h.

int nux::IOpenGLBaseTexture::_NumMipLevel [protected, inherited]

Definition at line 157 of file IOpenGLBaseTexture.h.

Definition at line 158 of file IOpenGLBaseTexture.h.

Definition at line 166 of file IOpenGLBaseTexture.h.

Definition at line 155 of file IOpenGLBaseTexture.h.

Definition at line 105 of file IOpenGLVolumeTexture.h.

Definition at line 104 of file IOpenGLVolumeTexture.h.

int nux::IOpenGLBaseTexture::_Width [protected, inherited]

Definition at line 163 of file IOpenGLBaseTexture.h.

sigc::signal<void, Object *> nux::Object::object_destroyed [inherited]

Signal emitted immediately before the object is destroyed.

Definition at line 214 of file Object.h.


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