texture_2d_array.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 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 
31 #pragma once
32 
33 #include "texture.h"
34 
35 namespace clan
36 {
39 
40 class Texture2D;
41 
43 class Texture2DArray : public Texture
44 {
47 public:
50 
54  Texture2DArray(const std::shared_ptr<Texture_Impl> &impl) : Texture(impl) { }
55 
65  Texture2DArray(GraphicContext &context, int width, int height, int array_size, TextureFormat texture_format = tf_rgba8, int levels = 1);
66 
75  Texture2DArray(GraphicContext &context, const Size &size, int array_size, TextureFormat texture_format = tf_rgba8, int levels = 1);
77 
80 public:
82  int get_width() const;
83 
85  int get_height() const;
86 
88  Size get_size() const { return Size{ get_width(), get_height() }; }
89 
94  float get_pixel_ratio() const;
95 
97  float get_dip_width() const { return get_width() / get_pixel_ratio(); }
98 
100  float get_dip_height() const { return get_height() / get_pixel_ratio(); }
101 
104 
106  int get_array_size() const;
107 
110 
114 
117 public:
124  void set_image(
125  GraphicContext &context,
126  int array_index,
127  const PixelBuffer &image,
128  int level = 0);
129 
141  GraphicContext &context,
142  int array_index,
143  int x,
144  int y,
145  const PixelBuffer &image,
146  const Rect &src_rect,
147  int level = 0);
148 
159  GraphicContext &context,
160  int array_index,
161  const Point &point,
162  const PixelBuffer &image,
163  const Rect &src_rect,
164  int level = 0);
165 
167  TextureWrapMode wrap_s,
168  TextureWrapMode wrap_t);
169 
171  Texture2D create_2d_view(int array_index, TextureFormat texture_format, int min_level, int num_levels);
172 
174  void set_pixel_ratio(float ratio);
176 };
177 
178 }
179 
2D (x,y) point structure - Integer
Definition: point.h:63
TextureWrapMode
Texture coordinate wrapping modes.
Definition: texture.h:66
Texture object class.
Definition: texture.h:104
void set_subimage(GraphicContext &context, int array_index, int x, int y, const PixelBuffer &image, const Rect &src_rect, int level=0)
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:471
int get_array_size() const
Returns the number of textures in the array.
@ tf_rgba8
Definition: texture_format.h:43
2D texture object class.
Definition: texture_2d.h:42
std::shared_ptr< Texture_Impl > impl
Definition: texture.h:271
void set_image(GraphicContext &context, int array_index, const PixelBuffer &image, int level=0)
void set_pixel_ratio(float ratio)
Sets the display pixel ratio for this texture.
float get_dip_width() const
Returns the device independent width of this texture.
Definition: texture_2d_array.h:97
Interface to drawing graphics.
Definition: graphic_context.h:258
Size get_size() const
Retrieves the actual size of the texture.
Definition: texture_2d_array.h:88
Texture2DArray(GraphicContext &context, int width, int height, int array_size, TextureFormat texture_format=tf_rgba8, int levels=1)
TextureFormat
Texture format.
Definition: texture_format.h:41
int get_height() const
Retrieves the actual height of the texture in the display.
2D texture array object class.
Definition: texture_2d_array.h:44
Definition: clanapp.h:36
TextureWrapMode get_wrap_mode_s() const
Get the texture wrap mode for the s coordinate.
Pixel data container.
Definition: pixel_buffer.h:69
float get_dip_height() const
Returns the device independent height of this texture.
Definition: texture_2d_array.h:100
Texture2D create_2d_view(int array_index, TextureFormat texture_format, int min_level, int num_levels)
Creates a 2D texture view.
Texture2DArray(GraphicContext &context, const Size &size, int array_size, TextureFormat texture_format=tf_rgba8, int levels=1)
Texture2DArray(const std::shared_ptr< Texture_Impl > &impl)
Definition: texture_2d_array.h:54
void set_wrap_mode(TextureWrapMode wrap_s, TextureWrapMode wrap_t)
Texture2DArray()
Constructs a null instance.
2D (width,height) size structure - Integer
Definition: size.h:157
void set_subimage(GraphicContext &context, int array_index, const Point &point, const PixelBuffer &image, const Rect &src_rect, int level=0)
float get_pixel_ratio() const
2D (width,height) size structure - Float
Definition: size.h:170
Sizef get_dip_size() const
Returns the device independent size of this texture.
Definition: texture_2d_array.h:103
TextureWrapMode get_wrap_mode_t() const
Get the texture wrap mode for the t coordinate.
int get_width() const
Retrieves the actual width of the texture in the display.