texture_provider.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 "../Render/texture.h"
34 #include "../api_display.h"
35 #include <memory>
36 
37 namespace clan
38 {
41 
42 enum TextureWrapMode;
43 enum TextureFilter;
45 enum CompareFunction;
46 class PixelBuffer;
47 class PixelFormat;
48 class GraphicContextProvider;
49 
51 class CL_API_DISPLAY TextureProvider
52 {
55 
56 public:
57  virtual ~TextureProvider() { return; }
58 
62 
63 public:
64 
68 
69 public:
71  virtual void create(int width, int height, int depth, int array_size, TextureFormat texture_format, int levels) = 0;
72 
74  virtual PixelBuffer get_pixeldata(GraphicContext &gc, TextureFormat texture_format, int level) const = 0;
75 
77  virtual void generate_mipmap() = 0;
78 
80  virtual void copy_from(GraphicContext &gc, int x, int y, int slice, int level, const PixelBuffer &src, const Rect &src_rect) = 0;
81 
83  virtual void copy_image_from(
84  int x,
85  int y,
86  int width,
87  int height,
88  int level,
89  TextureFormat texture_format,
90  GraphicContextProvider *gc) = 0;
91 
93  virtual void copy_subimage_from(
94  int offset_x,
95  int offset_y,
96  int x,
97  int y,
98  int width,
99  int height,
100  int level,
101  GraphicContextProvider *gc) = 0;
102 
104  virtual void set_min_lod(double min_lod) = 0;
105 
107  virtual void set_max_lod(double max_lod) = 0;
108 
110  virtual void set_lod_bias(double lod_bias) = 0;
111 
113  virtual void set_base_level(int base_level) = 0;
114 
116  virtual void set_max_level(int max_level) = 0;
117 
119  virtual void set_wrap_mode(
120  TextureWrapMode wrap_s,
121  TextureWrapMode wrap_t,
122  TextureWrapMode wrap_r) = 0;
123 
124  virtual void set_wrap_mode(
125  TextureWrapMode wrap_s,
126  TextureWrapMode wrap_t) = 0;
127 
128  virtual void set_wrap_mode(
129  TextureWrapMode wrap_s) = 0;
130 
132  virtual void set_min_filter(TextureFilter filter) = 0;
133 
135  virtual void set_mag_filter(TextureFilter filter) = 0;
136 
138  virtual void set_max_anisotropy(float v) = 0;
139 
141  virtual void set_texture_compare(TextureCompareMode mode, CompareFunction func) = 0;
142 
144  virtual TextureProvider *create_view(TextureDimensions texture_dimensions, TextureFormat texture_format, int min_level, int num_levels, int min_layer, int num_layers) = 0;
145 
149 
150 private:
152 };
153 
154 }
155 
TextureFilter
Texture filters.
Definition: texture.h:74
TextureWrapMode
Texture coordinate wrapping modes.
Definition: texture.h:66
Interface for implementing a GraphicContext target.
Definition: graphic_context_provider.h:87
Pixel data container.
Definition: pixel_buffer.h:69
virtual ~TextureProvider()
Definition: texture_provider.h:57
TextureDimensions
Texture dimensions.
Definition: texture.h:92
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
TextureCompareMode
Texture compare modes.
Definition: texture.h:85
TextureFormat
Texture format.
Definition: texture_format.h:41
Interface for implementing a Texture target.
Definition: texture_provider.h:51
Interface to drawing graphics.
Definition: graphic_context.h:257
CompareFunction
Compare functions.
Definition: graphic_context.h:93