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

A Shape object represents a shape (vertices + indices) to draw. More...

#include "shape.h"

Inheritance diagram for ion::gfx::Shape:
Collaboration diagram for ion::gfx::Shape:

Public Types

enum  PrimitiveType {
  kLines,
  kLineLoop,
  kLineStrip,
  kPoints,
  kTriangles,
  kTriangleFan,
  kTriangleStrip
}
 Supported primitive types. More...
 

Public Member Functions

 Shape ()
 
const std::string & GetLabel () const
 Returns/sets the label of this. More...
 
void SetLabel (const std::string &label)
 
void SetPrimitiveType (PrimitiveType type)
 Sets/returns the type of primitive to draw. More...
 
PrimitiveType GetPrimitiveType () const
 
void SetAttributeArray (const AttributeArrayPtr &attribute_array)
 Sets/returns the vertices used to create the primitives. More...
 
const AttributeArrayPtrGetAttributeArray () const
 
void SetIndexBuffer (const IndexBufferPtr &index_buffer)
 Sets/returns the index buffer. More...
 
const IndexBufferPtrGetIndexBuffer () const
 
size_t AddVertexRange (const math::Range1i &range)
 By default, a Shape draws all of its vertices (if there is no IndexBuffer) or all of its indexed vertices (if there is an IndexBuffer). More...
 
void SetVertexRange (size_t i, const math::Range1i &range)
 Modifies the specified vertex range if the passed index is valid (i.e., there is a range at i that has been added with AddVertexRange()); otherwise this logs an error message. More...
 
void ClearVertexRanges ()
 Removes all ranges from the Shape. More...
 
const math::Range1i GetVertexRange (size_t i) const
 Returns the i-th vertex range. More...
 
size_t GetVertexRangeCount () const
 Returns the number of vertex ranges in the Shape. More...
 
void EnableVertexRange (size_t i, bool enable)
 Enables or disables a specific vertex range. More...
 
bool IsVertexRangeEnabled (size_t i) const
 Returns whether the i-th vertex range is enabled, or false if i does not refer to a valid range. More...
 
void SetInstanceCount (int count)
 Sets the instance count of the shape. More...
 
int GetInstanceCount () const
 Returns the instance count that the shape is set to. More...
 
void SetVertexRangeInstanceCount (size_t i, int instance_count)
 Sets/Gets the instance count of vertex range. More...
 
int GetVertexRangeInstanceCount (size_t i) const
 Returns the instance count that the vertex range is set to. More...
 
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...
 

Protected Member Functions

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

Detailed Description

A Shape object represents a shape (vertices + indices) to draw.

Definition at line 32 of file shape.h.

Member Enumeration Documentation

Supported primitive types.

Enumerator
kLines 
kLineLoop 
kLineStrip 
kPoints 
kTriangles 
kTriangleFan 
kTriangleStrip 

Definition at line 35 of file shape.h.

Constructor & Destructor Documentation

ion::gfx::Shape::Shape ( )

Definition at line 28 of file shape.cc.

ion::gfx::Shape::~Shape ( )
overrideprotected

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

Definition at line 31 of file shape.cc.

Member Function Documentation

size_t ion::gfx::Shape::AddVertexRange ( const math::Range1i range)

By default, a Shape draws all of its vertices (if there is no IndexBuffer) or all of its indexed vertices (if there is an IndexBuffer).

This function modifies this behavior by adding a vertex range [min, max) to the Shape. The vertex range applies to the indices in the IndexBuffer if there is one; otherwise it applies to the vertices themselves. The new range is enabled by default. If the range is empty, a warning is printed and the range is not added. Returns the index of the added range, or base::kInvalidIndex if the range was not added.

Definition at line 34 of file shape.cc.

References ion::base::kInvalidIndex, LOG, and ion::port::WARNING.

void ion::gfx::Shape::ClearVertexRanges ( )
inline

Removes all ranges from the Shape.

Definition at line 86 of file shape.h.

void ion::gfx::Shape::EnableVertexRange ( size_t  i,
bool  enable 
)

Enables or disables a specific vertex range.

Does nothing if i does not refer to a valid range.

Definition at line 60 of file shape.cc.

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 AttributeArrayPtr& ion::gfx::Shape::GetAttributeArray ( ) const
inline

Definition at line 59 of file shape.h.

const IndexBufferPtr& ion::gfx::Shape::GetIndexBuffer ( ) const
inline

Definition at line 68 of file shape.h.

int ion::gfx::Shape::GetInstanceCount ( ) const
inline

Returns the instance count that the shape is set to.

Definition at line 106 of file shape.h.

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

Returns/sets the label of this.

Definition at line 48 of file shape.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().

PrimitiveType ion::gfx::Shape::GetPrimitiveType ( ) const
inline

Definition at line 53 of file shape.h.

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 math::Range1i ion::gfx::Shape::GetVertexRange ( size_t  i) const

Returns the i-th vertex range.

Returns an empty range if the index is not valid.

Definition at line 54 of file shape.cc.

size_t ion::gfx::Shape::GetVertexRangeCount ( ) const
inline

Returns the number of vertex ranges in the Shape.

Definition at line 91 of file shape.h.

int ion::gfx::Shape::GetVertexRangeInstanceCount ( size_t  i) const

Returns the instance count that the vertex range is set to.

Definition at line 76 of file shape.cc.

bool ion::gfx::Shape::IsVertexRangeEnabled ( size_t  i) const

Returns whether the i-th vertex range is enabled, or false if i does not refer to a valid range.

Definition at line 65 of file shape.cc.

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::Shape::SetAttributeArray ( const AttributeArrayPtr attribute_array)
inline

Sets/returns the vertices used to create the primitives.

Definition at line 56 of file shape.h.

void ion::gfx::Shape::SetIndexBuffer ( const IndexBufferPtr index_buffer)
inline

Sets/returns the index buffer.

A NULL index buffer (the default) signifies that the vertices of the shape are not indexed.

Definition at line 65 of file shape.h.

void ion::gfx::Shape::SetInstanceCount ( int  count)
inline

Sets the instance count of the shape.

If non-zero value is set, the shape will be drawn multiple times using the instanced drawing functions. The number of instances drawn depends on what instance_count is set to. Zero means instanced drawing is disabled and the shape will be drawn with the regular drawing functions.

Definition at line 104 of file shape.h.

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

Definition at line 49 of file shape.h.

References label.

void ion::gfx::Shape::SetPrimitiveType ( PrimitiveType  type)
inline

Sets/returns the type of primitive to draw.

Definition at line 52 of file shape.h.

References type.

void ion::gfx::Shape::SetVertexRange ( size_t  i,
const math::Range1i range 
)

Modifies the specified vertex range if the passed index is valid (i.e., there is a range at i that has been added with AddVertexRange()); otherwise this logs an error message.

Definition at line 45 of file shape.cc.

References LOG, and ion::port::WARNING.

void ion::gfx::Shape::SetVertexRangeInstanceCount ( size_t  i,
int  instance_count 
)

Sets/Gets the instance count of vertex range.

If non-zero value is set, the vertex range will be drawn multiple times using the instanced drawing functions. The number of instances drawn depends on what instance_count is set to. Zero means instanced drawing is disabled and the vertex range will be drawn with the regular drawing functions.

Definition at line 71 of file shape.cc.


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