clan::Texture2D Class Reference - ClanLib SDK
Description: clan::Texture2D Class Reference

Public Member Functions | List of all members
clan::Texture2D Class Reference
clanDisplay Display

2D texture object class. More...

`#include <texture_2d.h>`

Inheritance diagram for clan::Texture2D:

## Public Member Functions
| Texture2D ()
| Constructs a null instance.
| Texture2D (const std::shared_ptr< Texture_Impl > &impl)
| Texture2D (GraphicContext &context, const PixelBuffer &image, bool is_srgb=false)
| Texture2D (GraphicContext &context, const PixelBuffer &image, const Rect &src_rect, bool is_srgb=false)
| Texture2D (GraphicContext &context, const Size &size, TextureFormat texture_format=TextureFormat::rgba8, int levels=1)
| Texture2D (GraphicContext &context, const std::string &filename, const FileSystem &fs, const ImageImportDescription &import_desc={})
| Texture2D (GraphicContext &context, const std::string &fullname, const ImageImportDescription &import_desc={})
| Texture2D (GraphicContext &context, int width, int height, TextureFormat format=TextureFormat::rgba8, int levels=1)
| Texture2D (GraphicContext &context, IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc={})
void | copy_image_from (GraphicContext &context, const Rect &pos, int level=0, TextureFormat texture_format=TextureFormat::rgba8)
void | copy_image_from (GraphicContext &context, int level, TextureFormat texture_format=TextureFormat::rgba8)
| Copy image data from a graphic context.
void | copy_image_from (GraphicContext &context, int x, int y, int width, int height, int level=0, TextureFormat texture_format=TextureFormat::rgba8)
void | copy_subimage_from (GraphicContext &context, const Point &offset, const Rect &pos, int level=0)
void | copy_subimage_from (GraphicContext &context, int offset_x, int offset_y, int x, int y, int width, int height, int level=0)
| Copy sub image data from a graphic context.
float | get_dip_height () const
| Returns the device independent height of this texture.
Sizef | get_dip_size () const
| Returns the device independent size of this texture.
float | get_dip_width () const
| Returns the device independent width of this texture.
int | get_height () const
| Retrieves the actual height of the texture in the display.
float | get_pixel_ratio () const
PixelBuffer | get_pixeldata (GraphicContext &gc, int level=0) const
| Retrieve image data from texture.
PixelBuffer | get_pixeldata (GraphicContext &gc, TextureFormat texture_format, int level=0) const
Size | get_size () const
| Retrieves the actual size of the texture.
int | get_width () const
| Retrieves the actual width of the texture in the display.
TextureWrapMode | get_wrap_mode_s () const
| Get the texture wrap mode for the s coordinate.
TextureWrapMode | get_wrap_mode_t () const
| Get the texture wrap mode for the t coordinate.
void | set_image (GraphicContext &context, const PixelBuffer &image, int level=0)
void | set_pixel_ratio (float ratio)
| Sets the display pixel ratio for this texture.
void | set_subimage (GraphicContext &context, const Point &point, const PixelBuffer &image, const Rect &src_rect, int level=0)
void | set_subimage (GraphicContext &context, int x, int y, const PixelBuffer &image, const Rect &src_rect, int level=0)
void | set_wrap_mode (TextureWrapMode wrap_s, TextureWrapMode wrap_t)
Public Member Functions inherited from clan::Texture
| Texture ()
| Constructs a null instance.
| Texture (const std::shared_ptr< Texture_Impl > &impl)
| Constructs a texture from an implementation.
| Texture (GraphicContext &gc, PixelBufferSet pixelbuffer_set)
| Constructs a texture as described in a pixelbuffer set.
| Texture (TextureProvider *provider)
| Constructs a texture from a texture provider.
virtual | ~Texture ()
void | generate_mipmap ()
| Generate the mipmap.
int | get_base_level () const
| Get the texture base level.
CompareFunction | get_compare_function () const
| Get the texture compare function.
TextureCompareMode | get_compare_mode () const
| Get the texture compare mode.
std::weak_ptr< Texture_Impl > | get_impl () const
| Get the implementation weakptr.
float | get_lod_bias () const
| Get the level of detail bias constant.
TextureFilter | get_mag_filter () const
| Get the texture magnification filter.
int | get_max_level () const
| Get the texture max level.
float | get_max_lod () const
| Get the maximum level of detail.
TextureFilter | get_min_filter () const
| Get the texture minification filter.
float | get_min_lod () const
| Get the minimum level of detail.
TextureProvider * | get_provider () const
| Get Provider.
bool | is_null () const
| Returns true if this object is invalid.
bool | is_resident () const
| Returns true if texture is resident in texture memory.
| operator bool () const
bool | operator!= (const Texture &other) const
| Inequality operator.
bool | operator< (const Texture &other) const
| Less than operator.
bool | operator== (const Texture &other) const
| Equality operator.
void | set_base_level (int base_level)
| Sets the texture base level texture parameter.
void | set_lod_bias (float lod_bias)
| Sets the level of detail bias constant.
void | set_mag_filter (TextureFilter filter)
| Set the magnification filter.
void | set_max_anisotropy (float max_anisotropy)
| Set the maximum degree of anisotropy.
void | set_max_level (int max_level)
| Sets the texture max level texture parameter.
void | set_max_lod (float max_lod)
| Set the maximum level of detail texture parameter.
void | set_min_filter (TextureFilter filter)
| Set the minification filter.
void | set_min_lod (float min_lod)
| Set the minimum level of detail texture parameter.
void | set_texture_compare (TextureCompareMode mode, CompareFunction func)
| Sets the texture compare mode and compare function texture parameters.
void | throw_if_null () const
| Throw an exception if this object is invalid.
Texture1D | to_texture_1d () const
| Dynamic cast to Texture1D.
Texture1DArray | to_texture_1d_array () const
| Dynamic cast to Texture1DArray.
Texture2D | to_texture_2d () const
| Dynamic cast to Texture2D.
Texture2DArray | to_texture_2d_array () const
| Dynamic cast to Texture2DArray.
Texture3D | to_texture_3d () const
| Dynamic cast to Texture3D.
TextureCube | to_texture_cube () const
| Dynamic cast to TextureCube.
TextureCubeArray | to_texture_cube_array () const
| Dynamic cast to TextureCubeArray.

## Additional Inherited Members
Static Public Member Functions inherited from clan::Texture
static Texture | load (GraphicContext &gc, const std::string &id, const XMLResourceDocument &doc, const ImageImportDescription &import_desc=ImageImportDescription())
| Loads a Texture from a XML resource definition.
static Resource< Texture > | resource (GraphicContext &gc, const std::string &id, const ResourceManager &resources)
| Retrieves a Texture resource from the resource manager.
Protected Attributes inherited from clan::Texture
std::shared_ptr< Texture_Impl > | impl

## Detailed Description

2D texture object class.

## Constructor & Destructor Documentation

## ◆ Texture2D() [1/9]

clan::Texture2D::Texture2D | ( |  | ) |

Constructs a null instance.

## ◆ Texture2D() [2/9]

clan::Texture2D::Texture2D | ( | const std::shared_ptr< Texture_Impl > & | impl | ) |
| inline

Constructs a texture from an implementation.

Parameters

  impl | The Texture object implementation.

## ◆ Texture2D() [3/9]

clan::Texture2D::Texture2D | ( | GraphicContext & | context,
|  | int | width,
|  | int | height,
|  | TextureFormat | format = TextureFormat::rgba8,
|  | int | levels = 1 )

Constructs a new Texture object.

Parameters

  context | Graphic context to construct the texture on.
  width | Width of the new texture.
  height | Height of the new texture.
  format | Data format of the new texture.
  levels | Number of mipmap levels for the new texture. Setting this to `0` enables all levels.

## ◆ Texture2D() [4/9]

clan::Texture2D::Texture2D | ( | GraphicContext & | context,
|  | const Size & | size,
|  | TextureFormat | texture_format = TextureFormat::rgba8,
|  | int | levels = 1 )

Constructs a new Texture object.

Parameters

  context | Graphic context to construct the texture on.
  size | Size of the new texture.
  format | Data format of the new texture.
  levels | Number of mipmap levels for the new texture. Setting this to `0` enables all levels.

## ◆ Texture2D() [5/9]

clan::Texture2D::Texture2D | ( | GraphicContext & | context,
|  | const std::string & | fullname,
|  | const ImageImportDescription & | import_desc = {} )

## ◆ Texture2D() [6/9]

clan::Texture2D::Texture2D | ( | GraphicContext & | context,
|  | const std::string & | filename,
|  | const FileSystem & | fs,
|  | const ImageImportDescription & | import_desc = {} )

## ◆ Texture2D() [7/9]

clan::Texture2D::Texture2D | ( | GraphicContext & | context,
|  | IODevice & | file,
|  | const std::string & | image_type,
|  | const ImageImportDescription & | import_desc = {} )

## ◆ Texture2D() [8/9]

clan::Texture2D::Texture2D | ( | GraphicContext & | context,
|  | const PixelBuffer & | image,
|  | bool | is_srgb = false )

## ◆ Texture2D() [9/9]

clan::Texture2D::Texture2D | ( | GraphicContext & | context,
|  | const PixelBuffer & | image,
|  | const Rect & | src_rect,
|  | bool | is_srgb = false )

## Member Function Documentation

## ◆ copy_image_from() [1/3]

void clan::Texture2D::copy_image_from | ( | GraphicContext & | context,
|  | const Rect & | pos,
|  | int | level = 0,
|  | TextureFormat | texture_format = TextureFormat::rgba8 )

## ◆ copy_image_from() [2/3]

void clan::Texture2D::copy_image_from | ( | GraphicContext & | context,
|  | int | level,
|  | TextureFormat | texture_format = TextureFormat::rgba8 )

Copy image data from a graphic context.

## ◆ copy_image_from() [3/3]

void clan::Texture2D::copy_image_from | ( | GraphicContext & | context,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height,
|  | int | level = 0,
|  | TextureFormat | texture_format = TextureFormat::rgba8 )

## ◆ copy_subimage_from() [1/2]

void clan::Texture2D::copy_subimage_from | ( | GraphicContext & | context,
|  | const Point & | offset,
|  | const Rect & | pos,
|  | int | level = 0 )

## ◆ copy_subimage_from() [2/2]

void clan::Texture2D::copy_subimage_from | ( | GraphicContext & | context,
|  | int | offset_x,
|  | int | offset_y,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height,
|  | int | level = 0 )

Copy sub image data from a graphic context.

## ◆ get_dip_height()

float clan::Texture2D::get_dip_height | ( |  | ) | const
| inline

Returns the device independent height of this texture.

References get_height(), and get_pixel_ratio().

Referenced by get_dip_size().

## ◆ get_dip_size()

Sizef clan::Texture2D::get_dip_size | ( |  | ) | const
| inline

Returns the device independent size of this texture.

References get_dip_height(), and get_dip_width().

## ◆ get_dip_width()

float clan::Texture2D::get_dip_width | ( |  | ) | const
| inline

Returns the device independent width of this texture.

References get_pixel_ratio(), and get_width().

Referenced by get_dip_size().

## ◆ get_height()

int clan::Texture2D::get_height | ( |  | ) | const

Retrieves the actual height of the texture in the display.

Referenced by get_dip_height(), and get_size().

## ◆ get_pixel_ratio()

float clan::Texture2D::get_pixel_ratio | ( |  | ) | const

Retrieves the pixel ratio of this texture.

Returns
  The display pixel ratio set for this texture. A zero value implies that no pixel ratio has been set

Referenced by get_dip_height(), and get_dip_width().

## ◆ get_pixeldata() [1/2]

PixelBuffer clan::Texture2D::get_pixeldata | ( | GraphicContext & | gc,
|  | int | level = 0 ) const

Retrieve image data from texture.

## ◆ get_pixeldata() [2/2]

PixelBuffer clan::Texture2D::get_pixeldata | ( | GraphicContext & | gc,
|  | TextureFormat | texture_format,
|  | int | level = 0 ) const

Retrieve image data from this texture.

Parameters

  format | Output data format.
  level | Mipmap level of the texture to retrieve data from.

## ◆ get_size()

Size clan::Texture2D::get_size | ( |  | ) | const
| inline

Retrieves the actual size of the texture.

References get_height(), and get_width().

## ◆ get_width()

int clan::Texture2D::get_width | ( |  | ) | const

Retrieves the actual width of the texture in the display.

Referenced by get_dip_width(), and get_size().

## ◆ get_wrap_mode_s()

TextureWrapMode clan::Texture2D::get_wrap_mode_s | ( |  | ) | const

Get the texture wrap mode for the s coordinate.

## ◆ get_wrap_mode_t()

TextureWrapMode clan::Texture2D::get_wrap_mode_t | ( |  | ) | const

Get the texture wrap mode for the t coordinate.

## ◆ set_image()

void clan::Texture2D::set_image | ( | GraphicContext & | context,
|  | const PixelBuffer & | image,
|  | int | level = 0 )

Upload image to this texture.

Parameters

  context | Graphic context to use for the request.
  image | Image to upload.
  level | Mipmap level-of-detail number.

## ◆ set_pixel_ratio()

void clan::Texture2D::set_pixel_ratio | ( | float | ratio | ) |

Sets the display pixel ratio for this texture.

## ◆ set_subimage() [1/2]

void clan::Texture2D::set_subimage | ( | GraphicContext & | context,
|  | const Point & | point,
|  | const PixelBuffer & | image,
|  | const Rect & | src_rect,
|  | int | level = 0 )

Upload image to sub-texture.

Parameters

  context | Graphic context to use for the request.
  point | Point in the texture to write the new sub-texture image. onto.
  image | Image to upload.
  level | Mipmap level-of-detail number.

## ◆ set_subimage() [2/2]

void clan::Texture2D::set_subimage | ( | GraphicContext & | context,
|  | int | x,
|  | int | y,
|  | const PixelBuffer & | image,
|  | const Rect & | src_rect,
|  | int | level = 0 )

Upload image to sub-texture.

Parameters

  context | Graphic context to use for the request.
  x | The horizontal point in the texture to write the new sub-texture image onto.
  y | The vertical point in the texture to write the new sub-texture image onto.
  image | Image to upload.
  level | Mipmap level-of-detail number.

## ◆ set_wrap_mode()

void clan::Texture2D::set_wrap_mode | ( | TextureWrapMode | wrap_s,
|  | TextureWrapMode | wrap_t )

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

- texture_2d.h