OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Texture.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_TEXTURE
15 #define OSG_TEXTURE 1
16 
17 #include <osg/GL>
18 #include <osg/Image>
19 #include <osg/StateAttribute>
20 #include <osg/GraphicsContext>
21 #include <osg/ref_ptr>
22 #include <osg/Vec4>
23 #include <osg/Vec4d>
24 #include <osg/Vec4i>
25 #include <osg/buffered_value>
26 #include <osg/GLExtensions>
27 
28 #include <list>
29 #include <map>
30 
31 // If not defined by gl.h use the definition found in:
32 // http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_filter_anisotropic.txt
33 #ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
34  #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
35 #endif
36 
37 // If not defined, use the definition found in:
38 // http://www.opengl.org/registry/specs/ARB/texture_swizzle.txt
39 #ifndef GL_TEXTURE_SWIZZLE_RGBA
40  #define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
41 #endif
42 
43 #ifndef GL_ARB_texture_compression
44  #define GL_COMPRESSED_ALPHA_ARB 0x84E9
45  #define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
46  #define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
47  #define GL_COMPRESSED_INTENSITY_ARB 0x84EC
48  #define GL_COMPRESSED_RGB_ARB 0x84ED
49  #define GL_COMPRESSED_RGBA_ARB 0x84EE
50  #define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
51  #define GL_TEXTURE_COMPRESSED_ARB 0x86A1
52  #define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
53  #define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
54 #endif
55 
56 #ifndef GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
57  #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
58 #endif
59 
60 #ifndef GL_EXT_texture_compression_s3tc
61  #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
62  #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
63  #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
64  #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
65 #endif
66 
67 #ifndef GL_EXT_texture_compression_rgtc
68  #define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
69  #define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
70  #define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
71  #define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
72 #endif
73 
74 #ifndef GL_IMG_texture_compression_pvrtc
75  #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
76  #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
77  #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
78  #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
79 #endif
80 
81 #ifndef GL_OES_compressed_ETC1_RGB8_texture
82  #define GL_ETC1_RGB8_OES 0x8D64
83 #endif
84 
85 #ifndef GL_ARB_INTERNAL_TEXTURE_FORMAT
86  #define GL_RGBA32F_ARB 0x8814
87  #define GL_RGB32F_ARB 0x8815
88  #define GL_ALPHA32F_ARB 0x8816
89  #define GL_INTENSITY32F_ARB 0x8817
90  #define GL_LUMINANCE32F_ARB 0x8818
91  #define GL_LUMINANCE_ALPHA32F_ARB 0x8819
92  #define GL_RGBA16F_ARB 0x881A
93  #define GL_RGB16F_ARB 0x881B
94  #define GL_ALPHA16F_ARB 0x881C
95  #define GL_INTENSITY16F_ARB 0x881D
96  #define GL_LUMINANCE16F_ARB 0x881E
97  #define GL_LUMINANCE_ALPHA16F_ARB 0x881F
98 #endif
99 
100 #ifndef GL_HALF_FLOAT
101  #define GL_HALF_FLOAT 0x140B
102 #endif
103 
104 #ifndef GL_NV_texture_shader
105  #define GL_HILO_NV 0x86F4
106  #define GL_DSDT_NV 0x86F5
107  #define GL_DSDT_MAG_NV 0x86F6
108  #define GL_DSDT_MAG_VIB_NV 0x86F7
109  #define GL_HILO16_NV 0x86F8
110  #define GL_SIGNED_HILO_NV 0x86F9
111  #define GL_SIGNED_HILO16_NV 0x86FA
112  #define GL_SIGNED_RGBA_NV 0x86FB
113  #define GL_SIGNED_RGBA8_NV 0x86FC
114  #define GL_SIGNED_RGB_NV 0x86FE
115  #define GL_SIGNED_RGB8_NV 0x86FF
116  #define GL_SIGNED_LUMINANCE_NV 0x8701
117  #define GL_SIGNED_LUMINANCE8_NV 0x8702
118  #define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
119  #define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
120  #define GL_SIGNED_ALPHA_NV 0x8705
121  #define GL_SIGNED_ALPHA8_NV 0x8706
122  #define GL_SIGNED_INTENSITY_NV 0x8707
123  #define GL_SIGNED_INTENSITY8_NV 0x8708
124  #define GL_DSDT8_NV 0x8709
125  #define GL_DSDT8_MAG8_NV 0x870A
126  #define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
127  #define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
128  #define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
129 #endif
130 
131 #ifndef GL_NV_float_buffer
132  #define GL_FLOAT_R_NV 0x8880
133  #define GL_FLOAT_RG_NV 0x8881
134  #define GL_FLOAT_RGB_NV 0x8882
135  #define GL_FLOAT_RGBA_NV 0x8883
136  #define GL_FLOAT_R16_NV 0x8884
137  #define GL_FLOAT_R32_NV 0x8885
138  #define GL_FLOAT_RG16_NV 0x8886
139  #define GL_FLOAT_RG32_NV 0x8887
140  #define GL_FLOAT_RGB16_NV 0x8888
141  #define GL_FLOAT_RGB32_NV 0x8889
142  #define GL_FLOAT_RGBA16_NV 0x888A
143  #define GL_FLOAT_RGBA32_NV 0x888B
144 #endif
145 
146 #ifndef GL_ATI_texture_float
147  #define GL_RGBA_FLOAT32_ATI 0x8814
148  #define GL_RGB_FLOAT32_ATI 0x8815
149  #define GL_ALPHA_FLOAT32_ATI 0x8816
150  #define GL_INTENSITY_FLOAT32_ATI 0x8817
151  #define GL_LUMINANCE_FLOAT32_ATI 0x8818
152  #define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819
153  #define GL_RGBA_FLOAT16_ATI 0x881A
154  #define GL_RGB_FLOAT16_ATI 0x881B
155  #define GL_ALPHA_FLOAT16_ATI 0x881C
156  #define GL_INTENSITY_FLOAT16_ATI 0x881D
157  #define GL_LUMINANCE_FLOAT16_ATI 0x881E
158  #define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F
159 #endif
160 
161 #ifndef GL_MIRRORED_REPEAT_IBM
162  #define GL_MIRRORED_REPEAT_IBM 0x8370
163 #endif
164 
165 #ifndef GL_CLAMP_TO_EDGE
166  #define GL_CLAMP_TO_EDGE 0x812F
167 #endif
168 
169 #ifndef GL_CLAMP
170  #define GL_CLAMP 0x2900
171 #endif
172 
173 #ifndef GL_CLAMP_TO_BORDER_ARB
174  #define GL_CLAMP_TO_BORDER_ARB 0x812D
175 #endif
176 
177 #ifndef GL_INTENSITY
178  // OpenGL ES1 and ES2 doesn't provide GL_INTENSITY
179  #define GL_INTENSITY 0x8049
180 #endif
181 
182 #ifndef GL_GENERATE_MIPMAP_SGIS
183  #define GL_GENERATE_MIPMAP_SGIS 0x8191
184  #define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
185 #endif
186 
187 #ifndef GL_TEXTURE_3D
188  #define GL_TEXTURE_3D 0x806F
189 #endif
190 
191 
192 #ifndef GL_TEXTURE_CUBE_MAP
193  #define GL_TEXTURE_CUBE_MAP 0x8513
194  #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
195  #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
196  #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
197  #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
198  #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
199  #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
200  #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
201  #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
202  #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
203 #endif
204 
205 #ifndef GL_TEXTURE_BINDING_3D
206  #define GL_TEXTURE_BINDING_3D 0x806A
207 #endif
208 
209 #ifndef GL_DEPTH_TEXTURE_MODE_ARB
210  #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
211 #endif
212 
213 #ifndef GL_TEXTURE_COMPARE_MODE_ARB
214  #define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
215 #endif
216 #ifndef GL_TEXTURE_COMPARE_FUNC_ARB
217  #define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
218 #endif
219 #ifndef GL_COMPARE_R_TO_TEXTURE_ARB
220  #define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
221 #endif
222 
223 #ifndef TEXTURE_COMPARE_FAIL_VALUE_ARB
224  #define TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
225 #endif
226 
227 #if !defined( GL_MAX_TEXTURE_UNITS )
228  #define GL_MAX_TEXTURE_UNITS 0x84E2
229 #endif
230 
231 #ifndef GL_TEXTURE_DEPTH
232  #define GL_TEXTURE_DEPTH 0x8071
233 #endif
234 
235 #ifndef GL_TEXTURE_2D_MULTISAMPLE
236  #define GL_TEXTURE_2D_MULTISAMPLE 0x9100
237 #endif
238 
239 // Integer texture extension as in http://www.opengl.org/registry/specs/EXT/texture_integer.txt
240 #ifndef GL_EXT_texture_integer
241  #define GL_RGBA32UI_EXT 0x8D70
242  #define GL_RGB32UI_EXT 0x8D71
243  #define GL_ALPHA32UI_EXT 0x8D72
244  #define GL_INTENSITY32UI_EXT 0x8D73
245  #define GL_LUMINANCE32UI_EXT 0x8D74
246  #define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75
247 
248  #define GL_RGBA16UI_EXT 0x8D76
249  #define GL_RGB16UI_EXT 0x8D77
250  #define GL_ALPHA16UI_EXT 0x8D78
251  #define GL_INTENSITY16UI_EXT 0x8D79
252  #define GL_LUMINANCE16UI_EXT 0x8D7A
253  #define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B
254 
255  #define GL_RGBA8UI_EXT 0x8D7C
256  #define GL_RGB8UI_EXT 0x8D7D
257  #define GL_ALPHA8UI_EXT 0x8D7E
258  #define GL_INTENSITY8UI_EXT 0x8D7F
259  #define GL_LUMINANCE8UI_EXT 0x8D80
260  #define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81
261 
262  #define GL_RGBA32I_EXT 0x8D82
263  #define GL_RGB32I_EXT 0x8D83
264  #define GL_ALPHA32I_EXT 0x8D84
265  #define GL_INTENSITY32I_EXT 0x8D85
266  #define GL_LUMINANCE32I_EXT 0x8D86
267  #define GL_LUMINANCE_ALPHA32I_EXT 0x8D87
268 
269  #define GL_RGBA16I_EXT 0x8D88
270  #define GL_RGB16I_EXT 0x8D89
271  #define GL_ALPHA16I_EXT 0x8D8A
272  #define GL_INTENSITY16I_EXT 0x8D8B
273  #define GL_LUMINANCE16I_EXT 0x8D8C
274  #define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D
275 
276  #define GL_RGBA8I_EXT 0x8D8E
277  #define GL_RGB8I_EXT 0x8D8F
278  #define GL_ALPHA8I_EXT 0x8D90
279  #define GL_INTENSITY8I_EXT 0x8D91
280  #define GL_LUMINANCE8I_EXT 0x8D92
281  #define GL_LUMINANCE_ALPHA8I_EXT 0x8D93
282 
283  #define GL_RED_INTEGER_EXT 0x8D94
284  #define GL_GREEN_INTEGER_EXT 0x8D95
285  #define GL_BLUE_INTEGER_EXT 0x8D96
286  #define GL_ALPHA_INTEGER_EXT 0x8D97
287  #define GL_RGB_INTEGER_EXT 0x8D98
288  #define GL_RGBA_INTEGER_EXT 0x8D99
289  #define GL_BGR_INTEGER_EXT 0x8D9A
290  #define GL_BGRA_INTEGER_EXT 0x8D9B
291  #define GL_LUMINANCE_INTEGER_EXT 0x8D9C
292  #define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D
293 
294  #define GL_RGBA_INTEGER_MODE_EXT 0x8D9E
295 #endif
296 
297 #ifndef GL_VERSION_1_1
298 #define GL_R3_G3_B2 0x2A10
299 #define GL_RGB4 0x804F
300 #define GL_RGB5 0x8050
301 #define GL_RGB8 0x8051
302 #define GL_RGB10 0x8052
303 #define GL_RGB12 0x8053
304 #define GL_RGB16 0x8054
305 #define GL_RGBA2 0x8055
306 #define GL_RGBA4 0x8056
307 #define GL_RGB5_A1 0x8057
308 #define GL_RGBA8 0x8058
309 #define GL_RGB10_A2 0x8059
310 #define GL_RGBA12 0x805A
311 #define GL_RGBA16 0x805B
312 #define GL_BGR_EXT 0x80E0
313 #define GL_BGRA_EXT 0x80E1
314 #endif
315 
316 #ifndef GL_ARB_texture_rg
317  #define GL_RG 0x8227
318  #define GL_RG_INTEGER 0x8228
319  #define GL_R8 0x8229
320  #define GL_R16 0x822A
321  #define GL_RG8 0x822B
322  #define GL_RG16 0x822C
323  #define GL_R16F 0x822D
324  #define GL_R32F 0x822E
325  #define GL_RG16F 0x822F
326  #define GL_RG32F 0x8230
327  #define GL_R8I 0x8231
328  #define GL_R8UI 0x8232
329  #define GL_R16I 0x8233
330  #define GL_R16UI 0x8234
331  #define GL_R32I 0x8235
332  #define GL_R32UI 0x8236
333  #define GL_RG8I 0x8237
334  #define GL_RG8UI 0x8238
335  #define GL_RG16I 0x8239
336  #define GL_RG16UI 0x823A
337  #define GL_RG32I 0x823B
338  #define GL_RG32UI 0x823C
339 #endif
340 
341 #ifndef GL_ARB_shader_image_load_store
342  #define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
343  #define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
344  #define GL_UNIFORM_BARRIER_BIT 0x00000004
345  #define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
346  #define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
347  #define GL_COMMAND_BARRIER_BIT 0x00000040
348  #define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
349  #define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
350  #define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
351  #define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
352  #define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
353  #define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
354  #define GL_ALL_BARRIER_BITS 0xFFFFFFFF
355  #define GL_MAX_IMAGE_UNITS 0x8F38
356  #define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
357  #define GL_IMAGE_BINDING_NAME 0x8F3A
358  #define GL_IMAGE_BINDING_LEVEL 0x8F3B
359  #define GL_IMAGE_BINDING_LAYERED 0x8F3C
360  #define GL_IMAGE_BINDING_LAYER 0x8F3D
361  #define GL_IMAGE_BINDING_ACCESS 0x8F3E
362  #define GL_IMAGE_1D 0x904C
363  #define GL_IMAGE_2D 0x904D
364  #define GL_IMAGE_3D 0x904E
365  #define GL_IMAGE_2D_RECT 0x904F
366  #define GL_IMAGE_CUBE 0x9050
367  #define GL_IMAGE_BUFFER 0x9051
368  #define GL_IMAGE_1D_ARRAY 0x9052
369  #define GL_IMAGE_2D_ARRAY 0x9053
370  #define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
371  #define GL_IMAGE_2D_MULTISAMPLE 0x9055
372  #define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
373  #define GL_INT_IMAGE_1D 0x9057
374  #define GL_INT_IMAGE_2D 0x9058
375  #define GL_INT_IMAGE_3D 0x9059
376  #define GL_INT_IMAGE_2D_RECT 0x905A
377  #define GL_INT_IMAGE_CUBE 0x905B
378  #define GL_INT_IMAGE_BUFFER 0x905C
379  #define GL_INT_IMAGE_1D_ARRAY 0x905D
380  #define GL_INT_IMAGE_2D_ARRAY 0x905E
381  #define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
382  #define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
383  #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
384  #define GL_UNSIGNED_INT_IMAGE_1D 0x9062
385  #define GL_UNSIGNED_INT_IMAGE_2D 0x9063
386  #define GL_UNSIGNED_INT_IMAGE_3D 0x9064
387  #define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
388  #define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
389  #define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
390  #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
391  #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
392  #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
393  #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
394  #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
395  #define GL_MAX_IMAGE_SAMPLES 0x906D
396  #define GL_IMAGE_BINDING_FORMAT 0x906E
397  #define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
398  #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
399  #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
400  #define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA
401  #define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
402  #define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
403  #define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD
404  #define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE
405  #define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF
406 #endif
407 
408 namespace osg {
409 
410 
415 {
416 
417  public :
418 
419  Texture();
420 
422  Texture(const Texture& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
423 
424  virtual osg::Object* cloneType() const = 0;
425  virtual osg::Object* clone(const CopyOp& copyop) const = 0;
426  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Texture *>(obj)!=NULL; }
427  virtual const char* libraryName() const { return "osg"; }
428  virtual const char* className() const { return "Texture"; }
429 
431  virtual Texture* asTexture() { return this; }
432 
434  virtual const Texture* asTexture() const { return this; }
435 
436  virtual Type getType() const { return TEXTURE; }
437 
438  virtual bool isTextureAttribute() const { return true; }
439 
440  virtual GLenum getTextureTarget() const = 0;
441 
442  virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
443  {
444  #ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
445  usage.usesTextureMode(getTextureTarget());
446  #endif
447  return true;
448  }
449 
450  virtual int getTextureWidth() const { return 0; }
451  virtual int getTextureHeight() const { return 0; }
452  virtual int getTextureDepth() const { return 0; }
453 
457  WRAP_R
458  };
459 
460  enum WrapMode {
461  CLAMP = GL_CLAMP,
462  CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
463  CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER_ARB,
464  REPEAT = GL_REPEAT,
466  };
467 
469  void setWrap(WrapParameter which, WrapMode wrap);
471  WrapMode getWrap(WrapParameter which) const;
472 
473 
477  void setBorderColor(const Vec4d& color) { _borderColor = color; dirtyTextureParameters(); }
478 
480  const Vec4d& getBorderColor() const { return _borderColor; }
481 
483  void setBorderWidth(GLint width) { _borderWidth = width; dirtyTextureParameters(); }
484 
485  GLint getBorderWidth() const { return _borderWidth; }
486 
489  MAG_FILTER
490  };
491 
492  enum FilterMode {
493  LINEAR = GL_LINEAR,
494  LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR,
495  LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST,
496  NEAREST = GL_NEAREST,
497  NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR,
498  NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST
499  };
500 
502  void setFilter(FilterParameter which, FilterMode filter);
503 
505  FilterMode getFilter(FilterParameter which) const;
506 
512  void setMaxAnisotropy(float anis);
513 
515  inline float getMaxAnisotropy() const { return _maxAnisotropy; }
516 
518  inline void setSwizzle(const Vec4i& swizzle) { _swizzle = swizzle; dirtyTextureParameters(); };
519 
521  inline const Vec4i& getSwizzle() const { return _swizzle; }
522 
525  inline void setUseHardwareMipMapGeneration(bool useHardwareMipMapGeneration) { _useHardwareMipMapGeneration = useHardwareMipMapGeneration; }
526 
528  inline bool getUseHardwareMipMapGeneration() const { return _useHardwareMipMapGeneration; }
529 
533  inline void setUnRefImageDataAfterApply(bool flag) { _unrefImageDataAfterApply = flag; }
534 
536  inline bool getUnRefImageDataAfterApply() const { return _unrefImageDataAfterApply; }
537 
542  inline void setClientStorageHint(bool flag) { _clientStorageHint = flag; }
543 
545  inline bool getClientStorageHint() const { return _clientStorageHint; }
546 
551  inline void setResizeNonPowerOfTwoHint(bool flag) { _resizeNonPowerOfTwoHint = flag; }
552 
554  inline bool getResizeNonPowerOfTwoHint() const { return _resizeNonPowerOfTwoHint; }
555 
570  USE_S3TC_DXT1a_COMPRESSION
571  };
572 
577  inline void setInternalFormatMode(InternalFormatMode mode) { _internalFormatMode = mode; }
578 
580  inline InternalFormatMode getInternalFormatMode() const { return _internalFormatMode; }
581 
586  {
587  _internalFormatMode = USE_USER_DEFINED_FORMAT;
588  _internalFormat = internalFormat;
589  computeInternalFormatType();
590  }
591 
592 
594  inline GLint getInternalFormat() const { if (_internalFormat==0) computeInternalFormat(); return _internalFormat; }
595 
597  bool isCompressedInternalFormat() const;
598 
600  inline void setSourceFormat(GLenum sourceFormat) { _sourceFormat = sourceFormat; }
601 
603  inline GLenum getSourceFormat() const { return _sourceFormat; }
604 
606  inline void setSourceType(GLenum sourceType) { _sourceType = sourceType; }
607 
609  inline GLenum getSourceType() const { return _sourceType; }
610 
613 
615  NORMALIZED = 0x0,
616 
618  FLOAT = 0x1,
619 
621  SIGNED_INTEGER = 0x2,
622 
624  UNSIGNED_INTEGER = 0x4
625  };
626 
628  inline InternalFormatType getInternalFormatType() const { return _internalFormatType; }
629 
630  class TextureObject;
631 
633  inline TextureObject* getTextureObject(unsigned int contextID) const
634  {
635  return _textureObjectBuffer[contextID].get();
636  }
637 
638  inline void setTextureObject(unsigned int contextID, TextureObject* to)
639  {
640  _textureObjectBuffer[contextID] = to;
641  }
642 
645  void dirtyTextureObject();
646 
649  bool areAllTextureObjectsLoaded() const;
650 
651 
653  inline unsigned int& getTextureParameterDirty(unsigned int contextID) const
654  {
655  return _texParametersDirtyList[contextID];
656  }
657 
658 
661  void dirtyTextureParameters();
662 
670  void allocateMipmapLevels();
671 
674  {
675  GLuint unit;
676  GLint level;
677  GLboolean layered;
678  GLint layer;
679  GLenum access;
680  GLenum format;
681 
683  : unit(0), level(0), layered(GL_FALSE), layer(0), access(0), format(0) {}
684  };
685 
688  {
689  NOT_USED = 0,
690  READ_ONLY = GL_READ_ONLY_ARB,
691  WRITE_ONLY = GL_WRITE_ONLY_ARB,
692  READ_WRITE = GL_READ_WRITE_ARB
693  };
694 
699  void bindToImageUnit(unsigned int unit, GLenum access, GLenum format=0, int level=0, bool layered=false, int layer=0);
700 
701  ImageAttachment& getImageAttachment() { return _imageAttachment; }
702  const ImageAttachment& getImageAttachment() const { return _imageAttachment; }
703 
706  void setShadowComparison(bool flag) { _use_shadow_comparison = flag; }
707  bool getShadowComparison() const { return _use_shadow_comparison; }
708 
710  NEVER = GL_NEVER,
711  LESS = GL_LESS,
712  EQUAL = GL_EQUAL,
713  LEQUAL = GL_LEQUAL,
714  GREATER = GL_GREATER,
715  NOTEQUAL = GL_NOTEQUAL,
716  GEQUAL = GL_GEQUAL,
717  ALWAYS = GL_ALWAYS
718  };
719 
721  void setShadowCompareFunc(ShadowCompareFunc func) { _shadow_compare_func = func; }
722  ShadowCompareFunc getShadowCompareFunc() const { return _shadow_compare_func; }
723 
725  LUMINANCE = GL_LUMINANCE,
726  INTENSITY = GL_INTENSITY,
727  ALPHA = GL_ALPHA
728  };
729 
731  void setShadowTextureMode(ShadowTextureMode mode) { _shadow_texture_mode = mode; }
732  ShadowTextureMode getShadowTextureMode() const { return _shadow_texture_mode; }
733 
736  void setShadowAmbient(float shadow_ambient) { _shadow_ambient = shadow_ambient; }
737  float getShadowAmbient() const { return _shadow_ambient; }
738 
739 
741  virtual void setImage(unsigned int face, Image* image) = 0;
742 
744  virtual Image* getImage(unsigned int face) = 0;
745 
747  virtual const Image* getImage(unsigned int face) const = 0;
748 
750  virtual unsigned int getNumImages() const = 0;
751 
752 
754  void setReadPBuffer(GraphicsContext* context) { _readPBuffer = context; }
755 
757  GraphicsContext* getReadPBuffer() { return _readPBuffer.get(); }
758 
760  const GraphicsContext* getReadPBuffer() const { return _readPBuffer.get(); }
761 
763  virtual void apply(State& state) const = 0;
764 
766  virtual void compileGLObjects(State& state) const;
767 
769  virtual void resizeGLObjectBuffers(unsigned int maxSize);
770 
774  virtual void releaseGLObjects(State* state=0) const;
775 
778  static bool isCompressedInternalFormat(GLint internalFormat);
779 
783  static void getCompressedSize(GLenum internalFormat, GLint width, GLint height, GLint depth, GLint& blockSize, GLint& size);
784 
785 
789  void applyTexImage2D_load(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height,GLsizei numMipmapLevels) const;
790 
794  void applyTexImage2D_subload(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height, GLint inInternalFormat, GLsizei numMipmapLevels) const;
795 
796 
800  {
803  GENERATE_MIPMAP_TEX_PARAMETER
804  };
805 
806  protected :
807 
808  virtual ~Texture();
809 
810  virtual void computeInternalFormat() const = 0;
811 
813  void computeInternalFormatWithImage(const osg::Image& image) const;
814 
816  void computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& width, GLsizei& height,GLsizei& numMipmapLevels) const;
817 
819  void computeInternalFormatType() const;
820 
822  void applyTexParameters(GLenum target, State& state) const;
823 
826  bool isHardwareMipmapGenerationEnabled(const State& state) const;
827 
829  bool isSafeToUnrefImageData(const State& state) const {
830  return (_unrefImageDataAfterApply && state.getMaxTexturePoolSize()==0 && areAllTextureObjectsLoaded());
831  }
832 
835  GenerateMipmapMode mipmapBeforeTexImage(const State& state, bool hardwareMipmapOn) const;
836  void mipmapAfterTexImage(State& state, GenerateMipmapMode beforeResult) const;
837 
840  void generateMipmap(State& state) const;
841 
843  virtual void allocateMipmap(State& state) const = 0;
844 
846  int compareTexture(const Texture& rhs) const;
847 
849  int compareTextureObjects(const Texture& rhs) const;
850 
852  mutable TexParameterDirtyList _texParametersDirtyList;
853  mutable TexParameterDirtyList _texMipmapGenerationDirtyList;
854 
858 
867 
870 
873  mutable GLint _internalFormat;
874  mutable GLenum _sourceFormat;
875  mutable GLenum _sourceType;
876 
881 
883 
884  public:
885 
887  {
888  inline TextureProfile(GLenum target):
889  _target(target),
890  _numMipmapLevels(0),
891  _internalFormat(0),
892  _width(0),
893  _height(0),
894  _depth(0),
895  _border(0),
896  _size(0) {}
897 
898  inline TextureProfile(GLenum target,
899  GLint numMipmapLevels,
900  GLenum internalFormat,
901  GLsizei width,
902  GLsizei height,
903  GLsizei depth,
904  GLint border):
905  _target(target),
906  _numMipmapLevels(numMipmapLevels),
907  _internalFormat(internalFormat),
908  _width(width),
909  _height(height),
910  _depth(depth),
911  _border(border),
912  _size(0) { computeSize(); }
913 
914 
915  #define LESSTHAN(A,B) if (A<B) return true; if (B<A) return false;
916  #define FINALLESSTHAN(A,B) return (A<B);
917 
918  bool operator < (const TextureProfile& rhs) const
919  {
920  LESSTHAN(_size,rhs._size);
921  LESSTHAN(_target,rhs._target);
922  LESSTHAN(_numMipmapLevels,rhs._numMipmapLevels);
923  LESSTHAN(_internalFormat,rhs._internalFormat);
924  LESSTHAN(_width,rhs._width);
925  LESSTHAN(_height,rhs._height);
926  LESSTHAN(_depth,rhs._depth);
927  FINALLESSTHAN(_border, rhs._border);
928  }
929 
930  bool operator == (const TextureProfile& rhs) const
931  {
932  return _target == rhs._target &&
933  _numMipmapLevels == rhs._numMipmapLevels &&
934  _internalFormat == rhs._internalFormat &&
935  _width == rhs._width &&
936  _height == rhs._height &&
937  _depth == rhs._depth &&
938  _border == rhs._border;
939  }
940 
941  inline void set(GLint numMipmapLevels,
942  GLenum internalFormat,
943  GLsizei width,
944  GLsizei height,
945  GLsizei depth,
946  GLint border)
947  {
948  _numMipmapLevels = numMipmapLevels;
949  _internalFormat = internalFormat;
950  _width = width;
951  _height = height;
952  _depth = depth;
953  _border = border;
954  computeSize();
955  }
956 
957  inline bool match(GLenum target,
958  GLint numMipmapLevels,
959  GLenum internalFormat,
960  GLsizei width,
961  GLsizei height,
962  GLsizei depth,
963  GLint border)
964  {
965  return (_target == target) &&
966  (_numMipmapLevels == numMipmapLevels) &&
967  (_internalFormat == internalFormat) &&
968  (_width == width) &&
969  (_height == height) &&
970  (_depth == depth) &&
971  (_border == border);
972  }
973 
974  void computeSize();
975 
976  GLenum _target;
979  GLsizei _width;
980  GLsizei _height;
981  GLsizei _depth;
982  GLint _border;
983  unsigned int _size;
984  };
985 
986  // forward declare
987  class TextureObjectSet;
988  class TextureObjectManager;
989 
991  {
992  public:
993 
994  inline TextureObject(Texture* texture, GLuint id, GLenum target):
995  _id(id),
996  _profile(target),
997  _set(0),
998  _previous(0),
999  _next(0),
1000  _texture(texture),
1001  _allocated(false),
1002  _timeStamp(0) {}
1003 
1004  inline TextureObject(Texture* texture, GLuint id, const TextureProfile& profile):
1005  _id(id),
1006  _profile(profile),
1007  _set(0),
1008  _previous(0),
1009  _next(0),
1010  _texture(texture),
1011  _allocated(false),
1012  _timeStamp(0) {}
1013 
1014  inline TextureObject(Texture* texture,
1015  GLuint id,
1016  GLenum target,
1017  GLint numMipmapLevels,
1018  GLenum internalFormat,
1019  GLsizei width,
1020  GLsizei height,
1021  GLsizei depth,
1022  GLint border):
1023  _id(id),
1024  _profile(target,numMipmapLevels,internalFormat,width,height,depth,border),
1025  _set(0),
1026  _previous(0),
1027  _next(0),
1028  _texture(texture),
1029  _allocated(false),
1030  _timeStamp(0) {}
1031 
1032  inline bool match(GLenum target,
1033  GLint numMipmapLevels,
1034  GLenum internalFormat,
1035  GLsizei width,
1036  GLsizei height,
1037  GLsizei depth,
1038  GLint border)
1039  {
1040  return isReusable() &&
1041  _profile.match(target,numMipmapLevels,internalFormat,width,height,depth,border);
1042  }
1043 
1044 
1045  void bind();
1046 
1047  inline GLenum id() const { return _id; }
1048  inline GLenum target() const { return _profile._target; }
1049 
1050  inline unsigned int size() const { return _profile._size; }
1051 
1052  inline void setTexture(Texture* texture) { _texture = texture; }
1053  inline Texture* getTexture() const { return _texture; }
1054 
1055  inline void setTimeStamp(double timestamp) { _timeStamp = timestamp; }
1056  inline double getTimeStamp() const { return _timeStamp; }
1057 
1058  inline void setAllocated(bool allocated=true) { _allocated = allocated; }
1059 
1060  void setAllocated(GLint numMipmapLevels,
1061  GLenum internalFormat,
1062  GLsizei width,
1063  GLsizei height,
1064  GLsizei depth,
1065  GLint border);
1066 
1067  inline bool isAllocated() const { return _allocated; }
1068 
1069  inline bool isReusable() const { return _allocated && _profile._width!=0; }
1070 
1071 
1072  GLuint _id;
1079  unsigned int _frameLastUsed;
1080  double _timeStamp;
1081 
1082  protected:
1083  virtual ~TextureObject();
1084 
1085  };
1086 
1087  typedef std::list< ref_ptr<TextureObject> > TextureObjectList;
1088 
1090  {
1091  public:
1092  TextureObjectSet(TextureObjectManager* parent, const TextureProfile& profile);
1093 
1094  const TextureProfile& getProfile() const { return _profile; }
1095 
1096  void handlePendingOrphandedTextureObjects();
1097 
1098  void deleteAllTextureObjects();
1099  void discardAllTextureObjects();
1100  void flushAllDeletedTextureObjects();
1101  void discardAllDeletedTextureObjects();
1102  void flushDeletedTextureObjects(double currentTime, double& availableTime);
1103 
1104  osg::ref_ptr<TextureObject> takeFromOrphans(Texture* texture);
1105  osg::ref_ptr<TextureObject> takeOrGenerate(Texture* texture);
1106  void moveToBack(TextureObject* to);
1107  void addToBack(TextureObject* to);
1108  void orphan(TextureObject* to);
1109  void remove(TextureObject* to);
1110  void moveToSet(TextureObject* to, TextureObjectSet* set);
1111 
1112  unsigned int size() const { return _profile._size * _numOfTextureObjects; }
1113 
1114  bool makeSpace(unsigned int& size);
1115 
1116  bool checkConsistency() const;
1117 
1118  TextureObjectManager* getParent() { return _parent; }
1119 
1120  unsigned int computeNumTextureObjectsInList() const;
1121  unsigned int getNumOfTextureObjects() const { return _numOfTextureObjects; }
1122  unsigned int getNumOrphans() const { return static_cast<unsigned int>(_orphanedTextureObjects.size()); }
1123  unsigned int getNumPendingOrphans() const { return static_cast<unsigned int>(_pendingOrphanedTextureObjects.size()); }
1124 
1125  protected:
1126 
1127  virtual ~TextureObjectSet();
1128 
1130 
1132  unsigned int _contextID;
1134  unsigned int _numOfTextureObjects;
1135  TextureObjectList _orphanedTextureObjects;
1137 
1140 
1141  };
1142 
1144  {
1145  public:
1146  TextureObjectManager(unsigned int contextID);
1147 
1148  unsigned int getContextID() const { return _contextID; }
1149 
1150 
1151 
1152  void setNumberActiveTextureObjects(unsigned int size) { _numActiveTextureObjects = size; }
1153  unsigned int& getNumberActiveTextureObjects() { return _numActiveTextureObjects; }
1154  unsigned int getNumberActiveTextureObjects() const { return _numActiveTextureObjects; }
1155 
1156  void setNumberOrphanedTextureObjects(unsigned int size) { _numOrphanedTextureObjects = size; }
1157  unsigned int& getNumberOrphanedTextureObjects() { return _numOrphanedTextureObjects; }
1158  unsigned int getNumberOrphanedTextureObjects() const { return _numOrphanedTextureObjects; }
1159 
1160  void setCurrTexturePoolSize(unsigned int size) { _currTexturePoolSize = size; }
1161  unsigned int& getCurrTexturePoolSize() { return _currTexturePoolSize; }
1162  unsigned int getCurrTexturePoolSize() const { return _currTexturePoolSize; }
1163 
1164  void setMaxTexturePoolSize(unsigned int size);
1165  unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
1166 
1167  bool hasSpace(unsigned int size) const { return (_currTexturePoolSize+size)<=_maxTexturePoolSize; }
1168  bool makeSpace(unsigned int size);
1169 
1170  osg::ref_ptr<TextureObject> generateTextureObject(const Texture* texture, GLenum target);
1171  osg::ref_ptr<TextureObject> generateTextureObject(const Texture* texture,
1172  GLenum target,
1173  GLint numMipmapLevels,
1174  GLenum internalFormat,
1175  GLsizei width,
1176  GLsizei height,
1177  GLsizei depth,
1178  GLint border);
1179  void handlePendingOrphandedTextureObjects();
1180  void deleteAllTextureObjects();
1181  void discardAllTextureObjects();
1182  void flushAllDeletedTextureObjects();
1183  void discardAllDeletedTextureObjects();
1184  void flushDeletedTextureObjects(double currentTime, double& availableTime);
1185  void releaseTextureObject(TextureObject* to);
1186 
1187  TextureObjectSet* getTextureObjectSet(const TextureProfile& profile);
1188 
1189  void newFrame(osg::FrameStamp* fs);
1190  void resetStats();
1191  void reportStats(std::ostream& out);
1192  void recomputeStats(std::ostream& out) const;
1193  bool checkConsistency() const;
1194 
1195  unsigned int& getFrameNumber() { return _frameNumber; }
1196  unsigned int& getNumberFrames() { return _numFrames; }
1197 
1198  unsigned int& getNumberDeleted() { return _numDeleted; }
1199  double& getDeleteTime() { return _deleteTime; }
1200 
1201  unsigned int& getNumberGenerated() { return _numGenerated; }
1202  double& getGenerateTime() { return _generateTime; }
1203 
1204  unsigned int& getNumberApplied() { return _numApplied; }
1205  double& getApplyTime() { return _applyTime; }
1206 
1207 
1208  protected:
1209 
1210  typedef std::map< TextureProfile, osg::ref_ptr<TextureObjectSet> > TextureSetMap;
1211  unsigned int _contextID;
1214  unsigned int _currTexturePoolSize;
1215  unsigned int _maxTexturePoolSize;
1216  TextureSetMap _textureSetMap;
1217 
1218  unsigned int _frameNumber;
1219 
1220  unsigned int _numFrames;
1221  unsigned int _numDeleted;
1222  double _deleteTime;
1223 
1224  unsigned int _numGenerated;
1226 
1227  unsigned int _numApplied;
1228  double _applyTime;
1229 
1230  };
1231 
1232  static osg::ref_ptr<Texture::TextureObjectManager>& getTextureObjectManager(unsigned int contextID);
1233 
1234  static osg::ref_ptr<TextureObject> generateTextureObject(const Texture* texture, unsigned int contextID,GLenum target);
1235 
1236  static osg::ref_ptr<TextureObject> generateTextureObject(const Texture* texture,
1237  unsigned int contextID,
1238  GLenum target,
1239  GLint numMipmapLevels,
1240  GLenum internalFormat,
1241  GLsizei width,
1242  GLsizei height,
1243  GLsizei depth,
1244  GLint border);
1245 
1246  TextureObject* generateAndAssignTextureObject(unsigned int contextID, GLenum target) const;
1247 
1248  TextureObject* generateAndAssignTextureObject(unsigned int contextID,
1249  GLenum target,
1250  GLint numMipmapLevels,
1251  GLenum internalFormat,
1252  GLsizei width,
1253  GLsizei height,
1254  GLsizei depth,
1255  GLint border) const;
1256 
1257  static void deleteAllTextureObjects(unsigned int contextID);
1258  static void discardAllTextureObjects(unsigned int contextID);
1259  static void flushAllDeletedTextureObjects(unsigned int contextID);
1260  static void discardAllDeletedTextureObjects(unsigned int contextID);
1261  static void flushDeletedTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
1262  static void releaseTextureObject(unsigned int contextID, TextureObject* to);
1263 
1264  protected:
1265 
1267  mutable TextureObjectBuffer _textureObjectBuffer;
1269 
1270 };
1271 
1272 }
1273 
1274 #endif
virtual bool isTextureAttribute() const
Definition: Texture.h:438
InternalFormatType
Definition: Texture.h:612
unsigned int getNumOfTextureObjects() const
Definition: Texture.h:1121
#define OSG_EXPORT
Definition: Export.h:43
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: Texture.h:426
void setInternalFormatMode(InternalFormatMode mode)
Definition: Texture.h:577
TextureProfile(GLenum target)
Definition: Texture.h:888
float _shadow_ambient
Definition: Texture.h:880
InternalFormatType _internalFormatType
Definition: Texture.h:872
GLint getBorderWidth() const
Definition: Texture.h:485
TexParameterDirtyList _texParametersDirtyList
Definition: Texture.h:852
GLenum id() const
Definition: Texture.h:1047
#define LESSTHAN(A, B)
Definition: Texture.h:915
#define NULL
Definition: Export.h:59
float _maxAnisotropy
Definition: Texture.h:861
void setShadowTextureMode(ShadowTextureMode mode)
Definition: Texture.h:731
This class provides an object-oriented thread mutex interface.
Definition: Mutex.h:31
bool getShadowComparison() const
Definition: Texture.h:707
void setTexture(Texture *texture)
Definition: Texture.h:1052
unsigned int & getNumberDeleted()
Definition: Texture.h:1198
bool isReusable() const
Definition: Texture.h:1069
virtual int getTextureHeight() const
Definition: Texture.h:451
unsigned int getNumPendingOrphans() const
Definition: Texture.h:1123
GLint GLenum internalFormat
Definition: GLU.h:71
const GraphicsContext * getReadPBuffer() const
Definition: Texture.h:760
Texture * getTexture() const
Definition: Texture.h:1053
TextureObjectBuffer _textureObjectBuffer
Definition: Texture.h:1267
buffered_value< unsigned int > TexParameterDirtyList
Definition: Texture.h:851
#define GL_WRITE_ONLY_ARB
Definition: BufferObject.h:53
void setUseHardwareMipMapGeneration(bool useHardwareMipMapGeneration)
Definition: Texture.h:525
GLint GLenum GLsizei GLsizei GLsizei depth
Definition: GLU.h:71
bool _unrefImageDataAfterApply
Definition: Texture.h:864
GraphicsContext * getReadPBuffer()
Definition: Texture.h:757
unsigned int & getNumberOrphanedTextureObjects()
Definition: Texture.h:1157
ref_ptr< GraphicsContext > _readPBuffer
Definition: Texture.h:1268
OpenThreads::Mutex _mutex
Definition: Texture.h:1129
bool _use_shadow_comparison
Definition: Texture.h:877
FilterMode _min_filter
Definition: Texture.h:859
TextureObject(Texture *texture, GLuint id, GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition: Texture.h:1014
virtual const Texture * asTexture() const
Definition: Texture.h:434
unsigned int getContextID() const
Definition: Texture.h:1148
void setShadowComparison(bool flag)
Definition: Texture.h:706
InternalFormatType getInternalFormatType() const
Definition: Texture.h:628
GLenum _sourceType
Definition: Texture.h:875
unsigned int _numOrphanedTextureObjects
Definition: Texture.h:1213
bool _clientStorageHint
Definition: Texture.h:865
void setNumberOrphanedTextureObjects(unsigned int size)
Definition: Texture.h:1156
void setTextureObject(unsigned int contextID, TextureObject *to)
Definition: Texture.h:638
TextureProfile _profile
Definition: Texture.h:1073
bool match(GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition: Texture.h:1032
#define GL_CLAMP
Definition: Texture.h:170
GLint getInternalFormat() const
Definition: Texture.h:594
unsigned int & getTextureParameterDirty(unsigned int contextID) const
Definition: Texture.h:653
TextureObjectManager * _parent
Definition: Texture.h:1131
unsigned int getNumberOrphanedTextureObjects() const
Definition: Texture.h:1158
TextureObject * _previous
Definition: Texture.h:1075
void setNumberActiveTextureObjects(unsigned int size)
Definition: Texture.h:1152
WrapMode _wrap_s
Definition: Texture.h:855
GenerateMipmapMode
Definition: Texture.h:799
Vec4d _borderColor
Definition: Texture.h:868
unsigned int _numOfTextureObjects
Definition: Texture.h:1134
unsigned int & getFrameNumber()
Definition: Texture.h:1195
InternalFormatMode _internalFormatMode
Definition: Texture.h:871
T * clone(const T *t, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition: Object.h:242
void setSwizzle(const Vec4i &swizzle)
Definition: Texture.h:518
TextureObject * getTextureObject(unsigned int contextID) const
Definition: Texture.h:633
TextureProfile(GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition: Texture.h:898
bool isAllocated() const
Definition: Texture.h:1067
virtual void usesTextureMode(GLMode mode)=0
TextureObjectSet * _set
Definition: Texture.h:1074
#define GL_CLAMP_TO_BORDER_ARB
Definition: Texture.h:174
void set(GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition: Texture.h:941
std::list< ref_ptr< TextureObject > > TextureObjectList
Definition: Texture.h:1087
void setUnRefImageDataAfterApply(bool flag)
Definition: Texture.h:533
virtual Texture * asTexture()
Definition: Texture.h:431
bool _useHardwareMipMapGeneration
Definition: Texture.h:863
GLenum getSourceType() const
Definition: Texture.h:609
virtual const char * libraryName() const
Definition: Texture.h:427
#define GL_CLAMP_TO_EDGE
Definition: Texture.h:166
bool getUnRefImageDataAfterApply() const
Definition: Texture.h:536
InternalFormatMode
Definition: Texture.h:556
GLint GLenum GLsizei width
Definition: GLU.h:71
bool hasSpace(unsigned int size) const
Definition: Texture.h:1167
GLint _internalFormat
Definition: Texture.h:873
bool getClientStorageHint() const
Definition: Texture.h:545
FilterMode _mag_filter
Definition: Texture.h:860
TexParameterDirtyList _texMipmapGenerationDirtyList
Definition: Texture.h:853
void setShadowAmbient(float shadow_ambient)
Definition: Texture.h:736
void setTimeStamp(double timestamp)
Definition: Texture.h:1055
T * cloneType(const T *t)
Definition: Object.h:284
void setClientStorageHint(bool flag)
Definition: Texture.h:542
ImageAttachment _imageAttachment
Definition: Texture.h:882
bool _resizeNonPowerOfTwoHint
Definition: Texture.h:866
GLenum _sourceFormat
Definition: Texture.h:874
#define GL_MIRRORED_REPEAT_IBM
Definition: Texture.h:162
InternalFormatMode getInternalFormatMode() const
Definition: Texture.h:580
virtual int getTextureDepth() const
Definition: Texture.h:452
unsigned int getNumberActiveTextureObjects() const
Definition: Texture.h:1154
#define FINALLESSTHAN(A, B)
Definition: Texture.h:916
float getMaxAnisotropy() const
Definition: Texture.h:515
bool getResizeNonPowerOfTwoHint() const
Definition: Texture.h:554
buffered_object< ref_ptr< TextureObject > > TextureObjectBuffer
Definition: Texture.h:1266
TextureObject * _next
Definition: Texture.h:1076
TextureObject(Texture *texture, GLuint id, const TextureProfile &profile)
Definition: Texture.h:1004
bool match(GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition: Texture.h:957
TextureObject(Texture *texture, GLuint id, GLenum target)
Definition: Texture.h:994
void setAllocated(bool allocated=true)
Definition: Texture.h:1058
#define GL_READ_ONLY_ARB
Definition: BufferObject.h:52
ShadowCompareFunc _shadow_compare_func
Definition: Texture.h:878
void setCurrTexturePoolSize(unsigned int size)
Definition: Texture.h:1160
unsigned int & getCurrTexturePoolSize()
Definition: Texture.h:1161
GLint level
Definition: GLU.h:71
const ImageAttachment & getImageAttachment() const
Definition: Texture.h:702
GLint GLenum GLsizei GLsizei height
Definition: GLU.h:71
unsigned int & getNumberGenerated()
Definition: Texture.h:1201
const Vec4d & getBorderColor() const
Definition: Texture.h:480
void setSourceType(GLenum sourceType)
Definition: Texture.h:606
void setReadPBuffer(GraphicsContext *context)
Definition: Texture.h:754
bool getUseHardwareMipMapGeneration() const
Definition: Texture.h:528
unsigned int getMaxTexturePoolSize() const
Definition: Texture.h:1165
virtual int getTextureWidth() const
Definition: Texture.h:450
unsigned int getCurrTexturePoolSize() const
Definition: Texture.h:1162
GLenum target() const
Definition: Texture.h:1048
unsigned int & getNumberApplied()
Definition: Texture.h:1204
double getTimeStamp() const
Definition: Texture.h:1056
TextureObjectList _orphanedTextureObjects
Definition: Texture.h:1135
#define GL_READ_WRITE_ARB
Definition: BufferObject.h:54
Definition: AlphaFunc.h:19
unsigned int & getNumberActiveTextureObjects()
Definition: Texture.h:1153
void setInternalFormat(GLint internalFormat)
Definition: Texture.h:585
bool isSafeToUnrefImageData(const State &state) const
Definition: Texture.h:829
virtual const char * className() const
Definition: Texture.h:428
unsigned int size() const
Definition: Texture.h:1112
unsigned int size() const
Definition: Texture.h:1050
virtual Type getType() const
Definition: Texture.h:436
const Vec4i & getSwizzle() const
Definition: Texture.h:521
const TextureProfile & getProfile() const
Definition: Texture.h:1094
#define GL_INTENSITY
Definition: Texture.h:179
GLenum getSourceFormat() const
Definition: Texture.h:603
unsigned int & getNumberFrames()
Definition: Texture.h:1196
ShadowTextureMode getShadowTextureMode() const
Definition: Texture.h:732
unsigned int getNumOrphans() const
Definition: Texture.h:1122
GLint GLenum GLsizei GLsizei GLsizei GLint border
Definition: GLU.h:71
unsigned int _frameLastUsed
Definition: Texture.h:1079
ShadowCompareFunc getShadowCompareFunc() const
Definition: Texture.h:722
GLint _borderWidth
Definition: Texture.h:869
WrapMode _wrap_t
Definition: Texture.h:856
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition: Texture.h:442
void setShadowCompareFunc(ShadowCompareFunc func)
Definition: Texture.h:721
void setBorderColor(const Vec4d &color)
Definition: Texture.h:477
void setBorderWidth(GLint width)
Definition: Texture.h:483
TextureObjectList _pendingOrphanedTextureObjects
Definition: Texture.h:1136
TextureObjectManager * getParent()
Definition: Texture.h:1118
unsigned int getMaxTexturePoolSize() const
Definition: State.h:1455
std::map< TextureProfile, osg::ref_ptr< TextureObjectSet > > TextureSetMap
Definition: Texture.h:1210
void setResizeNonPowerOfTwoHint(bool flag)
Definition: Texture.h:551
float getShadowAmbient() const
Definition: Texture.h:737
WrapMode _wrap_r
Definition: Texture.h:857
void setSourceFormat(GLenum sourceFormat)
Definition: Texture.h:600
ImageAttachment & getImageAttachment()
Definition: Texture.h:701
Vec4i _swizzle
Definition: Texture.h:862
ShadowTextureMode _shadow_texture_mode
Definition: Texture.h:879
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: GLU.h:71