texture_2d_array.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore 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 UICore 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 
34 namespace uicore
35 {
36  class Texture2D;
37 
39  class Texture2DArray : public virtual Texture
40  {
41  public:
50  static std::shared_ptr<Texture2DArray> create(const GraphicContextPtr &context, int width, int height, int array_size, TextureFormat texture_format = tf_rgba8, int levels = 1);
51  static std::shared_ptr<Texture2DArray> create(const GraphicContextPtr &context, const Size &size, int array_size, TextureFormat texture_format = tf_rgba8, int levels = 1);
52 
54  virtual int width() const = 0;
55 
57  virtual int height() const = 0;
58 
60  Size size() const { return Size{ width(), height() }; }
61 
63  virtual int array_size() const = 0;
64 
66  virtual TextureWrapMode wrap_mode_s() const = 0;
67 
69  virtual TextureWrapMode wrap_mode_t() const = 0;
70 
77  virtual void set_image(const GraphicContextPtr &context, int array_index, const PixelBufferPtr &image, int level = 0) = 0;
78 
88  virtual void set_subimage(const GraphicContextPtr &context, int array_index, int x, int y, const PixelBufferPtr &image, const Rect &src_rect, int level = 0) = 0;
89  void set_subimage(const GraphicContextPtr &context, int array_index, const Point &point, const PixelBufferPtr &image, const Rect &src_rect, int level = 0)
90  {
91  set_subimage(context, array_index, point.x, point.y, image, src_rect, level);
92  }
93 
94  virtual void set_wrap_mode(TextureWrapMode wrap_s, TextureWrapMode wrap_t) = 0;
95 
97  virtual std::shared_ptr<Texture2D> create_2d_view(int array_index, TextureFormat texture_format, int min_level, int num_levels) = 0;
98  };
99 }
virtual TextureWrapMode wrap_mode_s() const =0
Get the texture wrap mode for the s coordinate.
Texture object class.
Definition: texture.h:94
2D (width,height) size structure - Integer
Definition: size.h:167
virtual std::shared_ptr< Texture2D > create_2d_view(int array_index, TextureFormat texture_format, int min_level, int num_levels)=0
Creates a 2D texture view.
Type x
Definition: vec2.h:75
Size size() const
Retrieves the actual size of the texture.
Definition: texture_2d_array.h:60
virtual void set_subimage(const GraphicContextPtr &context, int array_index, int x, int y, const PixelBufferPtr &image, const Rect &src_rect, int level=0)=0
TextureFormat
Texture format.
Definition: texture_format.h:35
Definition: texture_format.h:38
virtual void set_image(const GraphicContextPtr &context, int array_index, const PixelBufferPtr &image, int level=0)=0
2D (x,y) point structure - Integer
Definition: point.h:58
virtual int array_size() const =0
Returns the number of textures in the array.
Type y
Definition: vec2.h:76
virtual int width() const =0
Retrieves the actual width of the texture in the display.
2D texture array object class.
Definition: texture_2d_array.h:39
virtual TextureWrapMode wrap_mode_t() const =0
Get the texture wrap mode for the t coordinate.
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:491
static std::shared_ptr< Texture2DArray > create(const GraphicContextPtr &context, int width, int height, int array_size, TextureFormat texture_format=tf_rgba8, int levels=1)
virtual void set_wrap_mode(TextureWrapMode wrap_s, TextureWrapMode wrap_t)=0
void set_subimage(const GraphicContextPtr &context, int array_index, const Point &point, const PixelBufferPtr &image, const Rect &src_rect, int level=0)
Definition: texture_2d_array.h:89
std::shared_ptr< PixelBuffer > PixelBufferPtr
Definition: d3d_target.h:39
std::shared_ptr< GraphicContext > GraphicContextPtr
Definition: d3d_target.h:49
virtual int height() const =0
Retrieves the actual height of the texture in the display.
TextureWrapMode
Texture coordinate wrapping modes.
Definition: texture.h:56
Definition: Application/application.h:35