texture_2d.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 "../api_display.h"
34 #include "texture.h"
35 
36 namespace clan
37 {
40 
42 class CL_API_DISPLAY Texture2D : public Texture
43 {
46 public:
48  Texture2D();
49 
53  Texture2D(const std::shared_ptr<Texture_Impl> &impl) : Texture(impl) { }
54 
62  Texture2D(GraphicContext &context, int width, int height, TextureFormat texture_format = tf_rgba8, int levels = 1);
63 
70  Texture2D(GraphicContext &context, const Size &size, TextureFormat texture_format = tf_rgba8, int levels = 1);
71 
72  Texture2D(
73  GraphicContext &context,
74  const std::string &fullname, const ImageImportDescription &import_desc = ImageImportDescription ());
75 
76  Texture2D(
77  GraphicContext &context,
78  const std::string &filename,
79  const FileSystem &fs, const ImageImportDescription &import_desc = ImageImportDescription ());
80 
81  Texture2D(
82  GraphicContext &context,
83  IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc = ImageImportDescription ());
84 
85  Texture2D(GraphicContext &context, const PixelBuffer &image, bool is_srgb = false);
86  Texture2D(GraphicContext &context, const PixelBuffer &image, const Rect &src_rect, bool is_srgb = false);
87 
89 
92 public:
94  int get_width() const;
95 
97  int get_height() const;
98 
100  Size get_size() const;
101 
103  PixelBuffer get_pixeldata(GraphicContext &gc, int level = 0) const;
104 
111  PixelBuffer get_pixeldata(GraphicContext &gc, TextureFormat texture_format, int level = 0) const;
112 
114  TextureWrapMode get_wrap_mode_s() const;
115 
117  TextureWrapMode get_wrap_mode_t() const;
119 
122 public:
128  void set_image(
129  GraphicContext &context,
130  const PixelBuffer &image,
131  int level = 0);
132 
138  void set_subimage(
139  GraphicContext &context,
140  int x,
141  int y,
142  const PixelBuffer &image,
143  const Rect &src_rect,
144  int level = 0);
145 
146  void set_subimage(
147  GraphicContext &context,
148  const Point &point,
149  const PixelBuffer &image,
150  const Rect &src_rect,
151  int level = 0);
152 
154  void copy_image_from(
155  GraphicContext &context,
156  int level,
157  TextureFormat texture_format = tf_rgba8);
158 
159  void copy_image_from(
160  GraphicContext &context,
161  int x,
162  int y,
163  int width,
164  int height,
165  int level = 0,
166  TextureFormat texture_format = tf_rgba8);
167 
168  void copy_image_from(
169  GraphicContext &context,
170  const Rect &pos,
171  int level = 0,
172  TextureFormat texture_format = tf_rgba8);
173 
175  void copy_subimage_from(
176  GraphicContext &context,
177  int offset_x,
178  int offset_y,
179  int x,
180  int y,
181  int width,
182  int height,
183  int level = 0);
184 
185  void copy_subimage_from(
186  GraphicContext &context,
187  const Point &offset,
188  const Rect &pos,
189  int level = 0);
190 
191  void set_wrap_mode(
192  TextureWrapMode wrap_s,
193  TextureWrapMode wrap_t);
195 };
196 
197 }
198 
Texture2D(const std::shared_ptr< Texture_Impl > &impl)
Constructs a texture from an implementation.
Definition: texture_2d.h:53
TextureWrapMode
Texture coordinate wrapping modes.
Definition: texture.h:66
I/O Device interface.
Definition: iodevice.h:51
Texture object class.
Definition: texture.h:104
Pixel data container.
Definition: pixel_buffer.h:69
Image Import Description Class.
Definition: image_import_description.h:49
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
2D texture object class.
Definition: texture_2d.h:42
Virtual File System (VFS).
Definition: file_system.h:48
TextureFormat
Texture format.
Definition: texture_format.h:41
Interface to drawing graphics.
Definition: graphic_context.h:257
2D (x,y) point structure - Integer
Definition: point.h:63
2D (width,height) size structure - Integer
Definition: size.h:157
Definition: texture_format.h:44