texture.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 #include "../api_display.h"
00036 #include "../../Core/System/sharedptr.h"
00037 #include "../../Core/Text/string_types.h"
00038 #include "../../Core/IOData/virtual_directory.h"
00039 #include "../../Core/Resources/resource_data_session.h"
00040 #include "graphic_context.h"
00041 #include "compare_function.h"
00042 
00043 class CL_Color;
00044 class CL_Point;
00045 class CL_PixelBuffer;
00046 class CL_PixelFormat;
00047 class CL_TextureProvider;
00048 class CL_DataBuffer;
00049 class CL_Texture_Impl;
00050 class CL_SharedGCData_Impl;
00051 
00055 enum CL_TextureWrapMode
00056 {
00057         cl_wrap_clamp_to_edge,
00058         cl_wrap_repeat,
00059         cl_wrap_mirrored_repeat
00060 };
00061 
00065 enum CL_TextureFilter
00066 {
00067         cl_filter_nearest,
00068         cl_filter_linear,
00069         cl_filter_nearest_mipmap_nearest,
00070         cl_filter_nearest_mipmap_linear,
00071         cl_filter_linear_mipmap_nearest,
00072         cl_filter_linear_mipmap_linear
00073 };
00074 
00078 enum CL_TextureDepthMode
00079 {
00080         cl_depthmode_luminance,
00081         cl_depthmode_intensity,
00082         cl_depthmode_alpha
00083 };
00084 
00088 enum CL_TextureCompareMode
00089 {
00090         cl_comparemode_none,
00091         cl_comparemode_compare_r_to_texture
00092 };
00093 
00097 enum CL_TextureDimensions
00098 {
00099         cl_texture_1d,
00100         cl_texture_2d,
00101         cl_texture_3d,
00102         cl_texture_cube_map
00103 };
00104 
00108 enum CL_TextureFormat
00109 {
00110         // base internal format
00111         cl_alpha,
00112         cl_depth_component,
00113         cl_depth_stencil,
00114         cl_intensity,
00115         cl_luminance,
00116         cl_luminance_alpha,
00117         cl_red,
00118         cl_rg,
00119         cl_rgb,
00120         cl_rgba,
00121         cl_stencil_index,               // For CL_RenderBuffer
00122 
00123         // sized internal format
00124         cl_stencil_index1,              // For CL_RenderBuffer
00125         cl_stencil_index4,              // For CL_RenderBuffer
00126         cl_stencil_index8,              // For CL_RenderBuffer
00127         cl_stencil_index16,             // For CL_RenderBuffer
00128         cl_alpha4,
00129         cl_alpha8,
00130         cl_alpha12,
00131         cl_alpha16,
00132         cl_r8,
00133         cl_r16,
00134         cl_rg8,
00135         cl_rg16,
00136         cl_r3_g3_b2,
00137         cl_rgb4,
00138         cl_rgb5,
00139         cl_rgb8,
00140         cl_rgb10,
00141         cl_rgb12,
00142         cl_rgb16,
00143         cl_rgba2,
00144         cl_rgba4,
00145         cl_rgb5_a1,
00146         cl_rgba8,
00147         cl_rgb10_a2,
00148         cl_rgba12,
00149         cl_rgba16,
00150         cl_srgb8,
00151         cl_srgb8_alpha8,
00152         cl_r16f,
00153         cl_rg16f,
00154         cl_rgb16f,
00155         cl_rgba16f,
00156         cl_r32f,
00157         cl_rg32f,
00158         cl_rgb32f,
00159         cl_rgba32f,
00160         cl_r11f_g11f_b10f,
00161         cl_rgb9_e5,
00162         cl_r8i,
00163         cl_r8ui,
00164         cl_r16i,
00165         cl_r16ui,
00166         cl_r32i,
00167         cl_r32ui,
00168         cl_rg8i,
00169         cl_rg8ui,
00170         cl_rg16i,
00171         cl_rg16ui,
00172         cl_rg32i,
00173         cl_rg32ui,
00174         cl_rgb8i,
00175         cl_rgb8ui,
00176         cl_rgb16i,
00177         cl_rgb16ui,
00178         cl_rgb32i,
00179         cl_rgb32ui,
00180         cl_rgba8i,
00181         cl_rgba8ui,
00182         cl_rgba16i,
00183         cl_rgba16ui,
00184         cl_rgba32i,
00185         cl_rgba32ui,
00186         cl_luminance4,
00187         cl_luminance8,
00188         cl_luminance12,
00189         cl_luminance16,
00190         cl_luminance4_alpha4,
00191         cl_luminance6_alpha2,
00192         cl_luminance8_alpha8,
00193         cl_luminance12_alpha4,
00194         cl_luminance12_alpha12,
00195         cl_luminance16_alpha16,
00196         cl_intensity4,
00197         cl_intensity8,
00198         cl_intensity12,
00199         cl_intensity16,
00200         cl_depth_component16,
00201         cl_depth_component24,
00202         cl_depth_component32,
00203         cl_depth_component32f,
00204         cl_depth24_stencil8,
00205         cl_depth32f_stencil8,
00206         cl_sluminance,
00207         cl_sluminance_alpha8,
00208         cl_compressed_alpha,
00209         cl_compressed_luminance,
00210         cl_compressed_luminance_alpha,
00211         cl_compressed_intensity,
00212         cl_compressed_red,
00213         cl_compressed_rg,
00214         cl_compressed_rgb,
00215         cl_compressed_rgba,
00216         cl_compressed_srgb,
00217         cl_compressed_srgb_alpha,
00218         cl_compressed_sluminance,
00219         cl_compressed_sluminance_alpha,
00220         cl_compressed_red_rgtc1,
00221         cl_compressed_signed_red_rgtc1,
00222         cl_compressed_rg_rgtc2,
00223         cl_compressed_signed_rg_rgtc2
00224 };
00225 
00229 class CL_API_DISPLAY CL_Texture
00230 {
00233 public:
00235         CL_Texture();
00236 
00241         CL_Texture(CL_GraphicContext &context, CL_TextureDimensions texture_dimensions);
00242 
00249         CL_Texture(CL_GraphicContext &context, int width, int height, CL_TextureFormat internal_format = cl_rgba);
00250 
00256         CL_Texture(CL_GraphicContext &context, const CL_Size &size, CL_TextureFormat internal_format = cl_rgba);
00257 
00258         CL_Texture(
00259                 CL_GraphicContext &context,
00260                 const CL_StringRef &fullname);
00261 
00262         CL_Texture(
00263                 CL_GraphicContext &context,
00264                 const CL_StringRef &filename,
00265                 const CL_VirtualDirectory &directory);
00266 
00267         CL_Texture(
00268                 CL_GraphicContext &context,
00269                 CL_IODevice &file, const CL_String &image_type);
00270 
00271         CL_Texture(
00272                 const CL_StringRef &resource_id,
00273                 CL_ResourceManager *resources,
00274                 CL_GraphicContext &gc);
00275 
00279         CL_Texture(CL_SharedPtr<CL_Texture_Impl> &impl);
00280 
00281         virtual ~CL_Texture();
00282 
00286 public:
00288         bool operator==(const CL_Texture &other) const
00289         {
00290                 return impl==other.impl;
00291         }
00292 
00294         bool operator!=(const CL_Texture &other) const
00295         {
00296                 return impl!=other.impl;
00297         }
00298 
00300         bool operator<(const CL_Texture &other) const
00301         {
00302                 return impl < other.impl;
00303         }
00304 
00308 public:
00310         bool is_null() const;
00311 
00315         int get_width(int level = 0) const;
00316 
00320         int get_height(int level = 0) const;
00321 
00323         CL_Size get_size() const;
00324 
00326         int get_depth() const;
00327 
00329         CL_PixelBuffer get_pixeldata(int level = 0) const;
00330 
00337         CL_PixelBuffer get_pixeldata(CL_PixelFormat &format, int level = 0) const;
00338 
00340         float get_min_lod() const;
00341 
00343         float get_max_lod() const;
00344 
00346         float get_lod_bias() const;
00347 
00349         int get_base_level() const;
00350 
00352         int get_max_level() const;
00353 
00355         bool get_generate_mipmap() const;
00356 
00358         CL_TextureWrapMode get_wrap_mode_s() const;
00359 
00361         CL_TextureWrapMode get_wrap_mode_t() const;
00362 
00364         CL_TextureWrapMode get_wrap_mode_r() const;
00365 
00367         CL_TextureFilter get_min_filter() const;
00368 
00370         CL_TextureFilter get_mag_filter() const;
00371 
00373         bool is_resident() const;
00374 
00376         CL_TextureDepthMode get_depth_mode() const;
00377 
00379         CL_TextureCompareMode get_compare_mode() const;
00380 
00382         CL_CompareFunction get_compare_function() const;
00383 
00387         CL_TextureProvider *get_provider() const;
00388 
00392         CL_WeakPtr<CL_Texture_Impl> get_impl() const;
00393 
00397 public:
00403         void set_image(
00404                 CL_PixelBuffer &image,
00405                 int level = 0,
00406                 CL_TextureFormat internal_format = cl_rgba);
00407 
00409         void set_cube_map(
00410                 CL_PixelBuffer &cube_map_positive_x,
00411                 CL_PixelBuffer &cube_map_negative_x,
00412                 CL_PixelBuffer &cube_map_positive_y,
00413                 CL_PixelBuffer &cube_map_negative_y,
00414                 CL_PixelBuffer &cube_map_positive_z,
00415                 CL_PixelBuffer &cube_map_negative_z,
00416                 int level = 0,
00417                 CL_TextureFormat internal_format = cl_rgba);
00418 
00419         void set_compressed_image(
00420                 int level,
00421                 CL_TextureFormat internal_format,
00422                 int width,
00423                 int height,
00424                 CL_DataBuffer &image);
00425 
00430         void set_subimage(
00431                 int x,
00432                 int y,
00433                 const CL_PixelBufferRef &image,
00434                 int level = 0);
00435 
00436         void set_subimage(
00437                 const CL_Point &point,
00438                 const CL_PixelBufferRef &image,
00439                 int level = 0);
00440 
00442         void copy_image_from(
00443                 CL_GraphicContext &context,
00444                 int level,
00445                 CL_TextureFormat internal_format = cl_rgba);
00446 
00447         void copy_image_from(
00448                 CL_GraphicContext &context,
00449                 int x,
00450                 int y,
00451                 int width,
00452                 int height,
00453                 int level = 0,
00454                 CL_TextureFormat internal_format = cl_rgba);
00455 
00456         void copy_image_from(
00457                 CL_GraphicContext &context,
00458                 const CL_Rect &pos,
00459                 int level = 0,
00460                 CL_TextureFormat internal_format = cl_rgba);
00461 
00463         void copy_subimage_from(
00464                 CL_GraphicContext &context,
00465                 int offset_x,
00466                 int offset_y,
00467                 int x,
00468                 int y,
00469                 int width,
00470                 int height,
00471                 int level = 0);
00472 
00473         void copy_subimage_from(
00474                 CL_GraphicContext &context,
00475                 const CL_Point &offset,
00476                 const CL_Rect &pos,
00477                 int level = 0);
00478 
00480         void set_min_lod(float min_lod);
00481 
00483         void set_max_lod(float max_lod);
00484 
00486         void set_lod_bias(float lod_bias);
00487 
00489         void set_base_level(int base_level);
00490 
00492         void set_max_level(int max_level);
00493 
00495         void set_generate_mipmap(bool generate_mipmap = true);
00496 
00498         void set_wrap_mode(
00499                 CL_TextureWrapMode wrap_s,
00500                 CL_TextureWrapMode wrap_t,
00501                 CL_TextureWrapMode wrap_r);
00502 
00503         void set_wrap_mode(
00504                 CL_TextureWrapMode wrap_s,
00505                 CL_TextureWrapMode wrap_t);
00506 
00507         void set_wrap_mode(
00508                 CL_TextureWrapMode wrap_s);
00509 
00511         void set_min_filter(CL_TextureFilter filter);
00512 
00514         void set_mag_filter(CL_TextureFilter filter);
00515 
00517         void set_max_anisotropy(float max_anisotropy);
00518 
00520         void set_depth_mode(CL_TextureDepthMode depth_mode);
00521 
00523         void set_texture_compare(CL_TextureCompareMode mode, CL_CompareFunction func);
00524 
00528 private:
00529         CL_SharedPtr<CL_Texture_Impl> impl;
00531 };
00532 

Generated on Thu Dec 3 02:39:32 2009 for ClanLib by  doxygen 1.4.6