texture_2d_array.h Source File - ClanLib SDK
Description: texture_2d_array.h Source File

texture_2d_array.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** arising from the use of this software.
8**
9** Permission is granted to anyone to use this software for any purpose,
10** including commercial applications, and to alter it and redistribute it
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Magnus Norddahl
27** Harry Storbacka
28*/
29
30#pragma once
31
32#include "texture.h"
33
34namespace clan
35{
38
39 class Texture2D;
40
42 class Texture2DArray : public Texture
43 {
44 public:
46 Texture2DArray();
47
51 Texture2DArray(const std::shared_ptr<Texture_Impl> &impl) : Texture(impl) { }
52
62 Texture2DArray(GraphicContext &context, int width, int height, int array_size, TextureFormat texture_format = TextureFormat::rgba8, int levels = 1);
63
72 Texture2DArray(GraphicContext &context, const Size &size, int array_size, TextureFormat texture_format = TextureFormat::rgba8, int levels = 1);
73
75 int get_width() const;
76
78 int get_height() const;
79
81 Size get_size() const { return Size{ get_width(), get_height() }; }
82
87 float get_pixel_ratio() const;
88
90 float get_dip_width() const { return get_width() / get_pixel_ratio(); }
91
93 float get_dip_height() const { return get_height() / get_pixel_ratio(); }
94
96 Sizef get_dip_size() const { return Sizef{ get_dip_width(), get_dip_height() }; }
97
99 int get_array_size() const;
100
102 TextureWrapMode get_wrap_mode_s() const;
103
105 TextureWrapMode get_wrap_mode_t() const;
106
113 void set_image(
114 GraphicContext &context,
115 int array_index,
116 const PixelBuffer &image,
117 int level = 0);
118
129 void set_subimage(
130 GraphicContext &context,
131 int array_index,
132 int x,
133 int y,
134 const PixelBuffer &image,
135 const Rect &src_rect,
136 int level = 0);
137
146
147 void set_subimage(
148 GraphicContext &context,
149 int array_index,
150 const Point &point,
151 const PixelBuffer &image,
152 const Rect &src_rect,
153 int level = 0);
154
155 void set_wrap_mode(
156 TextureWrapMode wrap_s,
157 TextureWrapMode wrap_t);
158
160 Texture2D create_2d_view(int array_index, TextureFormat texture_format, int min_level, int num_levels);
161
163 void set_pixel_ratio(float ratio);
164 };
165
167}
clan::GraphicContext
Interface to drawing graphics.
Definition graphic_context.h:257
clan::PixelBuffer
Pixel data container.
Definition pixel_buffer.h:68
clan::Point
2D (x,y) point structure - Integer
Definition point.h:62
clan::Rect
2D (left,top,right,bottom) rectangle structure - Integer
Definition rect.h:446
clan::Size
2D (width,height) size structure - Integer
Definition size.h:176
clan::Sizef
2D (width,height) size structure - Float
Definition size.h:189
clan::Texture2DArray::get_wrap_mode_s
TextureWrapMode get_wrap_mode_s() const
Get the texture wrap mode for the s coordinate.
clan::Texture2DArray::get_size
Size get_size() const
Retrieves the actual size of the texture.
Definition texture_2d_array.h:81
clan::Texture2DArray::get_dip_height
float get_dip_height() const
Returns the device independent height of this texture.
Definition texture_2d_array.h:93
clan::Texture2DArray::get_dip_width
float get_dip_width() const
Returns the device independent width of this texture.
Definition texture_2d_array.h:90
clan::Texture2DArray::get_array_size
int get_array_size() const
Returns the number of textures in the array.
clan::Texture2DArray::Texture2DArray
Texture2DArray(const std::shared_ptr< Texture_Impl > &impl)
Definition texture_2d_array.h:51
clan::Texture2DArray::get_width
int get_width() const
Retrieves the actual width of the texture in the display.
clan::Texture2DArray::get_height
int get_height() const
Retrieves the actual height of the texture in the display.
clan::Texture2DArray::set_subimage
void set_subimage(GraphicContext &context, int array_index, const Point &point, const PixelBuffer &image, const Rect &src_rect, int level=0)
clan::Texture2DArray::Texture2DArray
Texture2DArray()
Constructs a null instance.
clan::Texture2DArray::set_image
void set_image(GraphicContext &context, int array_index, const PixelBuffer &image, int level=0)
clan::Texture2DArray::get_dip_size
Sizef get_dip_size() const
Returns the device independent size of this texture.
Definition texture_2d_array.h:96
clan::Texture2DArray::get_wrap_mode_t
TextureWrapMode get_wrap_mode_t() const
Get the texture wrap mode for the t coordinate.
clan::Texture2DArray::Texture2DArray
Texture2DArray(GraphicContext &context, const Size &size, int array_size, TextureFormat texture_format=TextureFormat::rgba8, int levels=1)
clan::Texture2DArray::get_pixel_ratio
float get_pixel_ratio() const
clan::Texture2DArray::Texture2DArray
Texture2DArray(GraphicContext &context, int width, int height, int array_size, TextureFormat texture_format=TextureFormat::rgba8, int levels=1)
clan::Texture2DArray::set_wrap_mode
void set_wrap_mode(TextureWrapMode wrap_s, TextureWrapMode wrap_t)
clan::Texture2DArray::set_pixel_ratio
void set_pixel_ratio(float ratio)
Sets the display pixel ratio for this texture.
clan::Texture2DArray::create_2d_view
Texture2D create_2d_view(int array_index, TextureFormat texture_format, int min_level, int num_levels)
Creates a 2D texture view.
clan::Texture2DArray::set_subimage
void set_subimage(GraphicContext &context, int array_index, int x, int y, const PixelBuffer &image, const Rect &src_rect, int level=0)
clan::Texture2D
2D texture object class.
Definition texture_2d.h:41
clan::Texture::impl
std::shared_ptr< Texture_Impl > impl
Definition texture.h:250
clan::Texture::Texture
Texture()
Constructs a null instance.
clan::TextureFormat
TextureFormat
Texture format.
Definition texture_format.h:39
clan::TextureWrapMode
TextureWrapMode
Texture coordinate wrapping modes.
Definition texture.h:65
clan::TextureFormat::rgba8
@ rgba8
Definition texture_format.h:41
clan::FillMode::point
@ point
Definition graphic_context.h:78
clan
Definition clanapp.h:36
clan::BrushType::image
@ image
Definition brush.h:54
clan::Key::y
@ y
Definition keys.h:105
clan::Key::x
@ x
Definition keys.h:104