Panda3D
frameBufferProperties.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 frameBufferProperties.cxx
10  * @author drose
11  * @date 2003-01-27
12  */
13 
14 #include "frameBufferProperties.h"
15 #include "string_utils.h"
16 #include "renderBuffer.h"
17 #include "config_display.h"
18 #include "texture.h"
19 
20 /**
21  * Returns true if this set of properties makes strictly greater or equal
22  * demands of the framebuffer than the other set of framebuffer properties.
23  */
25 subsumes(const FrameBufferProperties &other) const {
26  if (((other._flags & other._flags_specified) & ~(_flags & _flags_specified)) != 0) {
27  // The other has bits enabled that we don't have enabled.
28  return false;
29  }
30 
31  for (int i = 0; i < FBP_COUNT; ++i) {
32  if (other._property[i] > _property[i]) {
33  return false;
34  }
35  }
36 
37  return true;
38 }
39 
40 /**
41  * Returns a FrameBufferProperties structure with all of the default values
42  * filled in according to the user's config file.
43  */
46  static bool default_ready = false;
47  static FrameBufferProperties default_props;
48 
49  if (default_ready) {
50  return default_props;
51  }
52 
53  default_props.set_rgb_color(true);
54  default_props.set_back_buffers(back_buffers);
55 
56  int num_words = framebuffer_mode.get_num_words();
57  if (num_words > 0) {
58  display_cat.error()
59  << "The config-variable 'framebuffer-mode' no longer functions.\n";
60  display_cat.error()
61  << "Instead, use one or more of these:\n";
62  display_cat.error() << " framebuffer-hardware #t\n";
63  display_cat.error() << " framebuffer-software #t\n";
64  display_cat.error() << " framebuffer-depth #t\n";
65  display_cat.error() << " framebuffer-alpha #t\n";
66  display_cat.error() << " framebuffer-stencil #t\n";
67  display_cat.error() << " framebuffer-multisample #t\n";
68  display_cat.error() << " framebuffer-stereo #t\n";
69  display_cat.error() << " depth-bits N\n";
70  display_cat.error() << " color-bits N\n";
71  display_cat.error() << " red-bits N\n";
72  display_cat.error() << " green-bits N\n";
73  display_cat.error() << " blue-bits N\n";
74  display_cat.error() << " alpha-bits N\n";
75  display_cat.error() << " stencil-bits N\n";
76  display_cat.error() << " multisamples N\n";
77  display_cat.error() << " coverage-samples N\n";
78  display_cat.error() << " back-buffers N\n";
79  }
80 
81  if (framebuffer_hardware) {
82  default_props.set_force_hardware(true);
83  }
84  if (framebuffer_software) {
85  default_props.set_force_software(true);
86  }
87  if (framebuffer_depth) {
88  default_props.set_depth_bits(1);
89  }
90  if (framebuffer_alpha) {
91  default_props.set_alpha_bits(1);
92  }
93  if (framebuffer_stencil) {
94  default_props.set_stencil_bits(1);
95  }
96  if (framebuffer_accum) {
97  default_props.set_accum_bits(1);
98  }
99  if (framebuffer_multisample) {
100  default_props.set_multisamples(1);
101  }
102  if (framebuffer_stereo) {
103  default_props.set_stereo(true);
104  }
105  if (framebuffer_srgb) {
106  default_props.set_srgb_color(true);
107  }
108  if (framebuffer_float) {
109  default_props.set_float_color(true);
110  }
111  if (depth_bits > 0) {
112  default_props.set_depth_bits(depth_bits);
113  }
114  switch (color_bits.size()) {
115  case 0:
116  break;
117  case 1:
118  default_props.set_color_bits(color_bits[0]);
119  default_props.set_red_bits(1);
120  default_props.set_green_bits(1);
121  default_props.set_blue_bits(1);
122  break;
123  case 3:
124  default_props.set_color_bits(color_bits[0] + color_bits[1] + color_bits[2]);
125  default_props.set_red_bits(color_bits[0]);
126  default_props.set_green_bits(color_bits[1]);
127  default_props.set_blue_bits(color_bits[2]);
128  break;
129  default:
130  default_props.set_color_bits(color_bits[0]);
131  display_cat.error()
132  << "Configuration variable color-bits takes either 1 or 3 values, not "
133  << color_bits.size() << "\n";
134  break;
135  }
136  if (alpha_bits > 0) {
137  default_props.set_alpha_bits(alpha_bits);
138  }
139  if (stencil_bits > 0) {
140  default_props.set_stencil_bits(stencil_bits);
141  }
142  if (accum_bits > 0) {
143  default_props.set_accum_bits(accum_bits);
144  }
145  if (multisamples > 0) {
146  default_props.set_multisamples(multisamples);
147  }
148 
149  if ((default_props._flags & FBF_force_software) != 0 &&
150  (default_props._flags & FBF_force_hardware) != 0){
151  default_props._flags &= ~(FBF_force_software | FBF_force_hardware);
152  }
153 
154  default_ready = true;
155  return default_props;
156 }
157 
158 /**
159  *
160  */
161 bool FrameBufferProperties::
162 operator == (const FrameBufferProperties &other) const {
163  if ((_flags & _flags_specified) != (other._flags & other._flags_specified)) {
164  return false;
165  }
166 
167  if (_specified != other._specified) {
168  return false;
169  }
170 
171  for (int i = 0; i < FBP_COUNT; ++i) {
172  if (_property[i] != other._property[i]) {
173  return false;
174  }
175  }
176 
177  return true;
178 }
179 
180 /**
181  * Unsets all properties that have been specified so far, and resets the
182  * FrameBufferProperties structure to its initial empty state.
183  */
185 clear() {
186  _flags = 0;
187  _flags_specified = 0;
188 
189  for (int i = 0; i < FBP_COUNT; ++i) {
190  _property[i] = 0;
191  }
192  _specified = 0;
193 }
194 
195 /**
196  * Sets any properties that are explicitly specified in other on this object.
197  * Leaves other properties unchanged.
198  */
201  _flags &= ~other._flags_specified;
202  _flags |= other._flags & other._flags_specified;
203 
204  for (int i = 0; i < FBP_COUNT; ++i) {
205  if (other._specified & (1 << i)) {
206  _property[i] = other._property[i];
207  _specified |= (1 << i);
208  }
209  }
210 }
211 
212 /**
213  * Generates a string representation.
214  */
216 output(std::ostream &out) const {
217  if ((_flags & FBF_float_depth) != 0) {
218  out << "float_depth ";
219  }
220  if (_property[FBP_depth_bits] > 0) {
221  out << "depth_bits=" << _property[FBP_depth_bits] << " ";
222  }
223  if ((_flags & FBF_float_color) != 0) {
224  out << "float_color ";
225  }
226  if ((_flags & FBF_srgb_color) != 0) {
227  out << "srgb_color ";
228  }
229  if ((_flags & FBF_indexed_color) != 0) {
230  out << "indexed_color ";
231  }
232  if (_property[FBP_color_bits] > 0) {
233  out << "color_bits=" << _property[FBP_color_bits] << " ";
234  }
235  if (_property[FBP_red_bits] > 0) {
236  out << "red_bits=" << _property[FBP_red_bits] << " ";
237  }
238  if (_property[FBP_green_bits] > 0) {
239  out << "green_bits=" << _property[FBP_green_bits] << " ";
240  }
241  if (_property[FBP_blue_bits] > 0) {
242  out << "blue_bits=" << _property[FBP_blue_bits] << " ";
243  }
244  if (_property[FBP_alpha_bits] > 0) {
245  out << "alpha_bits=" << _property[FBP_alpha_bits] << " ";
246  }
247  if (_property[FBP_stencil_bits] > 0) {
248  out << "stencil_bits=" << _property[FBP_stencil_bits] << " ";
249  }
250  if (_property[FBP_accum_bits] > 0) {
251  out << "accum_bits=" << _property[FBP_accum_bits] << " ";
252  }
253  if (_property[FBP_aux_rgba] > 0) {
254  out << "aux_rgba=" << _property[FBP_aux_rgba] << " ";
255  }
256  if (_property[FBP_aux_hrgba] > 0) {
257  out << "aux_hrgba=" << _property[FBP_aux_hrgba] << " ";
258  }
259  if (_property[FBP_aux_float] > 0) {
260  out << "aux_float=" << _property[FBP_aux_float] << " ";
261  }
262  if (_property[FBP_multisamples] > 0) {
263  out << "multisamples=" << _property[FBP_multisamples] << " ";
264  }
265  if (_property[FBP_coverage_samples] > 0) {
266  out << "coverage_samples=" << _property[FBP_coverage_samples] << " ";
267  }
268  if (_property[FBP_back_buffers] > 0) {
269  out << "back_buffers=" << _property[FBP_back_buffers] << " ";
270  }
271  if ((_flags & FBF_stereo) != 0) {
272  out << "stereo ";
273  }
274  if ((_flags & FBF_force_hardware) != 0) {
275  out << "force_hardware ";
276  }
277  if ((_flags & FBF_force_software) != 0) {
278  out << "force_software ";
279  }
280 }
281 
282 /**
283  * Converts the aux bitplanes of the framebuffer into a RenderBuffer::Type.
284  */
286 get_aux_mask() const {
287  int mask = 0;
288  for (int i=0; i<_property[FBP_aux_rgba]; i++) {
289  mask |= (RenderBuffer::T_aux_rgba_0 << i);
290  }
291  for (int i=0; i<_property[FBP_aux_hrgba]; i++) {
292  mask |= (RenderBuffer::T_aux_hrgba_0 << i);
293  }
294  for (int i=0; i<_property[FBP_aux_float]; i++) {
295  mask |= (RenderBuffer::T_aux_float_0 << i);
296  }
297  return mask;
298 }
299 
300 /**
301  * Converts the non-aux bitplanes of the framebuffer into a
302  * RenderBuffer::Type.
303  */
306  int mask = 0;
307 
308  if (_property[FBP_back_buffers] > 0) {
309  mask = RenderBuffer::T_front | RenderBuffer::T_back;
310  } else {
311  mask = RenderBuffer::T_front;
312  }
313  if (_property[FBP_depth_bits] > 0) {
314  mask |= RenderBuffer::T_depth;
315  }
316  if (_property[FBP_stencil_bits] > 0) {
317  mask |= RenderBuffer::T_stencil;
318  }
319  return mask;
320 }
321 
322 /**
323  * Returns true if any properties have been specified, false otherwise.
324  */
327  return (_flags_specified | _specified) != 0;
328 }
329 
330 /**
331  * Marks all bits as having been specified.
332  */
335  _flags_specified = FBF_all;
336  _specified = (1 << FBP_COUNT) - 1;
337 }
338 
339 /**
340  * Returns true if the properties are extremely basic. The following count as
341  * basic: rgb or rgba, depth. If anything else is specified, the properties
342  * are non-basic.
343  */
345 is_basic() const {
346  if (_property[FBP_depth_bits] > 1) {
347  return false;
348  }
349  if (_property[FBP_color_bits] > 1) {
350  return false;
351  }
352  if (_property[FBP_red_bits] > 1) {
353  return false;
354  }
355  if (_property[FBP_green_bits] > 1) {
356  return false;
357  }
358  if (_property[FBP_blue_bits] > 1) {
359  return false;
360  }
361  if (_property[FBP_alpha_bits] > 1) {
362  return false;
363  }
364  if (_property[FBP_stencil_bits] > 0) {
365  return false;
366  }
367  if (_property[FBP_aux_rgba] > 0) {
368  return false;
369  }
370  if (_property[FBP_aux_hrgba] > 0) {
371  return false;
372  }
373  if (_property[FBP_aux_float] > 0) {
374  return false;
375  }
376  if (_property[FBP_multisamples] > 1) {
377  return false;
378  }
379  if (_property[FBP_coverage_samples] > 0) {
380  return false;
381  }
382  if (_property[FBP_back_buffers] > 0) {
383  return false;
384  }
385  if ((_flags & FBF_indexed_color) != 0) {
386  return false;
387  }
388  if ((_flags & FBF_force_hardware) != 0) {
389  return false;
390  }
391  if ((_flags & FBF_force_software) != 0) {
392  return false;
393  }
394  if ((_flags & FBF_srgb_color) != 0) {
395  return false;
396  }
397  if ((_flags & FBF_float_color) != 0) {
398  return false;
399  }
400  if ((_flags & FBF_float_depth) != 0) {
401  return false;
402  }
403  return true;
404 }
405 
406 /**
407  * If any of the depth, color, alpha, accum, or stencil properties is set to
408  * more than one, then they are reduced to one.
409  */
412  for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
413  if (_property[prop] > 1) {
414  _property[prop] = 1;
415  }
416  }
417 }
418 
419 /**
420  * Assumes that these properties are a description of a window.
421  *
422  * Measures how well this window satisfies a specified set of requirements. A
423  * higher quality number means that more requirements were satisfied. A
424  * quality of zero means that the window is unsuitable.
425  *
426  * The routine deducts a lot if the window fails to provide a requested
427  * feature. It deducts less if the window provides a feature, but at a
428  * degraded level of functionality (ie, the user asks for rgba8, color, but
429  * the window only provides rgba4). The routine also deducts a small amount
430  * for unnecessary features. For example, if the window has an accumulation
431  * buffer when one is not requested will reduce quality slightly. Maximum
432  * quality is obtained when the window exactly matches the request.
433  *
434  * If you want to know whether the window satisfies all of the requirements,
435  * use the "subsumes" function.
436  */
438 get_quality(const FrameBufferProperties &reqs) const {
439 
440  if (!get_indexed_color() && !get_rgb_color()) {
441  // Nonfunctioning window.
442  return 0;
443  }
444 
445  if ((reqs.get_rgb_color() && !get_rgb_color()) ||
446  (reqs.get_indexed_color() && !get_indexed_color())) {
447  // These properties are nonnegotiable.
448  return 0;
449  }
450 
451  int quality = 100000000;
452 
453  // Deduct for using the wrong kind of renderer (hardware or software). Cost:
454  // 10,000,000
455 
456  if ((reqs._flags & FBF_force_hardware) > (_flags & FBF_force_hardware) ||
457  (reqs._flags & FBF_force_software) > (_flags & FBF_force_software)) {
458  quality -= 10000000;
459  }
460 
461  // Deduct for software-only renderers in absence of a special request.
462  // Cost: 2,000,000
463 
464  if (get_force_software() && !reqs.get_force_software()) {
465  quality -= 2000000;
466  }
467 
468  // Deduct for missing depth, color, alpha, stencil, or accum. Cost:
469  // 1,000,000
470 
471  for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
472  if (reqs._property[prop] && _property[prop] == 0) {
473  quality -= 1000000;
474  }
475  }
476 
477  // Deduct for missing aux bitplanes. Cost: 100,000
478 
479  for (int prop = FBP_aux_rgba; prop <= FBP_aux_float; ++prop) {
480  if (reqs._property[prop] > _property[prop]) {
481  quality -= 100000;
482  }
483  }
484 
485  // Deduct for stereo not enabled. Cost: 100,000
486 
487  if (reqs.get_stereo() && !get_stereo()) {
488  quality -= 100000;
489  }
490 
491  // Deduct for not being sRGB-capable. Cost: 100,000
492 
493  if (reqs.get_srgb_color() && !get_srgb_color()) {
494  quality -= 100000;
495  }
496 
497  // Deduct for not having a floating-point format if we requested it. Cost:
498  // 100,000
499 
500  if (reqs.get_float_color() && !get_float_color()) {
501  quality -= 100000;
502  }
503 
504  if (reqs.get_float_depth() && !get_float_depth()) {
505  quality -= 100000;
506  }
507 
508  // Deduct for insufficient back-buffers. Cost: 100,000
509 
510  if (reqs._property[FBP_back_buffers] > _property[FBP_back_buffers]) {
511  quality -= 100000;
512  }
513 
514  // Deduct for lacking multisamples altogether. Cost: 100,000
515  if (reqs._property[FBP_multisamples] != 0 && _property[FBP_multisamples] == 0) {
516  quality -= 100000;
517  }
518 
519  // Deduct for not enough bits in depth, color, alpha, stencil, or accum.
520  // Cost: 10,000
521 
522  for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
523  if (_property[prop] != 0 && reqs._property[prop] > _property[prop]) {
524  quality -= 10000;
525  }
526  }
527 
528  // deduct for insufficient multisamples. Cost: 1,000
529 
530  if (_property[FBP_multisamples] != 0 &&
531  reqs._property[FBP_multisamples] > _property[FBP_multisamples]) {
532  quality -= 1000;
533  }
534 
535  // Deduct for unrequested bitplanes. Cost: 50
536 
537  for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
538  if ((_property[prop]) && (reqs._property[prop] == 0)) {
539  quality -= 50;
540  }
541  }
542  for (int prop = FBP_aux_rgba; prop <= FBP_aux_float; ++prop) {
543  int extra = _property[prop] > reqs._property[prop];
544  if (extra > 0) {
545  extra = std::min(extra, 3);
546  quality -= extra*50;
547  }
548  }
549 
550  // Deduct for excessive resolution in any bitplane (unless we asked for only
551  // 1 bit, which is the convention for any amount).
552 
553  // Cost: 50
554 
555  for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
556  if (reqs._property[prop] > 1 &&
557  _property[prop] > reqs._property[prop]) {
558  quality -= 50;
559  }
560  }
561 
562  // However, deduct for color bits above 24, if we are requesting only 1.
563  // This is to prevent choosing a 64-bit color mode in NVIDIA cards that
564  // is linear and therefore causes the gamma to be off in non-sRGB pipelines.
565  if (reqs._property[FBP_color_bits] <= 3 && _property[FBP_color_bits] > 24) {
566  quality -= 100;
567  }
568 
569  // Bonus for each depth bit. Extra: 8 per bit.
570  // Please note that the Intel Windows driver only gives extra depth in
571  // combination with a stencil buffer, so we need 8 extra depth bits to
572  // outweigh the penalty of 50 for the unwanted stencil buffer, otherwise we
573  // will end up only getting 16-bit depth.
574  if (reqs._property[FBP_depth_bits] != 0) {
575  quality += 8 * _property[FBP_depth_bits];
576  }
577 
578  // Bonus for each multisample. Extra: 2 per sample.
579  if (reqs._property[FBP_multisamples] != 0) {
580  quality += 2 * _property[FBP_multisamples];
581  }
582 
583  // Bonus for each coverage sample. Extra: 2 per sample.
584  if (reqs._property[FBP_coverage_samples] != 0) {
585  quality += 2 * _property[FBP_coverage_samples];
586  }
587 
588  // Bonus for each color, alpha, stencil, and accum. Extra: 1 per bit.
589  for (int prop=FBP_color_bits; prop<=FBP_accum_bits; prop++) {
590  if (reqs._property[prop] != 0) {
591  quality += _property[prop];
592  }
593  }
594 
595  return quality;
596 }
597 
598 /**
599  * Validates that the properties represent the desired kind of renderer
600  * (hardware or software). If not, prints out an error message and returns
601  * false.
602  */
604 verify_hardware_software(const FrameBufferProperties &props, const std::string &renderer) const {
605 
606  if (get_force_hardware() < props.get_force_hardware()) {
607  display_cat.error()
608  << "The application requested harware acceleration, but your OpenGL\n";
609  display_cat.error()
610  << "driver, " << renderer << ", only supports software rendering.\n";
611  display_cat.error()
612  << "You need to install a hardware-accelerated OpenGL driver, or,\n";
613  display_cat.error()
614  << "if you actually *want* to use a software renderer, then\n";
615  display_cat.error()
616  << "alter the hardware/software configuration in your Config.prc file.\n";
617  return false;
618  }
619 
620  if (get_force_software() < props.get_force_software()) {
621  display_cat.error()
622  << "The application requested a software renderer, but your OpenGL\n";
623  display_cat.error()
624  << "driver, " << renderer << ", is probably hardware-accelerated.\n";
625  display_cat.error()
626  << "If you want to allow hardware acceleration, then alter the\n";
627  display_cat.error()
628  << "hardware/software configuration in your Config.prc file.\n";
629  return false;
630  }
631 
632  return true;
633 }
634 
635 /**
636  * Sets the texture up for render-to-texture matching these framebuffer
637  * properties.
638  *
639  * Returns true if there was a format that had enough bits, false otherwise.
640  * Of course, this is no guarantee that a particular graphics back-end
641  * supports rendering to textures of that format.
642  */
645  // Note by rdb: I'm not entirely happy about this system. I'd eventually
646  // like to move to a system in which framebuffer color formats and texture
647  // formats are unified (like in Direct3D and OpenGL) and where a table such
648  // as the below one would be generated dynamically by the GSG to reflect the
649  // formats that are supported for render-to-texture.
650 
651  static const int num_formats = 17;
652  static const struct {
653  unsigned char color_bits, red_bits, green_bits, blue_bits, alpha_bits;
654  bool has_float;
655  Texture::Format format;
656  } formats[num_formats] = {
657  { 1, 1, 0, 0, 0, false, Texture::F_red },
658  { 1, 1, 1, 0, 0, false, Texture::F_rg },
659  { 1, 1, 1, 1, 0, false, Texture::F_rgb },
660  { 1, 1, 1, 1, 1, false, Texture::F_rgba },
661  { 8, 8, 0, 0, 0, false, Texture::F_red },
662  { 16, 8, 8, 0, 0, false, Texture::F_rg },
663  { 24, 8, 8, 8, 0, false, Texture::F_rgb8 },
664  { 32, 8, 8, 8, 8, false, Texture::F_rgba8 },
665  { 16, 16, 0, 0, 0, true, Texture::F_r16 },
666  { 32, 16, 16, 0, 0, true, Texture::F_rg16 },
667  { 32, 11, 11, 10, 0, true, Texture::F_r11_g11_b10 },
668  { 48, 16, 16, 16, 0, true, Texture::F_rgb16 },
669  { 48, 16, 16, 16, 16, true, Texture::F_rgba16 },
670  { 32, 32, 0, 0, 0, true, Texture::F_r32 },
671  { 64, 32, 32, 0, 0, true, Texture::F_rg32 },
672  { 96, 32, 32, 32, 0, true, Texture::F_rgb32 },
673  { 96, 32, 32, 32, 32, true, Texture::F_rgba32 },
674  };
675 
676  if (get_srgb_color()) {
677  // These are the only sRGB formats. Deal with it.
678  if (get_alpha_bits() == 0) {
679  tex->set_format(Texture::F_srgb);
680  } else {
681  tex->set_format(Texture::F_srgb_alpha);
682  }
683 
684  return (get_color_bits() <= 24 &&
685  get_red_bits() <= 8 &&
686  get_green_bits() <= 8 &&
687  get_blue_bits() <= 8 &&
688  get_alpha_bits() <= 8);
689 
690  } else {
691  if (get_float_color()) {
692  tex->set_component_type(Texture::T_float);
693  }
694 
695  for (int i = 0; i < num_formats; ++i) {
696  if (get_color_bits() <= (int)formats[i].color_bits &&
697  get_red_bits() <= (int)formats[i].red_bits &&
698  get_green_bits() <= (int)formats[i].green_bits &&
699  get_blue_bits() <= (int)formats[i].blue_bits &&
700  get_alpha_bits() <= (int)formats[i].alpha_bits &&
701  get_float_color() <= formats[i].has_float) {
702 
703  tex->set_format(formats[i].format);
704  return true;
705  }
706  }
707 
708  // Can't get requested bits. Choose a generic format and return.
709  tex->set_format((get_alpha_bits() == 0) ? Texture::F_rgb : Texture::F_rgba);
710  return false;
711  }
712 }
713 
714 /**
715  * Sets the texture up for render-to-texture matching these framebuffer
716  * properties.
717  *
718  * Returns true if there was a format that had enough bits, false otherwise.
719  * Of course, this is no guarantee that a particular graphics back-end
720  * supports rendering to textures of that format.
721  */
724  if (get_float_depth()) {
725  tex->set_component_type(Texture::T_float);
726  tex->set_format(Texture::F_depth_component32);
727  return (get_depth_bits() <= 32);
728 
729  } else if (get_depth_bits() <= 1) {
730  tex->set_format(Texture::F_depth_component);
731  return true;
732 
733  } else if (get_depth_bits() <= 16) {
734  tex->set_format(Texture::F_depth_component16);
735  return true;
736 
737  } else if (get_depth_bits() <= 24) {
738  tex->set_format(Texture::F_depth_component24);
739  return true;
740 
741  } else if (get_depth_bits() <= 32) {
742  tex->set_format(Texture::F_depth_component32);
743  return true;
744  }
745 
746  tex->set_format(Texture::F_depth_component);
747  return false;
748 }
bool is_basic() const
Returns true if the properties are extremely basic.
void output(std::ostream &out) const
Generates a string representation.
static const FrameBufferProperties & get_default()
Returns a FrameBufferProperties structure with all of the default values filled in according to the u...
void set_all_specified()
Marks all bits as having been specified.
void clear()
Unsets all properties that have been specified so far, and resets the FrameBufferProperties structure...
int get_aux_mask() const
Converts the aux bitplanes of the framebuffer into a RenderBuffer::Type.
void add_properties(const FrameBufferProperties &other)
Sets any properties that are explicitly specified in other on this object.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
size_t size() const
Returns the number of unique words in the variable.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_buffer_mask() const
Converts the non-aux bitplanes of the framebuffer into a RenderBuffer::Type.
bool is_any_specified() const
Returns true if any properties have been specified, false otherwise.
size_t get_num_words() const
Returns the number of words in the variable's value.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool setup_depth_texture(Texture *tex) const
Sets the texture up for render-to-texture matching these framebuffer properties.
set_format
Changes the format value for the texture components.
Definition: texture.h:362
void set_one_bit_per_channel()
If any of the depth, color, alpha, accum, or stencil properties is set to more than one,...
set_color_bits
Sets the number of requested color bits as a single number that represents the sum of the individual ...
bool verify_hardware_software(const FrameBufferProperties &props, const std::string &renderer) const
Validates that the properties represent the desired kind of renderer (hardware or software).
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_component_type
Changes the data value for the texture components.
Definition: texture.h:366
bool setup_color_texture(Texture *tex) const
Sets the texture up for render-to-texture matching these framebuffer properties.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
int get_quality(const FrameBufferProperties &reqs) const
Assumes that these properties are a description of a window.