Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::gfx::Node Class Reference

A Node instance represents a node in a scene graph. More...

#include "node.h"

Inheritance diagram for ion::gfx::Node:
Collaboration diagram for ion::gfx::Node:

Public Member Functions

 Node ()
 
const std::string & GetLabel () const
 Returns/sets the label of this. More...
 
void SetLabel (const std::string &label)
 
void SetStateTable (const StateTablePtr &state_table)
 StateTable management. More...
 
const StateTablePtrGetStateTable () const
 
void SetShaderProgram (const ShaderProgramPtr &shader_program)
 Shader program management. More...
 
const ShaderProgramPtrGetShaderProgram () const
 
void AddUniformBlock (const UniformBlockPtr &block)
 UniformBlock management. More...
 
void ReplaceUniformBlock (size_t index, const UniformBlockPtr &block)
 
void ClearUniformBlocks ()
 
const base::AllocVector
< UniformBlockPtr > & 
GetUniformBlocks () const
 
size_t AddShape (const ShapePtr &shape)
 Child node management. More...
 
void ReplaceShape (size_t index, const ShapePtr &shape)
 
void RemoveShape (const ShapePtr &shape)
 Removes all instances of the shape if it is contained in this' shapes. More...
 
void RemoveShapeAt (size_t index)
 Removes the Shape at the passed index if the index is valid. More...
 
void ClearShapes ()
 
const base::AllocVector
< ShapePtr > & 
GetShapes () const
 
size_t AddChild (const NodePtr &child)
 Child node management. More...
 
void ReplaceChild (size_t index, const NodePtr &child)
 
void RemoveChild (const NodePtr &child)
 Removes all instances of child from this' children if it is actually a child of this. More...
 
void RemoveChildAt (size_t index)
 Removes the child Node at the passed index if the index is valid. More...
 
void ClearChildren ()
 
const base::AllocVector
< NodePtr > & 
GetChildren () const
 
const AllocatorPtr & GetAllocator () const
 Returns the Allocator that was used for the instance. More...
 
const AllocatorPtr & GetNonNullAllocator () const
 Return our allocator, or the default allocator if the instance was declared on the stack. More...
 
const AllocatorPtr & GetAllocatorForLifetime (AllocationLifetime lifetime) const
 Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More...
 
void * operator new (size_t size)
 The standard no-parameter new operator uses the default Allocator. More...
 
void * operator new (size_t size, AllocationLifetime lifetime)
 This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator)
 This overloaded version of the new operator takes the Allocator to use directly as a parameter. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator, void *ptr)
 Special operator new for using placement new with Allocatables. More...
 
void * operator new (size_t size, void *ptr)
 The placement new operator is defined conventionally. More...
 
void operator delete (void *ptr)
 Define the delete operator to use specialized functions dealing with an Allocator. More...
 
void operator delete (void *ptr, AllocationLifetime lifetime)
 Windows requires these (or it issues C4291 warnings). More...
 
void operator delete (void *ptr, const AllocatorPtr &allocator)
 
void operator delete (void *ptr, void *ptr2)
 The placement delete operator does nothing, as usual. More...
 
int GetRefCount () const
 GetRefCount() is part of the interface necessary for SharedPtr. More...
 
size_t AddUniform (const Uniform &uniform)
 Adds a uniform to this and returns an index that can be used to refer to the uniform. More...
 
bool ReplaceUniform (size_t index, const Uniform &uniform)
 Replaces the uniform at an index with the passed value, if the index is valid. More...
 
bool RemoveUniformByName (const std::string &name)
 Removes the uniform with the passed name if it exists. More...
 
void ClearUniforms ()
 Clears the vector of uniforms in this. More...
 
const base::AllocVector
< Uniform > & 
GetUniforms () const
 Gets the vector of uniforms. More...
 
template<typename T >
bool SetUniformValue (size_t index, const T &value)
 Sets the value of the uniform at an index if the index is valid. More...
 
template<typename T >
bool SetUniformValueAt (size_t index, size_t array_index, const T &value)
 Sets the value of the array uniform at an index if the index is valid. More...
 
size_t GetUniformIndex (const std::string &name) const
 Returns the index of the uniform this with the given name, if it exists. More...
 
template<typename T >
bool SetUniformByName (const std::string &name, const T &value)
 Convenience function to set the value of a uniform specified by name. More...
 
template<typename T >
bool SetUniformByNameAt (const std::string &name, size_t array_index, const T &value)
 Convenience function to set the value of an element of an array uniform designated by name. More...
 
void Enable (bool enable)
 Enables or disables the UniformHolder. More...
 
bool IsEnabled () const
 

Protected Member Functions

 ~Node () override
 The destructor is protected because all base::Referent classes must have protected or private destructors. More...
 

Detailed Description

A Node instance represents a node in a scene graph.

It can have any or all of the following:

  • Shapes to draw.
  • A shader program to apply to all shapes in the node's subgraph.
  • Uniform variables (including textures) used by shaders in the node's subgraph.
  • UniformBlocks containing Uniforms. These are sent after the uniforms above.
  • Child nodes.

Definition at line 45 of file node.h.

Constructor & Destructor Documentation

ion::gfx::Node::Node ( )

Definition at line 23 of file node.cc.

ion::gfx::Node::~Node ( )
overrideprotected

The destructor is protected because all base::Referent classes must have protected or private destructors.

Definition at line 29 of file node.cc.

Member Function Documentation

size_t ion::gfx::Node::AddChild ( const NodePtr child)
inline

Child node management.

NULL children are not added, and ReplaceChild() does nothing if the index is invalid. AddChild() returns the index of the child added, or base::kInvalidIndex if the child is NULL. Note that the index may change after a call to RemoveChild[At]().

Definition at line 122 of file node.h.

References ion::base::SharedPtr< T >::Get(), and ion::base::kInvalidIndex.

size_t ion::gfx::Node::AddShape ( const ShapePtr shape)
inline

Child node management.

NULL children are not added, and ReplaceChild() Shape management. NULL shapes are not added, and ReplaceShape() does nothing if the index is invalid. AddShape returns the index of the Shape added, or base::kInvaidIndex if the Shape is NULL. Note that the index may change if RemoveShape[At]() is called.

Definition at line 85 of file node.h.

References ion::base::SharedPtr< T >::Get(), and ion::base::kInvalidIndex.

size_t ion::gfx::UniformHolder::AddUniform ( const Uniform uniform)
inlineinherited

Adds a uniform to this and returns an index that can be used to refer to the uniform.

Note that this index is invalid if ClearUniforms() is ever used, and may refer to a different uniform if the uniform is ever replaced with ReplaceUniform(). Returns base::kInvalidIndex if an attempt is made to add an invalid uniform.

Definition at line 46 of file uniformholder.h.

References ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::IsValid(), and ion::base::kInvalidIndex.

Referenced by ion::text::BasicBuilder::UpdateUniforms(), and ion::text::OutlineBuilder::UpdateUniforms().

void ion::gfx::Node::AddUniformBlock ( const UniformBlockPtr block)
inline

UniformBlock management.

NULL blocks are not added, and ReplaceUniformBlock() does nothing if the index is invalid.

Definition at line 67 of file node.h.

References ion::base::SharedPtr< T >::Get().

void ion::gfx::Node::ClearChildren ( )
inline

Definition at line 153 of file node.h.

void ion::gfx::Node::ClearShapes ( )
inline

Definition at line 115 of file node.h.

void ion::gfx::Node::ClearUniformBlocks ( )
inline

Definition at line 75 of file node.h.

void ion::gfx::UniformHolder::ClearUniforms ( )
inlineinherited

Clears the vector of uniforms in this.

Definition at line 78 of file uniformholder.h.

Referenced by ion::text::BasicBuilder::UpdateUniforms(), and ion::text::OutlineBuilder::UpdateUniforms().

void ion::gfx::UniformHolder::Enable ( bool  enable)
inlineinherited

Enables or disables the UniformHolder.

Disabled holders are skipped over during rendering; their values are not sent to OpenGL. UniformHolders are enabled by default.

Definition at line 137 of file uniformholder.h.

const AllocatorPtr& ion::base::Allocatable::GetAllocator ( ) const
inlineinherited

Returns the Allocator that was used for the instance.

This will be NULL if the instance was declared on the stack or created with normal placement new.

Definition at line 68 of file allocatable.h.

References allocator_.

Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().

const AllocatorPtr& ion::base::Allocatable::GetAllocatorForLifetime ( AllocationLifetime  lifetime) const
inlineinherited
const base::AllocVector<NodePtr>& ion::gfx::Node::GetChildren ( ) const
inline

Definition at line 154 of file node.h.

const std::string& ion::gfx::Node::GetLabel ( ) const
inline

Returns/sets the label of this.

Definition at line 50 of file node.h.

const AllocatorPtr& ion::base::Allocatable::GetNonNullAllocator ( ) const
inlineinherited

Return our allocator, or the default allocator if the instance was declared on the stack.

Definition at line 72 of file allocatable.h.

References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().

int ion::base::Shareable::GetRefCount ( ) const
inlineinherited

GetRefCount() is part of the interface necessary for SharedPtr.

Definition at line 34 of file shareable.h.

Referenced by ion::base::Notifier::RemoveReceiver().

const ShaderProgramPtr& ion::gfx::Node::GetShaderProgram ( ) const
inline

Definition at line 63 of file node.h.

const base::AllocVector<ShapePtr>& ion::gfx::Node::GetShapes ( ) const
inline

Definition at line 116 of file node.h.

const StateTablePtr& ion::gfx::Node::GetStateTable ( ) const
inline

Definition at line 57 of file node.h.

const base::AllocVector<UniformBlockPtr>& ion::gfx::Node::GetUniformBlocks ( ) const
inline

Definition at line 76 of file node.h.

size_t ion::gfx::UniformHolder::GetUniformIndex ( const std::string &  name) const
inherited

Returns the index of the uniform this with the given name, if it exists.

The Uniform must have been added with AddUniform() or ReplaceUniform(). If no uniform with the name exists in this then returns ion::base::kInvalidIndex. Note that this is a relatively slow operation and should be used sparingly.

Definition at line 30 of file uniformholder.cc.

References DCHECK, ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::GetIndexInRegistry(), ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::GetRegistry(), ion::gfx::ShaderInputRegistry::GetSpecs(), ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::IsValid(), and ion::base::kInvalidIndex.

const base::AllocVector<Uniform>& ion::gfx::UniformHolder::GetUniforms ( ) const
inlineinherited
bool ion::gfx::UniformHolder::IsEnabled ( ) const
inlineinherited

Definition at line 138 of file uniformholder.h.

void ion::base::Allocatable::operator delete ( void *  ptr)
inlineinherited

Define the delete operator to use specialized functions dealing with an Allocator.

Definition at line 109 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
AllocationLifetime  lifetime 
)
inlineinherited

Windows requires these (or it issues C4291 warnings).

Definition at line 112 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
const AllocatorPtr allocator 
)
inlineinherited

Definition at line 113 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
void *  ptr2 
)
inlineinherited

The placement delete operator does nothing, as usual.

Definition at line 118 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size)
inlineinherited

The standard no-parameter new operator uses the default Allocator.

Definition at line 84 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
AllocationLifetime  lifetime 
)
inlineinherited

This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.

Definition at line 88 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator 
)
inlineinherited

This overloaded version of the new operator takes the Allocator to use directly as a parameter.

If the Allocator pointer is NULL, this uses the default Allocator.

Definition at line 95 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator,
void *  ptr 
)
inlineinherited

Special operator new for using placement new with Allocatables.

Definition at line 100 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
void *  ptr 
)
inlineinherited

The placement new operator is defined conventionally.

Definition at line 105 of file allocatable.h.

void ion::gfx::Node::RemoveChild ( const NodePtr child)
inline

Removes all instances of child from this' children if it is actually a child of this.

Note that this is not an efficient operation if there are many children.

Definition at line 137 of file node.h.

void ion::gfx::Node::RemoveChildAt ( size_t  index)
inline

Removes the child Node at the passed index if the index is valid.

Note that this is not an efficient operation if there are many children.

Definition at line 147 of file node.h.

void ion::gfx::Node::RemoveShape ( const ShapePtr shape)
inline

Removes all instances of the shape if it is contained in this' shapes.

Note that this is not an efficient operation if this contains many Shapes.

Definition at line 99 of file node.h.

void ion::gfx::Node::RemoveShapeAt ( size_t  index)
inline

Removes the Shape at the passed index if the index is valid.

Note that this is not an efficient operation if this contains many Shapes.

Definition at line 109 of file node.h.

bool ion::gfx::UniformHolder::RemoveUniformByName ( const std::string &  name)
inlineinherited

Removes the uniform with the passed name if it exists.

Returns true iff the uniform existed and hence got removed. Note that this will change the indices of other uniforms within the holder.

Definition at line 69 of file uniformholder.h.

References ion::base::kInvalidIndex.

void ion::gfx::Node::ReplaceChild ( size_t  index,
const NodePtr child 
)
inline

Definition at line 130 of file node.h.

References ion::base::SharedPtr< T >::Get().

void ion::gfx::Node::ReplaceShape ( size_t  index,
const ShapePtr shape 
)
inline

Definition at line 93 of file node.h.

References ion::base::SharedPtr< T >::Get().

bool ion::gfx::UniformHolder::ReplaceUniform ( size_t  index,
const Uniform uniform 
)
inlineinherited

Replaces the uniform at an index with the passed value, if the index is valid.

Returns if the replacement is successful.

Definition at line 57 of file uniformholder.h.

References ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::IsValid().

void ion::gfx::Node::ReplaceUniformBlock ( size_t  index,
const UniformBlockPtr block 
)
inline

Definition at line 71 of file node.h.

References ion::base::SharedPtr< T >::Get().

void ion::gfx::Node::SetLabel ( const std::string &  label)
inline

Definition at line 51 of file node.h.

References label.

void ion::gfx::Node::SetShaderProgram ( const ShaderProgramPtr shader_program)
inline

Shader program management.

Definition at line 60 of file node.h.

void ion::gfx::Node::SetStateTable ( const StateTablePtr state_table)
inline

StateTable management.

Definition at line 54 of file node.h.

template<typename T >
bool ion::gfx::UniformHolder::SetUniformByName ( const std::string &  name,
const T value 
)
inlineinherited

Convenience function to set the value of a uniform specified by name.

This returns false if there is no uniform with that name or the value type does not match.

Definition at line 113 of file uniformholder.h.

References ion::base::kInvalidIndex, and value.

template<typename T >
bool ion::gfx::UniformHolder::SetUniformByNameAt ( const std::string &  name,
size_t  array_index,
const T value 
)
inlineinherited

Convenience function to set the value of an element of an array uniform designated by name.

This returns false if:

  • There is no uniform matching name.
  • Value type 'T' does not match the uniform array type.
  • array_index exceeds the size of the uniform array.

Definition at line 125 of file uniformholder.h.

References ion::base::kInvalidIndex.

template<typename T >
bool ion::gfx::UniformHolder::SetUniformValue ( size_t  index,
const T value 
)
inlineinherited

Sets the value of the uniform at an index if the index is valid.

Returns true if the index is valid and the set was successful (i.e., T is a valid type for the selected uniform), and false otherwise.

Definition at line 86 of file uniformholder.h.

Referenced by ion::text::Builder::UpdateFontImageTextureUniform(), ion::text::BasicBuilder::UpdateUniforms(), and ion::text::OutlineBuilder::UpdateUniforms().

template<typename T >
bool ion::gfx::UniformHolder::SetUniformValueAt ( size_t  index,
size_t  array_index,
const T value 
)
inlineinherited

Sets the value of the array uniform at an index if the index is valid.

Returns true if the index is valid and the set was successful (i.e., T is a valid type for the selected uniform), and false otherwise.

Definition at line 95 of file uniformholder.h.


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