Panda3D
textureProperties.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file textureProperties.cxx
10  * @author drose
11  * @date 2000-11-29
12  */
13 
14 #include "textureProperties.h"
15 #include "palettizer.h"
16 #include "pnmFileType.h"
17 #include "datagram.h"
18 #include "datagramIterator.h"
19 #include "bamReader.h"
20 #include "bamWriter.h"
21 #include "string_utils.h"
22 
23 using std::string;
24 
25 TypeHandle TextureProperties::_type_handle;
26 
27 /**
28  *
29  */
30 TextureProperties::
31 TextureProperties() {
32  _got_num_channels = false;
33  _num_channels = 0;
34  _effective_num_channels = 0;
35  _format = EggTexture::F_unspecified;
36  _force_format = false;
37  _generic_format = false;
38  _keep_format = false;
39  _minfilter = EggTexture::FT_unspecified;
40  _magfilter = EggTexture::FT_unspecified;
41  _quality_level = EggTexture::QL_unspecified;
42  _anisotropic_degree = 0;
43  _color_type = nullptr;
44  _alpha_type = nullptr;
45 }
46 
47 /**
48  *
49  */
50 TextureProperties::
51 TextureProperties(const TextureProperties &copy) :
52  _format(copy._format),
53  _force_format(copy._force_format),
54  _generic_format(copy._generic_format),
55  _keep_format(copy._keep_format),
56  _minfilter(copy._minfilter),
57  _magfilter(copy._magfilter),
58  _quality_level(copy._quality_level),
59  _anisotropic_degree(copy._anisotropic_degree),
60  _color_type(copy._color_type),
61  _alpha_type(copy._alpha_type),
62  _got_num_channels(copy._got_num_channels),
63  _num_channels(copy._num_channels),
64  _effective_num_channels(copy._effective_num_channels)
65 {
66 }
67 
68 /**
69  *
70  */
71 void TextureProperties::
72 operator = (const TextureProperties &copy) {
73  _force_format = copy._force_format;
74  _generic_format = copy._generic_format;
75  _keep_format = copy._keep_format;
76  _minfilter = copy._minfilter;
77  _magfilter = copy._magfilter;
78  _quality_level = copy._quality_level;
79  _anisotropic_degree = copy._anisotropic_degree;
80  _color_type = copy._color_type;
81  _alpha_type = copy._alpha_type;
82  _got_num_channels = copy._got_num_channels;
83  _num_channels = copy._num_channels;
84  _effective_num_channels = copy._effective_num_channels;
85  _format = copy._format;
86 }
87 
88 /**
89  * Resets only the properties that might be changed by update_properties() to
90  * a neutral state.
91  */
93 clear_basic() {
94  if (!_force_format) {
95  _format = EggTexture::F_unspecified;
96  }
97 
98  _minfilter = EggTexture::FT_unspecified;
99  _magfilter = EggTexture::FT_unspecified;
100  _quality_level = EggTexture::QL_unspecified;
101  _anisotropic_degree = 0;
102 }
103 
104 /**
105  * Returns true if the number of channels is known.
106  */
108 has_num_channels() const {
109  return _got_num_channels;
110 }
111 
112 /**
113  * Returns the number of channels (1 through 4) associated with the image. It
114  * is an error to call this unless has_num_channels() returns true.
115  */
117 get_num_channels() const {
118  nassertr(_got_num_channels, 0);
119  return _effective_num_channels;
120 }
121 
122 /**
123  * Sets the number of channels (1 through 4) associated with the image,
124  * presumably after reading this information from the image header.
125  */
127 set_num_channels(int num_channels) {
128  _num_channels = num_channels;
129  _effective_num_channels = num_channels;
130  _got_num_channels = true;
131 }
132 
133 /**
134  * Sets the actual number of channels to indicate a grayscale image,
135  * presumably after discovering that the image contains no colored pixels.
136  */
138 force_grayscale() {
139  nassertv(_got_num_channels && _num_channels >= 3);
140  _num_channels -= 2;
141  _effective_num_channels = _num_channels;
142 }
143 
144 /**
145  * Sets the actual number of channels to indicate an image with no alpha
146  * channel, presumably after discovering that the alpha channel contains no
147  * meaningful pixels.
148  */
150 force_nonalpha() {
151  nassertv(_got_num_channels && (_num_channels == 2 || _num_channels == 4));
152  _num_channels--;
153  _effective_num_channels = _num_channels;
154 }
155 
156 /**
157  * Returns true if the texture uses an alpha channel, false otherwise.
158  */
160 uses_alpha() const {
161  switch (_format) {
162  case EggTexture::F_rgba:
163  case EggTexture::F_rgbm:
164  case EggTexture::F_rgba12:
165  case EggTexture::F_rgba8:
166  case EggTexture::F_rgba4:
167  case EggTexture::F_rgba5:
168  case EggTexture::F_alpha:
169  case EggTexture::F_luminance_alpha:
170  case EggTexture::F_luminance_alphamask:
171  return true;
172 
173  default:
174  return false;
175  }
176 }
177 
178 /**
179  * Returns a string corresponding to the TextureProperties object. Each
180  * unique set of TextureProperties will generate a unique string. This is
181  * used to generate unique palette image filenames.
182  */
184 get_string() const {
185  string result;
186 
187  if (_got_num_channels) {
188  std::ostringstream num;
189  num << _effective_num_channels;
190  result += num.str();
191  }
192 
193  result += get_format_string(_format);
194  result += get_filter_string(_minfilter);
195  result += get_filter_string(_magfilter);
196  result += get_anisotropic_degree_string(_anisotropic_degree);
197  result += get_type_string(_color_type, _alpha_type);
198  result += get_quality_level_string(_quality_level);
199  return result;
200 }
201 
202 /**
203  * If the indicate TextureProperties structure is more specific than this one,
204  * updates this one.
205  */
207 update_properties(const TextureProperties &other) {
208  if (!_got_num_channels) {
209  _got_num_channels = other._got_num_channels;
210  _num_channels = other._num_channels;
211  _effective_num_channels = _num_channels;
212  }
213  if (_force_format) {
214  // If we've forced our own format, it doesn't change.
215  } else if (other._force_format) {
216  _format = other._format;
217  } else {
218  _format = union_format(_format, other._format);
219  }
220 
221  _minfilter = union_filter(_minfilter, other._minfilter);
222  _magfilter = union_filter(_magfilter, other._magfilter);
223  _quality_level = union_quality_level(_quality_level, other._quality_level);
224 
225  _anisotropic_degree = other._anisotropic_degree;
226 
227  if (_color_type == nullptr) {
228  _color_type = other._color_type;
229  _alpha_type = other._alpha_type;
230  }
231 }
232 
233 /**
234  * If any properties remain unspecified, specify them now. Also reconcile
235  * conflicting information.
236  */
238 fully_define() {
239  if (!_got_num_channels || _force_format) {
240  switch (_format) {
241  case EggTexture::F_rgba:
242  case EggTexture::F_rgbm:
243  case EggTexture::F_rgba12:
244  case EggTexture::F_rgba8:
245  case EggTexture::F_rgba4:
246  case EggTexture::F_rgba5:
247  case EggTexture::F_srgb_alpha:
248  _num_channels = 4;
249  break;
250 
251  case EggTexture::F_unspecified:
252  case EggTexture::F_rgb:
253  case EggTexture::F_rgb12:
254  case EggTexture::F_rgb8:
255  case EggTexture::F_rgb5:
256  case EggTexture::F_rgb332:
257  case EggTexture::F_srgb:
258  _num_channels = 3;
259  break;
260 
261  case EggTexture::F_luminance_alpha:
262  case EggTexture::F_luminance_alphamask:
263  _num_channels = 2;
264  break;
265 
266  case EggTexture::F_red:
267  case EggTexture::F_green:
268  case EggTexture::F_blue:
269  case EggTexture::F_alpha:
270  case EggTexture::F_luminance:
271  _num_channels = 1;
272  break;
273  }
274  _got_num_channels = true;
275  }
276 
277  _effective_num_channels = _num_channels;
278 
279  // Respect the _generic_format flag. If this is set, it means the user has
280  // indicated that we should strip off any bitcount-specific formats and
281  // replace them with the more generic equivalents.
282  if (_generic_format) {
283  switch (_format) {
284  case EggTexture::F_unspecified:
285  case EggTexture::F_rgba:
286  case EggTexture::F_rgbm:
287  case EggTexture::F_rgb:
288  case EggTexture::F_red:
289  case EggTexture::F_green:
290  case EggTexture::F_blue:
291  case EggTexture::F_alpha:
292  case EggTexture::F_luminance:
293  case EggTexture::F_luminance_alpha:
294  case EggTexture::F_luminance_alphamask:
295  break;
296 
297  case EggTexture::F_rgba12:
298  case EggTexture::F_rgba8:
299  case EggTexture::F_rgba4:
300  case EggTexture::F_rgba5:
301  _format = EggTexture::F_rgba;
302  break;
303 
304  case EggTexture::F_rgb12:
305  case EggTexture::F_rgb8:
306  case EggTexture::F_rgb5:
307  case EggTexture::F_rgb332:
308  _format = EggTexture::F_rgb;
309  break;
310  }
311  }
312 
313  // Make sure the format reflects the number of channels, although we accept
314  // a format that ignores an alpha channel.
315  if (!_force_format && !_keep_format) {
316  switch (_num_channels) {
317  case 1:
318  switch (_format) {
319  case EggTexture::F_red:
320  case EggTexture::F_green:
321  case EggTexture::F_blue:
322  case EggTexture::F_alpha:
323  case EggTexture::F_luminance:
324  break;
325 
326  // These formats suggest an alpha channel; they are quietly replaced
327  // with non-alpha equivalents.
328  case EggTexture::F_luminance_alpha:
329  case EggTexture::F_luminance_alphamask:
330  _format = EggTexture::F_luminance;
331  break;
332 
333  default:
334  _format = EggTexture::F_luminance;
335  }
336  break;
337 
338  case 2:
339  switch (_format) {
340  case EggTexture::F_luminance_alpha:
341  case EggTexture::F_luminance_alphamask:
342  break;
343 
344  // These formats implicitly reduce the number of channels to 1.
345  case EggTexture::F_red:
346  case EggTexture::F_green:
347  case EggTexture::F_blue:
348  case EggTexture::F_alpha:
349  case EggTexture::F_luminance:
350  break;
351 
352  default:
353  _format = EggTexture::F_luminance_alpha;
354  }
355  break;
356 
357  case 3:
358  switch (_format) {
359  case EggTexture::F_rgb:
360  case EggTexture::F_rgb12:
361  case EggTexture::F_rgb8:
362  case EggTexture::F_rgb5:
363  case EggTexture::F_rgb332:
364  break;
365 
366  // These formats suggest an alpha channel; they are quietly replaced
367  // with non-alpha equivalents.
368  case EggTexture::F_rgba8:
369  _format = EggTexture::F_rgb8;
370  break;
371 
372  case EggTexture::F_rgba5:
373  case EggTexture::F_rgba4:
374  _format = EggTexture::F_rgb5;
375  break;
376 
377  // These formats implicitly reduce the number of channels to 1.
378  case EggTexture::F_red:
379  case EggTexture::F_green:
380  case EggTexture::F_blue:
381  case EggTexture::F_alpha:
382  case EggTexture::F_luminance:
383  break;
384 
385  default:
386  _format = EggTexture::F_rgb;
387  }
388  break;
389 
390  case 4:
391  switch (_format) {
392  case EggTexture::F_rgba:
393  case EggTexture::F_rgbm:
394  case EggTexture::F_rgba12:
395  case EggTexture::F_rgba8:
396  case EggTexture::F_rgba4:
397  case EggTexture::F_rgba5:
398  break;
399 
400  // These formats implicitly reduce the number of channels to 3.
401  case EggTexture::F_rgb:
402  case EggTexture::F_rgb12:
403  case EggTexture::F_rgb8:
404  case EggTexture::F_rgb5:
405  case EggTexture::F_rgb332:
406  _effective_num_channels = 3;
407  break;
408 
409  // These formats implicitly reduce the number of channels to 2.
410  case EggTexture::F_luminance_alpha:
411  case EggTexture::F_luminance_alphamask:
412  _effective_num_channels = 2;
413  break;
414 
415  // These formats implicitly reduce the number of channels to 1.
416  case EggTexture::F_red:
417  case EggTexture::F_green:
418  case EggTexture::F_blue:
419  case EggTexture::F_alpha:
420  case EggTexture::F_luminance:
421  _effective_num_channels = 1;
422  break;
423 
424  default:
425  _format = EggTexture::F_rgba;
426  }
427  }
428  }
429 
430  switch (_minfilter) {
431  case EggTexture::FT_unspecified:
432  _minfilter = EggTexture::FT_linear;
433  break;
434 
435  default:
436  break;
437  }
438 
439  switch (_magfilter) {
440  case EggTexture::FT_unspecified:
441  case EggTexture::FT_nearest_mipmap_nearest:
442  case EggTexture::FT_linear_mipmap_nearest:
443  case EggTexture::FT_nearest_mipmap_linear:
444  case EggTexture::FT_linear_mipmap_linear:
445  _magfilter = EggTexture::FT_linear;
446  break;
447 
448  default:
449  break;
450  }
451 
452  if (_color_type == nullptr) {
453  _color_type = pal->_color_type;
454  _alpha_type = pal->_alpha_type;
455  }
456 }
457 
458 /**
459  * Adjusts the texture properties of the indicated egg reference to match
460  * these properties.
461  */
463 update_egg_tex(EggTexture *egg_tex) const {
464  egg_tex->set_format(_format);
465  egg_tex->set_minfilter(_minfilter);
466  egg_tex->set_magfilter(_minfilter);
467  egg_tex->set_quality_level(_quality_level);
468  egg_tex->set_anisotropic_degree(_anisotropic_degree);
469 }
470 
471 /**
472  * Returns true if all of the properties that are reflected directly in an egg
473  * file match between this TextureProperties object and the other, or false if
474  * any of them differ.
475  */
477 egg_properties_match(const TextureProperties &other) const {
478  return (_format == other._format &&
479  _minfilter == other._minfilter &&
480  _magfilter == other._magfilter &&
481  _quality_level == other._quality_level &&
482  _anisotropic_degree == other._anisotropic_degree);
483 }
484 
485 /**
486  *
487  */
488 bool TextureProperties::
489 operator < (const TextureProperties &other) const {
490  if (_format != other._format) {
491  return (int)_format < (int)other._format;
492  }
493  if (_minfilter != other._minfilter) {
494  return (int)_minfilter < (int)other._minfilter;
495  }
496  if (_magfilter != other._magfilter) {
497  return (int)_magfilter < (int)other._magfilter;
498  }
499  if (_quality_level != other._quality_level) {
500  return (int)_quality_level < (int)other._quality_level;
501  }
502  if (_anisotropic_degree != other._anisotropic_degree) {
503  return _anisotropic_degree < other._anisotropic_degree;
504  }
505  if (_color_type != other._color_type) {
506  return _color_type < other._color_type;
507  }
508  if (_color_type != nullptr) {
509  if (_alpha_type != other._alpha_type) {
510  return _alpha_type < other._alpha_type;
511  }
512  }
513  return false;
514 }
515 
516 /**
517  *
518  */
519 bool TextureProperties::
520 operator == (const TextureProperties &other) const {
521  return (_format == other._format &&
522  _minfilter == other._minfilter &&
523  _magfilter == other._magfilter &&
524  _quality_level == other._quality_level &&
525  _anisotropic_degree == other._anisotropic_degree &&
526  _color_type == other._color_type &&
527  (_color_type == nullptr ||
528  _alpha_type == other._alpha_type));
529 }
530 
531 /**
532  *
533  */
534 bool TextureProperties::
535 operator != (const TextureProperties &other) const {
536  return !operator == (other);
537 }
538 
539 /**
540  * Returns a short string representing the given EggTexture format.
541  */
542 string TextureProperties::
543 get_format_string(EggTexture::Format format) {
544  switch (format) {
545  case EggTexture::F_unspecified:
546  return "u";
547 
548  case EggTexture::F_rgba:
549  return "a";
550 
551  case EggTexture::F_rgbm:
552  return "m";
553 
554  case EggTexture::F_rgba12:
555  return "a12";
556 
557  case EggTexture::F_rgba8:
558  return "a8";
559 
560  case EggTexture::F_rgba4:
561  return "a4";
562 
563  case EggTexture::F_rgba5:
564  return "a5";
565 
566  case EggTexture::F_rgb:
567  return "c";
568 
569  case EggTexture::F_rgb12:
570  return "c12";
571 
572  case EggTexture::F_rgb8:
573  return "c8";
574 
575  case EggTexture::F_rgb5:
576  return "c5";
577 
578  case EggTexture::F_rgb332:
579  return "c3";
580 
581  case EggTexture::F_luminance_alpha:
582  return "t"; // t for two-channel
583 
584  case EggTexture::F_luminance_alphamask:
585  return "t1";
586 
587  case EggTexture::F_red:
588  return "r";
589 
590  case EggTexture::F_green:
591  return "g";
592 
593  case EggTexture::F_blue:
594  return "b";
595 
596  case EggTexture::F_alpha:
597  return "a";
598 
599  case EggTexture::F_luminance:
600  return "l";
601  }
602 
603  return "x";
604 }
605 
606 /**
607  * Returns a short string representing the given EggTexture filter type.
608  */
609 string TextureProperties::
610 get_filter_string(EggTexture::FilterType filter_type) {
611  switch (filter_type) {
612  case EggTexture::FT_unspecified:
613  return "u";
614 
615  case EggTexture::FT_nearest:
616  return "n";
617 
618  case EggTexture::FT_linear:
619  return "l";
620 
621  case EggTexture::FT_nearest_mipmap_nearest:
622  return "m1";
623 
624  case EggTexture::FT_linear_mipmap_nearest:
625  return "m2";
626 
627  case EggTexture::FT_nearest_mipmap_linear:
628  return "m3";
629 
630  case EggTexture::FT_linear_mipmap_linear:
631  return "m";
632  }
633 
634  return "x";
635 }
636 
637 /**
638  * Returns a short string describing the anisotropic degree.
639  */
640 string TextureProperties::
641 get_anisotropic_degree_string(int aniso_degree) {
642  if (aniso_degree <= 1) {
643  return "";
644  } else {
645  return string("an") + format_string(aniso_degree);
646  }
647 }
648 
649 /**
650  * Returns a short string describing the quality level.
651  */
652 string TextureProperties::
653 get_quality_level_string(EggTexture::QualityLevel quality_level) {
654  switch (quality_level) {
655  case EggTexture::QL_unspecified:
656  case EggTexture::QL_default:
657  return "";
658 
659  case EggTexture::QL_fastest:
660  return "f";
661 
662  case EggTexture::QL_normal:
663  return "n";
664 
665  case EggTexture::QL_best:
666  return "b";
667  }
668  return "";
669 }
670 
671 /**
672  * Returns a short string representing whether the color and/or alpha type has
673  * been specified or not.
674  */
675 string TextureProperties::
676 get_type_string(PNMFileType *color_type, PNMFileType *alpha_type) {
677  if (color_type == nullptr) {
678  return "";
679  }
680  if (alpha_type == nullptr) {
681  return "c";
682  }
683  return "a";
684 }
685 
686 /**
687  * Returns the EggTexture format which is the more specific of the two.
688  */
689 EggTexture::Format TextureProperties::
690 union_format(EggTexture::Format a, EggTexture::Format b) {
691  switch (a) {
692  case EggTexture::F_unspecified:
693  return b;
694 
695  case EggTexture::F_rgba:
696  switch (b) {
697  case EggTexture::F_rgbm:
698  case EggTexture::F_rgba12:
699  case EggTexture::F_rgba8:
700  case EggTexture::F_rgba4:
701  case EggTexture::F_rgba5:
702  case EggTexture::F_red:
703  case EggTexture::F_green:
704  case EggTexture::F_blue:
705  case EggTexture::F_alpha:
706  return b;
707 
708  default:
709  return a;
710  };
711 
712  case EggTexture::F_rgb:
713  if (b != EggTexture::F_unspecified) {
714  return b;
715  }
716  return a;
717 
718  default:
719  return a;
720  }
721 }
722 
723 /**
724  * Returns the EggTexture filter type which is the more specific of the two.
725  */
726 EggTexture::FilterType TextureProperties::
727 union_filter(EggTexture::FilterType a, EggTexture::FilterType b) {
728  if ((int)a < (int)b) {
729  return b;
730  } else {
731  return a;
732  }
733 }
734 
735 /**
736  * Returns the EggTexture quality level which is the more specific of the two.
737  */
738 EggTexture::QualityLevel TextureProperties::
739 union_quality_level(EggTexture::QualityLevel a, EggTexture::QualityLevel b) {
740  if ((int)a < (int)b) {
741  return b;
742  } else {
743  return a;
744  }
745 }
746 
747 /**
748  * Registers the current object as something that can be read from a Bam file.
749  */
753  register_factory(get_class_type(), make_TextureProperties);
754 }
755 
756 /**
757  * Fills the indicated datagram up with a binary representation of the current
758  * object, in preparation for writing to a Bam file.
759  */
761 write_datagram(BamWriter *writer, Datagram &datagram) {
762  TypedWritable::write_datagram(writer, datagram);
763  datagram.add_bool(_got_num_channels);
764  datagram.add_int32(_num_channels);
765  datagram.add_int32(_effective_num_channels);
766  datagram.add_int32((int)_format);
767  datagram.add_bool(_force_format);
768  datagram.add_bool(_generic_format);
769  datagram.add_bool(_keep_format);
770  datagram.add_int32((int)_minfilter);
771  datagram.add_int32((int)_magfilter);
772  datagram.add_int32((int)_quality_level);
773  datagram.add_int32(_anisotropic_degree);
774  writer->write_pointer(datagram, _color_type);
775  writer->write_pointer(datagram, _alpha_type);
776 }
777 
778 /**
779  * Called after the object is otherwise completely read from a Bam file, this
780  * function's job is to store the pointers that were retrieved from the Bam
781  * file for each pointer object written. The return value is the number of
782  * pointers processed from the list.
783  */
785 complete_pointers(TypedWritable **p_list, BamReader *manager) {
786  int index = TypedWritable::complete_pointers(p_list, manager);
787 
788  if (p_list[index] != nullptr) {
789  DCAST_INTO_R(_color_type, p_list[index], index);
790  }
791  index++;
792 
793  if (p_list[index] != nullptr) {
794  DCAST_INTO_R(_alpha_type, p_list[index], index);
795  }
796  index++;
797 
798  return index;
799 }
800 
801 /**
802  * This method is called by the BamReader when an object of this type is
803  * encountered in a Bam file; it should allocate and return a new object with
804  * all the data read.
805  */
806 TypedWritable* TextureProperties::
807 make_TextureProperties(const FactoryParams &params) {
809  DatagramIterator scan;
810  BamReader *manager;
811 
812  parse_params(params, scan, manager);
813  me->fillin(scan, manager);
814  return me;
815 }
816 
817 /**
818  * Reads the binary data from the given datagram iterator, which was written
819  * by a previous call to write_datagram().
820  */
822 fillin(DatagramIterator &scan, BamReader *manager) {
823  TypedWritable::fillin(scan, manager);
824  _got_num_channels = scan.get_bool();
825  _num_channels = scan.get_int32();
826  _effective_num_channels = _num_channels;
827  if (Palettizer::_read_pi_version >= 9) {
828  _effective_num_channels = scan.get_int32();
829  }
830  _format = (EggTexture::Format)scan.get_int32();
831  _force_format = scan.get_bool();
832  _generic_format = false;
833  if (Palettizer::_read_pi_version >= 9) {
834  _generic_format = scan.get_bool();
835  }
836  _keep_format = false;
837  if (Palettizer::_read_pi_version >= 13) {
838  _keep_format = scan.get_bool();
839  }
840  _minfilter = (EggTexture::FilterType)scan.get_int32();
841  _magfilter = (EggTexture::FilterType)scan.get_int32();
842  if (Palettizer::_read_pi_version >= 18) {
843  _quality_level = (EggTexture::QualityLevel)scan.get_int32();
844  }
845  _anisotropic_degree = scan.get_int32();
846 
847  manager->read_pointer(scan); // _color_type
848  manager->read_pointer(scan); // _alpha_type
849 }
TextureProperties::set_num_channels
void set_num_channels(int num_channels)
Sets the number of channels (1 through 4) associated with the image, presumably after reading this in...
Definition: textureProperties.cxx:127
DatagramIterator::get_int32
int32_t get_int32()
Extracts a signed 32-bit integer.
Definition: datagramIterator.I:107
string_utils.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
TypedWritable::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition: typedWritable.cxx:81
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
TextureProperties::get_num_channels
int get_num_channels() const
Returns the number of channels (1 through 4) associated with the image.
Definition: textureProperties.cxx:117
TextureProperties::get_string
std::string get_string() const
Returns a string corresponding to the TextureProperties object.
Definition: textureProperties.cxx:184
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
BamWriter::write_pointer
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
Definition: bamWriter.cxx:317
BamReader::get_factory
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:177
textureProperties.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bamReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TextureProperties::update_egg_tex
void update_egg_tex(EggTexture *egg_tex) const
Adjusts the texture properties of the indicated egg reference to match these properties.
Definition: textureProperties.cxx:463
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
TextureProperties::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Called after the object is otherwise completely read from a Bam file, this function's job is to store...
Definition: textureProperties.cxx:785
TextureProperties::write_datagram
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object,...
Definition: textureProperties.cxx:761
DatagramIterator::get_bool
bool get_bool()
Extracts a boolean value.
Definition: datagramIterator.I:48
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
TextureProperties::has_num_channels
bool has_num_channels() const
Returns true if the number of channels is known.
Definition: textureProperties.cxx:108
palettizer.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: typedWritable.cxx:54
TextureProperties::fillin
void fillin(DatagramIterator &scan, BamReader *manager)
Reads the binary data from the given datagram iterator, which was written by a previous call to write...
Definition: textureProperties.cxx:822
pnmFileType.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
datagram.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TextureProperties::egg_properties_match
bool egg_properties_match(const TextureProperties &other) const
Returns true if all of the properties that are reflected directly in an egg file match between this T...
Definition: textureProperties.cxx:477
TextureProperties::register_with_read_factory
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
Definition: textureProperties.cxx:751
TextureProperties::clear_basic
void clear_basic()
Resets only the properties that might be changed by update_properties() to a neutral state.
Definition: textureProperties.cxx:93
EggTexture::set_anisotropic_degree
set_anisotropic_degree
Sets the degree of anisotropic filtering for this texture.
Definition: eggTexture.h:326
TextureProperties::uses_alpha
bool uses_alpha() const
Returns true if the texture uses an alpha channel, false otherwise.
Definition: textureProperties.cxx:160
Datagram::add_int32
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
Definition: datagram.I:67
TextureProperties
This is the set of characteristics of a texture that, if different from another texture,...
Definition: textureProperties.h:30
TextureProperties::force_nonalpha
void force_nonalpha()
Sets the actual number of channels to indicate an image with no alpha channel, presumably after disco...
Definition: textureProperties.cxx:150
TextureProperties::fully_define
void fully_define()
If any properties remain unspecified, specify them now.
Definition: textureProperties.cxx:238
BamReader::read_pointer
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
Definition: bamReader.cxx:610
TextureProperties::force_grayscale
void force_grayscale()
Sets the actual number of channels to indicate a grayscale image, presumably after discovering that t...
Definition: textureProperties.cxx:138
Datagram::add_bool
void add_bool(bool value)
Adds a boolean value to the datagram.
Definition: datagram.I:34
EggTexture
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:30
TextureProperties::update_properties
void update_properties(const TextureProperties &other)
If the indicate TextureProperties structure is more specific than this one, updates this one.
Definition: textureProperties.cxx:207
datagramIterator.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritable::fillin
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
Definition: typedWritable.cxx:103
bamWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PNMFileType
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:32
parse_params
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition: bamReader.I:275