Panda3D
texture.I
1 // Filename: texture.I
2 // Created by: drose (05Feb99)
3 // Updated by: fperazzi, PandaSE(29Apr10) (added setup_2d_texture_array)
4 //
5 ////////////////////////////////////////////////////////////////////
6 //
7 // PANDA 3D SOFTWARE
8 // Copyright (c) Carnegie Mellon University. All rights reserved.
9 //
10 // All use of this software is subject to the terms of the revised BSD
11 // license. You should have received a copy of this license along
12 // with this source code in a file named "LICENSE."
13 //
14 ////////////////////////////////////////////////////////////////////
15 
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: Texture::make_copy
19 // Access: Published
20 // Description: Returns a new copy of the same Texture. This copy,
21 // if applied to geometry, will be copied into texture
22 // as a separate texture from the original, so it will
23 // be duplicated in texture memory (and may be
24 // independently modified if desired).
25 //
26 // If the Texture is a VideoTexture, the resulting
27 // duplicate may be animated independently of the
28 // original.
29 ////////////////////////////////////////////////////////////////////
30 INLINE PT(Texture) Texture::
31 make_copy() const {
32  PT(Texture) tex = make_copy_impl();
33  CDWriter cdata_tex(tex->_cycler, true);
34  cdata_tex->inc_properties_modified();
35  cdata_tex->inc_image_modified();
36  cdata_tex->inc_simple_image_modified();
37  return tex;
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: Texture::clear
42 // Access: Published, Virtual
43 // Description: Reinitializes the texture to its default, empty
44 // state (except for the name).
45 ////////////////////////////////////////////////////////////////////
46 INLINE void Texture::
47 clear() {
48  CDWriter cdata(_cycler, true);
49  do_clear(cdata);
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: Texture::setup_texture
54 // Access: Published
55 // Description: Sets the texture to the indicated type and
56 // dimensions, presumably in preparation for calling
57 // read() or load(), or set_ram_image() or
58 // modify_ram_image(), or use set_clear_color to let
59 // the texture be cleared to a solid color.
60 ////////////////////////////////////////////////////////////////////
61 INLINE void Texture::
62 setup_texture(Texture::TextureType texture_type, int x_size, int y_size,
63  int z_size, Texture::ComponentType component_type,
64  Texture::Format format) {
65  CDWriter cdata(_cycler, true);
66  do_setup_texture(cdata, texture_type, x_size, y_size, z_size,
67  component_type, format);
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: Texture::setup_1d_texture
72 // Access: Published
73 // Description: Sets the texture as an empty 1-d texture with no
74 // dimensions. Follow up with read() or load() to fill
75 // the texture properties and image data, or use
76 // set_clear_color to let the texture be cleared to a
77 // solid color.
78 ////////////////////////////////////////////////////////////////////
79 INLINE void Texture::
81  setup_1d_texture(0, T_unsigned_byte, F_rgb);
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: Texture::setup_1d_texture
86 // Access: Published
87 // Description: Sets the texture as an empty 1-d texture with the
88 // specified dimensions and properties. Follow up with
89 // set_ram_image() or modify_ram_image() to fill the
90 // image data, or use set_clear_color to let the
91 // texture be cleared to a solid color.
92 ////////////////////////////////////////////////////////////////////
93 INLINE void Texture::
94 setup_1d_texture(int x_size, ComponentType component_type, Format format) {
95  setup_texture(TT_1d_texture, x_size, 1, 1, component_type, format);
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: Texture::setup_2d_texture
100 // Access: Published
101 // Description: Sets the texture as an empty 2-d texture with no
102 // dimensions. Follow up with read() or load() to fill
103 // the texture properties and image data, or use
104 // set_clear_color to let the texture be cleared to a
105 // solid color.
106 ////////////////////////////////////////////////////////////////////
107 INLINE void Texture::
109  setup_2d_texture(0, 1, T_unsigned_byte, F_rgb);
110 }
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: Texture::setup_2d_texture
114 // Access: Published
115 // Description: Sets the texture as an empty 2-d texture with the
116 // specified dimensions and properties. Follow up with
117 // set_ram_image() or modify_ram_image() to fill the
118 // image data, or use set_clear_color to let the
119 // texture be cleared to a solid color.
120 ////////////////////////////////////////////////////////////////////
121 INLINE void Texture::
122 setup_2d_texture(int x_size, int y_size, ComponentType component_type,
123  Format format) {
124  setup_texture(TT_2d_texture, x_size, y_size, 1, component_type, format);
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: Texture::setup_3d_texture
129 // Access: Published
130 // Description: Sets the texture as an empty 3-d texture with no
131 // dimensions (though if you know the depth ahead
132 // of time, it saves a bit of reallocation later).
133 // Follow up with read() or load() to fill the texture
134 // properties and image data, or use set_clear_color
135 // to let the texture be cleared to a solid color.
136 ////////////////////////////////////////////////////////////////////
137 INLINE void Texture::
138 setup_3d_texture(int z_size) {
139  setup_3d_texture(0, 1, z_size, T_unsigned_byte, F_rgb);
140 }
141 
142 ////////////////////////////////////////////////////////////////////
143 // Function: Texture::setup_3d_texture
144 // Access: Published
145 // Description: Sets the texture as an empty 3-d texture with the
146 // specified dimensions and properties. Follow up with
147 // set_ram_image() or modify_ram_image() to fill the
148 // image data.
149 ////////////////////////////////////////////////////////////////////
150 INLINE void Texture::
151 setup_3d_texture(int x_size, int y_size, int z_size,
152  ComponentType component_type, Format format) {
153  setup_texture(TT_3d_texture, x_size, y_size, z_size, component_type, format);
154 }
155 
156 ////////////////////////////////////////////////////////////////////
157 // Function: Texture::setup_2d_texture_array
158 // Access: Published
159 // Description: Sets the texture as an empty 2-d texture array with
160 // no dimensions (though if you know the depth ahead
161 // of time, it saves a bit of reallocation later).
162 // Follow up with read() or load() to fill the texture
163 // properties and image data, or use set_clear_color
164 // to let the texture be cleared to a solid color.
165 ////////////////////////////////////////////////////////////////////
166 INLINE void Texture::
168  setup_2d_texture_array(0, 1, z_size, T_unsigned_byte, F_rgb);
169 }
170 
171 ////////////////////////////////////////////////////////////////////
172 // Function: Texture::setup_2d_texture_array
173 // Access: Published
174 // Description: Sets the texture as an empty 2-d texture array with the
175 // specified dimensions and properties. Follow up with
176 // set_ram_image() or modify_ram_image() to fill the
177 // image data, or use set_clear_color to let the
178 // texture be cleared to a solid color.
179 ////////////////////////////////////////////////////////////////////
180 INLINE void Texture::
181 setup_2d_texture_array(int x_size, int y_size, int z_size,
182  ComponentType component_type, Format format) {
183  setup_texture(TT_2d_texture_array, x_size, y_size, z_size, component_type, format);
184 }
185 
186 ////////////////////////////////////////////////////////////////////
187 // Function: Texture::setup_cube_map
188 // Access: Published
189 // Description: Sets the texture as an empty cube map texture with no
190 // dimensions. Follow up with read() or load() to fill
191 // the texture properties and image data, or use
192 // set_clear_color to let the texture be cleared to a
193 // solid color.
194 ////////////////////////////////////////////////////////////////////
195 INLINE void Texture::
197  setup_cube_map(0, T_unsigned_byte, F_rgb);
198 }
199 
200 ////////////////////////////////////////////////////////////////////
201 // Function: Texture::setup_cube_map
202 // Access: Published
203 // Description: Sets the texture as an empty cube map texture with
204 // the specified dimensions and properties. Follow up
205 // with set_ram_image() or modify_ram_image() to fill
206 // the image data, or use set_clear_color to let the
207 // texture be cleared to a solid color.
208 //
209 // Note that a cube map should always consist of six
210 // square images, so x_size and y_size will be the same,
211 // and z_size is always 6.
212 ////////////////////////////////////////////////////////////////////
213 INLINE void Texture::
214 setup_cube_map(int size, ComponentType component_type, Format format) {
215  setup_texture(TT_cube_map, size, size, 6, component_type, format);
216 }
217 
218 ////////////////////////////////////////////////////////////////////
219 // Function: Texture::clear_image
220 // Access: Published
221 // Description: Clears the texture data without changing its format
222 // or resolution. The texture is cleared on both the
223 // graphics hardware and from RAM, unlike clear_ram_image,
224 // which only removes the data from RAM.
225 //
226 // If a clear color has been specified using
227 // set_clear_color, the texture will be cleared using
228 // a solid color.
229 //
230 // The texture data will be cleared the first time in
231 // which the texture is used after this method is called.
232 ////////////////////////////////////////////////////////////////////
233 INLINE void Texture::
235  CDWriter cdata(_cycler, true);
236  do_clear_ram_image(cdata);
237  do_clear_simple_ram_image(cdata);
238  cdata->inc_image_modified();
239  cdata->inc_simple_image_modified();
240 }
241 
242 ////////////////////////////////////////////////////////////////////
243 // Function: Texture::has_clear_color
244 // Access: Published
245 // Description: Returns true if a color was previously set using
246 // set_clear_color.
247 ////////////////////////////////////////////////////////////////////
248 INLINE bool Texture::
250  CDReader cdata(_cycler);
251  return cdata->_has_clear_color;
252 }
253 
254 ////////////////////////////////////////////////////////////////////
255 // Function: Texture::get_clear_color
256 // Access: Published
257 // Description: Returns the color that was previously set using
258 // set_clear_color.
259 ////////////////////////////////////////////////////////////////////
260 INLINE LColor Texture::
262  CDReader cdata(_cycler);
263  return cdata->_clear_color;
264 }
265 
266 ////////////////////////////////////////////////////////////////////
267 // Function: Texture::set_clear_color
268 // Access: Published
269 // Description: Sets the color that will be used to fill the
270 // texture image in absence of any image data. It is
271 // used when any of the setup_texture functions or
272 // clear_image is called and image data is not
273 // provided using read() or modify_ram_image().
274 //
275 // This does not affect a texture that has already
276 // been cleared; call clear_image to clear it again.
277 ////////////////////////////////////////////////////////////////////
278 INLINE void Texture::
280  CDWriter cdata(_cycler, true);
281  cdata->_clear_color = color;
282  cdata->_has_clear_color = true;
283 }
284 
285 ////////////////////////////////////////////////////////////////////
286 // Function: Texture::get_clear_data
287 // Access: Published
288 // Description: Returns the raw image data for a single pixel if
289 // it were set to the clear color.
290 ////////////////////////////////////////////////////////////////////
291 INLINE string Texture::
292 get_clear_data() const {
293  CDReader cdata(_cycler);
294  unsigned char data[16];
295  int size = do_get_clear_data(cdata, data);
296  return string((char *)data, size);
297 }
298 
299 ////////////////////////////////////////////////////////////////////
300 // Function: Texture::write
301 // Access: Published
302 // Description: Writes the texture to the named filename.
303 ////////////////////////////////////////////////////////////////////
304 INLINE bool Texture::
305 write(const Filename &fullpath) {
306  CDWriter cdata(_cycler);
307 
308  // do_write() is non-const, because it might have to reload the ram
309  // image.
310  return do_write(cdata, fullpath, 0, 0, false, false);
311 }
312 
313 ////////////////////////////////////////////////////////////////////
314 // Function: Texture::write
315 // Access: Published
316 // Description: Writes a single page or mipmap level to a single
317 // file, or automatically writes a series of pages
318 // and/or mipmap levels to a numbered series of files.
319 //
320 // If the filename ends in the extension .txo, this
321 // implicitly writes a Panda texture object (.txo)
322 // instead of an image file. In this case, the
323 // remaining parameters are ignored, and only one file
324 // is written, which will contain all of the pages and
325 // resident mipmap levels in the texture.
326 //
327 // If write_pages is false, then z indicates the page
328 // number to write. 3-D textures have one page number
329 // for each level of depth; cube maps have six pages
330 // number 0 through 5. Other kinds of textures have
331 // only one page, numbered 0. If there are multiple
332 // views, the range of z is increased; the total range
333 // is [0, get_num_pages()).
334 //
335 // If write_pages is true, then all pages of the texture
336 // will be written. In this case z is ignored, and the
337 // filename should contain a sequence of hash marks
338 // ("#") which will be filled in with the page index
339 // number.
340 //
341 // If write_mipmaps is false, then n indicates the
342 // mipmap level number to write. Normally, this is 0,
343 // for the base texture image. Normally, the mipmap
344 // levels of a texture are not available in RAM (they
345 // are generated automatically by the graphics card).
346 // However, if you have the mipmap levels available, for
347 // instance because you called
348 // generate_ram_mipmap_images() to generate them
349 // internally, or you called
350 // GraphicsEngine::extract_texture_data() to retrieve
351 // them from the graphics card, then you may write out
352 // each mipmap level with this parameter.
353 //
354 // If write_mipmaps is true, then all mipmap levels of
355 // the texture will be written. In this case n is
356 // ignored, and the filename should contain a sequence
357 // of hash marks ("#") which will be filled in with the
358 // mipmap level number.
359 //
360 // If both write_pages and write_mipmaps is true, then
361 // all pages and all mipmap levels will be written. In
362 // this case, the filename should contain two different
363 // sequences of hash marks, separated by a character
364 // such as a hyphen, underscore, or dot. The first hash
365 // mark sequence will be filled in with the mipmap
366 // level, while the second hash mark sequence will be
367 // the page index.
368 ////////////////////////////////////////////////////////////////////
369 INLINE bool Texture::
370 write(const Filename &fullpath, int z, int n,
371  bool write_pages, bool write_mipmaps) {
372  CDWriter cdata(_cycler, false);
373  return do_write(cdata, fullpath, z, n, write_pages, write_mipmaps);
374 }
375 
376 ////////////////////////////////////////////////////////////////////
377 // Function: Texture::load
378 // Access: Published
379 // Description: Replaces the texture with the indicated image.
380 ////////////////////////////////////////////////////////////////////
381 INLINE bool Texture::
382 load(const PNMImage &pnmimage, const LoaderOptions &options) {
383  CDWriter cdata(_cycler, true);
384  do_clear(cdata);
385  cdata->inc_properties_modified();
386  cdata->inc_image_modified();
387  if (do_load_one(cdata, pnmimage, get_name(), 0, 0, options)) {
388  bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
389  consider_auto_process_ram_image(generate_mipmaps || uses_mipmaps(), true);
390  return true;
391  }
392  return false;
393 }
394 
395 ////////////////////////////////////////////////////////////////////
396 // Function: Texture::load
397 // Access: Published
398 // Description: Stores the indicated image in the given page and
399 // mipmap level. See read().
400 ////////////////////////////////////////////////////////////////////
401 INLINE bool Texture::
402 load(const PNMImage &pnmimage, int z, int n, const LoaderOptions &options) {
403  CDWriter cdata(_cycler, true);
404  cdata->inc_properties_modified();
405  cdata->inc_image_modified();
406  if (do_load_one(cdata, pnmimage, get_name(), z, n, options)) {
407  return true;
408  }
409  return false;
410 }
411 
412 ////////////////////////////////////////////////////////////////////
413 // Function: Texture::load
414 // Access: Published
415 // Description: Replaces the texture with the indicated image.
416 ////////////////////////////////////////////////////////////////////
417 INLINE bool Texture::
418 load(const PfmFile &pfm, const LoaderOptions &options) {
419  CDWriter cdata(_cycler, true);
420  do_clear(cdata);
421  cdata->inc_properties_modified();
422  cdata->inc_image_modified();
423  if (do_load_one(cdata, pfm, get_name(), 0, 0, options)) {
424  bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
425  consider_auto_process_ram_image(generate_mipmaps || uses_mipmaps(), true);
426  return true;
427  }
428  return false;
429 }
430 
431 ////////////////////////////////////////////////////////////////////
432 // Function: Texture::load
433 // Access: Published
434 // Description: Stores the indicated image in the given page and
435 // mipmap level. See read().
436 ////////////////////////////////////////////////////////////////////
437 INLINE bool Texture::
438 load(const PfmFile &pfm, int z, int n, const LoaderOptions &options) {
439  CDWriter cdata(_cycler, true);
440  cdata->inc_properties_modified();
441  cdata->inc_image_modified();
442  if (do_load_one(cdata, pfm, get_name(), z, n, options)) {
443  return true;
444  }
445  return false;
446 }
447 
448 ////////////////////////////////////////////////////////////////////
449 // Function: Texture::load_sub_image
450 // Access: Published
451 // Description: Stores the indicated image in a region of the
452 // texture. The texture properties remain unchanged.
453 // This can be more efficient than updating an entire
454 // texture, but has a few restrictions: for one, you
455 // must ensure that the texture is still in RAM (eg.
456 // using set_keep_ram_image) and it may not be
457 // compressed.
458 ////////////////////////////////////////////////////////////////////
459 INLINE bool Texture::
460 load_sub_image(const PNMImage &image, int x, int y, int z, int n) {
461  CDWriter cdata(_cycler, true);
462  return do_load_sub_image(cdata, image, x, y, z, n);
463 }
464 
465 ////////////////////////////////////////////////////////////////////
466 // Function: Texture::store
467 // Access: Published
468 // Description: Saves the texture to the indicated PNMImage, but does
469 // not write it to disk.
470 ////////////////////////////////////////////////////////////////////
471 INLINE bool Texture::
472 store(PNMImage &pnmimage) const {
473  CDWriter cdata(((Texture *)this)->_cycler, false);
474  return ((Texture *)this)->do_store_one(cdata, pnmimage, 0, 0);
475 }
476 
477 ////////////////////////////////////////////////////////////////////
478 // Function: Texture::store
479 // Access: Published
480 // Description: Saves the indicated page and mipmap level of the
481 // texture to the PNMImage.
482 ////////////////////////////////////////////////////////////////////
483 INLINE bool Texture::
484 store(PNMImage &pnmimage, int z, int n) const {
485  CDWriter cdata(((Texture *)this)->_cycler, false);
486  return ((Texture *)this)->do_store_one(cdata, pnmimage, z, n);
487 }
488 
489 ////////////////////////////////////////////////////////////////////
490 // Function: Texture::store
491 // Access: Published
492 // Description: Saves the texture to the indicated PfmFile, but does
493 // not write it to disk.
494 ////////////////////////////////////////////////////////////////////
495 INLINE bool Texture::
496 store(PfmFile &pfm) const {
497  CDWriter cdata(((Texture *)this)->_cycler, false);
498  return ((Texture *)this)->do_store_one(cdata, pfm, 0, 0);
499 }
500 
501 ////////////////////////////////////////////////////////////////////
502 // Function: Texture::store
503 // Access: Published
504 // Description: Saves the indicated page and mipmap level of the
505 // texture to the PfmFile.
506 ////////////////////////////////////////////////////////////////////
507 INLINE bool Texture::
508 store(PfmFile &pfm, int z, int n) const {
509  CDWriter cdata(((Texture *)this)->_cycler, false);
510  return ((Texture *)this)->do_store_one(cdata, pfm, z, n);
511 }
512 
513 ////////////////////////////////////////////////////////////////////
514 // Function: Texture::reload
515 // Access: Published
516 // Description: Re-reads the Texture from its disk file. Useful when
517 // you know the image on disk has recently changed, and
518 // you want to update the Texture image.
519 //
520 // Returns true on success, false on failure (in which
521 // case, the Texture may or may not still be valid).
522 ////////////////////////////////////////////////////////////////////
523 bool Texture::
525  CDWriter cdata(_cycler, true);
526  return do_reload(cdata);
527 }
528 
529 ////////////////////////////////////////////////////////////////////
530 // Function: Texture::has_filename
531 // Access: Published
532 // Description: Returns true if the filename has been set and
533 // is available. See set_filename().
534 ////////////////////////////////////////////////////////////////////
535 INLINE bool Texture::
536 has_filename() const {
537  CDReader cdata(_cycler);
538  return !cdata->_filename.empty();
539 }
540 
541 ////////////////////////////////////////////////////////////////////
542 // Function: Texture::get_filename
543 // Access: Published
544 // Description: Returns the filename that has been set. This is the
545 // name of the file as it was requested. Also see
546 // get_fullpath().
547 ////////////////////////////////////////////////////////////////////
548 INLINE const Filename &Texture::
549 get_filename() const {
550  CDReader cdata(_cycler);
551  return cdata->_filename;
552 }
553 
554 ////////////////////////////////////////////////////////////////////
555 // Function: Texture::has_alpha_filename
556 // Access: Published
557 // Description: Returns true if the alpha_filename has been set and
558 // is available. See set_alpha_filename().
559 ////////////////////////////////////////////////////////////////////
560 INLINE bool Texture::
562  CDReader cdata(_cycler);
563  return !cdata->_alpha_filename.empty();
564 }
565 
566 ////////////////////////////////////////////////////////////////////
567 // Function: Texture::get_alpha_filename
568 // Access: Published
569 // Description: Returns the alpha_filename that has been set. If
570 // this is set, it represents the name of the alpha
571 // component, which is stored in a separate file. See
572 // also get_filename(), and get_alpha_fullpath().
573 ////////////////////////////////////////////////////////////////////
574 INLINE const Filename &Texture::
576  CDReader cdata(_cycler);
577  return cdata->_alpha_filename;
578 }
579 
580 ////////////////////////////////////////////////////////////////////
581 // Function: Texture::has_fullpath
582 // Access: Published
583 // Description: Returns true if the fullpath has been set and
584 // is available. See set_fullpath().
585 ////////////////////////////////////////////////////////////////////
586 INLINE bool Texture::
587 has_fullpath() const {
588  CDReader cdata(_cycler);
589  return !cdata->_fullpath.empty();
590 }
591 
592 ////////////////////////////////////////////////////////////////////
593 // Function: Texture::get_fullpath
594 // Access: Published
595 // Description: Returns the fullpath that has been set. This is the
596 // full path to the file as it was found along the
597 // texture search path.
598 ////////////////////////////////////////////////////////////////////
599 INLINE const Filename &Texture::
600 get_fullpath() const {
601  CDReader cdata(_cycler);
602  return cdata->_fullpath;
603 }
604 
605 ////////////////////////////////////////////////////////////////////
606 // Function: Texture::has_alpha_fullpath
607 // Access: Published
608 // Description: Returns true if the alpha_fullpath has been set and
609 // is available. See set_alpha_fullpath().
610 ////////////////////////////////////////////////////////////////////
611 INLINE bool Texture::
613  CDReader cdata(_cycler);
614  return !cdata->_alpha_fullpath.empty();
615 }
616 
617 ////////////////////////////////////////////////////////////////////
618 // Function: Texture::get_alpha_fullpath
619 // Access: Published
620 // Description:
621 // Returns the alpha_fullpath that has been set. This
622 // is the full path to the alpha part of the image file
623 // as it was found along the texture search path.
624 ////////////////////////////////////////////////////////////////////
625 INLINE const Filename &Texture::
627  CDReader cdata(_cycler);
628  return cdata->_alpha_fullpath;
629 }
630 
631 
632 ////////////////////////////////////////////////////////////////////
633 // Function: Texture::get_x_size
634 // Access: Published
635 // Description: Returns the width of the texture image in texels.
636 ////////////////////////////////////////////////////////////////////
637 INLINE int Texture::
638 get_x_size() const {
639  CDReader cdata(_cycler);
640  return cdata->_x_size;
641 }
642 
643 ////////////////////////////////////////////////////////////////////
644 // Function: Texture::get_y_size
645 // Access: Published
646 // Description: Returns the height of the texture image in texels.
647 // For a 1-d texture, this will be 1.
648 ////////////////////////////////////////////////////////////////////
649 INLINE int Texture::
650 get_y_size() const {
651  CDReader cdata(_cycler);
652  return cdata->_y_size;
653 }
654 
655 ////////////////////////////////////////////////////////////////////
656 // Function: Texture::get_z_size
657 // Access: Published
658 // Description: Returns the depth of the texture image in texels.
659 // For a 1-d texture or 2-d texture, this will be 1.
660 // For a cube map texture, this will be 6.
661 ////////////////////////////////////////////////////////////////////
662 INLINE int Texture::
663 get_z_size() const {
664  CDReader cdata(_cycler);
665  return cdata->_z_size;
666 }
667 
668 ////////////////////////////////////////////////////////////////////
669 // Function: Texture::get_num_views
670 // Access: Published
671 // Description: Returns the number of "views" in the texture. A view
672 // is a completely separate image stored within the
673 // Texture object. Most textures have only one view,
674 // but a stereo texture, for instance, may have two
675 // views, a left and a right image. Other uses for
676 // multiple views are not yet defined.
677 //
678 // If this value is greater than one, the additional
679 // views are accessed as additional pages beyond
680 // get_z_size().
681 ////////////////////////////////////////////////////////////////////
682 INLINE int Texture::
683 get_num_views() const {
684  CDReader cdata(_cycler);
685  return cdata->_num_views;
686 }
687 
688 ////////////////////////////////////////////////////////////////////
689 // Function: Texture::get_num_pages
690 // Access: Published
691 // Description: Returns the total number of pages in the texture.
692 // Each "page" is a 2-d texture image within the larger
693 // image--a face of a cube map, or a level of a 3-d
694 // texture. Normally, get_num_pages() is the same as
695 // get_z_size(). However, in a multiview texture, this
696 // returns get_z_size() * get_num_views().
697 ////////////////////////////////////////////////////////////////////
698 INLINE int Texture::
699 get_num_pages() const {
700  return get_z_size() * get_num_views();
701 }
702 
703 ////////////////////////////////////////////////////////////////////
704 // Function: Texture::get_pad_x_size
705 // Access: Published
706 // Description: Returns size of the pad region. See set_pad_size.
707 ////////////////////////////////////////////////////////////////////
708 INLINE int Texture::
709 get_pad_x_size() const {
710  CDReader cdata(_cycler);
711  return cdata->_pad_x_size;
712 }
713 
714 ////////////////////////////////////////////////////////////////////
715 // Function: Texture::get_pad_y_size
716 // Access: Published
717 // Description: Returns size of the pad region. See set_pad_size.
718 ////////////////////////////////////////////////////////////////////
719 INLINE int Texture::
720 get_pad_y_size() const {
721  CDReader cdata(_cycler);
722  return cdata->_pad_y_size;
723 }
724 
725 ////////////////////////////////////////////////////////////////////
726 // Function: Texture::get_pad_z_size
727 // Access: Published
728 // Description: Returns size of the pad region. See set_pad_size.
729 ////////////////////////////////////////////////////////////////////
730 INLINE int Texture::
731 get_pad_z_size() const {
732  CDReader cdata(_cycler);
733  return cdata->_pad_z_size;
734 }
735 
736 ////////////////////////////////////////////////////////////////////
737 // Function: Texture::get_tex_scale
738 // Access: Published
739 // Description: Returns a scale pair that is suitable for applying to
740 // geometry via NodePath::set_tex_scale(), which will
741 // convert texture coordinates on the geometry from the
742 // range 0..1 into the appropriate range to render the
743 // video part of the texture.
744 //
745 // This is necessary only if a padding size has been set
746 // via set_pad_size() (or implicitly via something like
747 // "textures-power-2 pad" in the config.prc file). In
748 // this case, this is a convenient way to generate UV's
749 // that reflect the built-in padding size.
750 ////////////////////////////////////////////////////////////////////
751 INLINE LVecBase2 Texture::
752 get_tex_scale() const {
753  CDReader cdata(_cycler);
754  if (cdata->_pad_x_size == 0 || cdata->_pad_y_size == 0 ||
755  cdata->_x_size == 0 || cdata->_y_size == 0) {
756  LVecBase2(1.0f, 1.0f);
757  }
758  return LVecBase2((PN_stdfloat)(cdata->_x_size - cdata->_pad_x_size) / (PN_stdfloat)cdata->_x_size,
759  (PN_stdfloat)(cdata->_y_size - cdata->_pad_y_size) / (PN_stdfloat)cdata->_y_size);
760 }
761 
762 ////////////////////////////////////////////////////////////////////
763 // Function: Texture::set_pad_size
764 // Access: Published
765 // Description: Sets the size of the pad region.
766 //
767 // Sometimes, when a video card demands power-of-two
768 // textures, it is necessary to create a big texture
769 // and then only use a portion of it. The pad region
770 // indicates which portion of the texture is not
771 // really in use. All operations use the texture
772 // as a whole, including the pad region, unless they
773 // explicitly state that they use only the non-pad
774 // region.
775 //
776 // Changing the texture's size clears the pad region.
777 ////////////////////////////////////////////////////////////////////
778 INLINE void Texture::
779 set_pad_size(int x, int y, int z) {
780  CDWriter cdata(_cycler, true);
781  do_set_pad_size(cdata, x, y, z);
782 }
783 
784 ////////////////////////////////////////////////////////////////////
785 // Function: Texture::get_orig_file_x_size
786 // Access: Published
787 // Description: Returns the X size of the original disk image that
788 // this Texture was loaded from (if it came from a disk
789 // file), before any automatic rescaling by Panda.
790 ////////////////////////////////////////////////////////////////////
791 INLINE int Texture::
793  CDReader cdata(_cycler);
794  return cdata->_orig_file_x_size;
795 }
796 
797 ////////////////////////////////////////////////////////////////////
798 // Function: Texture::get_orig_file_y_size
799 // Access: Published
800 // Description: Returns the Y size of the original disk image that
801 // this Texture was loaded from (if it came from a disk
802 // file), before any automatic rescaling by Panda.
803 ////////////////////////////////////////////////////////////////////
804 INLINE int Texture::
806  CDReader cdata(_cycler);
807  return cdata->_orig_file_y_size;
808 }
809 
810 ////////////////////////////////////////////////////////////////////
811 // Function: Texture::get_orig_file_z_size
812 // Access: Published
813 // Description: Returns the Z size of the original disk image that
814 // this Texture was loaded from (if it came from a disk
815 // file), before any automatic rescaling by Panda.
816 ////////////////////////////////////////////////////////////////////
817 INLINE int Texture::
819  // At the moment, we perform no automatic adjustment of Z size. So
820  // we can just return the current value, since it would be the same
821  // thing.
822  CDReader cdata(_cycler);
823  return cdata->_z_size;
824 }
825 
826 ////////////////////////////////////////////////////////////////////
827 // Function: Texture::get_num_components
828 // Access: Published
829 // Description: Returns the number of color components for each texel
830 // of the texture image. This is 3 for an rgb texture
831 // or 4 for an rgba texture; it may also be 1 or 2 for a
832 // grayscale texture.
833 ////////////////////////////////////////////////////////////////////
834 INLINE int Texture::
836  CDReader cdata(_cycler);
837  return cdata->_num_components;
838 }
839 
840 ////////////////////////////////////////////////////////////////////
841 // Function: Texture::get_component_width
842 // Access: Published
843 // Description: Returns the number of bytes stored for each color
844 // component of a texel. Typically this is 1, but it
845 // may be 2 for 16-bit texels.
846 ////////////////////////////////////////////////////////////////////
847 INLINE int Texture::
849  CDReader cdata(_cycler);
850  return cdata->_component_width;
851 }
852 
853 ////////////////////////////////////////////////////////////////////
854 // Function: Texture::get_texture_type
855 // Access: Published
856 // Description: Returns the overall interpretation of the texture.
857 ////////////////////////////////////////////////////////////////////
858 INLINE Texture::TextureType Texture::
860  CDReader cdata(_cycler);
861  return cdata->_texture_type;
862 }
863 
864 ////////////////////////////////////////////////////////////////////
865 // Function: Texture::get_format
866 // Access: Published
867 // Description: Returns the format of the texture, which represents
868 // both the semantic meaning of the texels and, to some
869 // extent, their storage information.
870 ////////////////////////////////////////////////////////////////////
871 INLINE Texture::Format Texture::
872 get_format() const {
873  CDReader cdata(_cycler);
874  return cdata->_format;
875 }
876 
877 ////////////////////////////////////////////////////////////////////
878 // Function: Texture::get_component_type
879 // Access: Published
880 // Description: Returns the numeric interpretation of each component
881 // of the texture.
882 ////////////////////////////////////////////////////////////////////
883 INLINE Texture::ComponentType Texture::
885  CDReader cdata(_cycler);
886  return cdata->_component_type;
887 }
888 
889 ////////////////////////////////////////////////////////////////////
890 // Function: Texture::set_wrap_u
891 // Access: Published
892 // Description: This setting determines what happens when the
893 // texture is sampled with a U value outside the range
894 // 0.0-1.0. The default is WM_repeat, which indicates
895 // that the texture should repeat indefinitely.
896 //
897 // This sets the default sampler state for this
898 // texture; it may still be overridden by a sampler
899 // state specified at a higher level.
900 ////////////////////////////////////////////////////////////////////
901 INLINE void Texture::
902 set_wrap_u(SamplerState::WrapMode wrap) {
903  CDWriter cdata(_cycler, true);
904  do_set_wrap_u(cdata, wrap);
905 }
906 
907 ////////////////////////////////////////////////////////////////////
908 // Function: Texture::set_wrap_v
909 // Access: Published
910 // Description: This setting determines what happens when the
911 // texture is sampled with a V value outside the range
912 // 0.0-1.0. The default is WM_repeat, which indicates
913 // that the texture should repeat indefinitely.
914 //
915 // This sets the default sampler state for this
916 // texture; it may still be overridden by a sampler
917 // state specified at a higher level.
918 ////////////////////////////////////////////////////////////////////
919 INLINE void Texture::
920 set_wrap_v(SamplerState::WrapMode wrap) {
921  CDWriter cdata(_cycler, true);
922  do_set_wrap_v(cdata, wrap);
923 }
924 
925 ////////////////////////////////////////////////////////////////////
926 // Function: Texture::set_wrap_w
927 // Access: Published
928 // Description: The W wrap direction is only used for 3-d textures.
929 //
930 // This sets the default sampler state for this
931 // texture; it may still be overridden by a sampler
932 // state specified at a higher level.
933 ////////////////////////////////////////////////////////////////////
934 INLINE void Texture::
935 set_wrap_w(SamplerState::WrapMode wrap) {
936  CDWriter cdata(_cycler, true);
937  do_set_wrap_w(cdata, wrap);
938 }
939 
940 ////////////////////////////////////////////////////////////////////
941 // Function: Texture::set_minfilter
942 // Access: Published
943 // Description: Sets the filtering method that should be used when
944 // viewing the texture from a distance.
945 //
946 // This sets the default sampler state for this
947 // texture; it may still be overridden by a sampler
948 // state specified at a higher level.
949 ////////////////////////////////////////////////////////////////////
950 INLINE void Texture::
951 set_minfilter(SamplerState::FilterType filter) {
952  CDWriter cdata(_cycler, true);
953  do_set_minfilter(cdata, filter);
954 }
955 
956 ////////////////////////////////////////////////////////////////////
957 // Function: Texture::set_magfilter
958 // Access: Published
959 // Description: Sets the filtering method that should be used when
960 // viewing the texture up close.
961 //
962 // This sets the default sampler state for this
963 // texture; it may still be overridden by a sampler
964 // state specified at a higher level.
965 ////////////////////////////////////////////////////////////////////
966 INLINE void Texture::
967 set_magfilter(SamplerState::FilterType filter) {
968  CDWriter cdata(_cycler, true);
969  do_set_magfilter(cdata, filter);
970 }
971 
972 ////////////////////////////////////////////////////////////////////
973 // Function: Texture::set_anisotropic_degree
974 // Access: Published
975 // Description: Specifies the level of anisotropic filtering to apply
976 // to the texture. Set this 0 to indicate the default
977 // value, which is specified in the
978 // texture-anisotropic-degree config variable.
979 //
980 // To explicitly disable anisotropic filtering, set this
981 // value to 1. To explicitly enable anisotropic
982 // filtering, set it to a value higher than 1; larger
983 // numbers indicate greater degrees of filtering.
984 //
985 // This sets the default sampler state for this
986 // texture; it may still be overridden by a sampler
987 // state specified at a higher level.
988 ////////////////////////////////////////////////////////////////////
989 INLINE void Texture::
990 set_anisotropic_degree(int anisotropic_degree) {
991  CDWriter cdata(_cycler, true);
992  do_set_anisotropic_degree(cdata, anisotropic_degree);
993 }
994 
995 ////////////////////////////////////////////////////////////////////
996 // Function: Texture::set_border_color
997 // Access: Published
998 // Description: Specifies the solid color of the texture's border.
999 // Some OpenGL implementations use a border for tiling
1000 // textures; in Panda, it is only used for specifying
1001 // the clamp color.
1002 //
1003 // This sets the default sampler state for this
1004 // texture; it may still be overridden by a sampler
1005 // state specified at a higher level.
1006 ////////////////////////////////////////////////////////////////////
1007 INLINE void Texture::
1009  CDWriter cdata(_cycler, true);
1010  do_set_border_color(cdata, color);
1011 }
1012 
1013 ////////////////////////////////////////////////////////////////////
1014 // Function: Texture::set_compression
1015 // Access: Published
1016 // Description: Requests that this particular Texture be compressed
1017 // when it is loaded into texture memory.
1018 //
1019 // This refers to the internal compression of the
1020 // texture image within texture memory; it is not
1021 // related to jpeg or png compression, which are disk
1022 // file compression formats. The actual disk file that
1023 // generated this texture may be stored in a compressed
1024 // or uncompressed format supported by Panda; it will be
1025 // decompressed on load, and then recompressed by the
1026 // graphics API if this parameter is not CM_off.
1027 //
1028 // If the GSG does not support this texture compression
1029 // mode, the texture will silently be loaded
1030 // uncompressed.
1031 ////////////////////////////////////////////////////////////////////
1032 INLINE void Texture::
1033 set_compression(Texture::CompressionMode compression) {
1034  CDWriter cdata(_cycler, true);
1035  do_set_compression(cdata, compression);
1036 }
1037 
1038 ////////////////////////////////////////////////////////////////////
1039 // Function: Texture::set_render_to_texture
1040 // Access: Published
1041 // Description: Sets a flag on the texture that indicates whether the
1042 // texture is intended to be used as a direct-render
1043 // target, by binding a framebuffer to a texture and
1044 // rendering directly into the texture.
1045 //
1046 // This controls some low-level choices made about the
1047 // texture object itself. For instance, compressed
1048 // textures are disallowed when this flag is set true.
1049 //
1050 // Normally, a user should not need to set this flag
1051 // directly; it is set automatically by the low-level
1052 // display code when a texture is bound to a
1053 // framebuffer.
1054 ////////////////////////////////////////////////////////////////////
1055 INLINE void Texture::
1056 set_render_to_texture(bool render_to_texture) {
1057  CDWriter cdata(_cycler, false);
1058  cdata->_render_to_texture = render_to_texture;
1059 }
1060 
1061 ////////////////////////////////////////////////////////////////////
1062 // Function: Texture::get_default_sampler
1063 // Access: Published
1064 // Description: This returns the default sampler state for this
1065 // texture, containing the wrap and filter properties
1066 // specified on the texture level; it may still be
1067 // overridden by a sampler state specified at a higher
1068 // level.
1069 ////////////////////////////////////////////////////////////////////
1070 INLINE const SamplerState &Texture::
1072  CDReader cdata(_cycler);
1073  return cdata->_default_sampler;
1074 }
1075 
1076 ////////////////////////////////////////////////////////////////////
1077 // Function: Texture::get_wrap_u
1078 // Access: Published
1079 // Description: Returns the wrap mode of the texture in the U
1080 // direction.
1081 //
1082 // This returns the default sampler state for this
1083 // texture; it may still be overridden by a sampler
1084 // state specified at a higher level.
1085 ////////////////////////////////////////////////////////////////////
1086 INLINE SamplerState::WrapMode Texture::
1087 get_wrap_u() const {
1088  CDReader cdata(_cycler);
1089  return cdata->_default_sampler.get_wrap_u();
1090 }
1091 
1092 ////////////////////////////////////////////////////////////////////
1093 // Function: Texture::get_wrap_v
1094 // Access: Published
1095 // Description: Returns the wrap mode of the texture in the V
1096 // direction.
1097 //
1098 // This returns the default sampler state for this
1099 // texture; it may still be overridden by a sampler
1100 // state specified at a higher level.
1101 ////////////////////////////////////////////////////////////////////
1102 INLINE SamplerState::WrapMode Texture::
1103 get_wrap_v() const {
1104  CDReader cdata(_cycler);
1105  return cdata->_default_sampler.get_wrap_v();
1106 }
1107 
1108 ////////////////////////////////////////////////////////////////////
1109 // Function: Texture::get_wrap_w
1110 // Access: Published
1111 // Description: Returns the wrap mode of the texture in the W
1112 // direction. This is the depth direction of 3-d
1113 // textures.
1114 //
1115 // This returns the default sampler state for this
1116 // texture; it may still be overridden by a sampler
1117 // state specified at a higher level.
1118 ////////////////////////////////////////////////////////////////////
1119 INLINE SamplerState::WrapMode Texture::
1120 get_wrap_w() const {
1121  CDReader cdata(_cycler);
1122  return cdata->_default_sampler.get_wrap_w();
1123 }
1124 
1125 ////////////////////////////////////////////////////////////////////
1126 // Function: Texture::get_minfilter
1127 // Access: Published
1128 // Description: Returns the filter mode of the texture for
1129 // minification. If this is one of the mipmap
1130 // constants, then the texture requires mipmaps. This
1131 // may return FT_default; see also
1132 // get_effective_minfilter().
1133 //
1134 // This returns the default sampler state for this
1135 // texture; it may still be overridden by a sampler
1136 // state specified at a higher level.
1137 ////////////////////////////////////////////////////////////////////
1138 INLINE SamplerState::FilterType Texture::
1139 get_minfilter() const {
1140  CDReader cdata(_cycler);
1141  return cdata->_default_sampler.get_minfilter();
1142 }
1143 
1144 ////////////////////////////////////////////////////////////////////
1145 // Function: Texture::get_magfilter
1146 // Access: Published
1147 // Description: Returns the filter mode of the texture for
1148 // magnification. The mipmap constants are invalid
1149 // here. This may return FT_default; see also
1150 // get_effective_minfilter().
1151 //
1152 // This returns the default sampler state for this
1153 // texture; it may still be overridden by a sampler
1154 // state specified at a higher level.
1155 ////////////////////////////////////////////////////////////////////
1156 INLINE SamplerState::FilterType Texture::
1157 get_magfilter() const {
1158  CDReader cdata(_cycler);
1159  return cdata->_default_sampler.get_magfilter();
1160 }
1161 
1162 ////////////////////////////////////////////////////////////////////
1163 // Function: Texture::get_effective_minfilter
1164 // Access: Published
1165 // Description: Returns the filter mode of the texture for
1166 // minification, with special treatment for FT_default.
1167 // This will normally not return FT_default, unless
1168 // there is an error in the config file.
1169 //
1170 // This returns the default sampler state for this
1171 // texture; it may still be overridden by a sampler
1172 // state specified at a higher level.
1173 ////////////////////////////////////////////////////////////////////
1174 SamplerState::FilterType Texture::
1176  CDReader cdata(_cycler);
1177  return cdata->_default_sampler.get_effective_minfilter();
1178 }
1179 
1180 ////////////////////////////////////////////////////////////////////
1181 // Function: Texture::get_effective_magfilter
1182 // Access: Published
1183 // Description: Returns the filter mode of the texture for
1184 // magnification, with special treatment for FT_default.
1185 // This will normally not return FT_default, unless
1186 // there is an error in the config file.
1187 //
1188 // This returns the default sampler state for this
1189 // texture; it may still be overridden by a sampler
1190 // state specified at a higher level.
1191 ////////////////////////////////////////////////////////////////////
1192 SamplerState::FilterType Texture::
1194  CDReader cdata(_cycler);
1195  return cdata->_default_sampler.get_effective_magfilter();
1196 }
1197 
1198 ////////////////////////////////////////////////////////////////////
1199 // Function: Texture::get_anisotropic_degree
1200 // Access: Published
1201 // Description: Returns the degree of anisotropic filtering that
1202 // should be applied to the texture. This value may
1203 // return 0, indicating the default value; see also
1204 // get_effective_anisotropic_degree.
1205 //
1206 // This returns the default sampler state for this
1207 // texture; it may still be overridden by a sampler
1208 // state specified at a higher level.
1209 ////////////////////////////////////////////////////////////////////
1210 INLINE int Texture::
1212  CDReader cdata(_cycler);
1213  return cdata->_default_sampler.get_anisotropic_degree();
1214 }
1215 
1216 ////////////////////////////////////////////////////////////////////
1217 // Function: Texture::get_effective_anisotropic_degree
1218 // Access: Published
1219 // Description: Returns the degree of anisotropic filtering that
1220 // should be applied to the texture. This value will
1221 // normally not return 0, unless there is an error in
1222 // the config file.
1223 //
1224 // This returns the default sampler state for this
1225 // texture; it may still be overridden by a sampler
1226 // state specified at a higher level.
1227 ////////////////////////////////////////////////////////////////////
1228 INLINE int Texture::
1230  CDReader cdata(_cycler);
1231  return cdata->_default_sampler.get_effective_anisotropic_degree();
1232 }
1233 
1234 ////////////////////////////////////////////////////////////////////
1235 // Function: Texture::get_border_color
1236 // Access: Published
1237 // Description: Returns the solid color of the texture's border.
1238 // Some OpenGL implementations use a border for tiling
1239 // textures; in Panda, it is only used for specifying
1240 // the clamp color.
1241 //
1242 // This returns the default sampler state for this
1243 // texture; it may still be overridden by a sampler
1244 // state specified at a higher level.
1245 ////////////////////////////////////////////////////////////////////
1246 INLINE LColor Texture::
1248  CDReader cdata(_cycler);
1249  return cdata->_default_sampler.get_border_color();
1250 }
1251 
1252 ////////////////////////////////////////////////////////////////////
1253 // Function: Texture::get_compression
1254 // Access: Published
1255 // Description: Returns the compression mode requested for this
1256 // particular texture, or CM_off if the texture is not
1257 // to be compressed.
1258 //
1259 // If a value other than CM_off is returned, this is
1260 // not a guarantee that the texture is actually
1261 // successfully compressed on the GSG. It may be that
1262 // the GSG does not support the requested compression
1263 // mode, in which case the texture may actually be
1264 // stored uncompressed in texture memory.
1265 ////////////////////////////////////////////////////////////////////
1266 INLINE Texture::CompressionMode Texture::
1268  CDReader cdata(_cycler);
1269  return cdata->_compression;
1270 }
1271 
1272 ////////////////////////////////////////////////////////////////////
1273 // Function: Texture::has_compression
1274 // Access: Published
1275 // Description: Returns true if the texture indicates it wants to be
1276 // compressed, either with CM_on or higher, or
1277 // CM_default and compressed-textures is true.
1278 //
1279 // If true returned, this is not a guarantee that the
1280 // texture is actually successfully compressed on the
1281 // GSG. It may be that the GSG does not support the
1282 // requested compression mode, in which case the texture
1283 // may actually be stored uncompressed in texture
1284 // memory.
1285 ////////////////////////////////////////////////////////////////////
1286 INLINE bool Texture::
1288  CDReader cdata(_cycler);
1289  return do_has_compression(cdata);
1290 }
1291 
1292 ////////////////////////////////////////////////////////////////////
1293 // Function: Texture::get_render_to_texture
1294 // Access: Published
1295 // Description: Returns a flag on the texture that indicates whether the
1296 // texture is intended to be used as a direct-render
1297 // target, by binding a framebuffer to a texture and
1298 // rendering directly into the texture.
1299 //
1300 // Normally, a user should not need to set this flag
1301 // directly; it is set automatically by the low-level
1302 // display code when a texture is bound to a
1303 // framebuffer.
1304 ////////////////////////////////////////////////////////////////////
1305 INLINE bool Texture::
1307  CDReader cdata(_cycler);
1308  return cdata->_render_to_texture;
1309 }
1310 
1311 ////////////////////////////////////////////////////////////////////
1312 // Function: Texture::uses_mipmaps
1313 // Access: Public
1314 // Description: Returns true if the minfilter settings on this
1315 // texture indicate the use of mipmapping, false
1316 // otherwise.
1317 ////////////////////////////////////////////////////////////////////
1318 INLINE bool Texture::
1319 uses_mipmaps() const {
1321 }
1322 
1323 ////////////////////////////////////////////////////////////////////
1324 // Function: Texture::set_quality_level
1325 // Access: Public
1326 // Description: Sets a hint to the renderer about the desired
1327 // performance / quality tradeoff for this particular
1328 // texture. This is most useful for the tinydisplay
1329 // software renderer; for normal, hardware-accelerated
1330 // renderers, this may have little or no effect.
1331 ////////////////////////////////////////////////////////////////////
1332 INLINE void Texture::
1333 set_quality_level(Texture::QualityLevel quality_level) {
1334  CDWriter cdata(_cycler, true);
1335  do_set_quality_level(cdata, quality_level);
1336 }
1337 
1338 ////////////////////////////////////////////////////////////////////
1339 // Function: Texture::get_quality_level
1340 // Access: Public
1341 // Description: Returns the current quality_level hint. See
1342 // set_quality_level(). This value may return
1343 // QL_default; see get_effective_quality_level().
1344 ////////////////////////////////////////////////////////////////////
1345 INLINE Texture::QualityLevel Texture::
1347  CDReader cdata(_cycler);
1348  return cdata->_quality_level;
1349 }
1350 
1351 ////////////////////////////////////////////////////////////////////
1352 // Function: Texture::get_effective_quality_level
1353 // Access: Public
1354 // Description: Returns the current quality_level hint, or the global
1355 // default quality_level if this texture doesn't specify
1356 // a quality level. This value will not normally return
1357 // QL_default (unless there is an error in the config
1358 // file)
1359 ////////////////////////////////////////////////////////////////////
1360 INLINE Texture::QualityLevel Texture::
1362  CDReader cdata(_cycler);
1363  if (cdata->_quality_level == QL_default) {
1364  return texture_quality_level;
1365  }
1366  return cdata->_quality_level;
1367 }
1368 
1369 ////////////////////////////////////////////////////////////////////
1370 // Function: Texture::get_expected_num_mipmap_levels
1371 // Access: Published
1372 // Description: Returns the number of mipmap levels that should be
1373 // defined for this texture, given the texture's size.
1374 //
1375 // Note that this returns a number appropriate for
1376 // mipmapping, even if the texture does not currently
1377 // have mipmapping enabled.
1378 ////////////////////////////////////////////////////////////////////
1379 INLINE int Texture::
1381  CDReader cdata(_cycler);
1382  return do_get_expected_num_mipmap_levels(cdata);
1383 }
1384 
1385 ////////////////////////////////////////////////////////////////////
1386 // Function: Texture::get_expected_mipmap_x_size
1387 // Access: Published
1388 // Description: Returns the x_size that the nth mipmap level should
1389 // have, based on the texture's size.
1390 ////////////////////////////////////////////////////////////////////
1391 INLINE int Texture::
1393  CDReader cdata(_cycler);
1394  return do_get_expected_mipmap_x_size(cdata, n);
1395 }
1396 
1397 ////////////////////////////////////////////////////////////////////
1398 // Function: Texture::get_expected_mipmap_y_size
1399 // Access: Published
1400 // Description: Returns the y_size that the nth mipmap level should
1401 // have, based on the texture's size.
1402 ////////////////////////////////////////////////////////////////////
1403 INLINE int Texture::
1405  CDReader cdata(_cycler);
1406  return do_get_expected_mipmap_y_size(cdata, n);
1407 }
1408 
1409 ////////////////////////////////////////////////////////////////////
1410 // Function: Texture::get_expected_mipmap_z_size
1411 // Access: Published
1412 // Description: Returns the z_size that the nth mipmap level should
1413 // have, based on the texture's size.
1414 ////////////////////////////////////////////////////////////////////
1415 INLINE int Texture::
1417  CDReader cdata(_cycler);
1418  return do_get_expected_mipmap_z_size(cdata, n);
1419 }
1420 
1421 ////////////////////////////////////////////////////////////////////
1422 // Function: Texture::get_expected_mipmap_num_pages
1423 // Access: Published
1424 // Description: Returns the total number of pages that the nth mipmap
1425 // level should have, based on the texture's size. This
1426 // is usually the same as get_expected_mipmap_z_size(),
1427 // except for a multiview texture, in which case it is
1428 // get_expected_mipmap_z_size() * get_num_views().
1429 ////////////////////////////////////////////////////////////////////
1430 INLINE int Texture::
1432  CDReader cdata(_cycler);
1433  return do_get_expected_mipmap_num_pages(cdata, n);
1434 }
1435 
1436 ////////////////////////////////////////////////////////////////////
1437 // Function: Texture::has_ram_image
1438 // Access: Published
1439 // Description: Returns true if the Texture has its image contents
1440 // available in main RAM, false if it exists only in
1441 // texture memory or in the prepared GSG context.
1442 //
1443 // Note that this has nothing to do with whether
1444 // get_ram_image() will fail or not. Even if
1445 // has_ram_image() returns false, get_ram_image() may
1446 // still return a valid RAM image, because
1447 // get_ram_image() will automatically load the texture
1448 // from disk if necessary. The only thing
1449 // has_ram_image() tells you is whether the texture is
1450 // available right now without hitting the disk first.
1451 //
1452 // Note also that if an application uses only one GSG,
1453 // it may appear that has_ram_image() returns true if
1454 // the texture has not yet been loaded by the GSG, but
1455 // this correlation is not true in general and should
1456 // not be depended on. Specifically, if an application
1457 // ever uses multiple GSG's in its lifetime (for
1458 // instance, by opening more than one window, or by
1459 // closing its window and opening another one later),
1460 // then has_ram_image() may well return false on
1461 // textures that have never been loaded on the current
1462 // GSG.
1463 ////////////////////////////////////////////////////////////////////
1464 INLINE bool Texture::
1465 has_ram_image() const {
1466  CDReader cdata(_cycler);
1467  return do_has_ram_image(cdata);
1468 }
1469 
1470 ////////////////////////////////////////////////////////////////////
1471 // Function: Texture::has_uncompressed_ram_image
1472 // Access: Published
1473 // Description: Returns true if the Texture has its image contents
1474 // available in main RAM and is uncompressed, false
1475 // otherwise. See has_ram_image().
1476 ////////////////////////////////////////////////////////////////////
1477 INLINE bool Texture::
1479  CDReader cdata(_cycler);
1480  return do_has_uncompressed_ram_image(cdata);
1481 }
1482 
1483 ////////////////////////////////////////////////////////////////////
1484 // Function: Texture::might_have_ram_image
1485 // Access: Published
1486 // Description: Returns true if the texture's image contents are
1487 // currently available in main RAM, or there is reason
1488 // to believe it can be loaded on demand. That is, this
1489 // function returns a "best guess" as to whether
1490 // get_ram_image() will succeed without actually calling
1491 // it first.
1492 ////////////////////////////////////////////////////////////////////
1493 INLINE bool Texture::
1495  CDReader cdata(_cycler);
1496  return (do_has_ram_image(cdata) || !cdata->_fullpath.empty());
1497 }
1498 
1499 ////////////////////////////////////////////////////////////////////
1500 // Function: Texture::get_ram_image_size
1501 // Access: Published
1502 // Description: Returns the total number of bytes used by the
1503 // in-memory image, across all pages and views, or 0 if
1504 // there is no in-memory image.
1505 ////////////////////////////////////////////////////////////////////
1506 INLINE size_t Texture::
1508  CDReader cdata(_cycler);
1509  return do_get_ram_image_size(cdata);
1510 }
1511 
1512 ////////////////////////////////////////////////////////////////////
1513 // Function: Texture::get_ram_view_size
1514 // Access: Published
1515 // Description: Returns the number of bytes used by the in-memory
1516 // image per view, or 0 if there is no in-memory image.
1517 // Since each view is a stack of z_size pages, this is
1518 // get_z_size() * get_ram_page_size().
1519 ////////////////////////////////////////////////////////////////////
1520 INLINE size_t Texture::
1522  CDReader cdata(_cycler);
1523  if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1524  return do_get_expected_ram_view_size(cdata);
1525  } else {
1526  return cdata->_z_size * cdata->_ram_images[0]._page_size;
1527  }
1528 }
1529 
1530 ////////////////////////////////////////////////////////////////////
1531 // Function: Texture::get_ram_page_size
1532 // Access: Published
1533 // Description: Returns the number of bytes used by the in-memory
1534 // image per page, or 0 if there is no in-memory image.
1535 //
1536 // For a non-compressed texture, this is the same as
1537 // get_expected_ram_page_size(). For a compressed
1538 // texture, this may be a smaller value. (We do assume
1539 // that all pages will be the same size on a compressed
1540 // texture).
1541 ////////////////////////////////////////////////////////////////////
1542 INLINE size_t Texture::
1544  CDReader cdata(_cycler);
1545  if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1546  return do_get_expected_ram_page_size(cdata);
1547  } else {
1548  return cdata->_ram_images[0]._page_size;
1549  }
1550 }
1551 
1552 ////////////////////////////////////////////////////////////////////
1553 // Function: Texture::get_expected_ram_image_size
1554 // Access: Published
1555 // Description: Returns the number of bytes that *ought* to be used
1556 // by the in-memory image, based on the texture
1557 // parameters.
1558 ////////////////////////////////////////////////////////////////////
1559 INLINE size_t Texture::
1561  CDReader cdata(_cycler);
1562  return do_get_expected_ram_image_size(cdata);
1563 }
1564 
1565 ////////////////////////////////////////////////////////////////////
1566 // Function: Texture::get_expected_ram_page_size
1567 // Access: Published
1568 // Description: Returns the number of bytes that should be used per
1569 // each Z page of the 3-d texture. For a 2-d or 1-d
1570 // texture, this is the same as
1571 // get_expected_ram_image_size().
1572 ////////////////////////////////////////////////////////////////////
1573 INLINE size_t Texture::
1575  CDReader cdata(_cycler);
1576  return do_get_expected_ram_page_size(cdata);
1577 }
1578 
1579 ////////////////////////////////////////////////////////////////////
1580 // Function: Texture::get_ram_image
1581 // Access: Published
1582 // Description: Returns the system-RAM image data associated with the
1583 // texture. If the texture does not currently have an
1584 // associated RAM image, and the texture was generated
1585 // by loading an image from a disk file (the most common
1586 // case), this forces the reload of the same texture.
1587 // This can happen if keep_texture_ram is configured to
1588 // false, and we have previously prepared this texture
1589 // with a GSG.
1590 //
1591 // Note that it is not correct to call has_ram_image()
1592 // first to test whether this function will fail. A
1593 // false return value from has_ram_image() indicates
1594 // only that get_ram_image() may need to reload the
1595 // texture from disk, which it will do automatically.
1596 // However, you can call might_have_ram_image(), which
1597 // will return true if the ram image exists, or there is
1598 // a reasonable reason to believe it can be loaded.
1599 //
1600 // On the other hand, it is possible that the texture
1601 // cannot be found on disk or is otherwise unavailable.
1602 // If that happens, this function will return NULL.
1603 // There is no way to predict with 100% accuracy whether
1604 // get_ram_image() will return NULL without calling it
1605 // first; might_have_ram_image() is the closest.
1606 ////////////////////////////////////////////////////////////////////
1607 INLINE CPTA_uchar Texture::
1609  CDWriter cdata(_cycler, unlocked_ensure_ram_image(true));
1610  return do_get_ram_image(cdata);
1611 }
1612 
1613 ////////////////////////////////////////////////////////////////////
1614 // Function: Texture::get_ram_image_compression
1615 // Access: Published
1616 // Description: Returns the compression mode in which the ram image
1617 // is already stored pre-compressed. If this is other
1618 // than CM_off, you cannot rely on the contents of the
1619 // ram image to be anything predicatable (it will not be
1620 // an array of x by y pixels, and it probably won't have
1621 // the same length as get_expected_ram_image_size()).
1622 ////////////////////////////////////////////////////////////////////
1623 INLINE Texture::CompressionMode Texture::
1625  CDReader cdata(_cycler);
1626  return cdata->_ram_image_compression;
1627 }
1628 
1629 ////////////////////////////////////////////////////////////////////
1630 // Function: Texture::modify_ram_image
1631 // Access: Published
1632 // Description: Returns a modifiable pointer to the system-RAM image.
1633 // This assumes the RAM image should be uncompressed.
1634 // If the RAM image has been dumped, or is stored
1635 // compressed, creates a new one.
1636 //
1637 // This does *not* affect keep_ram_image.
1638 ////////////////////////////////////////////////////////////////////
1639 INLINE PTA_uchar Texture::
1641  CDWriter cdata(_cycler, true);
1642  cdata->inc_image_modified();
1643  return do_modify_ram_image(cdata);
1644 }
1645 
1646 ////////////////////////////////////////////////////////////////////
1647 // Function: Texture::get_uncompressed_ram_image
1648 // Access: Published
1649 // Description: Returns the system-RAM image associated with the
1650 // texture, in an uncompressed form if at all possible.
1651 //
1652 // If get_ram_image_compression() is CM_off, then the
1653 // system-RAM image is already uncompressed, and this
1654 // returns the same thing as get_ram_image().
1655 //
1656 // If get_ram_image_compression() is anything else, then
1657 // the system-RAM image is compressed. In this case,
1658 // the image will be reloaded from the *original* file
1659 // (not from the cache), in the hopes that an
1660 // uncompressed image will be found there.
1661 //
1662 // If an uncompressed image cannot be found, returns
1663 // NULL.
1664 ////////////////////////////////////////////////////////////////////
1665 INLINE CPTA_uchar Texture::
1667  CDWriter cdata(_cycler, false);
1668  return do_get_uncompressed_ram_image(cdata);
1669 }
1670 
1671 ////////////////////////////////////////////////////////////////////
1672 // Function: Texture::make_ram_image
1673 // Access: Published
1674 // Description: Discards the current system-RAM image for the
1675 // texture, if any, and allocates a new buffer of the
1676 // appropriate size. Returns the new buffer.
1677 //
1678 // This does *not* affect keep_ram_image.
1679 ////////////////////////////////////////////////////////////////////
1680 INLINE PTA_uchar Texture::
1682  CDWriter cdata(_cycler, true);
1683  cdata->inc_image_modified();
1684  return do_make_ram_image(cdata);
1685 }
1686 
1687 ////////////////////////////////////////////////////////////////////
1688 // Function: Texture::set_ram_image
1689 // Access: Published
1690 // Description: Replaces the current system-RAM image with the new
1691 // data. If compression is not CM_off, it indicates
1692 // that the new data is already pre-compressed in the
1693 // indicated format.
1694 //
1695 // This does *not* affect keep_ram_image.
1696 ////////////////////////////////////////////////////////////////////
1697 INLINE void Texture::
1698 set_ram_image(CPTA_uchar image, Texture::CompressionMode compression,
1699  size_t page_size) {
1700  CDWriter cdata(_cycler, true);
1701  do_set_ram_image(cdata, image, compression, page_size);
1702 }
1703 
1704 ////////////////////////////////////////////////////////////////////
1705 // Function: Texture::clear_ram_image
1706 // Access: Published
1707 // Description: Discards the current system-RAM image.
1708 ////////////////////////////////////////////////////////////////////
1709 INLINE void Texture::
1711  CDWriter cdata(_cycler, false);
1712  do_clear_ram_image(cdata);
1713 }
1714 
1715 ////////////////////////////////////////////////////////////////////
1716 // Function: Texture::set_keep_ram_image
1717 // Access: Published
1718 // Description: Sets the flag that indicates whether this Texture is
1719 // eligible to have its main RAM copy of the texture
1720 // memory dumped when the texture is prepared for
1721 // rendering.
1722 //
1723 // This will be false for most textures, which can
1724 // reload their images if needed by rereading the input
1725 // file. However, textures that were generated
1726 // dynamically and cannot be easily reloaded will want
1727 // to set this flag to true, so that the texture will
1728 // always keep its image copy around.
1729 ////////////////////////////////////////////////////////////////////
1730 INLINE void Texture::
1731 set_keep_ram_image(bool keep_ram_image) {
1732  CDWriter cdata(_cycler, true);
1733  cdata->_keep_ram_image = keep_ram_image;
1734 }
1735 
1736 ////////////////////////////////////////////////////////////////////
1737 // Function: Texture::compress_ram_image
1738 // Access: Published
1739 // Description: Attempts to compress the texture's RAM image
1740 // internally, to a format supported by the indicated
1741 // GSG. In order for this to work, the squish library
1742 // must have been compiled into Panda.
1743 //
1744 // If compression is CM_on, then an appropriate
1745 // compression method that is supported by the indicated
1746 // GSG is automatically chosen. If the GSG pointer is
1747 // NULL, any of the standard DXT1/3/5 compression
1748 // methods will be used, regardless of whether it is
1749 // supported.
1750 //
1751 // If compression is any specific compression method,
1752 // that method is used regardless of whether the GSG
1753 // supports it.
1754 //
1755 // quality_level determines the speed/quality tradeoff
1756 // of the compression. If it is QL_default, the
1757 // texture's own quality_level parameter is used.
1758 //
1759 // Returns true if successful, false otherwise.
1760 ////////////////////////////////////////////////////////////////////
1761 INLINE bool Texture::
1762 compress_ram_image(Texture::CompressionMode compression,
1763  Texture::QualityLevel quality_level,
1765  CDWriter cdata(_cycler, false);
1766  if (do_compress_ram_image(cdata, compression, quality_level, gsg)) {
1767  cdata->inc_image_modified();
1768  return true;
1769  }
1770  return false;
1771 }
1772 
1773 ////////////////////////////////////////////////////////////////////
1774 // Function: Texture::uncompress_ram_image
1775 // Access: Published
1776 // Description: Attempts to uncompress the texture's RAM image
1777 // internally. In order for this to work, the squish
1778 // library must have been compiled into Panda, and the
1779 // ram image must be compressed in a format supported by
1780 // squish.
1781 //
1782 // Returns true if successful, false otherwise.
1783 ////////////////////////////////////////////////////////////////////
1784 INLINE bool Texture::
1786  CDWriter cdata(_cycler, false);
1787  if (do_uncompress_ram_image(cdata)) {
1788  cdata->inc_image_modified();
1789  return true;
1790  }
1791  return false;
1792 }
1793 
1794 ////////////////////////////////////////////////////////////////////
1795 // Function: Texture::get_num_ram_mipmap_images
1796 // Access: Published
1797 // Description: Returns the maximum number of mipmap level images
1798 // available in system memory. The actual number may be
1799 // less than this (that is, there might be gaps in the
1800 // sequence); use has_ram_mipmap_image() to verify each
1801 // level.
1802 //
1803 // Also see get_num_loadable_ram_mipmap_images().
1804 ////////////////////////////////////////////////////////////////////
1805 INLINE int Texture::
1807  CDReader cdata(_cycler);
1808  return cdata->_ram_images.size();
1809 }
1810 
1811 ////////////////////////////////////////////////////////////////////
1812 // Function: Texture::has_ram_mipmap_image
1813 // Access: Published
1814 // Description: Returns true if the Texture has the nth mipmap level
1815 // available in system memory, false otherwise. If the
1816 // texture's minfilter mode requires mipmapping (see
1817 // uses_mipmaps()), and all the texture's mipmap levels
1818 // are not available when the texture is rendered, they
1819 // will be generated automatically.
1820 ////////////////////////////////////////////////////////////////////
1821 INLINE bool Texture::
1822 has_ram_mipmap_image(int n) const {
1823  CDReader cdata(_cycler);
1824  return do_has_ram_mipmap_image(cdata, n);
1825 }
1826 
1827 ////////////////////////////////////////////////////////////////////
1828 // Function: Texture::has_all_ram_mipmap_images
1829 // Access: Published
1830 // Description: Returns true if all expected mipmap levels have been
1831 // defined and exist in the system RAM, or false if even
1832 // one mipmap level is missing.
1833 ////////////////////////////////////////////////////////////////////
1834 INLINE bool Texture::
1836  CDReader cdata(_cycler);
1837  return do_has_all_ram_mipmap_images(cdata);
1838 }
1839 
1840 ////////////////////////////////////////////////////////////////////
1841 // Function: Texture::get_ram_mipmap_image_size
1842 // Access: Published
1843 // Description: Returns the number of bytes used by the in-memory
1844 // image for mipmap level n, or 0 if there is no
1845 // in-memory image for this mipmap level.
1846 ////////////////////////////////////////////////////////////////////
1847 INLINE size_t Texture::
1849  CDReader cdata(_cycler);
1850  if (n >= 0 && n < (int)cdata->_ram_images.size()) {
1851  return cdata->_ram_images[n]._image.size();
1852  }
1853  return 0;
1854 }
1855 
1856 ////////////////////////////////////////////////////////////////////
1857 // Function: Texture::get_ram_mipmap_view_size
1858 // Access: Published
1859 // Description: Returns the number of bytes used by the in-memory
1860 // image per view for mipmap level n, or 0 if there is
1861 // no in-memory image for this mipmap level.
1862 //
1863 // A "view" is a collection of z_size pages for each
1864 // mipmap level. Most textures have only one view,
1865 // except for multiview or stereo textures.
1866 //
1867 // For a non-compressed texture, this is the same as
1868 // get_expected_ram_mipmap_view_size(). For a compressed
1869 // texture, this may be a smaller value. (We do assume
1870 // that all pages will be the same size on a compressed
1871 // texture).
1872 ////////////////////////////////////////////////////////////////////
1873 INLINE size_t Texture::
1875  CDReader cdata(_cycler);
1876  return do_get_ram_mipmap_page_size(cdata, n) * do_get_expected_mipmap_z_size(cdata, n);
1877 }
1878 
1879 ////////////////////////////////////////////////////////////////////
1880 // Function: Texture::get_ram_mipmap_page_size
1881 // Access: Published
1882 // Description: Returns the number of bytes used by the in-memory
1883 // image per page for mipmap level n, or 0 if there is
1884 // no in-memory image for this mipmap level.
1885 //
1886 // For a non-compressed texture, this is the same as
1887 // get_expected_ram_mipmap_page_size(). For a compressed
1888 // texture, this may be a smaller value. (We do assume
1889 // that all pages will be the same size on a compressed
1890 // texture).
1891 ////////////////////////////////////////////////////////////////////
1892 INLINE size_t Texture::
1894  CDReader cdata(_cycler);
1895  return do_get_ram_mipmap_page_size(cdata, n);
1896 }
1897 
1898 ////////////////////////////////////////////////////////////////////
1899 // Function: Texture::get_expected_ram_mipmap_image_size
1900 // Access: Published
1901 // Description: Returns the number of bytes that *ought* to be used
1902 // by the in-memory image for mipmap level n, based on
1903 // the texture parameters.
1904 ////////////////////////////////////////////////////////////////////
1905 INLINE size_t Texture::
1907  CDReader cdata(_cycler);
1908  return do_get_expected_ram_mipmap_image_size(cdata, n);
1909 }
1910 
1911 ////////////////////////////////////////////////////////////////////
1912 // Function: Texture::get_expected_ram_mipmap_view_size
1913 // Access: Published
1914 // Description: Returns the number of bytes that *ought* to be used
1915 // by each view of the in-memory image for mipmap level
1916 // n, based on the texture parameters. For a normal,
1917 // non-multiview texture, this is the same as
1918 // get_expected_ram_mipmap_image_size(n).
1919 ////////////////////////////////////////////////////////////////////
1920 INLINE size_t Texture::
1922  CDReader cdata(_cycler);
1923  return do_get_expected_ram_mipmap_view_size(cdata, n);
1924 }
1925 
1926 ////////////////////////////////////////////////////////////////////
1927 // Function: Texture::get_expected_ram_mipmap_page_size
1928 // Access: Published
1929 // Description: Returns the number of bytes that should be used per
1930 // each Z page of the 3-d texture, for mipmap level n.
1931 // For a 2-d or 1-d texture, this is the same as
1932 // get_expected_ram_mipmap_view_size(n).
1933 ////////////////////////////////////////////////////////////////////
1934 INLINE size_t Texture::
1936  CDReader cdata(_cycler);
1937  return do_get_expected_ram_mipmap_page_size(cdata, n);
1938 }
1939 
1940 ////////////////////////////////////////////////////////////////////
1941 // Function: Texture::modify_ram_mipmap_image
1942 // Access: Published
1943 // Description: Returns a modifiable pointer to the system-RAM image
1944 // for the nth mipmap level. This assumes the RAM image
1945 // is uncompressed; if this is not the case, raises an
1946 // assertion.
1947 //
1948 // This does *not* affect keep_ram_image.
1949 ////////////////////////////////////////////////////////////////////
1950 INLINE PTA_uchar Texture::
1952  CDWriter cdata(_cycler, false);
1953  cdata->inc_image_modified();
1954  return do_modify_ram_mipmap_image(cdata, n);
1955 }
1956 
1957 ////////////////////////////////////////////////////////////////////
1958 // Function: Texture::make_ram_mipmap_image
1959 // Access: Published
1960 // Description: Discards the current system-RAM image for the
1961 // nth mipmap level, if any, and allocates a new buffer
1962 // of the appropriate size. Returns the new buffer.
1963 //
1964 // This does *not* affect keep_ram_image.
1965 ////////////////////////////////////////////////////////////////////
1966 INLINE PTA_uchar Texture::
1968  CDWriter cdata(_cycler, false);
1969  cdata->inc_image_modified();
1970  return do_make_ram_mipmap_image(cdata, n);
1971 }
1972 
1973 ////////////////////////////////////////////////////////////////////
1974 // Function: Texture::set_ram_mipmap_image
1975 // Access: Published
1976 // Description: Replaces the current system-RAM image for the
1977 // indicated mipmap level with the new data. If
1978 // compression is not CM_off, it indicates that the new
1979 // data is already pre-compressed in the indicated
1980 // format.
1981 //
1982 // This does *not* affect keep_ram_image.
1983 ////////////////////////////////////////////////////////////////////
1984 INLINE void Texture::
1985 set_ram_mipmap_image(int n, CPTA_uchar image, size_t page_size) {
1986  CDWriter cdata(_cycler, false);
1987  do_set_ram_mipmap_image(cdata, n, image, page_size);
1988 }
1989 
1990 ////////////////////////////////////////////////////////////////////
1991 // Function: Texture::clear_ram_mipmap_images
1992 // Access: Published
1993 // Description: Discards the current system-RAM image for all
1994 // mipmap levels, except level 0 (the base image).
1995 ////////////////////////////////////////////////////////////////////
1996 INLINE void Texture::
1998  CDWriter cdata(_cycler, false);
1999  cdata->inc_image_modified();
2000  do_clear_ram_mipmap_images(cdata);
2001 }
2002 
2003 ////////////////////////////////////////////////////////////////////
2004 // Function: Texture::generate_ram_mipmap_images
2005 // Access: Published
2006 // Description: Automatically fills in the n mipmap levels of the
2007 // Texture, based on the texture's source image. This
2008 // requires the texture's uncompressed ram image to be
2009 // available in system memory. If it is not already, it
2010 // will be fetched if possible.
2011 //
2012 // This call is not normally necessary, since the mipmap
2013 // levels will be generated automatically if needed.
2014 // But there may be certain cases in which you would
2015 // like to call this explicitly.
2016 ////////////////////////////////////////////////////////////////////
2017 INLINE void Texture::
2019  CDWriter cdata(_cycler, unlocked_ensure_ram_image(false));
2020  cdata->inc_image_modified();
2021  do_generate_ram_mipmap_images(cdata);
2022 }
2023 
2024 ////////////////////////////////////////////////////////////////////
2025 // Function: Texture::get_simple_x_size
2026 // Access: Published
2027 // Description: Returns the width of the "simple" image in texels.
2028 ////////////////////////////////////////////////////////////////////
2029 INLINE int Texture::
2031  CDReader cdata(_cycler);
2032  return cdata->_simple_x_size;
2033 }
2034 
2035 ////////////////////////////////////////////////////////////////////
2036 // Function: Texture::get_simple_y_size
2037 // Access: Published
2038 // Description: Returns the height of the "simple" image in texels.
2039 ////////////////////////////////////////////////////////////////////
2040 INLINE int Texture::
2042  CDReader cdata(_cycler);
2043  return cdata->_simple_y_size;
2044 }
2045 
2046 ////////////////////////////////////////////////////////////////////
2047 // Function: Texture::has_simple_ram_image
2048 // Access: Published, Virtual
2049 // Description: Returns true if the Texture has a "simple" image
2050 // available in main RAM.
2051 ////////////////////////////////////////////////////////////////////
2052 INLINE bool Texture::
2054  CDReader cdata(_cycler);
2055  return !cdata->_simple_ram_image._image.empty();
2056 }
2057 
2058 ////////////////////////////////////////////////////////////////////
2059 // Function: Texture::get_simple_ram_image_size
2060 // Access: Published
2061 // Description: Returns the number of bytes used by the "simple"
2062 // image, or 0 if there is no simple image.
2063 ////////////////////////////////////////////////////////////////////
2064 INLINE size_t Texture::
2066  CDReader cdata(_cycler);
2067  return cdata->_simple_ram_image._image.size();
2068 }
2069 
2070 ////////////////////////////////////////////////////////////////////
2071 // Function: Texture::get_simple_ram_image
2072 // Access: Published
2073 // Description: Returns the image data associated with the "simple"
2074 // texture image. This is provided for some textures as
2075 // an option to display while the main texture image is
2076 // being loaded from disk.
2077 //
2078 // Unlike get_ram_image(), this function will always
2079 // return immediately. Either the simple image is
2080 // available, or it is not.
2081 //
2082 // The "simple" image is always 4 components, 1 byte
2083 // each, regardless of the parameters of the full
2084 // texture. The simple image is only supported for
2085 // ordinary 2-d textures.
2086 ////////////////////////////////////////////////////////////////////
2087 INLINE CPTA_uchar Texture::
2089  CDReader cdata(_cycler);
2090  return cdata->_simple_ram_image._image;
2091 }
2092 
2093 ////////////////////////////////////////////////////////////////////
2094 // Function: Texture::set_simple_ram_image
2095 // Access: Published
2096 // Description: Replaces the internal "simple" texture image. This
2097 // can be used as an option to display while the main
2098 // texture image is being loaded from disk. It is
2099 // normally a very small image, 16x16 or smaller (and
2100 // maybe even 1x1), that is designed to give just enough
2101 // sense of color to serve as a placeholder until the
2102 // full texture is available.
2103 //
2104 // The "simple" image is always 4 components, 1 byte
2105 // each, regardless of the parameters of the full
2106 // texture. The simple image is only supported for
2107 // ordinary 2-d textures.
2108 //
2109 // Also see generate_simple_ram_image(),
2110 // modify_simple_ram_image(), and
2111 // new_simple_ram_image().
2112 ////////////////////////////////////////////////////////////////////
2113 INLINE void Texture::
2114 set_simple_ram_image(CPTA_uchar image, int x_size, int y_size) {
2115  CDWriter cdata(_cycler, true);
2116  do_set_simple_ram_image(cdata, image, x_size, y_size);
2117 }
2118 
2119 ////////////////////////////////////////////////////////////////////
2120 // Function: Texture::clear_simple_ram_image
2121 // Access: Published
2122 // Description: Discards the current "simple" image.
2123 ////////////////////////////////////////////////////////////////////
2124 INLINE void Texture::
2126  CDWriter cdata(_cycler, true);
2127  do_clear_simple_ram_image(cdata);
2128 }
2129 
2130 ////////////////////////////////////////////////////////////////////
2131 // Function: Texture::get_properties_modified
2132 // Access: Published
2133 // Description: Returns a sequence number which is guaranteed to
2134 // change at least every time the texture properties
2135 // (unrelated to the image) are modified.
2136 ////////////////////////////////////////////////////////////////////
2137 INLINE UpdateSeq Texture::
2139  CDReader cdata(_cycler);
2140  return cdata->_properties_modified;
2141 }
2142 
2143 ////////////////////////////////////////////////////////////////////
2144 // Function: Texture::get_image_modified
2145 // Access: Published
2146 // Description: Returns a sequence number which is guaranteed to
2147 // change at least every time the texture image data
2148 // (including mipmap levels) are modified.
2149 ////////////////////////////////////////////////////////////////////
2150 INLINE UpdateSeq Texture::
2152  CDReader cdata(_cycler);
2153  return cdata->_image_modified;
2154 }
2155 
2156 ////////////////////////////////////////////////////////////////////
2157 // Function: Texture::get_simple_image_modified
2158 // Access: Published
2159 // Description: Returns a sequence number which is guaranteed to
2160 // change at least every time the texture's "simple"
2161 // image data is modified.
2162 ////////////////////////////////////////////////////////////////////
2163 INLINE UpdateSeq Texture::
2165  CDReader cdata(_cycler);
2166  return cdata->_simple_image_modified;
2167 }
2168 
2169 ////////////////////////////////////////////////////////////////////
2170 // Function: Texture::set_auto_texture_scale
2171 // Access: Published
2172 // Description: Specifies the power-of-2 texture-scaling mode that
2173 // will be applied to this particular texture when it is
2174 // next loaded from disk. See set_textures_power_2().
2175 ////////////////////////////////////////////////////////////////////
2176 INLINE void Texture::
2177 set_auto_texture_scale(AutoTextureScale scale) {
2178  CDWriter cdata(_cycler, true);
2179  cdata->_auto_texture_scale = scale;
2180 }
2181 
2182 ////////////////////////////////////////////////////////////////////
2183 // Function: Texture::get_auto_texture_scale
2184 // Access: Published
2185 // Description: Returns the power-of-2 texture-scaling mode that will
2186 // be applied to this particular texture when it is next
2187 // loaded from disk. See set_textures_power_2().
2188 ////////////////////////////////////////////////////////////////////
2189 INLINE AutoTextureScale Texture::
2191  CDReader cdata(_cycler);
2192  return do_get_auto_texture_scale(cdata);
2193 }
2194 
2195 ////////////////////////////////////////////////////////////////////
2196 // Function: Texture::has_auto_texture_scale
2197 // Access: Published
2198 // Description: Returns true if set_auto_texture_scale() has been set
2199 // to something other than ATS_unspecified for this
2200 // particular texture.
2201 ////////////////////////////////////////////////////////////////////
2202 INLINE bool Texture::
2204  CDReader cdata(_cycler);
2205  return (cdata->_auto_texture_scale != ATS_unspecified);
2206 }
2207 
2208 ////////////////////////////////////////////////////////////////////
2209 // Function: Texture::set_textures_power_2
2210 // Access: Published, Static
2211 // Description: Set this flag to ATS_none, ATS_up, ATS_down, or
2212 // ATS_pad to control the scaling of textures in
2213 // general, if a particular texture does not override
2214 // this. See also set_auto_texture_scale() for the
2215 // per-texture override.
2216 ////////////////////////////////////////////////////////////////////
2217 INLINE void Texture::
2218 set_textures_power_2(AutoTextureScale scale) {
2219  _textures_power_2 = scale;
2220 }
2221 
2222 ////////////////////////////////////////////////////////////////////
2223 // Function: Texture::get_textures_power_2
2224 // Access: Published, Static
2225 // Description: This flag returns ATS_none, ATS_up, or ATS_down
2226 // and controls the scaling of textures in general. It
2227 // is initialized from the config variable of the same
2228 // name, but it can be subsequently adjusted. See also
2229 // get_auto_texture_scale().
2230 ////////////////////////////////////////////////////////////////////
2231 INLINE AutoTextureScale Texture::
2233  if (_textures_power_2 == ATS_unspecified) {
2234  return textures_power_2;
2235  } else {
2236  return _textures_power_2;
2237  }
2238 }
2239 
2240 ////////////////////////////////////////////////////////////////////
2241 // Function: Texture::has_textures_power_2
2242 // Access: Published, Static
2243 // Description: If true, then get_textures_power_2 has been
2244 // set using set_textures_power_2.
2245 // If false, then get_textures_power_2 simply
2246 // returns the config variable of the same name.
2247 ////////////////////////////////////////////////////////////////////
2248 INLINE bool Texture::
2250  return (_textures_power_2 != ATS_unspecified);
2251 }
2252 
2253 ////////////////////////////////////////////////////////////////////
2254 // Function: Texture::set_filename
2255 // Access: Published
2256 // Description: Sets the name of the file that contains the image's
2257 // contents. Normally, this is set automatically when
2258 // the image is loaded, for instance via
2259 // Texture::read().
2260 //
2261 // The Texture's get_name() function used to return
2262 // the filename, but now returns just the basename
2263 // (without the extension), which is a more useful name
2264 // for identifying an image in show code.
2265 ////////////////////////////////////////////////////////////////////
2266 INLINE void Texture::
2267 set_filename(const Filename &filename) {
2268  CDWriter cdata(_cycler, true);
2269  cdata->_filename = filename;
2270 }
2271 
2272 ////////////////////////////////////////////////////////////////////
2273 // Function: Texture::clear_filename
2274 // Access: Published
2275 // Description: Removes the alpha filename, if it was previously set.
2276 // See set_filename().
2277 ////////////////////////////////////////////////////////////////////
2278 INLINE void Texture::
2280  CDWriter cdata(_cycler, true);
2281  cdata->_filename = Filename();
2282 }
2283 
2284 ////////////////////////////////////////////////////////////////////
2285 // Function: Texture::set_alpha_filename
2286 // Access: Published
2287 // Description: Sets the name of the file that contains the image's
2288 // alpha channel contents. Normally, this is set
2289 // automatically when the image is loaded, for instance
2290 // via Texture::read().
2291 //
2292 // The Texture's get_filename() function returns the
2293 // name of the image file that was loaded into the
2294 // buffer. In the case where a texture specified two
2295 // separate files to load, a 1- or 3-channel color image
2296 // and a 1-channel alpha image, this Filename is update
2297 // to contain the name of the image file that was loaded
2298 // into the buffer's alpha channel.
2299 ////////////////////////////////////////////////////////////////////
2300 INLINE void Texture::
2301 set_alpha_filename(const Filename &alpha_filename) {
2302  CDWriter cdata(_cycler, true);
2303  cdata->_alpha_filename = alpha_filename;
2304 }
2305 
2306 ////////////////////////////////////////////////////////////////////
2307 // Function: Texture::clear_alpha_filename
2308 // Access: Published
2309 // Description: Removes the alpha filename, if it was previously set.
2310 // See set_alpha_filename().
2311 ////////////////////////////////////////////////////////////////////
2312 INLINE void Texture::
2314  CDWriter cdata(_cycler, true);
2315  cdata->_alpha_filename = Filename();
2316 }
2317 
2318 ////////////////////////////////////////////////////////////////////
2319 // Function: Texture::set_fullpath
2320 // Access: Published
2321 // Description: Sets the full pathname to the file that contains the
2322 // image's contents, as found along the search path.
2323 // Normally, this is set automatically when the image is
2324 // loaded, for instance via Texture::read().
2325 ////////////////////////////////////////////////////////////////////
2326 INLINE void Texture::
2327 set_fullpath(const Filename &fullpath) {
2328  CDWriter cdata(_cycler, true);
2329  cdata->_fullpath = fullpath;
2330 }
2331 
2332 ////////////////////////////////////////////////////////////////////
2333 // Function: Texture::clear_fullpath
2334 // Access: Published
2335 // Description: Removes the alpha fullpath, if it was previously set.
2336 // See set_fullpath().
2337 ////////////////////////////////////////////////////////////////////
2338 INLINE void Texture::
2340  CDWriter cdata(_cycler, true);
2341  cdata->_fullpath = Filename();
2342 }
2343 
2344 ////////////////////////////////////////////////////////////////////
2345 // Function: Texture::set_alpha_fullpath
2346 // Access: Published
2347 // Description: Sets the full pathname to the file that contains the
2348 // image's alpha channel contents, as found along the
2349 // search path. Normally, this is set automatically
2350 // when the image is loaded, for instance via
2351 // Texture::read().
2352 ////////////////////////////////////////////////////////////////////
2353 INLINE void Texture::
2354 set_alpha_fullpath(const Filename &alpha_fullpath) {
2355  CDWriter cdata(_cycler, true);
2356  cdata->_alpha_fullpath = alpha_fullpath;
2357 }
2358 
2359 ////////////////////////////////////////////////////////////////////
2360 // Function: Texture::clear_alpha_fullpath
2361 // Access: Published
2362 // Description: Removes the alpha fullpath, if it was previously set.
2363 // See set_alpha_fullpath().
2364 ////////////////////////////////////////////////////////////////////
2365 INLINE void Texture::
2367  CDWriter cdata(_cycler, true);
2368  cdata->_alpha_fullpath = Filename();
2369 }
2370 
2371 ////////////////////////////////////////////////////////////////////
2372 // Function: Texture::set_x_size
2373 // Access: Published
2374 // Description: Changes the x size indicated for the texture. This
2375 // also implicitly unloads the texture if it has already
2376 // been loaded.
2377 ////////////////////////////////////////////////////////////////////
2378 INLINE void Texture::
2379 set_x_size(int x_size) {
2380  CDWriter cdata(_cycler, true);
2381  do_set_x_size(cdata, x_size);
2382 }
2383 
2384 ////////////////////////////////////////////////////////////////////
2385 // Function: Texture::set_y_size
2386 // Access: Published
2387 // Description: Changes the y size indicated for the texture. This
2388 // also implicitly unloads the texture if it has already
2389 // been loaded.
2390 ////////////////////////////////////////////////////////////////////
2391 INLINE void Texture::
2392 set_y_size(int y_size) {
2393  CDWriter cdata(_cycler, true);
2394  do_set_y_size(cdata, y_size);
2395 }
2396 
2397 ////////////////////////////////////////////////////////////////////
2398 // Function: Texture::set_z_size
2399 // Access: Published
2400 // Description: Changes the z size indicated for the texture. This
2401 // also implicitly unloads the texture if it has already
2402 // been loaded.
2403 ////////////////////////////////////////////////////////////////////
2404 INLINE void Texture::
2405 set_z_size(int z_size) {
2406  CDWriter cdata(_cycler, true);
2407  do_set_z_size(cdata, z_size);
2408 }
2409 
2410 ////////////////////////////////////////////////////////////////////
2411 // Function: Texture::set_num_views
2412 // Access: Published
2413 // Description: Sets the number of "views" within a texture. A view
2414 // is a completely separate image stored within the
2415 // Texture object. Most textures have only one view,
2416 // but a stereo texture, for instance, may have two
2417 // views, a left and a right image. Other uses for
2418 // multiple views are not yet defined.
2419 //
2420 // If this value is greater than one, the additional
2421 // views are accessed as additional pages beyond
2422 // get_z_size().
2423 //
2424 // This also implicitly unloads the texture if it has
2425 // already been loaded.
2426 ////////////////////////////////////////////////////////////////////
2427 INLINE void Texture::
2428 set_num_views(int num_views) {
2429  CDWriter cdata(_cycler, true);
2430  do_set_num_views(cdata, num_views);
2431 }
2432 
2433 ////////////////////////////////////////////////////////////////////
2434 // Function: Texture::set_format
2435 // Access: Published
2436 // Description: Changes the format value for the texture components.
2437 // This implicitly sets num_components as well.
2438 ////////////////////////////////////////////////////////////////////
2439 INLINE void Texture::
2440 set_format(Texture::Format format) {
2441  CDWriter cdata(_cycler, true);
2442  do_set_format(cdata, format);
2443 }
2444 
2445 ////////////////////////////////////////////////////////////////////
2446 // Function: Texture::set_component_type
2447 // Access: Published
2448 // Description: Changes the data value for the texture components.
2449 // This implicitly sets component_width as well.
2450 ////////////////////////////////////////////////////////////////////
2451 INLINE void Texture::
2452 set_component_type(Texture::ComponentType component_type) {
2453  CDWriter cdata(_cycler, true);
2454  do_set_component_type(cdata, component_type);
2455 }
2456 
2457 ////////////////////////////////////////////////////////////////////
2458 // Function: Texture::set_loaded_from_image
2459 // Access: Published
2460 // Description: Sets the flag that indicates the texture has been
2461 // loaded from a disk file or PNMImage. You should also
2462 // ensure the filename has been set correctly. When
2463 // this flag is true, the texture may be automatically
2464 // reloaded when its ram image needs to be replaced.
2465 ////////////////////////////////////////////////////////////////////
2466 INLINE void Texture::
2468  CDWriter cdata(_cycler, false);
2469  cdata->_loaded_from_image = true;
2470 }
2471 
2472 ////////////////////////////////////////////////////////////////////
2473 // Function: Texture::get_loaded_from_image
2474 // Access: Published
2475 // Description: Returns the flag that indicates the texture has been
2476 // loaded from a disk file or PNMImage. See
2477 // set_loaded_from_image().
2478 ////////////////////////////////////////////////////////////////////
2479 INLINE bool Texture::
2481  CDReader cdata(_cycler);
2482  return cdata->_loaded_from_image;
2483 }
2484 
2485 ////////////////////////////////////////////////////////////////////
2486 // Function: Texture::set_loaded_from_txo
2487 // Access: Published
2488 // Description: Sets the flag that indicates the texture has been
2489 // loaded from a txo file. You probably shouldn't be
2490 // setting this directly; it is set automatically when a
2491 // Texture is loaded.
2492 ////////////////////////////////////////////////////////////////////
2493 INLINE void Texture::
2495  CDWriter cdata(_cycler, false);
2496  cdata->_loaded_from_txo = true;
2497 }
2498 
2499 ////////////////////////////////////////////////////////////////////
2500 // Function: Texture::get_loaded_from_txo
2501 // Access: Published
2502 // Description: Returns the flag that indicates the texture has been
2503 // loaded from a txo file.
2504 ////////////////////////////////////////////////////////////////////
2505 INLINE bool Texture::
2507  CDReader cdata(_cycler);
2508  return cdata->_loaded_from_txo;
2509 }
2510 
2511 ////////////////////////////////////////////////////////////////////
2512 // Function: Texture::get_match_framebuffer_format
2513 // Access: Public
2514 // Description: Returns true if the special flag was set that
2515 // indicates to the GSG that the Texture's format should
2516 // be chosen to exactly match the framebuffer's format,
2517 // presumably because the application intends to copy
2518 // image data from the framebuffer into the Texture (or
2519 // vice-versa).
2520 ////////////////////////////////////////////////////////////////////
2521 INLINE bool Texture::
2523  CDReader cdata(_cycler);
2524  return cdata->_match_framebuffer_format;
2525 }
2526 
2527 ////////////////////////////////////////////////////////////////////
2528 // Function: Texture::set_match_framebuffer_format
2529 // Access: Public
2530 // Description: Sets the special flag that, if true, indicates to the
2531 // GSG that the Texture's format should be chosen to
2532 // exactly match the framebuffer's format, presumably
2533 // because the application intends to copy image data
2534 // from the framebuffer into the Texture (or
2535 // vice-versa).
2536 //
2537 // This sets only the graphics card's idea of the
2538 // texture format; it is not related to the
2539 // system-memory format.
2540 ////////////////////////////////////////////////////////////////////
2541 INLINE void Texture::
2543  CDWriter cdata(_cycler, true);
2544  cdata->_match_framebuffer_format = flag;
2545 }
2546 
2547 ////////////////////////////////////////////////////////////////////
2548 // Function: Texture::get_post_load_store_cache
2549 // Access: Public
2550 // Description: Returns the setting of the post_load_store_cache
2551 // flag. See set_post_load_store_cache().
2552 ////////////////////////////////////////////////////////////////////
2553 INLINE bool Texture::
2555  CDReader cdata(_cycler);
2556  return cdata->_post_load_store_cache;
2557 }
2558 
2559 ////////////////////////////////////////////////////////////////////
2560 // Function: Texture::set_post_load_store_cache
2561 // Access: Public
2562 // Description: Sets the post_load_store_cache flag. When this is
2563 // set, the next time the texture is loaded on a GSG, it
2564 // will automatically extract its RAM image from the GSG
2565 // and save it to the global BamCache.
2566 //
2567 // This is used to store compressed RAM images in the
2568 // BamCache. This flag should not be set explicitly; it
2569 // is set automatically by the TexturePool when
2570 // model-cache-compressed-textures is set true.
2571 ////////////////////////////////////////////////////////////////////
2572 INLINE void Texture::
2574  CDWriter cdata(_cycler, true);
2575  cdata->_post_load_store_cache = flag;
2576 }
2577 
2578 ////////////////////////////////////////////////////////////////////
2579 // Function: Texture::rescale_texture
2580 // Access: Published
2581 // Description: This method is similar to consider_rescale(), but
2582 // instead of scaling a separate PNMImage, it will ask
2583 // the Texture to rescale its own internal image to a
2584 // power of 2, according to the config file
2585 // requirements. This may be useful after loading a
2586 // Texture image by hand, instead of reading it from a
2587 // disk file. Returns true if the texture is changed,
2588 // false if it was not.
2589 ////////////////////////////////////////////////////////////////////
2590 INLINE bool Texture::
2592  CDWriter cdata(_cycler, true);
2593  return do_rescale_texture(cdata);
2594 }
2595 
2596 ////////////////////////////////////////////////////////////////////
2597 // Function: Texture::adjust_this_size
2598 // Access: Public
2599 // Description: Works like adjust_size, but also considers the
2600 // texture class. Movie textures, for instance, always
2601 // pad outwards, regardless of textures-power-2.
2602 ////////////////////////////////////////////////////////////////////
2603 INLINE bool Texture::
2604 adjust_this_size(int &x_size, int &y_size, const string &name,
2605  bool for_padding) const {
2606  CDReader cdata(_cycler);
2607  return do_adjust_this_size(cdata, x_size, y_size, name, for_padding);
2608 }
2609 
2610 ////////////////////////////////////////////////////////////////////
2611 // Function: Texture::do_get_ram_image_size
2612 // Access: Protected
2613 // Description:
2614 ////////////////////////////////////////////////////////////////////
2615 INLINE size_t Texture::
2616 do_get_ram_image_size(const CData *cdata) const {
2617  if (cdata->_ram_images.empty()) {
2618  return 0;
2619  }
2620  return cdata->_ram_images[0]._image.size();
2621 }
2622 
2623 ////////////////////////////////////////////////////////////////////
2624 // Function: Texture::do_has_ram_mipmap_image
2625 // Access: Protected
2626 // Description:
2627 ////////////////////////////////////////////////////////////////////
2628 INLINE bool Texture::
2629 do_has_ram_mipmap_image(const CData *cdata, int n) const {
2630  return (n >= 0 && n < (int)cdata->_ram_images.size() &&
2631  !cdata->_ram_images[n]._image.empty());
2632 }
2633 
2634 ////////////////////////////////////////////////////////////////////
2635 // Function: Texture::do_get_expected_ram_image_size
2636 // Access: Protected
2637 // Description:
2638 ////////////////////////////////////////////////////////////////////
2639 INLINE size_t Texture::
2640 do_get_expected_ram_image_size(const CData *cdata) const {
2641  return do_get_expected_ram_view_size(cdata) * (size_t)cdata->_num_views;
2642 }
2643 
2644 ////////////////////////////////////////////////////////////////////
2645 // Function: Texture::do_get_expected_ram_view_size
2646 // Access: Protected
2647 // Description:
2648 ////////////////////////////////////////////////////////////////////
2649 INLINE size_t Texture::
2650 do_get_expected_ram_view_size(const CData *cdata) const {
2651  return do_get_expected_ram_page_size(cdata) * (size_t)cdata->_z_size;
2652 }
2653 
2654 ////////////////////////////////////////////////////////////////////
2655 // Function: Texture::do_get_expected_ram_page_size
2656 // Access: Protected
2657 // Description:
2658 ////////////////////////////////////////////////////////////////////
2659 INLINE size_t Texture::
2660 do_get_expected_ram_page_size(const CData *cdata) const {
2661  return (size_t)(cdata->_x_size * cdata->_y_size * cdata->_num_components * cdata->_component_width);
2662 }
2663 
2664 ////////////////////////////////////////////////////////////////////
2665 // Function: Texture::do_get_expected_ram_mipmap_image_size
2666 // Access: Protected
2667 // Description:
2668 ////////////////////////////////////////////////////////////////////
2669 INLINE size_t Texture::
2670 do_get_expected_ram_mipmap_image_size(const CData *cdata, int n) const {
2671  return do_get_expected_ram_mipmap_view_size(cdata, n) * (size_t)cdata->_num_views;
2672 }
2673 
2674 ////////////////////////////////////////////////////////////////////
2675 // Function: Texture::do_get_expected_ram_mipmap_view_size
2676 // Access: Protected
2677 // Description:
2678 ////////////////////////////////////////////////////////////////////
2679 INLINE size_t Texture::
2680 do_get_expected_ram_mipmap_view_size(const CData *cdata, int n) const {
2681  return do_get_expected_ram_mipmap_page_size(cdata, n) * (size_t)do_get_expected_mipmap_z_size(cdata, n);
2682 }
2683 
2684 ////////////////////////////////////////////////////////////////////
2685 // Function: Texture::do_get_expected_ram_mipmap_page_size
2686 // Access: Protected
2687 // Description:
2688 ////////////////////////////////////////////////////////////////////
2689 INLINE size_t Texture::
2690 do_get_expected_ram_mipmap_page_size(const CData *cdata, int n) const {
2691  return (size_t)(do_get_expected_mipmap_x_size(cdata, n) * do_get_expected_mipmap_y_size(cdata, n) * cdata->_num_components * cdata->_component_width);
2692 }
2693 
2694 ////////////////////////////////////////////////////////////////////
2695 // Function: Texture::do_get_expected_mipmap_num_pages
2696 // Access: Protected
2697 // Description:
2698 ////////////////////////////////////////////////////////////////////
2699 INLINE int Texture::
2700 do_get_expected_mipmap_num_pages(const CData *cdata, int n) const {
2701  return do_get_expected_mipmap_z_size(cdata, n) * cdata->_num_views;
2702 }
2703 
2704 ////////////////////////////////////////////////////////////////////
2705 // Function: Texture::do_clear_ram_image
2706 // Access: Protected
2707 // Description:
2708 ////////////////////////////////////////////////////////////////////
2709 INLINE void Texture::
2710 do_clear_ram_image(CData *cdata) {
2711  cdata->_ram_image_compression = CM_off;
2712  cdata->_ram_images.clear();
2713 }
2714 
2715 ////////////////////////////////////////////////////////////////////
2716 // Function: Texture::do_get_auto_texture_scale
2717 // Access: Protected
2718 // Description:
2719 ////////////////////////////////////////////////////////////////////
2720 INLINE AutoTextureScale Texture::
2721 do_get_auto_texture_scale(const CData *cdata) const {
2722  if (cdata->_auto_texture_scale == ATS_unspecified) {
2723  return get_textures_power_2();
2724  } else {
2725  return cdata->_auto_texture_scale;
2726  }
2727 }
2728 
2729 ////////////////////////////////////////////////////////////////////
2730 // Function: Texture::store_unscaled_byte
2731 // Access: Private, Static
2732 // Description: This is used by load() to store the next consecutive
2733 // component value into the indicated element of the
2734 // array, which is taken to be an array of unsigned
2735 // bytes. The value is assumed to be in the range
2736 // 0-255.
2737 ////////////////////////////////////////////////////////////////////
2738 INLINE void Texture::
2739 store_unscaled_byte(unsigned char *&p, int value) {
2740  (*p++) = (uchar)value;
2741 }
2742 
2743 ////////////////////////////////////////////////////////////////////
2744 // Function: Texture::store_unscaled_short
2745 // Access: Private, Static
2746 // Description: This is used by load() to store the next consecutive
2747 // component value into the indicated element of the
2748 // array, which is taken to be an array of unsigned
2749 // shorts. The value is assumed to be in the range
2750 // 0-65535.
2751 ////////////////////////////////////////////////////////////////////
2752 INLINE void Texture::
2753 store_unscaled_short(unsigned char *&p, int value) {
2754  union {
2755  ushort us;
2756  uchar uc[2];
2757  } v;
2758  v.us = (ushort)value;
2759  (*p++) = v.uc[0];
2760  (*p++) = v.uc[1];
2761 }
2762 
2763 ////////////////////////////////////////////////////////////////////
2764 // Function: Texture::store_scaled_byte
2765 // Access: Private, Static
2766 // Description: This is used by load() to store the next consecutive
2767 // component value into the indicated element of the
2768 // array, which is taken to be an array of unsigned
2769 // bytes. The value will be scaled by the indicated
2770 // factor before storing it.
2771 ////////////////////////////////////////////////////////////////////
2772 INLINE void Texture::
2773 store_scaled_byte(unsigned char *&p, int value, double scale) {
2774  store_unscaled_byte(p, (int)(value * scale));
2775 }
2776 
2777 ////////////////////////////////////////////////////////////////////
2778 // Function: Texture::store_scaled_short
2779 // Access: Private, Static
2780 // Description: This is used by load() to store the next consecutive
2781 // component value into the indicated element of the
2782 // array, which is taken to be an array of unsigned
2783 // shorts. The value will be scaled by the indicated
2784 // factor before storing it.
2785 ////////////////////////////////////////////////////////////////////
2786 INLINE void Texture::
2787 store_scaled_short(unsigned char *&p, int value, double scale) {
2788  store_unscaled_short(p, (int)(value * scale));
2789 }
2790 
2791 ////////////////////////////////////////////////////////////////////
2792 // Function: Texture::get_unsigned_byte
2793 // Access: Private, Static
2794 // Description: This is used by store() to retrieve the next
2795 // consecutive component value from the indicated
2796 // element of the array, which is taken to be an array
2797 // of unsigned bytes.
2798 ////////////////////////////////////////////////////////////////////
2799 INLINE double Texture::
2800 get_unsigned_byte(const unsigned char *&p) {
2801  return (double)(*p++) / 255.0;
2802 }
2803 
2804 ////////////////////////////////////////////////////////////////////
2805 // Function: Texture::get_unsigned_short
2806 // Access: Private, Static
2807 // Description: This is used by store() to retrieve the next
2808 // consecutive component value from the indicated
2809 // element of the array, which is taken to be an array
2810 // of unsigned shorts.
2811 ////////////////////////////////////////////////////////////////////
2812 INLINE double Texture::
2813 get_unsigned_short(const unsigned char *&p) {
2814  union {
2815  ushort us;
2816  uchar uc[2];
2817  } v;
2818  v.uc[0] = (*p++);
2819  v.uc[1] = (*p++);
2820  return (double)v.us / 65535.0;
2821 }
2822 
2823 ////////////////////////////////////////////////////////////////////
2824 // Function: Texture::is_txo_filename
2825 // Access: Private, Static
2826 // Description: Returns true if the indicated filename ends in .txo
2827 // or .txo.pz, false otherwise.
2828 ////////////////////////////////////////////////////////////////////
2829 INLINE bool Texture::
2830 is_txo_filename(const Filename &fullpath) {
2831  string extension = fullpath.get_extension();
2832 #ifdef HAVE_ZLIB
2833  if (extension == "pz") {
2834  extension = Filename(fullpath.get_basename_wo_extension()).get_extension();
2835  }
2836 #endif // HAVE_ZLIB
2837  return (extension == "txo");
2838 }
2839 
2840 ////////////////////////////////////////////////////////////////////
2841 // Function: Texture::is_dds_filename
2842 // Access: Private, Static
2843 // Description: Returns true if the indicated filename ends in .dds
2844 // or .dds.pz, false otherwise.
2845 ////////////////////////////////////////////////////////////////////
2846 INLINE bool Texture::
2847 is_dds_filename(const Filename &fullpath) {
2848  string extension = fullpath.get_extension();
2849 #ifdef HAVE_ZLIB
2850  if (extension == "pz") {
2851  extension = Filename(fullpath.get_basename_wo_extension()).get_extension();
2852  }
2853 #endif // HAVE_ZLIB
2854  return (downcase(extension) == "dds");
2855 }
2856 
2857 ////////////////////////////////////////////////////////////////////
2858 // Function: Texture::CData::inc_properties_modified
2859 // Access: Public
2860 // Description:
2861 ////////////////////////////////////////////////////////////////////
2862 INLINE void Texture::CData::
2863 inc_properties_modified() {
2864  ++_properties_modified;
2865 }
2866 
2867 ////////////////////////////////////////////////////////////////////
2868 // Function: Texture::CData::inc_image_modified
2869 // Access: Public
2870 // Description:
2871 ////////////////////////////////////////////////////////////////////
2872 INLINE void Texture::CData::
2873 inc_image_modified() {
2874  ++_image_modified;
2875 }
2876 
2877 ////////////////////////////////////////////////////////////////////
2878 // Function: Texture::CData::inc_simple_image_modified
2879 // Access: Public
2880 // Description:
2881 ////////////////////////////////////////////////////////////////////
2882 INLINE void Texture::CData::
2883 inc_simple_image_modified() {
2884  ++_simple_image_modified;
2885 }
2886 
2887 ////////////////////////////////////////////////////////////////////
2888 // Function: Texture::RamImage::Constructor
2889 // Access: Public
2890 // Description:
2891 ////////////////////////////////////////////////////////////////////
2892 INLINE Texture::RamImage::
2893 RamImage() :
2894  _page_size(0),
2895  _pointer_image(NULL)
2896 {
2897 }
CPTA_uchar get_ram_image()
Returns the system-RAM image data associated with the texture.
Definition: texture.I:1608
int get_num_pages() const
Returns the total number of pages in the texture.
Definition: texture.I:699
int get_num_ram_mipmap_images() const
Returns the maximum number of mipmap level images available in system memory.
Definition: texture.I:1806
Format get_format() const
Returns the format of the texture, which represents both the semantic meaning of the texels and...
Definition: texture.I:872
const Filename & get_fullpath() const
Returns the fullpath that has been set.
Definition: texture.I:600
bool has_auto_texture_scale() const
Returns true if set_auto_texture_scale() has been set to something other than ATS_unspecified for thi...
Definition: texture.I:2203
int get_expected_mipmap_x_size(int n) const
Returns the x_size that the nth mipmap level should have, based on the texture&#39;s size.
Definition: texture.I:1392
static void set_textures_power_2(AutoTextureScale scale)
Set this flag to ATS_none, ATS_up, ATS_down, or ATS_pad to control the scaling of textures in general...
Definition: texture.I:2218
int get_pad_y_size() const
Returns size of the pad region.
Definition: texture.I:720
int get_z_size() const
Returns the depth of the texture image in texels.
Definition: texture.I:663
LColor get_border_color() const
Returns the solid color of the texture&#39;s border.
Definition: texture.I:1247
size_t get_ram_mipmap_image_size(int n) const
Returns the number of bytes used by the in-memory image for mipmap level n, or 0 if there is no in-me...
Definition: texture.I:1848
void setup_2d_texture()
Sets the texture as an empty 2-d texture with no dimensions.
Definition: texture.I:108
size_t get_expected_ram_mipmap_view_size(int n) const
Returns the number of bytes that *ought* to be used by each view of the in-memory image for mipmap le...
Definition: texture.I:1921
const Filename & get_alpha_filename() const
Returns the alpha_filename that has been set.
Definition: texture.I:575
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Definition: pnmImage.h:68
string get_clear_data() const
Returns the raw image data for a single pixel if it were set to the clear color.
Definition: texture.I:292
CompressionMode get_compression() const
Returns the compression mode requested for this particular texture, or CM_off if the texture is not t...
Definition: texture.I:1267
TextureType get_texture_type() const
Returns the overall interpretation of the texture.
Definition: texture.I:859
size_t get_ram_image_size() const
Returns the total number of bytes used by the in-memory image, across all pages and views...
Definition: texture.I:1507
int get_anisotropic_degree() const
Returns the degree of anisotropic filtering that should be applied to the texture.
Definition: texture.I:1211
void set_loaded_from_txo()
Sets the flag that indicates the texture has been loaded from a txo file.
Definition: texture.I:2494
bool get_render_to_texture() const
Returns a flag on the texture that indicates whether the texture is intended to be used as a direct-r...
Definition: texture.I:1306
void clear_filename()
Removes the alpha filename, if it was previously set.
Definition: texture.I:2279
bool might_have_ram_image() const
Returns true if the texture&#39;s image contents are currently available in main RAM, or there is reason ...
Definition: texture.I:1494
void clear_image()
Clears the texture data without changing its format or resolution.
Definition: texture.I:234
PTA_uchar make_ram_mipmap_image(int n)
Discards the current system-RAM image for the nth mipmap level, if any, and allocates a new buffer of...
Definition: texture.I:1967
SamplerState::WrapMode get_wrap_v() const
Returns the wrap mode of the texture in the V direction.
Definition: texture.I:1103
int get_orig_file_y_size() const
Returns the Y size of the original disk image that this Texture was loaded from (if it came from a di...
Definition: texture.I:805
AutoTextureScale get_auto_texture_scale() const
Returns the power-of-2 texture-scaling mode that will be applied to this particular texture when it i...
Definition: texture.I:2190
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:26
void clear_fullpath()
Removes the alpha fullpath, if it was previously set.
Definition: texture.I:2339
PTA_uchar make_ram_image()
Discards the current system-RAM image for the texture, if any, and allocates a new buffer of the appr...
Definition: texture.I:1681
int get_orig_file_z_size() const
Returns the Z size of the original disk image that this Texture was loaded from (if it came from a di...
Definition: texture.I:818
bool rescale_texture()
This method is similar to consider_rescale(), but instead of scaling a separate PNMImage, it will ask the Texture to rescale its own internal image to a power of 2, according to the config file requirements.
Definition: texture.I:2591
const SamplerState & get_default_sampler() const
This returns the default sampler state for this texture, containing the wrap and filter properties sp...
Definition: texture.I:1071
CPTA_uchar get_uncompressed_ram_image()
Returns the system-RAM image associated with the texture, in an uncompressed form if at all possible...
Definition: texture.I:1666
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
void setup_texture(TextureType texture_type, int x_size, int y_size, int z_size, ComponentType component_type, Format format)
Sets the texture to the indicated type and dimensions, presumably in preparation for calling read() o...
Definition: texture.I:62
void set_format(Format format)
Changes the format value for the texture components.
Definition: texture.I:2440
void set_match_framebuffer_format(bool flag)
Sets the special flag that, if true, indicates to the GSG that the Texture&#39;s format should be chosen ...
Definition: texture.I:2542
void set_post_load_store_cache(bool flag)
Sets the post_load_store_cache flag.
Definition: texture.I:2573
SamplerState::FilterType get_magfilter() const
Returns the filter mode of the texture for magnification.
Definition: texture.I:1157
bool has_alpha_filename() const
Returns true if the alpha_filename has been set and is available.
Definition: texture.I:561
bool has_ram_mipmap_image(int n) const
Returns true if the Texture has the nth mipmap level available in system memory, false otherwise...
Definition: texture.I:1822
void clear_alpha_fullpath()
Removes the alpha fullpath, if it was previously set.
Definition: texture.I:2366
bool store(PNMImage &pnmimage) const
Saves the texture to the indicated PNMImage, but does not write it to disk.
Definition: texture.I:472
bool has_alpha_fullpath() const
Returns true if the alpha_fullpath has been set and is available.
Definition: texture.I:612
bool load_sub_image(const PNMImage &pnmimage, int x, int y, int z=0, int n=0)
Stores the indicated image in a region of the texture.
Definition: texture.I:460
static bool is_mipmap(FilterType type)
Returns true if the indicated filter type requires the use of mipmaps, or false if it does not...
Definition: samplerState.I:329
size_t get_ram_view_size() const
Returns the number of bytes used by the in-memory image per view, or 0 if there is no in-memory image...
Definition: texture.I:1521
const Filename & get_alpha_fullpath() const
Returns the alpha_fullpath that has been set.
Definition: texture.I:626
void set_magfilter(FilterType filter)
Sets the filtering method that should be used when viewing the texture up close.
Definition: texture.I:967
int get_component_width() const
Returns the number of bytes stored for each color component of a texel.
Definition: texture.I:848
PTA_uchar modify_ram_mipmap_image(int n)
Returns a modifiable pointer to the system-RAM image for the nth mipmap level.
Definition: texture.I:1951
bool compress_ram_image(CompressionMode compression=CM_on, QualityLevel quality_level=QL_default, GraphicsStateGuardianBase *gsg=NULL)
Attempts to compress the texture&#39;s RAM image internally, to a format supported by the indicated GSG...
Definition: texture.I:1762
string get_extension() const
Returns the file extension.
Definition: filename.I:477
bool has_ram_image() const
Returns true if the Texture has its image contents available in main RAM, false if it exists only in ...
Definition: texture.I:1465
void setup_cube_map()
Sets the texture as an empty cube map texture with no dimensions.
Definition: texture.I:196
int get_expected_mipmap_y_size(int n) const
Returns the y_size that the nth mipmap level should have, based on the texture&#39;s size.
Definition: texture.I:1404
ComponentType get_component_type() const
Returns the numeric interpretation of each component of the texture.
Definition: texture.I:884
int get_simple_y_size() const
Returns the height of the "simple" image in texels.
Definition: texture.I:2041
void set_alpha_fullpath(const Filename &alpha_fullpath)
Sets the full pathname to the file that contains the image&#39;s alpha channel contents, as found along the search path.
Definition: texture.I:2354
void set_fullpath(const Filename &fullpath)
Sets the full pathname to the file that contains the image&#39;s contents, as found along the search path...
Definition: texture.I:2327
int get_pad_x_size() const
Returns size of the pad region.
Definition: texture.I:709
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
int get_orig_file_x_size() const
Returns the X size of the original disk image that this Texture was loaded from (if it came from a di...
Definition: texture.I:792
size_t get_ram_mipmap_view_size(int n) const
Returns the number of bytes used by the in-memory image per view for mipmap level n...
Definition: texture.I:1874
size_t get_ram_page_size() const
Returns the number of bytes used by the in-memory image per page, or 0 if there is no in-memory image...
Definition: texture.I:1543
bool get_match_framebuffer_format() const
Returns true if the special flag was set that indicates to the GSG that the Texture&#39;s format should b...
Definition: texture.I:2522
SamplerState::WrapMode get_wrap_u() const
Returns the wrap mode of the texture in the U direction.
Definition: texture.I:1087
int get_expected_mipmap_z_size(int n) const
Returns the z_size that the nth mipmap level should have, based on the texture&#39;s size.
Definition: texture.I:1416
static AutoTextureScale get_textures_power_2()
This flag returns ATS_none, ATS_up, or ATS_down and controls the scaling of textures in general...
Definition: texture.I:2232
size_t get_ram_mipmap_page_size(int n) const
Returns the number of bytes used by the in-memory image per page for mipmap level n...
Definition: texture.I:1893
CPTA_uchar get_simple_ram_image() const
Returns the image data associated with the "simple" texture image.
Definition: texture.I:2088
size_t get_expected_ram_image_size() const
Returns the number of bytes that *ought* to be used by the in-memory image, based on the texture para...
Definition: texture.I:1560
QualityLevel get_effective_quality_level() const
Returns the current quality_level hint, or the global default quality_level if this texture doesn&#39;t s...
Definition: texture.I:1361
bool uses_mipmaps() const
Returns true if the minfilter settings on this texture indicate the use of mipmapping, false otherwise.
Definition: texture.I:1319
UpdateSeq get_image_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture image data (i...
Definition: texture.I:2151
bool has_filename() const
Returns true if the filename has been set and is available.
Definition: texture.I:536
UpdateSeq get_properties_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture properties (u...
Definition: texture.I:2138
void set_ram_mipmap_image(int n, CPTA_uchar image, size_t page_size=0)
Replaces the current system-RAM image for the indicated mipmap level with the new data...
Definition: texture.I:1985
void setup_3d_texture(int z_size=1)
Sets the texture as an empty 3-d texture with no dimensions (though if you know the depth ahead of ti...
Definition: texture.I:138
void clear_simple_ram_image()
Discards the current "simple" image.
Definition: texture.I:2125
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
Definition: pfmFile.h:34
bool get_loaded_from_txo() const
Returns the flag that indicates the texture has been loaded from a txo file.
Definition: texture.I:2506
void set_pad_size(int x=0, int y=0, int z=0)
Sets the size of the pad region.
Definition: texture.I:779
void set_wrap_v(WrapMode wrap)
This setting determines what happens when the texture is sampled with a V value outside the range 0...
Definition: texture.I:920
void setup_2d_texture_array(int z_size=1)
Sets the texture as an empty 2-d texture array with no dimensions (though if you know the depth ahead...
Definition: texture.I:167
void set_keep_ram_image(bool keep_ram_image)
Sets the flag that indicates whether this Texture is eligible to have its main RAM copy of the textur...
Definition: texture.I:1731
void clear_ram_mipmap_images()
Discards the current system-RAM image for all mipmap levels, except level 0 (the base image)...
Definition: texture.I:1997
bool has_simple_ram_image() const
Returns true if the Texture has a "simple" image available in main RAM.
Definition: texture.I:2053
int get_effective_anisotropic_degree() const
Returns the degree of anisotropic filtering that should be applied to the texture.
Definition: texture.I:1229
int get_pad_z_size() const
Returns size of the pad region.
Definition: texture.I:731
LColor get_clear_color() const
Returns the color that was previously set using set_clear_color.
Definition: texture.I:261
void set_alpha_filename(const Filename &alpha_filename)
Sets the name of the file that contains the image&#39;s alpha channel contents.
Definition: texture.I:2301
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
void set_quality_level(QualityLevel quality_level)
Sets a hint to the renderer about the desired performance / quality tradeoff for this particular text...
Definition: texture.I:1333
int get_expected_num_mipmap_levels() const
Returns the number of mipmap levels that should be defined for this texture, given the texture&#39;s size...
Definition: texture.I:1380
QualityLevel get_quality_level() const
Returns the current quality_level hint.
Definition: texture.I:1346
void set_render_to_texture(bool render_to_texture)
Sets a flag on the texture that indicates whether the texture is intended to be used as a direct-rend...
Definition: texture.I:1056
void setup_1d_texture()
Sets the texture as an empty 1-d texture with no dimensions.
Definition: texture.I:80
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
size_t get_expected_ram_mipmap_image_size(int n) const
Returns the number of bytes that *ought* to be used by the in-memory image for mipmap level n...
Definition: texture.I:1906
bool has_clear_color() const
Returns true if a color was previously set using set_clear_color.
Definition: texture.I:249
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
Definition: filename.I:460
size_t get_expected_ram_mipmap_page_size(int n) const
Returns the number of bytes that should be used per each Z page of the 3-d texture, for mipmap level n.
Definition: texture.I:1935
void set_compression(CompressionMode compression)
Requests that this particular Texture be compressed when it is loaded into texture memory...
Definition: texture.I:1033
void clear_ram_image()
Discards the current system-RAM image.
Definition: texture.I:1710
SamplerState::FilterType get_effective_magfilter() const
Returns the filter mode of the texture for magnification, with special treatment for FT_default...
Definition: texture.I:1193
void set_loaded_from_image()
Sets the flag that indicates the texture has been loaded from a disk file or PNMImage.
Definition: texture.I:2467
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:39
bool uncompress_ram_image()
Attempts to uncompress the texture&#39;s RAM image internally.
Definition: texture.I:1785
void set_num_views(int num_views)
Sets the number of "views" within a texture.
Definition: texture.I:2428
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
bool has_all_ram_mipmap_images() const
Returns true if all expected mipmap levels have been defined and exist in the system RAM...
Definition: texture.I:1835
CompressionMode get_ram_image_compression() const
Returns the compression mode in which the ram image is already stored pre-compressed.
Definition: texture.I:1624
void set_anisotropic_degree(int anisotropic_degree)
Specifies the level of anisotropic filtering to apply to the texture.
Definition: texture.I:990
void set_ram_image(CPTA_uchar image, CompressionMode compression=CM_off, size_t page_size=0)
Replaces the current system-RAM image with the new data.
Definition: texture.I:1698
void set_auto_texture_scale(AutoTextureScale scale)
Specifies the power-of-2 texture-scaling mode that will be applied to this particular texture when it...
Definition: texture.I:2177
void set_wrap_u(WrapMode wrap)
This setting determines what happens when the texture is sampled with a U value outside the range 0...
Definition: texture.I:902
void set_component_type(ComponentType component_type)
Changes the data value for the texture components.
Definition: texture.I:2452
bool load(const PNMImage &pnmimage, const LoaderOptions &options=LoaderOptions())
Replaces the texture with the indicated image.
Definition: texture.I:382
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
LVecBase2 get_tex_scale() const
Returns a scale pair that is suitable for applying to geometry via NodePath::set_tex_scale(), which will convert texture coordinates on the geometry from the range 0..1 into the appropriate range to render the video part of the texture.
Definition: texture.I:752
void clear_alpha_filename()
Removes the alpha filename, if it was previously set.
Definition: texture.I:2313
void generate_ram_mipmap_images()
Automatically fills in the n mipmap levels of the Texture, based on the texture&#39;s source image...
Definition: texture.I:2018
void set_y_size(int y_size)
Changes the y size indicated for the texture.
Definition: texture.I:2392
int get_y_size() const
Returns the height of the texture image in texels.
Definition: texture.I:650
UpdateSeq get_simple_image_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture&#39;s "simple" im...
Definition: texture.I:2164
SamplerState::FilterType get_effective_minfilter() const
Returns the filter mode of the texture for minification, with special treatment for FT_default...
Definition: texture.I:1175
bool get_loaded_from_image() const
Returns the flag that indicates the texture has been loaded from a disk file or PNMImage.
Definition: texture.I:2480
void set_minfilter(FilterType filter)
Sets the filtering method that should be used when viewing the texture from a distance.
Definition: texture.I:951
int get_num_views() const
Returns the number of "views" in the texture.
Definition: texture.I:683
int get_expected_mipmap_num_pages(int n) const
Returns the total number of pages that the nth mipmap level should have, based on the texture&#39;s size...
Definition: texture.I:1431
bool has_fullpath() const
Returns true if the fullpath has been set and is available.
Definition: texture.I:587
void set_simple_ram_image(CPTA_uchar image, int x_size, int y_size)
Replaces the internal "simple" texture image.
Definition: texture.I:2114
int get_num_components() const
Returns the number of color components for each texel of the texture image.
Definition: texture.I:835
void set_clear_color(const LColor &color)
Sets the color that will be used to fill the texture image in absence of any image data...
Definition: texture.I:279
static bool has_textures_power_2()
If true, then get_textures_power_2 has been set using set_textures_power_2.
Definition: texture.I:2249
void set_border_color(const LColor &color)
Specifies the solid color of the texture&#39;s border.
Definition: texture.I:1008
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
PTA_uchar modify_ram_image()
Returns a modifiable pointer to the system-RAM image.
Definition: texture.I:1640
bool has_compression() const
Returns true if the texture indicates it wants to be compressed, either with CM_on or higher...
Definition: texture.I:1287
void set_z_size(int z_size)
Changes the z size indicated for the texture.
Definition: texture.I:2405
void set_x_size(int x_size)
Changes the x size indicated for the texture.
Definition: texture.I:2379
int get_simple_x_size() const
Returns the width of the "simple" image in texels.
Definition: texture.I:2030
size_t get_simple_ram_image_size() const
Returns the number of bytes used by the "simple" image, or 0 if there is no simple image...
Definition: texture.I:2065
bool adjust_this_size(int &x_size, int &y_size, const string &name, bool for_padding) const
Works like adjust_size, but also considers the texture class.
Definition: texture.I:2604
void set_wrap_w(WrapMode wrap)
The W wrap direction is only used for 3-d textures.
Definition: texture.I:935
SamplerState::FilterType get_minfilter() const
Returns the filter mode of the texture for minification.
Definition: texture.I:1139
SamplerState::WrapMode get_wrap_w() const
Returns the wrap mode of the texture in the W direction.
Definition: texture.I:1120
bool reload()
Re-reads the Texture from its disk file.
Definition: texture.I:524
size_t get_expected_ram_page_size() const
Returns the number of bytes that should be used per each Z page of the 3-d texture.
Definition: texture.I:1574
void set_filename(const Filename &filename)
Sets the name of the file that contains the image&#39;s contents.
Definition: texture.I:2267
bool get_post_load_store_cache() const
Returns the setting of the post_load_store_cache flag.
Definition: texture.I:2554
bool write(const Filename &fullpath)
Writes the texture to the named filename.
Definition: texture.I:305
int get_x_size() const
Returns the width of the texture image in texels.
Definition: texture.I:638
const Filename & get_filename() const
Returns the filename that has been set.
Definition: texture.I:549
bool has_uncompressed_ram_image() const
Returns true if the Texture has its image contents available in main RAM and is uncompressed, false otherwise.
Definition: texture.I:1478