texture_provider.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 "../Render/texture.h"
34 #include <memory>
35 
36 namespace clan
37 {
40 
41 enum TextureWrapMode;
42 enum TextureFilter;
44 enum CompareFunction;
45 class PixelBuffer;
46 class PixelFormat;
47 class GraphicContextProvider;
48 
51 {
54 
55 public:
56  virtual ~TextureProvider() { return; }
57 
61 
62 public:
63 
67 
68 public:
70  virtual void create(int width, int height, int depth, int array_size, TextureFormat texture_format, int levels) = 0;
71 
73  virtual PixelBuffer get_pixeldata(GraphicContext &gc, TextureFormat texture_format, int level) const = 0;
74 
76  virtual void generate_mipmap() = 0;
77 
79  virtual void copy_from(GraphicContext &gc, int x, int y, int slice, int level, const PixelBuffer &src, const Rect &src_rect) = 0;
80 
82  virtual void copy_image_from(
83  int x,
84  int y,
85  int width,
86  int height,
87  int level,
88  TextureFormat texture_format,
89  GraphicContextProvider *gc) = 0;
90 
92  virtual void copy_subimage_from(
93  int offset_x,
94  int offset_y,
95  int x,
96  int y,
97  int width,
98  int height,
99  int level,
100  GraphicContextProvider *gc) = 0;
101 
103  virtual void set_min_lod(double min_lod) = 0;
104 
106  virtual void set_max_lod(double max_lod) = 0;
107 
109  virtual void set_lod_bias(double lod_bias) = 0;
110 
112  virtual void set_base_level(int base_level) = 0;
113 
115  virtual void set_max_level(int max_level) = 0;
116 
118  virtual void set_wrap_mode(
119  TextureWrapMode wrap_s,
120  TextureWrapMode wrap_t,
121  TextureWrapMode wrap_r) = 0;
122 
123  virtual void set_wrap_mode(
124  TextureWrapMode wrap_s,
125  TextureWrapMode wrap_t) = 0;
126 
127  virtual void set_wrap_mode(
128  TextureWrapMode wrap_s) = 0;
129 
131  virtual void set_min_filter(TextureFilter filter) = 0;
132 
134  virtual void set_mag_filter(TextureFilter filter) = 0;
135 
137  virtual void set_max_anisotropy(float v) = 0;
138 
141 
143  virtual TextureProvider *create_view(TextureDimensions texture_dimensions, TextureFormat texture_format, int min_level, int num_levels, int min_layer, int num_layers) = 0;
144 
148 
149 private:
151 };
152 
153 }
154 
TextureWrapMode
Texture coordinate wrapping modes.
Definition: texture.h:66
TextureDimensions
Texture dimensions.
Definition: texture.h:92
TextureFilter
Texture filters.
Definition: texture.h:74
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:471
virtual void set_texture_compare(TextureCompareMode mode, CompareFunction func)=0
Sets the texture compare mode and compare function texture parameters.
virtual void set_mag_filter(TextureFilter filter)=0
Set the magnification filter.
virtual ~TextureProvider()
Definition: texture_provider.h:56
virtual void set_base_level(int base_level)=0
Sets the texture base level texture parameter.
virtual void set_max_lod(double max_lod)=0
Set the maximum level of detail texture parameter.
TextureCompareMode
Texture compare modes.
Definition: texture.h:85
virtual void set_wrap_mode(TextureWrapMode wrap_s, TextureWrapMode wrap_t)=0
virtual void set_wrap_mode(TextureWrapMode wrap_s, TextureWrapMode wrap_t, TextureWrapMode wrap_r)=0
Set the texture wrapping mode.
Interface to drawing graphics.
Definition: graphic_context.h:258
Interface for implementing a Texture target.
Definition: texture_provider.h:51
virtual void copy_image_from(int x, int y, int width, int height, int level, TextureFormat texture_format, GraphicContextProvider *gc)=0
Copy image data from a graphic context.
virtual void create(int width, int height, int depth, int array_size, TextureFormat texture_format, int levels)=0
Create texture.
virtual void set_wrap_mode(TextureWrapMode wrap_s)=0
TextureFormat
Texture format.
Definition: texture_format.h:41
virtual void set_lod_bias(double lod_bias)=0
Sets the level of detail bias constant.
Definition: clanapp.h:36
virtual void copy_subimage_from(int offset_x, int offset_y, int x, int y, int width, int height, int level, GraphicContextProvider *gc)=0
Copy sub image data from a graphic context.
virtual void copy_from(GraphicContext &gc, int x, int y, int slice, int level, const PixelBuffer &src, const Rect &src_rect)=0
Copy image data to texture.
Pixel data container.
Definition: pixel_buffer.h:69
virtual void set_min_lod(double min_lod)=0
Set the minimum level of detail texture parameter.
virtual TextureProvider * create_view(TextureDimensions texture_dimensions, TextureFormat texture_format, int min_level, int num_levels, int min_layer, int num_layers)=0
\breif Creates a texture view for this texture
virtual void set_max_level(int max_level)=0
Sets the texture max level texture parameter.
CompareFunction
Compare functions.
Definition: graphic_context.h:93
virtual void set_min_filter(TextureFilter filter)=0
Set the minification filter.
Interface for implementing a GraphicContext target.
Definition: graphic_context_provider.h:87
virtual PixelBuffer get_pixeldata(GraphicContext &gc, TextureFormat texture_format, int level) const =0
Retrieve image data from texture.
virtual void generate_mipmap()=0
Generate the mipmap.
virtual void set_max_anisotropy(float v)=0
Set the maximum degree of anisotropy.