Support Forum       G3D Web Page     
Classes | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
G3D::IconSet Class Reference


A set of small image files packed into a single G3D::Texture for efficiency. More...

Inherits G3D::ReferenceCountedObject.

Public Member Functions

const Stringfilename (int index) const
 Returns the filename of the icon with the given index. More...
 
Icon get (int index) const
 
Icon get (const String &s) const
 
Icon get (const char *s) const
 
int getIndex (const String &s) const
 Returns the index of the icon named s. More...
 
int getIndex (const char *s) const
 
const Rect2Drect (int index) const
 Texture coordinates. More...
 
int size () const
 Number of icons. More...
 
const shared_ptr< Texture > & texture () const
 

Static Public Member Functions

static shared_ptr< IconSetfromFile (const String &filename)
 Load an existing icon set from a file. More...
 
static void makeIconSet (const String &sourceDir, const String &outFile)
 Load all of the image files (see G3D::Image::supportedFormat) from sourceDir and its subdirectories and pack them into a single G3D::IconSet named outFile. More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 

Detailed Description


A set of small image files packed into a single G3D::Texture for efficiency.

Examples:

shared_ptr<IconSet> icons = IconSet::fromFile("tango.icn");
debugPane->addButton(icons->get("16x16/actions/document-open.png"));
int index = icons->getIndex("16x16/actions/edit-clear.png");
debugPane->addButton(icons->get(index));

Member Function Documentation

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ filename()

const String& G3D::IconSet::filename ( int  index) const
inline

Returns the filename of the icon with the given index.

◆ fromFile()

static shared_ptr<IconSet> G3D::IconSet::fromFile ( const String filename)
static

Load an existing icon set from a file.

◆ get() [1/3]

Icon G3D::IconSet::get ( int  index) const

◆ get() [2/3]

Icon G3D::IconSet::get ( const String s) const
inline

◆ get() [3/3]

Icon G3D::IconSet::get ( const char *  s) const
inline

◆ getIndex() [1/2]

int G3D::IconSet::getIndex ( const String s) const

Returns the index of the icon named s.

Referenced by get(), and getIndex().

◆ getIndex() [2/2]

int G3D::IconSet::getIndex ( const char *  s) const
inline

◆ makeIconSet()

static void G3D::IconSet::makeIconSet ( const String sourceDir,
const String outFile 
)
static

Load all of the image files (see G3D::Image::supportedFormat) from sourceDir and its subdirectories and pack them into a single G3D::IconSet named outFile.

The packing algorithm is not optimal. Future versions of G3D may provide improved packing, and you can also create icon sets with your own packing algorithm–the indexing scheme allows arbitrary packing algorithms within the same file format.

Ignores .svn and CVS directories.

◆ rect()

const Rect2D& G3D::IconSet::rect ( int  index) const
inline

Texture coordinates.

◆ size()

int G3D::IconSet::size ( ) const
inline

Number of icons.

◆ texture()

const shared_ptr<Texture>& G3D::IconSet::texture ( ) const
inline

documentation generated on Wed Nov 24 2021 08:01:57 using doxygen 1.8.15