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::IOpenGLShaderProgram Class Reference

#include <IOpenGLGLSLShader.h>

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

List of all members.

Public Member Functions

virtual ~IOpenGLShaderProgram ()
void LoadVertexShader (const char *glslshader, const char *VtxShaderPreprocessorDefines="")
void LoadPixelShader (const char *glslshader, const char *FrgShaderPreprocessorDefines="")
void LoadIShaderFile (const char *ShaderFileName, const char *VtxShaderPreprocessorDefines="", const char *FrgShaderPreprocessorDefines="")
void LoadIShader (const char *ShaderCode, const char *VtxShaderPreprocessorDefines="", const char *FrgShaderPreprocessorDefines="")
void AddShaderParameter (GLShaderParameter *Parameter)
void AddShaderObject (ObjectPtr< IOpenGLShader > ShaderObject)
void RemoveShaderObject (ObjectPtr< IOpenGLShader > ShaderObject)
void ClearShaderObjects ()
bool Link ()
void Begin ()
void End ()
bool SetUniform1f (char *varname, GLfloat v0)
bool SetUniform2f (char *varname, GLfloat v0, GLfloat v1)
bool SetUniform3f (char *varname, GLfloat v0, GLfloat v1, GLfloat v2)
bool SetUniform4f (char *varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
bool SetUniform1i (char *varname, GLint v0)
bool SetUniform2i (char *varname, GLint v0, GLint v1)
bool SetUniform3i (char *varname, GLint v0, GLint v1, GLint v2)
bool SetUniform4i (char *varname, GLint v0, GLint v1, GLint v2, GLint v3)
bool SetUniform1fv (char *varname, GLsizei count, GLfloat *value)
bool SetUniform2fv (char *varname, GLsizei count, GLfloat *value)
bool SetUniform3fv (char *varname, GLsizei count, GLfloat *value)
bool SetUniform4fv (char *varname, GLsizei count, GLfloat *value)
bool SetUniform1iv (char *varname, GLsizei count, GLint *value)
bool SetUniform2iv (char *varname, GLsizei count, GLint *value)
bool SetUniform3iv (char *varname, GLsizei count, GLint *value)
bool SetUniform4iv (char *varname, GLsizei count, GLint *value)
bool SetUniformMatrix2fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
bool SetUniformMatrix3fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
bool SetUniformMatrix4fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
bool SetUniform1f (GLint loc, GLfloat v0)
bool SetUniform2f (GLint loc, GLfloat v0, GLfloat v1)
bool SetUniform3f (GLint loc, GLfloat v0, GLfloat v1, GLfloat v2)
bool SetUniform4f (GLint loc, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
bool SetUniform1i (GLint loc, GLint v0)
bool SetUniform2i (GLint loc, GLint v0, GLint v1)
bool SetUniform3i (GLint loc, GLint v0, GLint v1, GLint v2)
bool SetUniform4i (GLint loc, GLint v0, GLint v1, GLint v2, GLint v3)
bool SetUniform1fv (GLint loc, GLsizei count, GLfloat *value)
bool SetUniform2fv (GLint loc, GLsizei count, GLfloat *value)
bool SetUniform3fv (GLint loc, GLsizei count, GLfloat *value)
bool SetUniform4fv (GLint loc, GLsizei count, GLfloat *value)
bool SetUniform1iv (GLint loc, GLsizei count, GLint *value)
bool SetUniform2iv (GLint loc, GLsizei count, GLint *value)
bool SetUniform3iv (GLint loc, GLsizei count, GLint *value)
bool SetUniform4iv (GLint loc, GLsizei count, GLint *value)
bool SetUniformLocMatrix2fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
bool SetUniformLocMatrix3fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
bool SetUniformLocMatrix4fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
void GetUniformfv (char *name, GLfloat *values)
void GetUniformiv (char *name, GLint *values)
int GetUniformLocationARB (const GLchar *name)
void GetActiveUniformARB (GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
void GetObjectParameterfvARB (GLenum pname, GLfloat *params)
bool SetSampler (char *name, int exture_unit)
void CheckAttributeLocation ()
void CheckUniformLocation ()
int GetAttributeLocation (const char *AttributeName)
 NUX_DECLARE_OBJECT_TYPE (BaseObject, Trackable)
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 void SetShaderTracking (bool enabled)
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

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

Protected Member Functions

void SetOwnedReference (bool b)

Protected Attributes

int _heap_allocated

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (IOpenGLShaderProgram, IOpenGLResource)
 IOpenGLShaderProgram (NString ShaderProgramName=NString("ShaderProgram"))

Private Attributes

ShaderAttributeDefinition m_ProgramAttributeDefinition [16]
std::vector< ObjectPtr
< IOpenGLShader > > 
ShaderObjectList
bool m_CompiledAndReady
NString _ShaderProgramName

Friends

class GpuDevice

Detailed Description

Definition at line 95 of file IOpenGLGLSLShader.h.


Constructor & Destructor Documentation

Definition at line 462 of file IOpenGLGLSLShader.cpp.

  {
    if (local::last_loaded_shader == _OpenGLID)
    {
      CHECKGL(glUseProgramObjectARB(0));
      local::last_loaded_shader = 0;
    }
      
    CHECKGL(glDeleteProgram(_OpenGLID));
    _OpenGLID = 0;
    m_CompiledAndReady = false;
  }
nux::IOpenGLShaderProgram::IOpenGLShaderProgram ( NString  ShaderProgramName = NString("ShaderProgram")) [private]

Definition at line 452 of file IOpenGLGLSLShader.cpp.

    :   IOpenGLResource(RT_GLSL_SHADERPROGRAM)
    ,   _FirstParameter(0)
    ,   m_CompiledAndReady(false)
    ,   _ShaderProgramName(ShaderProgramName)
  {
    _OpenGLID = glCreateProgram();
    CHECKGL_MSG( glCreateProgram());
  }

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 537 of file IOpenGLGLSLShader.cpp.

  {
    ShaderObjectList.push_back(ShaderObject);
  }

Here is the caller graph for this function:

Definition at line 542 of file IOpenGLGLSLShader.cpp.

  {
    GLShaderParameter* temp = _FirstParameter;

    while (temp)
    {
      if (temp == parameter)
      {
        // Parameter already added
        return;
      }
      temp = temp->m_NextParameter;
    }

    parameter->m_NextParameter = _FirstParameter;
    _FirstParameter = parameter;

    // If we add shader parameters after the program is linked, we need to call CheckUniformLocation().
    CheckUniformLocation();
  }

Here is the call graph for this function:

Definition at line 687 of file IOpenGLGLSLShader.cpp.

  {
    if (local::last_loaded_shader == _OpenGLID && local::enable_tracking)
      return;
    
    local::last_loaded_shader = _OpenGLID;
    CHECKGL(glUseProgramObjectARB(_OpenGLID));
  }

Here is the caller graph for this function:

Definition at line 702 of file IOpenGLGLSLShader.cpp.

  {
    //ResetAttributeVariable(m_ProgramAttributeDefinition);
    for (int i = 0; i < NUM_VERTEX_SHADER_INPUT_ATTRIBUTE; i++)
    {
      m_ProgramAttributeDefinition[i].attribute_index = -1;
      m_ProgramAttributeDefinition[i].attribute_name = "";
      m_ProgramAttributeDefinition[i].type = VAT_UNDEFINED;
      m_ProgramAttributeDefinition[i].valid = false;
    }

    char active_attribute_name[256];
    GLsizei length;
    GLint size;
    GLenum type;

    GLint num_active_attributes;
    CHECKGL(glGetObjectParameterivARB(_OpenGLID, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &num_active_attributes));


    //         Vertex Attribute Aliasing
    //         GLSL attempts to eliminate aliasing of vertex attributes but this is integral to NVIDIA's hardware
    //         approach and necessary for maintaining compatibility with existing OpenGL applications that NVIDIA customers rely on.
    //         NVIDIA's GLSL implementation therefore does not allow built-in vertex attributes to collide with a
    //         generic vertex attributes that is assigned to a particular vertex attribute index with glBindAttribLocation.
    //         For example, you should not use gl_Normal(a built-in vertex attribute) and also use glBindAttribLocation to
    //         bind a generic vertex attribute named "whatever" to vertex attribute index 2 because gl_Normal aliases to index 2.
    //
    //         Built-in vertex attribute name      Incompatible aliased vertex attribute index
    //         gl_Vertex                           0
    //         gl_Normal                           2
    //         gl_Color                            3
    //         gl_SecondaryColor                   4
    //         gl_FogCoord                         5
    //         gl_MultiTexCoord0                   8
    //         gl_MultiTexCoord1                   9
    //         gl_MultiTexCoord2                   10
    //         gl_MultiTexCoord3                   11
    //         gl_MultiTexCoord4                   12
    //         gl_MultiTexCoord5                   13
    //         gl_MultiTexCoord6                   14
    //         gl_MultiTexCoord7                   15
    //         The compiler will automatically assign vertex shader attribute variables not pre-assigned
    //         by glBindAttribLocation to locations that do not collide with any built-in attribute variables
    //         used by the vertex shader. The assigned locations can be queries with glGetAttribLocation.
    //         This means that a developer only needs to worry about collisions when they are explicitly requesting
    //         an attribute to be bound to a specific location.

    for (int index = 0; index < num_active_attributes; index++)
    {
      glGetActiveAttribARB(_OpenGLID,
                            index,
                            256,
                            &length,
                            &size,
                            &type,
                            active_attribute_name);
      CHECKGL_MSG( glGetActiveAttribARB );
      m_ProgramAttributeDefinition[index].attribute_index = glGetAttribLocationARB(_OpenGLID, active_attribute_name);
      CHECKGL_MSG( glGetAttribLocationARB );
      m_ProgramAttributeDefinition[index].attribute_name = active_attribute_name;
      m_ProgramAttributeDefinition[index].valid = true;

      switch(type)
      {
        case GL_FLOAT:
          m_ProgramAttributeDefinition[index].type = VAT_FLOAT;
          break;
        case GL_FLOAT_VEC2:
          m_ProgramAttributeDefinition[index].type = VAT_FLOAT2;
          break;
        case GL_FLOAT_VEC3:
          m_ProgramAttributeDefinition[index].type = VAT_FLOAT3;
          break;
        case GL_FLOAT_VEC4:
          m_ProgramAttributeDefinition[index].type = VAT_FLOAT4;
          break;

        case GL_FLOAT_MAT2:
        case GL_FLOAT_MAT3:
        case GL_FLOAT_MAT4:
        default:
          //todo
          nuxAssert(0);
      }
    }
  }

Here is the caller graph for this function:

Definition at line 790 of file IOpenGLGLSLShader.cpp.

  {
    GLShaderParameter *parameter = _FirstParameter;

    while (m_CompiledAndReady && parameter)
    {
      int location = glGetUniformLocationARB(_OpenGLID, TCHAR_TO_ANSI(parameter->m_Name.GetTCharPtr()));
      CHECKGL_MSG( glGetUniformLocationARB(_OpenGLID, TCHAR_TO_ANSI(parameter->m_Name.GetTCharPtr())));

      //nuxDebugMsg("[IOpenGLShaderProgram::CheckUniformLocation] Location index: %d", location);
      if (location == -1 && (!parameter->m_bIsOptional))
      {
        nuxDebugMsg("[IOpenGLShaderProgram::CheckUniformLocation] Couldn't find shader program parameter %s \n", parameter->m_Name.GetTCharPtr());
        nuxAssert(0);
      }

      GLint size = 0;
      GLenum type = 0;

      if (location >= 0)
      {
        CHECKGL(glGetActiveUniformARB(_OpenGLID, location, 0, NULL /*&length*/, &size, &type, NULL));
      }

      parameter->m_Index = location;
      parameter->m_Size = size;
      parameter->m_Type = type;

      parameter = parameter->m_NextParameter;
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 573 of file IOpenGLGLSLShader.cpp.

  {
    ShaderObjectList.clear();
  }

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:

Definition at line 696 of file IOpenGLGLSLShader.cpp.

  {
    if (!local::enable_tracking)
      CHECKGL(glUseProgramObjectARB(0));
  }

Here is the caller graph for this function:

void nux::IOpenGLShaderProgram::GetActiveUniformARB ( GLuint  index,
GLsizei  maxLength,
GLsizei *  length,
GLint *  size,
GLenum *  type,
GLchar *  name 
)

Definition at line 1234 of file IOpenGLGLSLShader.cpp.

  {

    glGetActiveUniformARB(_OpenGLID,
                           index,
                           maxLength,
                           length,
                           size,
                           type,
                           name);
    CHECKGL_MSG(glGetActiveUniformARB);
  }
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::IOpenGLShaderProgram::GetAttributeLocation ( const char *  AttributeName)

Definition at line 822 of file IOpenGLGLSLShader.cpp.

  {
    for (int i = 0; i < 16 /*NUM_VERTEX_SHADER_INPUT_ATTRIBUTE*/; i++)
    {
      if (m_ProgramAttributeDefinition[i].attribute_name == AttributeName)
        return m_ProgramAttributeDefinition[i].attribute_index;
    }

    return -1;
  }

Here is the caller graph for this function:

void nux::IOpenGLShaderProgram::GetObjectParameterfvARB ( GLenum  pname,
GLfloat *  params 
)

Definition at line 1254 of file IOpenGLGLSLShader.cpp.

  {
#ifndef NUX_OPENGLES_20
    glGetObjectParameterfvARB(_OpenGLID,
                               pname,
                               params);
    CHECKGL_MSG(glGetObjectParameterfvARB);
#endif
  }
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:

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:

void nux::IOpenGLShaderProgram::GetUniformfv ( char *  name,
GLfloat *  values 
)

Definition at line 1196 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc;

    loc = glGetUniformLocationARB(_OpenGLID, name);
    CHECKGL_MSG( glGetUniformLocationARB );

    if (loc == -1)
    {
      std::cout << "Error: can't find uniform variable \"" << name << "\"\n";
    }

    CHECKGL(glGetUniformfvARB(_OpenGLID, loc, values));
  }
void nux::IOpenGLShaderProgram::GetUniformiv ( char *  name,
GLint *  values 
)

Definition at line 1212 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc;
    loc = glGetUniformLocationARB(_OpenGLID, name);
    CHECKGL_MSG( glGetUniformLocationARB );

    if (loc == -1)
    {
      std::cout << "Error: can't find uniform variable \"" << name << "\"\n";
    }

    CHECKGL(glGetUniformivARB(_OpenGLID, loc, values));
  }

Definition at line 1226 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc;
    loc = glGetUniformLocationARB(_OpenGLID, name);
    CHECKGL_MSG( glGetUniformLocationARB );
    return loc;
  }
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:

Definition at line 578 of file IOpenGLGLSLShader.cpp.

  {
    // Get the number of attached shaders.
    GLint NumAttachedShaders;
    CHECKGL(glGetProgramiv(_OpenGLID, GL_ATTACHED_SHADERS, &NumAttachedShaders));
    GLuint *ShaderObjects = 0;

    if (NumAttachedShaders)
    {
      ShaderObjects = new GLuint[NumAttachedShaders];
    }

    CHECKGL(glGetAttachedShaders(_OpenGLID, NumAttachedShaders, NULL, ShaderObjects));

    // Detach everything first
    for (int i = 0; i < (int) NumAttachedShaders; i++)
    {
      unsigned int obj = ShaderObjects[i];
      CHECKGL(glDetachShader(_OpenGLID, obj));
    }

    if (NumAttachedShaders)
    {
      delete[] ShaderObjects;
    }

    for (int i = 0; i < (int) ShaderObjectList.size(); i++)
    {
      if (!ShaderObjectList[i]->IsValid())
      {
        if (ShaderObjectList[i]->Compile() == false)
        {
          nuxDebugMsg("[IOpenGLShaderProgram::Link] Attached shader %s does not compile with program: %s.", ShaderObjectList[i]->_ShaderName.GetTCharPtr(), _ShaderProgramName.GetTCharPtr());
        }
      }

      unsigned int obj = ShaderObjectList[i]->GetOpenGLID();
      CHECKGL(glAttachShader(_OpenGLID, obj));
    }

    GLint linked;
    CHECKGL(glLinkProgram(_OpenGLID));
    CHECKGL(glGetProgramiv(_OpenGLID, GL_LINK_STATUS, &linked));

    if (linked == GL_FALSE)
    {
      ANSICHAR *InfoLogBuffer = 0;
      GLint InfoLogBufferSize = 0;
      GLint InfoLogReturnSize = 0;
      GLint iLog = 0;
      glGetProgramiv(_OpenGLID, GL_INFO_LOG_LENGTH, &iLog);
      InfoLogBuffer = new ANSICHAR[iLog+1];
      InfoLogBufferSize = iLog + 1;

      glGetProgramInfoLog(_OpenGLID, InfoLogBufferSize, &InfoLogReturnSize, InfoLogBuffer);

      if (InfoLogReturnSize != 0)
      {
        nuxError("[IOpenGLShaderProgram::Link] glLinkProgram: %s", InfoLogBuffer);
      }

      delete[] InfoLogBuffer;
      m_CompiledAndReady = false;
      return m_CompiledAndReady;
    }

    GLint validated;
    // glValidateProgram checks to see whether the executables contained in program can execute given the current OpenGL state.
    CHECKGL(glValidateProgram(_OpenGLID));
    CHECKGL(glGetProgramiv(_OpenGLID, GL_VALIDATE_STATUS, &validated));

    if (validated == GL_FALSE)
    {
      ANSICHAR *InfoLogBuffer = 0;
      GLint InfoLogBufferSize = 0;
      GLint InfoLogReturnSize = 0;
      GLint iLog = 0;
      glGetProgramiv(_OpenGLID, GL_INFO_LOG_LENGTH, &iLog);
      InfoLogBuffer = new ANSICHAR[iLog+1];
      InfoLogBufferSize = iLog + 1;

      glGetProgramInfoLog(_OpenGLID, InfoLogBufferSize, &InfoLogReturnSize, InfoLogBuffer);

      if (InfoLogReturnSize != 0)
      {
        nuxError("[IOpenGLShaderProgram::Link] glValidateProgram: %s", InfoLogBuffer);
      }

      delete [] InfoLogBuffer;
    }

    m_CompiledAndReady = true;

    Begin();
    CheckUniformLocation();
    CheckAttributeLocation();
    
    End();

    return m_CompiledAndReady;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::IOpenGLShaderProgram::LoadIShader ( const char *  ShaderCode,
const char *  VtxShaderPreprocessorDefines = "",
const char *  FrgShaderPreprocessorDefines = "" 
)

Definition at line 484 of file IOpenGLGLSLShader.cpp.

  {
    nuxAssertMsg(ShaderCode, "[IOpenGLShaderProgram::LoadIShader] Invalid shader code.");
    NUX_RETURN_IF_NULL(ShaderCode);
    NString VertexShaderSource;
    ExtractShaderString3("[Vertex Shader]", ShaderCode, VertexShaderSource, NString(VtxShaderPreprocessorDefines));
    NString PixelShaderSource;
    ExtractShaderString3("[Fragment Shader]", ShaderCode, PixelShaderSource, NString(FrgShaderPreprocessorDefines));

    ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader;
    ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader;

    vs->SetShaderCode(&VertexShaderSource[0]);
    ps->SetShaderCode(&PixelShaderSource[0]);
    vs->Compile();
    ps->Compile();

    ShaderObjectList.clear();

    AddShaderObject(vs);
    AddShaderObject(ps);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::IOpenGLShaderProgram::LoadIShaderFile ( const char *  ShaderFileName,
const char *  VtxShaderPreprocessorDefines = "",
const char *  FrgShaderPreprocessorDefines = "" 
)

Definition at line 475 of file IOpenGLGLSLShader.cpp.

  {
    nuxAssertMsg(ShaderFileName, "[IOpenGLShaderProgram::LoadIShaderFile] Invalid shader file name.");
    NUX_RETURN_IF_NULL(ShaderFileName);
    NString SourceCode;
    LoadFileToString(SourceCode, ShaderFileName);
    LoadIShader(&SourceCode[0], VtxShaderPreprocessorDefines, FrgShaderPreprocessorDefines);
  }

Here is the call graph for this function:

void nux::IOpenGLShaderProgram::LoadPixelShader ( const char *  glslshader,
const char *  FrgShaderPreprocessorDefines = "" 
)

Definition at line 522 of file IOpenGLGLSLShader.cpp.

  {
    nuxAssertMsg(glslshader, "[IOpenGLShaderProgram::LoadPixelShader] Invalid shader code.");
    NUX_RETURN_IF_NULL(glslshader);
    ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader;

    NString ProcessedShaderSource;
    NString Defines(FrgShaderPreprocessorDefines);
    InsertPreProcessorDefinitions(glslshader, ProcessedShaderSource, Defines);

    ps->SetShaderCode(glslshader);
    ps->Compile();
    AddShaderObject(ps);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::IOpenGLShaderProgram::LoadVertexShader ( const char *  glslshader,
const char *  VtxShaderPreprocessorDefines = "" 
)

Definition at line 507 of file IOpenGLGLSLShader.cpp.

  {
    nuxAssertMsg(glslshader, "[IOpenGLShaderProgram::LoadVertexShader] Invalid shader code.");
    NUX_RETURN_IF_NULL(glslshader);
    ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader;

    NString ProcessedShaderSource;
    NString Defines(VtxShaderPreprocessorDefines);
    InsertPreProcessorDefinitions(glslshader, ProcessedShaderSource, Defines);

    vs->SetShaderCode(glslshader);
    vs->Compile();
    AddShaderObject(vs);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

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:

Definition at line 563 of file IOpenGLGLSLShader.cpp.

  {
    std::vector< ObjectPtr<IOpenGLShader> >::iterator it = find(ShaderObjectList.begin(), ShaderObjectList.end(), ShaderObject);

    if (it != ShaderObjectList.end())
    {
      ShaderObjectList.erase(it);
    }
  }
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::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));
  }
}
bool nux::IOpenGLShaderProgram::SetSampler ( char *  name,
int  exture_unit 
)

Definition at line 1265 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(name);

    if (loc == -1) return false; // can't find variable

    glUniform1iARB(loc, texture_unit);
    return true;
  }

Here is the call graph for this function:

void nux::IOpenGLShaderProgram::SetShaderTracking ( bool  enabled) [static]

Definition at line 680 of file IOpenGLGLSLShader.cpp.

  {
    local::enable_tracking = enabled;
    local::last_loaded_shader = 0;
    CHECKGL(glUseProgramObjectARB(0));
  }
bool nux::IOpenGLShaderProgram::SetUniform1f ( char *  varname,
GLfloat  v0 
)

Definition at line 833 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform1fARB(loc, v0);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform1f ( GLint  loc,
GLfloat  v0 
)

Definition at line 843 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform1fARB(loc, v0);
    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform1fv ( char *  varname,
GLsizei  count,
GLfloat *  value 
)

Definition at line 986 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform1fvARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform1fv ( GLint  loc,
GLsizei  count,
GLfloat *  value 
)

Definition at line 996 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform1fvARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform1i ( char *  varname,
GLint  v0 
)

Definition at line 908 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform1iARB(loc, v0);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform1i ( GLint  loc,
GLint  v0 
)

Definition at line 918 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform1iARB(loc, v0);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform1iv ( char *  varname,
GLsizei  count,
GLint *  value 
)

Definition at line 1062 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform1ivARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform1iv ( GLint  loc,
GLsizei  count,
GLint *  value 
)

Definition at line 1072 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform1ivARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform2f ( char *  varname,
GLfloat  v0,
GLfloat  v1 
)

Definition at line 852 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform2fARB(loc, v0, v1);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform2f ( GLint  loc,
GLfloat  v0,
GLfloat  v1 
)

Definition at line 862 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform2fARB(loc, v0, v1);
    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform2fv ( char *  varname,
GLsizei  count,
GLfloat *  value 
)

Definition at line 1005 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform2fvARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform2fv ( GLint  loc,
GLsizei  count,
GLfloat *  value 
)

Definition at line 1015 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform2fvARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform2i ( char *  varname,
GLint  v0,
GLint  v1 
)

Definition at line 927 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform2iARB(loc, v0, v1);


    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform2i ( GLint  loc,
GLint  v0,
GLint  v1 
)

Definition at line 938 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform2iARB(loc, v0, v1);


    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform2iv ( char *  varname,
GLsizei  count,
GLint *  value 
)

Definition at line 1081 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform2ivARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform2iv ( GLint  loc,
GLsizei  count,
GLint *  value 
)

Definition at line 1091 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform2ivARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform3f ( char *  varname,
GLfloat  v0,
GLfloat  v1,
GLfloat  v2 
)

Definition at line 870 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform3fARB(loc, v0, v1, v2);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform3f ( GLint  loc,
GLfloat  v0,
GLfloat  v1,
GLfloat  v2 
)

Definition at line 880 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform3fARB(loc, v0, v1, v2);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform3fv ( char *  varname,
GLsizei  count,
GLfloat *  value 
)

Definition at line 1024 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform3fvARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform3fv ( GLint  loc,
GLsizei  count,
GLfloat *  value 
)

Definition at line 1034 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform3fvARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform3i ( char *  varname,
GLint  v0,
GLint  v1,
GLint  v2 
)

Definition at line 948 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform3iARB(loc, v0, v1, v2);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform3i ( GLint  loc,
GLint  v0,
GLint  v1,
GLint  v2 
)

Definition at line 958 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform3iARB(loc, v0, v1, v2);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform3iv ( char *  varname,
GLsizei  count,
GLint *  value 
)

Definition at line 1100 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform3ivARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform3iv ( GLint  loc,
GLsizei  count,
GLint *  value 
)

Definition at line 1110 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform3ivARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform4f ( char *  varname,
GLfloat  v0,
GLfloat  v1,
GLfloat  v2,
GLfloat  v3 
)

Definition at line 889 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform4fARB(loc, v0, v1, v2, v3);

    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform4f ( GLint  loc,
GLfloat  v0,
GLfloat  v1,
GLfloat  v2,
GLfloat  v3 
)

Definition at line 899 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform4fARB(loc, v0, v1, v2, v3);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform4fv ( char *  varname,
GLsizei  count,
GLfloat *  value 
)

Definition at line 1043 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform4fvARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform4fv ( GLint  loc,
GLsizei  count,
GLfloat *  value 
)

Definition at line 1053 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform4fvARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform4i ( char *  varname,
GLint  v0,
GLint  v1,
GLint  v2,
GLint  v3 
)

Definition at line 967 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform4iARB(loc, v0, v1, v2, v3);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform4i ( GLint  loc,
GLint  v0,
GLint  v1,
GLint  v2,
GLint  v3 
)

Definition at line 977 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform4iARB(loc, v0, v1, v2, v3);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniform4iv ( char *  varname,
GLsizei  count,
GLint *  value 
)

Definition at line 1119 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniform4ivARB(loc, count, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniform4iv ( GLint  loc,
GLsizei  count,
GLint *  value 
)

Definition at line 1129 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniform4ivARB(loc, count, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniformLocMatrix2fv ( GLint  loc,
GLsizei  count,
GLboolean  transpose,
GLfloat *  value 
)

Definition at line 1148 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniformMatrix2fvARB(loc, count, transpose, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniformLocMatrix3fv ( GLint  loc,
GLsizei  count,
GLboolean  transpose,
GLfloat *  value 
)

Definition at line 1167 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniformMatrix3fvARB(loc, count, transpose, value);

    return true;
  }
bool nux::IOpenGLShaderProgram::SetUniformLocMatrix4fv ( GLint  loc,
GLsizei  count,
GLboolean  transpose,
GLfloat *  value 
)

Definition at line 1186 of file IOpenGLGLSLShader.cpp.

  {
    if (loc == -1) return false; // can't find variable

    glUniformMatrix4fvARB(loc, count, transpose, value);

    return true;
  }

Here is the caller graph for this function:

bool nux::IOpenGLShaderProgram::SetUniformMatrix2fv ( char *  varname,
GLsizei  count,
GLboolean  transpose,
GLfloat *  value 
)

Definition at line 1138 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniformMatrix2fvARB(loc, count, transpose, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniformMatrix3fv ( char *  varname,
GLsizei  count,
GLboolean  transpose,
GLfloat *  value 
)

Definition at line 1157 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniformMatrix3fvARB(loc, count, transpose, value);

    return true;
  }

Here is the call graph for this function:

bool nux::IOpenGLShaderProgram::SetUniformMatrix4fv ( char *  varname,
GLsizei  count,
GLboolean  transpose,
GLfloat *  value 
)

Definition at line 1176 of file IOpenGLGLSLShader.cpp.

  {
    GLint loc = GetUniformLocationARB(varname);

    if (loc == -1) return false; // can't find variable

    glUniformMatrix4fvARB(loc, count, transpose, value);

    return true;
  }

Here is the call 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:

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

friend class GpuDevice [friend]

Reimplemented from nux::IOpenGLResource.

Definition at line 215 of file IOpenGLGLSLShader.h.


Member Data Documentation

Definition at line 204 of file IOpenGLGLSLShader.h.

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

Definition at line 158 of file Object.h.

Definition at line 214 of file IOpenGLGLSLShader.h.

Definition at line 213 of file IOpenGLGLSLShader.h.

Definition at line 211 of file IOpenGLGLSLShader.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.

Definition at line 212 of file IOpenGLGLSLShader.h.


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