openscenegraph
Texture
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//#define OSG_COLLECT_TEXTURE_APPLIED_STATS 1
409
410namespace osg {
411
412
413// forward declare
414class TextureObjectSet;
415class TextureObjectManager;
416
417
422{
423
424 public :
425
427
429 Texture(const Texture& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
430
431 virtual osg::Object* cloneType() const = 0;
432 virtual osg::Object* clone(const CopyOp& copyop) const = 0;
433 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Texture *>(obj)!=NULL; }
434 virtual const char* libraryName() const { return "osg"; }
435 virtual const char* className() const { return "Texture"; }
436
438 virtual Texture* asTexture() { return this; }
439
441 virtual const Texture* asTexture() const { return this; }
442
443 virtual Type getType() const { return TEXTURE; }
444
445 virtual bool isTextureAttribute() const { return true; }
446
447 virtual GLenum getTextureTarget() const = 0;
448
449 #ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
450 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
451 {
452 usage.usesTextureMode(getTextureTarget());
453 return true;
454 }
455 #endif
456
457 virtual int getTextureWidth() const { return 0; }
458 virtual int getTextureHeight() const { return 0; }
459 virtual int getTextureDepth() const { return 0; }
460
466
467 enum WrapMode {
468 CLAMP = GL_CLAMP,
469 CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
470 CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER_ARB,
471 REPEAT = GL_REPEAT,
473 };
474
476 void setWrap(WrapParameter which, WrapMode wrap);
479
480
484 void setBorderColor(const Vec4d& color) { _borderColor = color; dirtyTextureParameters(); }
485
487 const Vec4d& getBorderColor() const { return _borderColor; }
488
490 void setBorderWidth(GLint width) { _borderWidth = width; dirtyTextureParameters(); }
491
492 GLint getBorderWidth() const { return _borderWidth; }
493
496 MAG_FILTER
497 };
498
500 LINEAR = GL_LINEAR,
501 LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR,
502 LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST,
503 NEAREST = GL_NEAREST,
504 NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR,
505 NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST
506 };
507
510
513
519 void setMaxAnisotropy(float anis);
520
522 inline float getMaxAnisotropy() const { return _maxAnisotropy; }
523
525 void setMinLOD(float minlod);
526
528 inline float getMinLOD() const { return _minlod; }
529
531 void setMaxLOD(float maxlod);
532
534 inline float getMaxLOD() const { return _maxlod; }
535
537 void setLODBias(float lodbias);
538
540 inline float getLODBias() const { return _lodbias; }
541
543 inline void setSwizzle(const Vec4i& swizzle) { _swizzle = swizzle; dirtyTextureParameters(); };
544
546 inline const Vec4i& getSwizzle() const { return _swizzle; }
547
550 inline void setUseHardwareMipMapGeneration(bool useHardwareMipMapGeneration) { _useHardwareMipMapGeneration = useHardwareMipMapGeneration; }
551
553 inline bool getUseHardwareMipMapGeneration() const { return _useHardwareMipMapGeneration; }
554
558 inline void setUnRefImageDataAfterApply(bool flag) { _unrefImageDataAfterApply = flag; }
559
561 inline bool getUnRefImageDataAfterApply() const { return _unrefImageDataAfterApply; }
562
567 inline void setClientStorageHint(bool flag) { _clientStorageHint = flag; }
568
570 inline bool getClientStorageHint() const { return _clientStorageHint; }
571
576 inline void setResizeNonPowerOfTwoHint(bool flag) { _resizeNonPowerOfTwoHint = flag; }
577
579 inline bool getResizeNonPowerOfTwoHint() const { return _resizeNonPowerOfTwoHint; }
580
597
602 inline void setInternalFormatMode(InternalFormatMode mode) { _internalFormatMode = mode; }
603
605 inline InternalFormatMode getInternalFormatMode() const { return _internalFormatMode; }
606
610 inline void setInternalFormat(GLint internalFormat)
611 {
612 _internalFormatMode = USE_USER_DEFINED_FORMAT;
613 _internalFormat = internalFormat;
614 computeInternalFormatType();
615 }
616
617
619 inline GLint getInternalFormat() const { if (_internalFormat==0) computeInternalFormat(); return _internalFormat; }
620
623
625 inline void setSourceFormat(GLenum sourceFormat) { _sourceFormat = sourceFormat; }
626
628 inline GLenum getSourceFormat() const { return _sourceFormat; }
629
631 inline void setSourceType(GLenum sourceType) { _sourceType = sourceType; }
632
634 inline GLenum getSourceType() const { return _sourceType; }
635
638
640 NORMALIZED = 0x0,
641
643 FLOAT = 0x1,
644
646 SIGNED_INTEGER = 0x2,
647
649 UNSIGNED_INTEGER = 0x4
650 };
651
653 inline InternalFormatType getInternalFormatType() const { return _internalFormatType; }
654
655 /* select the size internal format to use based on Image when available or Texture format settings.*/
656 GLenum selectSizedInternalFormat(const osg::Image* image=0) const;
657
658 class TextureObject;
659
661 virtual bool isDirty(unsigned int /*contextID*/) const { return false; }
662
663
665 inline TextureObject* getTextureObject(unsigned int contextID) const
666 {
667 return _textureObjectBuffer[contextID].get();
668 }
669
670 inline void setTextureObject(unsigned int contextID, TextureObject* to)
671 {
672 _textureObjectBuffer[contextID] = to;
673 }
674
678
682
683
685 inline unsigned int& getTextureParameterDirty(unsigned int contextID) const
686 {
687 return _texParametersDirtyList[contextID];
688 }
689
690
694
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 NONE = GL_NONE
729 };
730
732 void setShadowTextureMode(ShadowTextureMode mode) { _shadow_texture_mode = mode; }
733 ShadowTextureMode getShadowTextureMode() const { return _shadow_texture_mode; }
734
737 void setShadowAmbient(float shadow_ambient) { _shadow_ambient = shadow_ambient; }
738 float getShadowAmbient() const { return _shadow_ambient; }
739
740
742 virtual void setImage(unsigned int face, Image* image) = 0;
743
744 template<class T> void setImage(unsigned int face, const ref_ptr<T>& image) { setImage(face, image.get()); }
745
747 virtual Image* getImage(unsigned int face) = 0;
748
750 virtual const Image* getImage(unsigned int face) const = 0;
751
753 virtual unsigned int getNumImages() const = 0;
754
755
757 void setReadPBuffer(GraphicsContext* context) { _readPBuffer = context; }
758
759 template<class T> void setReadPBuffer(const ref_ptr<T>& context) { setReadPBuffer(context.get()); }
760
762 GraphicsContext* getReadPBuffer() { return _readPBuffer.get(); }
763
765 const GraphicsContext* getReadPBuffer() const { return _readPBuffer.get(); }
766
768 virtual void apply(State& state) const = 0;
769
771 virtual void compileGLObjects(State& state) const;
772
774 virtual void resizeGLObjectBuffers(unsigned int maxSize);
775
779 virtual void releaseGLObjects(State* state=0) const;
780
783 static bool isCompressedInternalFormat(GLint internalFormat);
784
788 static void getCompressedSize(GLenum internalFormat, GLint width, GLint height, GLint depth, GLint& blockSize, GLint& size);
789
790
794 void applyTexImage2D_load(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height,GLsizei numMipmapLevels) const;
795
799 void applyTexImage2D_subload(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height, GLint inInternalFormat, GLsizei numMipmapLevels) const;
800
801
805 {
808 GENERATE_MIPMAP_TEX_PARAMETER
809 };
810
811 protected :
812
813 virtual ~Texture();
814
815 virtual void computeInternalFormat() const = 0;
816
819
821 void computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& width, GLsizei& height,GLsizei& numMipmapLevels) const;
822
825
827 void applyTexParameters(GLenum target, State& state) const;
828
831 bool isHardwareMipmapGenerationEnabled(const State& state) const;
832
834 bool isSafeToUnrefImageData(const State& state) const {
835 return (_unrefImageDataAfterApply && state.getMaxTexturePoolSize()==0 && areAllTextureObjectsLoaded());
836 }
837
840 GenerateMipmapMode mipmapBeforeTexImage(const State& state, bool hardwareMipmapOn) const;
841 void mipmapAfterTexImage(State& state, GenerateMipmapMode beforeResult) const;
842
845 void generateMipmap(State& state) const;
846
848 virtual void allocateMipmap(State& state) const = 0;
849
851 int compareTexture(const Texture& rhs) const;
852
854 int compareTextureObjects(const Texture& rhs) const;
855
859
863
867 float _minlod;
868 float _maxlod;
869 float _lodbias;
875
878
881 mutable GLint _internalFormat;
882 mutable GLenum _sourceFormat;
883 mutable GLenum _sourceType;
884
889
890 public:
891
893 {
894 inline TextureProfile(GLenum target):
895 _target(target),
896 _numMipmapLevels(0),
897 _internalFormat(0),
898 _width(0),
899 _height(0),
900 _depth(0),
901 _border(0),
902 _size(0) {}
903
904 inline TextureProfile(GLenum target,
905 GLint numMipmapLevels,
906 GLenum internalFormat,
907 GLsizei width,
908 GLsizei height,
909 GLsizei depth,
910 GLint border):
911 _target(target),
912 _numMipmapLevels(numMipmapLevels),
913 _internalFormat(internalFormat),
914 _width(width),
915 _height(height),
916 _depth(depth),
917 _border(border),
918 _size(0) { computeSize(); }
919
920
921 #define LESSTHAN(A,B) if (A<B) return true; if (B<A) return false;
922 #define FINALLESSTHAN(A,B) return (A<B);
923
924 bool operator < (const TextureProfile& rhs) const
925 {
926 LESSTHAN(_size,rhs._size);
927 LESSTHAN(_target,rhs._target);
928 LESSTHAN(_numMipmapLevels,rhs._numMipmapLevels);
929 LESSTHAN(_internalFormat,rhs._internalFormat);
930 LESSTHAN(_width,rhs._width);
931 LESSTHAN(_height,rhs._height);
932 LESSTHAN(_depth,rhs._depth);
933 FINALLESSTHAN(_border, rhs._border);
934 }
935
936 bool operator == (const TextureProfile& rhs) const
937 {
938 return _target == rhs._target &&
939 _numMipmapLevels == rhs._numMipmapLevels &&
940 _internalFormat == rhs._internalFormat &&
941 _width == rhs._width &&
942 _height == rhs._height &&
943 _depth == rhs._depth &&
944 _border == rhs._border;
945 }
946
947 inline void set(GLint numMipmapLevels,
948 GLenum internalFormat,
949 GLsizei width,
950 GLsizei height,
951 GLsizei depth,
952 GLint border)
953 {
954 _numMipmapLevels = numMipmapLevels;
955 _internalFormat = internalFormat;
956 _width = width;
957 _height = height;
958 _depth = depth;
959 _border = border;
960 computeSize();
961 }
962
963 inline bool match(GLenum target,
964 GLint numMipmapLevels,
965 GLenum internalFormat,
966 GLsizei width,
967 GLsizei height,
968 GLsizei depth,
969 GLint border)
970 {
971 return (_target == target) &&
972 (_numMipmapLevels == numMipmapLevels) &&
973 (_internalFormat == internalFormat) &&
974 (_width == width) &&
975 (_height == height) &&
976 (_depth == depth) &&
977 (_border == border);
978 }
979
981
982 GLenum _target;
985 GLsizei _width;
986 GLsizei _height;
987 GLsizei _depth;
988 GLint _border;
989 unsigned int _size;
990 };
991
993 {
994 public:
995
996 inline TextureObject(Texture* texture, GLuint id, GLenum target):
997 _id(id),
998 _profile(target),
999 _set(0),
1000 _previous(0),
1001 _next(0),
1002 _texture(texture),
1003 _allocated(false),
1004 _frameLastUsed(0),
1005 _timeStamp(0) {}
1006
1007 inline TextureObject(Texture* texture, GLuint id, const TextureProfile& profile):
1008 _id(id),
1009 _profile(profile),
1010 _set(0),
1011 _previous(0),
1012 _next(0),
1013 _texture(texture),
1014 _allocated(false),
1015 _frameLastUsed(0),
1016 _timeStamp(0) {}
1017
1018 inline TextureObject(Texture* texture,
1019 GLuint id,
1020 GLenum target,
1021 GLint numMipmapLevels,
1022 GLenum internalFormat,
1023 GLsizei width,
1024 GLsizei height,
1025 GLsizei depth,
1026 GLint border):
1027 _id(id),
1028 _profile(target,numMipmapLevels,internalFormat,width,height,depth,border),
1029 _set(0),
1030 _previous(0),
1031 _next(0),
1032 _texture(texture),
1033 _allocated(false),
1034 _frameLastUsed(0),
1035 _timeStamp(0) {}
1036
1037 inline bool match(GLenum target,
1038 GLint numMipmapLevels,
1039 GLenum internalFormat,
1040 GLsizei width,
1041 GLsizei height,
1042 GLsizei depth,
1043 GLint border)
1044 {
1045 return isReusable() &&
1046 _profile.match(target,numMipmapLevels,internalFormat,width,height,depth,border);
1047 }
1048
1049
1050 void bind();
1051
1052 inline GLenum id() const { return _id; }
1053 inline GLenum target() const { return _profile._target; }
1054
1055 inline unsigned int size() const { return _profile._size; }
1056
1057 inline void setTexture(Texture* texture) { _texture = texture; }
1058 inline Texture* getTexture() const { return _texture; }
1059
1060 inline void setTimeStamp(double timestamp) { _timeStamp = timestamp; }
1061 inline double getTimeStamp() const { return _timeStamp; }
1062
1063 inline void setAllocated(bool allocated=true) { _allocated = allocated; }
1064
1065 void setAllocated(GLint numMipmapLevels,
1066 GLenum internalFormat,
1067 GLsizei width,
1068 GLsizei height,
1069 GLsizei depth,
1070 GLint border);
1071
1072 inline bool isAllocated() const { return _allocated; }
1073
1074 inline bool isReusable() const { return _allocated && _profile._width!=0; }
1075
1077 void release();
1078
1079 GLuint _id;
1086 unsigned int _frameLastUsed;
1088
1089 protected:
1091
1092 };
1093
1094 typedef std::list< ref_ptr<TextureObject> > TextureObjectList;
1095
1096
1097 static osg::ref_ptr<TextureObject> generateTextureObject(const Texture* texture, unsigned int contextID,GLenum target);
1098
1100 unsigned int contextID,
1101 GLenum target,
1102 GLint numMipmapLevels,
1103 GLenum internalFormat,
1104 GLsizei width,
1105 GLsizei height,
1106 GLsizei depth,
1107 GLint border);
1108
1109 TextureObject* generateAndAssignTextureObject(unsigned int contextID, GLenum target) const;
1110
1112 GLenum target,
1113 GLint numMipmapLevels,
1114 GLenum internalFormat,
1115 GLsizei width,
1116 GLsizei height,
1117 GLsizei depth,
1118 GLint border) const;
1119
1120 protected:
1121
1125
1126};
1127
1129{
1130public:
1132
1133 const Texture::TextureProfile& getProfile() const { return _profile; }
1134
1136
1141 void flushDeletedTextureObjects(double currentTime, double& availableTime);
1142
1150
1151 unsigned int size() const { return _profile._size * _numOfTextureObjects; }
1152
1153 bool makeSpace(unsigned int& size);
1154
1155 bool checkConsistency() const;
1156
1157 TextureObjectManager* getParent() { return _parent; }
1158
1160 unsigned int getNumOfTextureObjects() const { return _numOfTextureObjects; }
1161 unsigned int getNumOrphans() const { return static_cast<unsigned int>(_orphanedTextureObjects.size()); }
1162 unsigned int getNumPendingOrphans() const { return static_cast<unsigned int>(_pendingOrphanedTextureObjects.size()); }
1163
1164protected:
1165
1167
1169
1171 unsigned int _contextID;
1176
1179
1180};
1181
1183{
1184public:
1185 TextureObjectManager(unsigned int contextID);
1186
1187
1188 void setNumberActiveTextureObjects(unsigned int size) { _numActiveTextureObjects = size; }
1189 unsigned int& getNumberActiveTextureObjects() { return _numActiveTextureObjects; }
1190 unsigned int getNumberActiveTextureObjects() const { return _numActiveTextureObjects; }
1191
1192 void setNumberOrphanedTextureObjects(unsigned int size) { _numOrphanedTextureObjects = size; }
1193 unsigned int& getNumberOrphanedTextureObjects() { return _numOrphanedTextureObjects; }
1194 unsigned int getNumberOrphanedTextureObjects() const { return _numOrphanedTextureObjects; }
1195
1196 void setCurrTexturePoolSize(unsigned int size) { _currTexturePoolSize = size; }
1197 unsigned int& getCurrTexturePoolSize() { return _currTexturePoolSize; }
1198 unsigned int getCurrTexturePoolSize() const { return _currTexturePoolSize; }
1199
1200 void setMaxTexturePoolSize(unsigned int size);
1201 unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
1202
1203 bool hasSpace(unsigned int size) const { return (_currTexturePoolSize+size)<=_maxTexturePoolSize; }
1204 bool makeSpace(unsigned int size);
1205
1208 GLenum target,
1209 GLint numMipmapLevels,
1210 GLenum internalFormat,
1211 GLsizei width,
1212 GLsizei height,
1213 GLsizei depth,
1214 GLint border);
1216
1221 void flushDeletedGLObjects(double currentTime, double& availableTime);
1222
1224
1227 void reportStats(std::ostream& out);
1228 void recomputeStats(std::ostream& out) const;
1229 bool checkConsistency() const;
1230
1231 unsigned int& getFrameNumber() { return _frameNumber; }
1232 unsigned int& getNumberFrames() { return _numFrames; }
1233
1234 unsigned int& getNumberDeleted() { return _numDeleted; }
1235 double& getDeleteTime() { return _deleteTime; }
1236
1237 unsigned int& getNumberGenerated() { return _numGenerated; }
1238 double& getGenerateTime() { return _generateTime; }
1239
1240protected:
1241
1243
1244 typedef std::map< Texture::TextureProfile, osg::ref_ptr<TextureObjectSet> > TextureSetMap;
1245
1251
1252 unsigned int _frameNumber;
1253
1254 unsigned int _numFrames;
1255 unsigned int _numDeleted;
1257
1258 unsigned int _numGenerated;
1260};
1261}
1262
1263#endif
#define GL_CLAMP
Definition Texture:170
#define GL_INTENSITY
Definition Texture:179
#define GL_CLAMP_TO_BORDER_ARB
Definition Texture:174
#define GL_MIRRORED_REPEAT_IBM
Definition Texture:162
#define LESSTHAN(A, B)
Definition Texture:921
#define FINALLESSTHAN(A, B)
Definition Texture:922
#define GL_CLAMP_TO_EDGE
Definition Texture:166
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
Definition CopyOp:41
Definition FrameStamp:35
Definition GraphicsContext:30
Definition GLObjects:57
Definition GLObjects:47
Definition Image:179
Definition Object:61
Definition Referenced:44
Definition StateAttribute:77
Type
Definition StateAttribute:124
Definition State:80
unsigned int getMaxTexturePoolSize() const
Definition State:898
Definition Texture:1183
void flushDeletedGLObjects(double currentTime, double &availableTime)
double & getDeleteTime()
Definition Texture:1235
void setCurrTexturePoolSize(unsigned int size)
Definition Texture:1196
unsigned int & getNumberFrames()
Definition Texture:1232
double _deleteTime
Definition Texture:1256
osg::ref_ptr< Texture::TextureObject > generateTextureObject(const Texture *texture, GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
TextureObjectManager(unsigned int contextID)
unsigned int _maxTexturePoolSize
Definition Texture:1249
void handlePendingOrphandedTextureObjects()
void recomputeStats(std::ostream &out) const
unsigned int & getNumberOrphanedTextureObjects()
Definition Texture:1193
unsigned int _currTexturePoolSize
Definition Texture:1248
std::map< Texture::TextureProfile, osg::ref_ptr< TextureObjectSet > > TextureSetMap
Definition Texture:1244
unsigned int _numFrames
Definition Texture:1254
osg::ref_ptr< Texture::TextureObject > generateTextureObject(const Texture *texture, GLenum target)
void reportStats(std::ostream &out)
unsigned int getNumberOrphanedTextureObjects() const
Definition Texture:1194
unsigned int _numGenerated
Definition Texture:1258
unsigned int & getNumberDeleted()
Definition Texture:1234
unsigned int & getCurrTexturePoolSize()
Definition Texture:1197
bool hasSpace(unsigned int size) const
Definition Texture:1203
void newFrame(osg::FrameStamp *fs)
void setNumberOrphanedTextureObjects(unsigned int size)
Definition Texture:1192
unsigned int & getNumberGenerated()
Definition Texture:1237
bool checkConsistency() const
void setNumberActiveTextureObjects(unsigned int size)
Definition Texture:1188
void setMaxTexturePoolSize(unsigned int size)
bool makeSpace(unsigned int size)
unsigned int _numDeleted
Definition Texture:1255
unsigned int _frameNumber
Definition Texture:1252
unsigned int getNumberActiveTextureObjects() const
Definition Texture:1190
TextureSetMap _textureSetMap
Definition Texture:1250
double & getGenerateTime()
Definition Texture:1238
TextureObjectSet * getTextureObjectSet(const Texture::TextureProfile &profile)
unsigned int getMaxTexturePoolSize() const
Definition Texture:1201
unsigned int & getNumberActiveTextureObjects()
Definition Texture:1189
unsigned int getCurrTexturePoolSize() const
Definition Texture:1198
double _generateTime
Definition Texture:1259
unsigned int & getFrameNumber()
Definition Texture:1231
unsigned int _numActiveTextureObjects
Definition Texture:1246
unsigned int _numOrphanedTextureObjects
Definition Texture:1247
Definition Texture:1129
unsigned int getNumOfTextureObjects() const
Definition Texture:1160
bool makeSpace(unsigned int &size)
Texture::TextureProfile _profile
Definition Texture:1172
Texture::TextureObjectList _pendingOrphanedTextureObjects
Definition Texture:1175
unsigned int size() const
Definition Texture:1151
unsigned int getNumOrphans() const
Definition Texture:1161
void moveToBack(Texture::TextureObject *to)
void addToBack(Texture::TextureObject *to)
void remove(Texture::TextureObject *to)
unsigned int _numOfTextureObjects
Definition Texture:1173
void handlePendingOrphandedTextureObjects()
Texture::TextureObject * _head
Definition Texture:1177
virtual ~TextureObjectSet()
bool checkConsistency() const
OpenThreads::Mutex _mutex
Definition Texture:1168
TextureObjectManager * _parent
Definition Texture:1170
void flushAllDeletedTextureObjects()
void orphan(Texture::TextureObject *to)
TextureObjectSet(TextureObjectManager *parent, const Texture::TextureProfile &profile)
unsigned int _contextID
Definition Texture:1171
osg::ref_ptr< Texture::TextureObject > takeFromOrphans(Texture *texture)
Texture::TextureObject * _tail
Definition Texture:1178
void moveToSet(Texture::TextureObject *to, TextureObjectSet *set)
unsigned int computeNumTextureObjectsInList() const
void discardAllDeletedTextureObjects()
TextureObjectManager * getParent()
Definition Texture:1157
unsigned int getNumPendingOrphans() const
Definition Texture:1162
Texture::TextureObjectList _orphanedTextureObjects
Definition Texture:1174
const Texture::TextureProfile & getProfile() const
Definition Texture:1133
osg::ref_ptr< Texture::TextureObject > takeOrGenerate(Texture *texture)
void flushDeletedTextureObjects(double currentTime, double &availableTime)
Definition Texture:993
TextureObject * _next
Definition Texture:1083
GLenum target() const
Definition Texture:1053
unsigned int _frameLastUsed
Definition Texture:1086
TextureObject(Texture *texture, GLuint id, GLenum target)
Definition Texture:996
bool isReusable() const
Definition Texture:1074
void setAllocated(bool allocated=true)
Definition Texture:1063
double _timeStamp
Definition Texture:1087
TextureObject(Texture *texture, GLuint id, GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition Texture:1018
GLenum id() const
Definition Texture:1052
bool _allocated
Definition Texture:1085
Texture * getTexture() const
Definition Texture:1058
TextureObjectSet * _set
Definition Texture:1081
Texture * _texture
Definition Texture:1084
unsigned int size() const
Definition Texture:1055
TextureObject(Texture *texture, GLuint id, const TextureProfile &profile)
Definition Texture:1007
void setTexture(Texture *texture)
Definition Texture:1057
void setAllocated(GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
TextureProfile _profile
Definition Texture:1080
void setTimeStamp(double timestamp)
Definition Texture:1060
double getTimeStamp() const
Definition Texture:1061
GLuint _id
Definition Texture:1079
TextureObject * _previous
Definition Texture:1082
bool match(GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition Texture:1037
bool isAllocated() const
Definition Texture:1072
Definition Texture:422
bool isCompressedInternalFormat() const
WrapMode _wrap_t
Definition Texture:861
void setClientStorageHint(bool flag)
Definition Texture:567
ShadowCompareFunc
Definition Texture:709
bool getResizeNonPowerOfTwoHint() const
Definition Texture:579
bool getShadowComparison() const
Definition Texture:707
void applyTexParameters(GLenum target, State &state) const
Vec4i _swizzle
Definition Texture:870
void applyTexImage2D_load(State &state, GLenum target, const Image *image, GLsizei width, GLsizei height, GLsizei numMipmapLevels) const
void generateMipmap(State &state) const
const Vec4d & getBorderColor() const
Definition Texture:487
float _lodbias
Definition Texture:869
virtual int getTextureHeight() const
Definition Texture:458
void setTextureObject(unsigned int contextID, TextureObject *to)
Definition Texture:670
bool isSafeToUnrefImageData(const State &state) const
Definition Texture:834
virtual void releaseGLObjects(State *state=0) const
virtual bool isSameKindAs(const osg::Object *obj) const
Definition Texture:433
bool getUseHardwareMipMapGeneration() const
Definition Texture:553
Vec4d _borderColor
Definition Texture:876
float getMinLOD() const
Definition Texture:528
void setResizeNonPowerOfTwoHint(bool flag)
Definition Texture:576
ShadowTextureMode
Definition Texture:724
float _minlod
Definition Texture:867
virtual void allocateMipmap(State &state) const =0
float _shadow_ambient
Definition Texture:888
virtual void computeInternalFormat() const =0
ShadowCompareFunc _shadow_compare_func
Definition Texture:886
void setReadPBuffer(GraphicsContext *context)
Definition Texture:757
float getMaxLOD() const
Definition Texture:534
void setShadowTextureMode(ShadowTextureMode mode)
Definition Texture:732
float getShadowAmbient() const
Definition Texture:738
void setFilter(FilterParameter which, FilterMode filter)
void setUnRefImageDataAfterApply(bool flag)
Definition Texture:558
static osg::ref_ptr< TextureObject > generateTextureObject(const Texture *texture, unsigned int contextID, GLenum target)
int compareTextureObjects(const Texture &rhs) const
GLint getBorderWidth() const
Definition Texture:492
TexParameterDirtyList _texMipmapGenerationDirtyList
Definition Texture:858
bool _useHardwareMipMapGeneration
Definition Texture:871
void setBorderWidth(GLint width)
Definition Texture:490
virtual osg::Object * clone(const CopyOp &copyop) const =0
void setShadowCompareFunc(ShadowCompareFunc func)
Definition Texture:721
void dirtyTextureObject()
GLint getInternalFormat() const
Definition Texture:619
virtual Texture * asTexture()
Definition Texture:438
buffered_object< ref_ptr< TextureObject > > TextureObjectBuffer
Definition Texture:1122
InternalFormatMode
Definition Texture:581
@ USE_PVRTC_2BPP_COMPRESSION
Definition Texture:588
@ USE_PVRTC_4BPP_COMPRESSION
Definition Texture:589
@ USE_RGTC2_COMPRESSION
Definition Texture:593
@ USE_S3TC_DXT3_COMPRESSION
Definition Texture:586
@ USE_S3TC_DXT1c_COMPRESSION
Definition Texture:594
@ USE_USER_DEFINED_FORMAT
Definition Texture:583
@ USE_S3TC_DXT5_COMPRESSION
Definition Texture:587
@ USE_ETC_COMPRESSION
Definition Texture:590
@ USE_ETC2_COMPRESSION
Definition Texture:591
@ USE_S3TC_DXT1_COMPRESSION
Definition Texture:585
@ USE_ARB_COMPRESSION
Definition Texture:584
@ USE_RGTC1_COMPRESSION
Definition Texture:592
@ USE_IMAGE_DATA_FORMAT
Definition Texture:582
void setUseHardwareMipMapGeneration(bool useHardwareMipMapGeneration)
Definition Texture:550
FilterMode getFilter(FilterParameter which) const
bool getClientStorageHint() const
Definition Texture:570
FilterMode _mag_filter
Definition Texture:865
ShadowTextureMode getShadowTextureMode() const
Definition Texture:733
GenerateMipmapMode mipmapBeforeTexImage(const State &state, bool hardwareMipmapOn) const
float getLODBias() const
Definition Texture:540
void mipmapAfterTexImage(State &state, GenerateMipmapMode beforeResult) const
static osg::ref_ptr< TextureObject > generateTextureObject(const Texture *texture, unsigned int contextID, GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
void computeInternalFormatWithImage(const osg::Image &image) const
InternalFormatType _internalFormatType
Definition Texture:880
virtual bool isTextureAttribute() const
Definition Texture:445
void setSourceFormat(GLenum sourceFormat)
Definition Texture:625
GraphicsContext * getReadPBuffer()
Definition Texture:762
GLint _borderWidth
Definition Texture:877
ShadowTextureMode _shadow_texture_mode
Definition Texture:887
buffered_value< unsigned int > TexParameterDirtyList
Definition Texture:856
virtual unsigned int getNumImages() const =0
WrapMode getWrap(WrapParameter which) const
virtual const char * className() const
Definition Texture:435
FilterMode
Definition Texture:499
float _maxAnisotropy
Definition Texture:866
WrapMode _wrap_s
Definition Texture:860
void setInternalFormat(GLint internalFormat)
Definition Texture:610
virtual int getTextureWidth() const
Definition Texture:457
void setMinLOD(float minlod)
WrapMode
Definition Texture:467
bool _resizeNonPowerOfTwoHint
Definition Texture:874
ref_ptr< GraphicsContext > _readPBuffer
Definition Texture:1124
ShadowCompareFunc getShadowCompareFunc() const
Definition Texture:722
GLenum _sourceType
Definition Texture:883
void setImage(unsigned int face, const ref_ptr< T > &image)
Definition Texture:744
bool _clientStorageHint
Definition Texture:873
FilterMode _min_filter
Definition Texture:864
void setReadPBuffer(const ref_ptr< T > &context)
Definition Texture:759
virtual Type getType() const
Definition Texture:443
GenerateMipmapMode
Definition Texture:805
@ GENERATE_MIPMAP_NONE
Definition Texture:806
@ GENERATE_MIPMAP
Definition Texture:807
TextureObject * getTextureObject(unsigned int contextID) const
Definition Texture:665
std::list< ref_ptr< TextureObject > > TextureObjectList
Definition Texture:1094
bool areAllTextureObjectsLoaded() const
const GraphicsContext * getReadPBuffer() const
Definition Texture:765
InternalFormatType
Definition Texture:637
GLenum _sourceFormat
Definition Texture:882
bool getUnRefImageDataAfterApply() const
Definition Texture:561
void setMaxLOD(float maxlod)
InternalFormatMode getInternalFormatMode() const
Definition Texture:605
void setInternalFormatMode(InternalFormatMode mode)
Definition Texture:602
void setShadowAmbient(float shadow_ambient)
Definition Texture:737
GLint _internalFormat
Definition Texture:881
void setBorderColor(const Vec4d &color)
Definition Texture:484
virtual bool isDirty(unsigned int) const
Definition Texture:661
void allocateMipmapLevels()
bool _use_shadow_comparison
Definition Texture:885
void setMaxAnisotropy(float anis)
int compareTexture(const Texture &rhs) const
virtual Image * getImage(unsigned int face)=0
virtual int getTextureDepth() const
Definition Texture:459
static void getCompressedSize(GLenum internalFormat, GLint width, GLint height, GLint depth, GLint &blockSize, GLint &size)
bool _unrefImageDataAfterApply
Definition Texture:872
virtual osg::Object * cloneType() const =0
GLenum selectSizedInternalFormat(const osg::Image *image=0) const
virtual void setImage(unsigned int face, Image *image)=0
virtual const Texture * asTexture() const
Definition Texture:441
void setSwizzle(const Vec4i &swizzle)
Definition Texture:543
static bool isCompressedInternalFormat(GLint internalFormat)
void applyTexImage2D_subload(State &state, GLenum target, const Image *image, GLsizei width, GLsizei height, GLint inInternalFormat, GLsizei numMipmapLevels) const
virtual void resizeGLObjectBuffers(unsigned int maxSize)
GLenum getSourceType() const
Definition Texture:634
virtual const Image * getImage(unsigned int face) const =0
InternalFormatType getInternalFormatType() const
Definition Texture:653
void setSourceType(GLenum sourceType)
Definition Texture:631
float _maxlod
Definition Texture:868
TextureObjectBuffer _textureObjectBuffer
Definition Texture:1123
virtual const char * libraryName() const
Definition Texture:434
GLenum getSourceFormat() const
Definition Texture:628
virtual GLenum getTextureTarget() const =0
WrapParameter
Definition Texture:461
@ WRAP_S
Definition Texture:462
@ WRAP_T
Definition Texture:463
virtual void compileGLObjects(State &state) const
float getMaxAnisotropy() const
Definition Texture:522
FilterParameter
Definition Texture:494
@ MIN_FILTER
Definition Texture:495
bool isHardwareMipmapGenerationEnabled(const State &state) const
void setLODBias(float lodbias)
WrapMode _wrap_r
Definition Texture:862
virtual void apply(State &state) const =0
void computeInternalFormatType() const
virtual ~Texture()
InternalFormatMode _internalFormatMode
Definition Texture:879
void computeRequiredTextureDimensions(State &state, const osg::Image &image, GLsizei &width, GLsizei &height, GLsizei &numMipmapLevels) const
Texture(const Texture &text, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
TexParameterDirtyList _texParametersDirtyList
Definition Texture:857
void setShadowComparison(bool flag)
Definition Texture:706
void dirtyTextureParameters()
unsigned int & getTextureParameterDirty(unsigned int contextID) const
Definition Texture:685
const Vec4i & getSwizzle() const
Definition Texture:546
TextureObject * generateAndAssignTextureObject(unsigned int contextID, GLenum target) const
TextureObject * generateAndAssignTextureObject(unsigned int contextID, GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border) const
void setWrap(WrapParameter which, WrapMode wrap)
Definition Vec4d:29
Definition Vec4i:22
Definition buffered_value:79
Definition buffered_value:27
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
@ ALWAYS
Definition Notify:31
#define NULL
Definition osg/Export:55
#define OSG_EXPORT
Definition osg/Export:39
Definition StateAttribute:308
virtual void usesTextureMode(GLMode mode)=0
Definition Texture:893
GLsizei _depth
Definition Texture:987
GLenum _target
Definition Texture:982
TextureProfile(GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition Texture:904
GLsizei _height
Definition Texture:986
unsigned int _size
Definition Texture:989
GLsizei _width
Definition Texture:985
bool match(GLenum target, GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition Texture:963
TextureProfile(GLenum target)
Definition Texture:894
GLint _numMipmapLevels
Definition Texture:983
GLenum _internalFormat
Definition Texture:984
GLint _border
Definition Texture:988
void set(GLint numMipmapLevels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition Texture:947