26 if (((other._flags & other._flags_specified) & ~(_flags & _flags_specified)) != 0) {
31 for (
int i = 0; i < FBP_COUNT; ++i) {
32 if (other._property[i] > _property[i]) {
46 static bool default_ready =
false;
53 default_props.set_rgb_color(
true);
54 default_props.set_back_buffers(back_buffers);
59 <<
"The config-variable 'framebuffer-mode' no longer functions.\n";
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";
81 if (framebuffer_hardware) {
82 default_props.set_force_hardware(
true);
84 if (framebuffer_software) {
85 default_props.set_force_software(
true);
87 if (framebuffer_depth) {
88 default_props.set_depth_bits(1);
90 if (framebuffer_alpha) {
91 default_props.set_alpha_bits(1);
93 if (framebuffer_stencil) {
94 default_props.set_stencil_bits(1);
96 if (framebuffer_accum) {
97 default_props.set_accum_bits(1);
99 if (framebuffer_multisample) {
100 default_props.set_multisamples(1);
102 if (framebuffer_stereo) {
103 default_props.set_stereo(
true);
105 if (framebuffer_srgb) {
106 default_props.set_srgb_color(
true);
108 if (framebuffer_float) {
109 default_props.set_float_color(
true);
111 if (depth_bits > 0) {
112 default_props.set_depth_bits(depth_bits);
114 switch (color_bits.
size()) {
119 default_props.set_red_bits(1);
120 default_props.set_green_bits(1);
121 default_props.set_blue_bits(1);
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]);
132 <<
"Configuration variable color-bits takes either 1 or 3 values, not " 133 << color_bits.
size() <<
"\n";
136 if (alpha_bits > 0) {
137 default_props.set_alpha_bits(alpha_bits);
139 if (stencil_bits > 0) {
140 default_props.set_stencil_bits(stencil_bits);
142 if (accum_bits > 0) {
143 default_props.set_accum_bits(accum_bits);
145 if (multisamples > 0) {
146 default_props.set_multisamples(multisamples);
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);
154 default_ready =
true;
155 return default_props;
161 bool FrameBufferProperties::
163 if ((_flags & _flags_specified) != (other._flags & other._flags_specified)) {
167 if (_specified != other._specified) {
171 for (
int i = 0; i < FBP_COUNT; ++i) {
172 if (_property[i] != other._property[i]) {
187 _flags_specified = 0;
189 for (
int i = 0; i < FBP_COUNT; ++i) {
201 _flags &= ~other._flags_specified;
202 _flags |= other._flags & other._flags_specified;
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);
217 if ((_flags & FBF_float_depth) != 0) {
218 out <<
"float_depth ";
220 if (_property[FBP_depth_bits] > 0) {
221 out <<
"depth_bits=" << _property[FBP_depth_bits] <<
" ";
223 if ((_flags & FBF_float_color) != 0) {
224 out <<
"float_color ";
226 if ((_flags & FBF_srgb_color) != 0) {
227 out <<
"srgb_color ";
229 if ((_flags & FBF_indexed_color) != 0) {
230 out <<
"indexed_color ";
232 if (_property[FBP_color_bits] > 0) {
233 out <<
"color_bits=" << _property[FBP_color_bits] <<
" ";
235 if (_property[FBP_red_bits] > 0) {
236 out <<
"red_bits=" << _property[FBP_red_bits] <<
" ";
238 if (_property[FBP_green_bits] > 0) {
239 out <<
"green_bits=" << _property[FBP_green_bits] <<
" ";
241 if (_property[FBP_blue_bits] > 0) {
242 out <<
"blue_bits=" << _property[FBP_blue_bits] <<
" ";
244 if (_property[FBP_alpha_bits] > 0) {
245 out <<
"alpha_bits=" << _property[FBP_alpha_bits] <<
" ";
247 if (_property[FBP_stencil_bits] > 0) {
248 out <<
"stencil_bits=" << _property[FBP_stencil_bits] <<
" ";
250 if (_property[FBP_accum_bits] > 0) {
251 out <<
"accum_bits=" << _property[FBP_accum_bits] <<
" ";
253 if (_property[FBP_aux_rgba] > 0) {
254 out <<
"aux_rgba=" << _property[FBP_aux_rgba] <<
" ";
256 if (_property[FBP_aux_hrgba] > 0) {
257 out <<
"aux_hrgba=" << _property[FBP_aux_hrgba] <<
" ";
259 if (_property[FBP_aux_float] > 0) {
260 out <<
"aux_float=" << _property[FBP_aux_float] <<
" ";
262 if (_property[FBP_multisamples] > 0) {
263 out <<
"multisamples=" << _property[FBP_multisamples] <<
" ";
265 if (_property[FBP_coverage_samples] > 0) {
266 out <<
"coverage_samples=" << _property[FBP_coverage_samples] <<
" ";
268 if (_property[FBP_back_buffers] > 0) {
269 out <<
"back_buffers=" << _property[FBP_back_buffers] <<
" ";
271 if ((_flags & FBF_stereo) != 0) {
274 if ((_flags & FBF_force_hardware) != 0) {
275 out <<
"force_hardware ";
277 if ((_flags & FBF_force_software) != 0) {
278 out <<
"force_software ";
288 for (
int i=0; i<_property[FBP_aux_rgba]; i++) {
289 mask |= (RenderBuffer::T_aux_rgba_0 << i);
291 for (
int i=0; i<_property[FBP_aux_hrgba]; i++) {
292 mask |= (RenderBuffer::T_aux_hrgba_0 << i);
294 for (
int i=0; i<_property[FBP_aux_float]; i++) {
295 mask |= (RenderBuffer::T_aux_float_0 << i);
308 if (_property[FBP_back_buffers] > 0) {
309 mask = RenderBuffer::T_front | RenderBuffer::T_back;
311 mask = RenderBuffer::T_front;
313 if (_property[FBP_depth_bits] > 0) {
314 mask |= RenderBuffer::T_depth;
316 if (_property[FBP_stencil_bits] > 0) {
317 mask |= RenderBuffer::T_stencil;
327 return (_flags_specified | _specified) != 0;
335 _flags_specified = FBF_all;
336 _specified = (1 << FBP_COUNT) - 1;
346 if (_property[FBP_depth_bits] > 1) {
349 if (_property[FBP_color_bits] > 1) {
352 if (_property[FBP_red_bits] > 1) {
355 if (_property[FBP_green_bits] > 1) {
358 if (_property[FBP_blue_bits] > 1) {
361 if (_property[FBP_alpha_bits] > 1) {
364 if (_property[FBP_stencil_bits] > 0) {
367 if (_property[FBP_aux_rgba] > 0) {
370 if (_property[FBP_aux_hrgba] > 0) {
373 if (_property[FBP_aux_float] > 0) {
376 if (_property[FBP_multisamples] > 1) {
379 if (_property[FBP_coverage_samples] > 0) {
382 if (_property[FBP_back_buffers] > 0) {
385 if ((_flags & FBF_indexed_color) != 0) {
388 if ((_flags & FBF_force_hardware) != 0) {
391 if ((_flags & FBF_force_software) != 0) {
394 if ((_flags & FBF_srgb_color) != 0) {
397 if ((_flags & FBF_float_color) != 0) {
400 if ((_flags & FBF_float_depth) != 0) {
412 for (
int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
413 if (_property[prop] > 1) {
440 if (!get_indexed_color() && !get_rgb_color()) {
445 if ((reqs.get_rgb_color() && !get_rgb_color()) ||
446 (reqs.get_indexed_color() && !get_indexed_color())) {
451 int quality = 100000000;
456 if ((reqs._flags & FBF_force_hardware) > (_flags & FBF_force_hardware) ||
457 (reqs._flags & FBF_force_software) > (_flags & FBF_force_software)) {
464 if (get_force_software() && !reqs.get_force_software()) {
471 for (
int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
472 if (reqs._property[prop] && _property[prop] == 0) {
479 for (
int prop = FBP_aux_rgba; prop <= FBP_aux_float; ++prop) {
480 if (reqs._property[prop] > _property[prop]) {
487 if (reqs.get_stereo() && !get_stereo()) {
493 if (reqs.get_srgb_color() && !get_srgb_color()) {
500 if (reqs.get_float_color() && !get_float_color()) {
504 if (reqs.get_float_depth() && !get_float_depth()) {
510 if (reqs._property[FBP_back_buffers] > _property[FBP_back_buffers]) {
515 if (reqs._property[FBP_multisamples] != 0 && _property[FBP_multisamples] == 0) {
522 for (
int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
523 if (_property[prop] != 0 && reqs._property[prop] > _property[prop]) {
530 if (_property[FBP_multisamples] != 0 &&
531 reqs._property[FBP_multisamples] > _property[FBP_multisamples]) {
537 for (
int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
538 if ((_property[prop]) && (reqs._property[prop] == 0)) {
542 for (
int prop = FBP_aux_rgba; prop <= FBP_aux_float; ++prop) {
543 int extra = _property[prop] > reqs._property[prop];
545 extra = std::min(extra, 3);
555 for (
int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) {
556 if (reqs._property[prop] > 1 &&
557 _property[prop] > reqs._property[prop]) {
565 if (reqs._property[FBP_color_bits] <= 3 && _property[FBP_color_bits] > 24) {
574 if (reqs._property[FBP_depth_bits] != 0) {
575 quality += 8 * _property[FBP_depth_bits];
579 if (reqs._property[FBP_multisamples] != 0) {
580 quality += 2 * _property[FBP_multisamples];
584 if (reqs._property[FBP_coverage_samples] != 0) {
585 quality += 2 * _property[FBP_coverage_samples];
589 for (
int prop=FBP_color_bits; prop<=FBP_accum_bits; prop++) {
590 if (reqs._property[prop] != 0) {
591 quality += _property[prop];
606 if (get_force_hardware() < props.get_force_hardware()) {
608 <<
"The application requested harware acceleration, but your OpenGL\n";
610 <<
"driver, " << renderer <<
", only supports software rendering.\n";
612 <<
"You need to install a hardware-accelerated OpenGL driver, or,\n";
614 <<
"if you actually *want* to use a software renderer, then\n";
616 <<
"alter the hardware/software configuration in your Config.prc file.\n";
620 if (get_force_software() < props.get_force_software()) {
622 <<
"The application requested a software renderer, but your OpenGL\n";
624 <<
"driver, " << renderer <<
", is probably hardware-accelerated.\n";
626 <<
"If you want to allow hardware acceleration, then alter the\n";
628 <<
"hardware/software configuration in your Config.prc file.\n";
651 static const int num_formats = 17;
652 static const struct {
653 unsigned char color_bits, red_bits, green_bits, blue_bits, alpha_bits;
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 },
676 if (get_srgb_color()) {
678 if (get_alpha_bits() == 0) {
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);
691 if (get_float_color()) {
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) {
709 tex->
set_format((get_alpha_bits() == 0) ? Texture::F_rgb : Texture::F_rgba);
724 if (get_float_depth()) {
726 tex->
set_format(Texture::F_depth_component32);
727 return (get_depth_bits() <= 32);
729 }
else if (get_depth_bits() <= 1) {
733 }
else if (get_depth_bits() <= 16) {
734 tex->
set_format(Texture::F_depth_component16);
737 }
else if (get_depth_bits() <= 24) {
738 tex->
set_format(Texture::F_depth_component24);
741 }
else if (get_depth_bits() <= 32) {
742 tex->
set_format(Texture::F_depth_component32);
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-...
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.
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.
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.