Public Member Functions | Static Public Member Functions

Tiny2D::Texture Class Reference

Texture handle (optionally render target too) More...

#include <Tiny2D.h>

List of all members.

Public Member Functions

 Texture ()
 Creates an empty texture.
 Texture (const Texture &other)
 Copy constructor; internally only increases texture reference count.
 ~Texture ()
 Destroys the texture if not done before.
ResourceState GetState () const
 Gets resource state.
void operator= (const Texture &other)
 Copy operator; internally only increases texture reference count.
bool operator== (const Texture &other) const
 Equality operator.
bool operator!= (const Texture &other) const
 Inequality operator.
bool Create (const std::string &path, bool immediate=true)
 Creates texture of given name; 'immediate' set to true indicates to load it synchronously.
bool CreateRenderTarget (int width, int height)
 Creates texture that can also be used as a render target; created texture has RGBA components.
void Destroy ()
 Destroys texture.
bool Save (const std::string &path, bool saveAlpha=false)
 Saves texture under folowing path; supported formats are: PNG and BMP; by default alpha channel is not saved even if present.
void Draw (const Shape::DrawParams *params, const Sampler &sampler=Sampler::Default)
 Draws texture with given shape parameters.
void Draw (const Vec2 &position=Vec2(0.0f, 0.0f), float rotation=0.0f, float scale=1.0f, const Color &color=Color::White)
 Draws texture.
int GetWidth ()
 Gets texture width (note: applies fake scaling if the texture was loaded as part of non-default texture version set - see App::DisplayParameters::textureVersionSizeMultiplier)
int GetHeight ()
 Gets texture height (note: applies fake scaling if the texture was loaded as part of non-default texture version set - see App::DisplayParameters::textureVersionSizeMultiplier)
int GetRealWidth ()
 Gets the actual texture width in pixels.
int GetRealHeight ()
 Gets teh actual texture height in pixels.
bool GetPixels (std::vector< unsigned char > &pixels, bool removeAlpha=true)
 Gets data of all of the texture pixels; every pixel is described by 3 or 4 values (Red Green Blue and optionally Alpha); returned pixels array has GetRealWidth() * GetRealHeight() * (3 or 4) values.
void BeginDrawing (const Color *clearColor=NULL)
 Begins rendering to texture; only works for render targets; optional clearColor specifies color to which to clear render target.
void Clear (const Color &color=Color::Black)
 Clears texture to given color; only works for render targets.
void EndDrawing ()
 Ends rendering to this texture; only works for render targets.

Static Public Member Functions

static void DrawBlended (Texture &texture0, Texture &texture1, const Shape::DrawParams *params, float scale)
 Draws result of blending between 2 textures (useful when rendering animated objects)

Detailed Description

Texture handle (optionally render target too)


Constructor & Destructor Documentation

Tiny2D::Texture::Texture (  )

Creates an empty texture.

Tiny2D::Texture::Texture ( const Texture other )

Copy constructor; internally only increases texture reference count.

Tiny2D::Texture::~Texture (  )

Destroys the texture if not done before.


Member Function Documentation

void Tiny2D::Texture::BeginDrawing ( const Color clearColor = NULL )

Begins rendering to texture; only works for render targets; optional clearColor specifies color to which to clear render target.

void Tiny2D::Texture::Clear ( const Color color = Color::Black )

Clears texture to given color; only works for render targets.

bool Tiny2D::Texture::Create ( const std::string &  path,
bool  immediate = true 
)

Creates texture of given name; 'immediate' set to true indicates to load it synchronously.

bool Tiny2D::Texture::CreateRenderTarget ( int  width,
int  height 
)

Creates texture that can also be used as a render target; created texture has RGBA components.

void Tiny2D::Texture::Destroy (  )

Destroys texture.

void Tiny2D::Texture::Draw ( const Shape::DrawParams params,
const Sampler sampler = Sampler::Default 
)

Draws texture with given shape parameters.

void Tiny2D::Texture::Draw ( const Vec2 position = Vec2(0.0f, 0.0f),
float  rotation = 0.0f,
float  scale = 1.0f,
const Color color = Color::White 
)

Draws texture.

static void Tiny2D::Texture::DrawBlended ( Texture texture0,
Texture texture1,
const Shape::DrawParams params,
float  scale 
) [static]

Draws result of blending between 2 textures (useful when rendering animated objects)

void Tiny2D::Texture::EndDrawing (  )

Ends rendering to this texture; only works for render targets.

int Tiny2D::Texture::GetHeight (  )

Gets texture height (note: applies fake scaling if the texture was loaded as part of non-default texture version set - see App::DisplayParameters::textureVersionSizeMultiplier)

bool Tiny2D::Texture::GetPixels ( std::vector< unsigned char > &  pixels,
bool  removeAlpha = true 
)

Gets data of all of the texture pixels; every pixel is described by 3 or 4 values (Red Green Blue and optionally Alpha); returned pixels array has GetRealWidth() * GetRealHeight() * (3 or 4) values.

int Tiny2D::Texture::GetRealHeight (  )

Gets teh actual texture height in pixels.

int Tiny2D::Texture::GetRealWidth (  )

Gets the actual texture width in pixels.

ResourceState Tiny2D::Texture::GetState (  ) const

Gets resource state.

int Tiny2D::Texture::GetWidth (  )

Gets texture width (note: applies fake scaling if the texture was loaded as part of non-default texture version set - see App::DisplayParameters::textureVersionSizeMultiplier)

bool Tiny2D::Texture::operator!= ( const Texture other ) const

Inequality operator.

void Tiny2D::Texture::operator= ( const Texture other )

Copy operator; internally only increases texture reference count.

bool Tiny2D::Texture::operator== ( const Texture other ) const

Equality operator.

bool Tiny2D::Texture::Save ( const std::string &  path,
bool  saveAlpha = false 
)

Saves texture under folowing path; supported formats are: PNG and BMP; by default alpha channel is not saved even if present.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines