Simple++
Powerfull and lightning fast C++ Library
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Graphic::Texture< T > Class Template Reference

#include <Texture.h>

Inheritance diagram for Graphic::Texture< T >:
BasicIO BasicSimpleIO Graphic::TextureLoadable< T >

Public Member Functions

 Texture (typename Format format=Format::RGB)
 Empty constructor, create an image unallocated of size (0:0) More...
 
 Texture (const Math::Vec2< Size > &size, typename Format format=Format::RGB)
 Constructor to create an not initialized image of specified size. More...
 
 Texture (const WString &filePath)
 create a new image using a path to a file (only support official file format) More...
 
 Texture (std::fstream *fileStream)
 create a new Texture using a file stream to read. More...
 
 Texture (const Texture< T > &image)
 copy constructor More...
 
 Texture (const T *dataBuffer, const Math::Vec2< Size > &size, typename LoadingFormat loadingFormat=LoadingFormat::RGB, bool invertY=false)
 create a Texture from a image data More...
 
 Texture (Texture< T > &&image)
 move constructor More...
 
 ~Texture ()
 
const Math::Vec2< Size > & getSize (typename Vector< _Image< T >>::Size i=0) const
 get the actual size (width:height) of the image More...
 
unsigned int getWidth (typename Vector< _Image< T >>::Size i=0) const
 get the actual width of the image More...
 
unsigned int getHeight (typename Vector< _Image< T >>::Size i=0) const
 get the actual height of the image More...
 
void setDatas (const T *data, const Math::Vec2< Size > &size, typename LoadingFormat loadingFormat=LoadingFormat::RGB, bool invertY=false)
 set the data from an another data buffer. More...
 
void clear (const Math::Vec2< Size > &size)
 reset this image with a new size. More...
 
void clear (const Math::Vec2< Size > &size, typename Format format)
 reset this image with a new size and a new format More...
 
_Image< T > * getMipmap (typename Vector< _Image< T >>::Size i=0)
 get a mipmap from this texture More...
 
_Image< T > * operator[] (typename Vector< _Image< T >>::Size i)
 get a mipmap from this texture More...
 
void generateMipmaps ()
 generate the mipmap from the actual lod 0 More...
 
const T * getDatas (typename Vector< _Image< T >>::Size i=0) const
 get the data buffer of this image More...
 
T * getDatas (typename Vector< _Image< T >>::Size i=0)
 get the data buffer of this image More...
 
const T * getPixel (typename Vector< _Image< T >>::Size i, unsigned int x, unsigned int y) const
 get a pixel from this texture More...
 
void setPixel (typename Vector< _Image< T >>::Size i, unsigned int x, unsigned int y, const T *p)
 set a pixel inside this image More...
 
Texture< T > & operator= (const Texture< T > &image)
 copy operator More...
 
Texture< T > & operator= (Texture< T > &&image)
 move operator More...
 
bool read (std::fstream *fileStream)
 read from a file stream More...
 
bool write (std::fstream *fileStream) const
 write this object as binary into a file stream More...
 
Format getFormat () const
 get the format of this image More...
 
Vector< _Image< T > * >::Size getNumMipmaps () const
 get the number of mipmap of this texture More...
 
- Public Member Functions inherited from BasicSimpleIO
bool read (std::fstream *fileStream)
 read from a file stream More...
 
bool write (std::fstream *fileStream) const
 write this object as binary into a file stream More...
 

Protected Types

enum  ctor { null }
 

Protected Member Functions

 Texture (ctor)
 
bool _read (std::fstream *fileStream)
 
void _unload ()
 

Protected Attributes

Vector< _Image< T > * > datas
 

Member Enumeration Documentation

template<typename T = unsigned char>
enum Graphic::Texture::ctor
protected
Enumerator
null 

Constructor & Destructor Documentation

template<typename T >
Graphic::Texture< T >::Texture ( typename Format  format = Format::RGB)

Empty constructor, create an image unallocated of size (0:0)

Parameters
formatof the image
template<typename T >
Graphic::Texture< T >::Texture ( const Math::Vec2< Size > &  size,
typename Format  format = Format::RGB 
)

Constructor to create an not initialized image of specified size.

Parameters
sizesize of the image to create.
formatof the image
template<typename T >
Graphic::Texture< T >::Texture ( const WString filePath)

create a new image using a path to a file (only support official file format)

template<typename T >
Graphic::Texture< T >::Texture ( std::fstream *  fileStream)

create a new Texture using a file stream to read.

Parameters
fileStreamfile stream to read.
template<typename T >
Graphic::Texture< T >::Texture ( const Texture< T > &  image)

copy constructor

template<typename T >
Graphic::Texture< T >::Texture ( const T *  dataBuffer,
const Math::Vec2< Size > &  size,
typename LoadingFormat  loadingFormat = LoadingFormat::RGB,
bool  invertY = false 
)

create a Texture from a image data

Parameters
dataBufferbuffer of the image to copy.
sizesize of the image to copy.
formatof the image
invertYif the image has to be flipped vertically or not.
template<typename T >
Graphic::Texture< T >::Texture ( Texture< T > &&  image)

move constructor

template<typename T >
Graphic::Texture< T >::~Texture ( )
template<typename T >
Graphic::Texture< T >::Texture ( ctor  )
protected

Member Function Documentation

template<typename T >
bool Graphic::Texture< T >::_read ( std::fstream *  fileStream)
protected
template<typename T >
void Graphic::Texture< T >::_unload ( )
protected
template<typename T >
void Graphic::Texture< T >::clear ( const Math::Vec2< Size > &  size)

reset this image with a new size.

Parameters
sizenew size
template<typename T >
void Graphic::Texture< T >::clear ( const Math::Vec2< Size > &  size,
typename Format  format 
)

reset this image with a new size and a new format

Parameters
sizenew size
formatnew format of the image
template<typename T >
void Graphic::Texture< T >::generateMipmaps ( )

generate the mipmap from the actual lod 0

template<typename T >
const T * Graphic::Texture< T >::getDatas ( typename Vector< _Image< T >>::Size  i = 0) const

get the data buffer of this image

Parameters
inumber of mipmap (0 = original image)
Returns
data buffer
template<typename T >
T * Graphic::Texture< T >::getDatas ( typename Vector< _Image< T >>::Size  i = 0)

get the data buffer of this image

Parameters
inumber of mipmap (0 = original image)
Returns
data buffer
template<typename T >
Format Graphic::Texture< T >::getFormat ( ) const

get the format of this image

Returns
format of this image (its castable in unsigned char to retrieve the number of components)
template<typename T >
unsigned int Graphic::Texture< T >::getHeight ( typename Vector< _Image< T >>::Size  i = 0) const

get the actual height of the image

Parameters
inum of the mipmap
Returns
actual height of this image
template<typename T >
_Image< T > * Graphic::Texture< T >::getMipmap ( typename Vector< _Image< T >>::Size  i = 0)

get a mipmap from this texture

Parameters
imipmap number (0 mean original size)
Returns
pointer to the mipmap wanted.
template<typename T >
Vector< _Image< T > * >::Size Graphic::Texture< T >::getNumMipmaps ( ) const

get the number of mipmap of this texture

Returns
number of mipmaps
template<typename T >
const T * Graphic::Texture< T >::getPixel ( typename Vector< _Image< T >>::Size  i,
unsigned int  x,
unsigned int  y 
) const

get a pixel from this texture

Parameters
imipmap level
xx coordinate of the pixel
yy coordinate of the pixel
Returns
the pixel from the picture at the specified 2D coordinate.
template<typename T >
const Math::Vec2< Size > & Graphic::Texture< T >::getSize ( typename Vector< _Image< T >>::Size  i = 0) const

get the actual size (width:height) of the image

Parameters
inum of the mipmap
Returns
the actual size of this image
template<typename T >
unsigned int Graphic::Texture< T >::getWidth ( typename Vector< _Image< T >>::Size  i = 0) const

get the actual width of the image

Parameters
inum of the mipmap
Returns
actual width of this image
template<typename T >
Texture< T > & Graphic::Texture< T >::operator= ( const Texture< T > &  image)

copy operator

Parameters
imageImage to copy
template<typename T >
Texture< T > & Graphic::Texture< T >::operator= ( Texture< T > &&  image)

move operator

Parameters
imageImage to move from
template<typename T >
_Image< T > * Graphic::Texture< T >::operator[] ( typename Vector< _Image< T >>::Size  i)

get a mipmap from this texture

Parameters
imipmap number (0 mean the original size)
Returns
pointer to the mipmap
template<typename T >
bool Graphic::Texture< T >::read ( std::fstream *  fileStream)

read from a file stream

Parameters
fileStreamstream used to read load this object
Returns
boolean to know if the operation is a success of not.
template<typename T >
void Graphic::Texture< T >::setDatas ( const T *  data,
const Math::Vec2< Size > &  size,
typename LoadingFormat  loadingFormat = LoadingFormat::RGB,
bool  invertY = false 
)

set the data from an another data buffer.

Parameters
dataData buffer to copy
sizesize of the new image
invertYif the image has to be flipped vertically or not.
template<typename T >
void Graphic::Texture< T >::setPixel ( typename Vector< _Image< T >>::Size  i,
unsigned int  x,
unsigned int  y,
const T *  p 
)

set a pixel inside this image

Parameters
imipmap level
xx coordinate of the pixel
yy coordinate of the pixel
pThe pixel to set.
template<typename T >
bool Graphic::Texture< T >::write ( std::fstream *  fileStream) const

write this object as binary into a file stream

Parameters
fileStreamstream used to write this object
Returns
boolean to know if the operation is a success of not.

Member Data Documentation

template<typename T = unsigned char>
Vector<_Image<T> * > Graphic::Texture< T >::datas
protected

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