Panda3D

Loading...
Searching...
No Matches
frameBufferProperties.h
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.h
10 * @author drose
11 * @date 2003-01-27
12 */
13
14#ifndef FRAMEBUFFERPROPERTIES_H
15#define FRAMEBUFFERPROPERTIES_H
16
17#include "pandabase.h"
18#include "pnotify.h"
19
20 class Texture;
21
22/**
23 * A container for the various kinds of properties we might ask to have on a
24 * graphics frameBuffer before we create a GSG.
25 */
26 class EXPCL_PANDA_DISPLAY FrameBufferProperties {
27
28 private:
29 enum FrameBufferProperty {
30 // This section has to start with "depth" and end with "accum"
31 FBP_depth_bits,
32 FBP_color_bits,
33 FBP_red_bits,
34 FBP_green_bits,
35 FBP_blue_bits,
36 FBP_alpha_bits,
37 FBP_stencil_bits,
38 FBP_accum_bits,
39
40 // This section has to start with "rgba" and end with "float"
41 FBP_aux_rgba,
42 FBP_aux_hrgba,
43 FBP_aux_float,
44
45 // This section can be in any order.
46 FBP_multisamples,
47 FBP_coverage_samples,
48 FBP_back_buffers,
49
50 // This is a sentinel value.
51 FBP_COUNT
52 };
53
54 enum FrameBufferFlag {
55 FBF_indexed_color = 0x001,
56 FBF_rgb_color = 0x002,
57 FBF_stereo = 0x004,
58 FBF_force_hardware = 0x008,
59 FBF_force_software = 0x010,
60 FBF_srgb_color = 0x020,
61 FBF_float_color = 0x040,
62 FBF_float_depth = 0x080,
63 FBF_all = 0x100-1,
64 };
65
66 int _property[FBP_COUNT] = {0};
67 int _specified = 0;
68
69 int _flags = 0;
70 int _flags_specified = 0;
71
72PUBLISHED:
73
74 // Individual queries.
75 INLINE int get_depth_bits() const;
76 INLINE int get_color_bits() const;
77 INLINE int get_red_bits() const;
78 INLINE int get_green_bits() const;
79 INLINE int get_blue_bits() const;
80 INLINE int get_alpha_bits() const;
81 INLINE int get_stencil_bits() const;
82 INLINE int get_accum_bits() const;
83 INLINE int get_aux_rgba() const;
84 INLINE int get_aux_hrgba() const;
85 INLINE int get_aux_float() const;
86 INLINE int get_multisamples() const;
87 INLINE int get_coverage_samples() const;
88 INLINE int get_back_buffers() const;
89 INLINE bool get_indexed_color() const;
90 INLINE bool get_rgb_color() const;
91 INLINE bool get_stereo() const;
92 INLINE bool get_force_hardware() const;
93 INLINE bool get_force_software() const;
94 INLINE bool get_srgb_color() const;
95 INLINE bool get_float_color() const;
96 INLINE bool get_float_depth() const;
97
98 // Individual assigners.
99 INLINE void set_depth_bits(int n);
100 INLINE void set_color_bits(int n);
101 INLINE void set_rgba_bits(int r, int g, int b, int a);
102 INLINE void set_red_bits(int n);
103 INLINE void set_green_bits(int n);
104 INLINE void set_blue_bits(int n);
105 INLINE void set_alpha_bits(int n);
106 INLINE void set_stencil_bits(int n);
107 INLINE void set_accum_bits(int n);
108 INLINE void set_aux_rgba(int n);
109 INLINE void set_aux_hrgba(int n);
110 INLINE void set_aux_float(int n);
111 INLINE void set_multisamples(int n);
112 INLINE void set_coverage_samples(int n);
113 INLINE void set_back_buffers(int n);
114 INLINE void set_indexed_color(bool n);
115 INLINE void set_rgb_color(bool n);
116 INLINE void set_stereo(bool n);
117 INLINE void set_force_hardware(bool n);
118 INLINE void set_force_software(bool n);
119 INLINE void set_srgb_color(bool n);
120 INLINE void set_float_color(bool n);
121 INLINE void set_float_depth(bool n);
122
123 MAKE_PROPERTY(depth_bits, get_depth_bits, set_depth_bits);
124 MAKE_PROPERTY(color_bits, get_color_bits, set_color_bits);
125 MAKE_PROPERTY(red_bits, get_red_bits, set_red_bits);
126 MAKE_PROPERTY(green_bits, get_green_bits, set_green_bits);
127 MAKE_PROPERTY(blue_bits, get_blue_bits, set_blue_bits);
128 MAKE_PROPERTY(alpha_bits, get_alpha_bits, set_alpha_bits);
129 MAKE_PROPERTY(stencil_bits, get_stencil_bits, set_stencil_bits);
130 MAKE_PROPERTY(accum_bits, get_accum_bits, set_accum_bits);
131 MAKE_PROPERTY(aux_rgba, get_aux_rgba, set_aux_rgba);
132 MAKE_PROPERTY(aux_hrgba, get_aux_hrgba, set_aux_hrgba);
133 MAKE_PROPERTY(aux_float, get_aux_float, set_aux_float);
134 MAKE_PROPERTY(multisamples, get_multisamples, set_multisamples);
135 MAKE_PROPERTY(coverage_samples, get_coverage_samples, set_coverage_samples);
136 MAKE_PROPERTY(back_buffers, get_back_buffers, set_back_buffers);
137 MAKE_PROPERTY(indexed_color, get_indexed_color, set_indexed_color);
138 MAKE_PROPERTY(rgb_color, get_rgb_color, set_rgb_color);
139 MAKE_PROPERTY(stereo, get_stereo, set_stereo);
140 MAKE_PROPERTY(force_hardware, get_force_hardware, set_force_hardware);
141 MAKE_PROPERTY(force_software, get_force_software, set_force_software);
142 MAKE_PROPERTY(srgb_color, get_srgb_color, set_srgb_color);
143 MAKE_PROPERTY(float_color, get_float_color, set_float_color);
144 MAKE_PROPERTY(float_depth, get_float_depth, set_float_depth);
145
146 // Other.
147
148 constexpr FrameBufferProperties() = default;
149
150 static const FrameBufferProperties &get_default();
151 bool operator == (const FrameBufferProperties &other) const;
152 INLINE bool operator != (const FrameBufferProperties &other) const;
153
154 void clear();
155 void set_all_specified();
156 bool subsumes(const FrameBufferProperties &other) const;
157 void add_properties(const FrameBufferProperties &other);
158 void output(std::ostream &out) const;
159 void set_one_bit_per_channel();
160
161 INLINE bool is_stereo() const;
162 INLINE bool is_single_buffered() const;
163 int get_quality(const FrameBufferProperties &reqs) const;
164 bool is_any_specified() const;
165 bool is_basic() const;
166 int get_aux_mask() const;
167 int get_buffer_mask() const;
168 bool verify_hardware_software(const FrameBufferProperties &props, const std::string &renderer) const;
169
170 bool setup_color_texture(Texture *tex) const;
171 bool setup_depth_texture(Texture *tex) const;
172};
173
174INLINE std::ostream &operator << (std::ostream &out, const FrameBufferProperties &properties);
175
176#include "frameBufferProperties.I"
177
178#endif
FrameBufferProperties
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Definition frameBufferProperties.h:26
FrameBufferProperties::set_color_bits
set_color_bits
Sets the number of requested color bits as a single number that represents the sum of the individual ...
Definition frameBufferProperties.h:124
FrameBufferProperties::setup_color_texture
bool setup_color_texture(Texture *tex) const
Sets the texture up for render-to-texture matching these framebuffer properties.
Definition frameBufferProperties.cxx:644
FrameBufferProperties::get_aux_mask
int get_aux_mask() const
Converts the aux bitplanes of the framebuffer into a RenderBuffer::Type.
Definition frameBufferProperties.cxx:286
FrameBufferProperties::set_rgba_bits
void set_rgba_bits(int r, int g, int b, int a)
Convenience method for setting the red, green, blue and alpha bits in one go.
Definition frameBufferProperties.I:256
FrameBufferProperties::clear
void clear()
Unsets all properties that have been specified so far, and resets the FrameBufferProperties structure...
Definition frameBufferProperties.cxx:185
FrameBufferProperties::get_quality
int get_quality(const FrameBufferProperties &reqs) const
Assumes that these properties are a description of a window.
Definition frameBufferProperties.cxx:438
FrameBufferProperties::is_any_specified
bool is_any_specified() const
Returns true if any properties have been specified, false otherwise.
Definition frameBufferProperties.cxx:326
FrameBufferProperties::output
void output(std::ostream &out) const
Generates a string representation.
Definition frameBufferProperties.cxx:216
FrameBufferProperties::get_coverage_samples
get_coverage_samples
If coverage samples are specified, and there is hardware support, we use coverage multisampling.
Definition frameBufferProperties.h:135
FrameBufferProperties::get_default
static const FrameBufferProperties & get_default()
Returns a FrameBufferProperties structure with all of the default values filled in according to the u...
Definition frameBufferProperties.cxx:45
FrameBufferProperties::setup_depth_texture
bool setup_depth_texture(Texture *tex) const
Sets the texture up for render-to-texture matching these framebuffer properties.
Definition frameBufferProperties.cxx:723
FrameBufferProperties::verify_hardware_software
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).
Definition frameBufferProperties.cxx:604
FrameBufferProperties::get_buffer_mask
int get_buffer_mask() const
Converts the non-aux bitplanes of the framebuffer into a RenderBuffer::Type.
Definition frameBufferProperties.cxx:305
FrameBufferProperties::set_all_specified
void set_all_specified()
Marks all bits as having been specified.
Definition frameBufferProperties.cxx:334
FrameBufferProperties::subsumes
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
Definition frameBufferProperties.cxx:25
FrameBufferProperties::set_one_bit_per_channel
void set_one_bit_per_channel()
If any of the depth, color, alpha, accum, or stencil properties is set to more than one,...
Definition frameBufferProperties.cxx:411
FrameBufferProperties::add_properties
void add_properties(const FrameBufferProperties &other)
Sets any properties that are explicitly specified in other on this object.
Definition frameBufferProperties.cxx:200
FrameBufferProperties::set_coverage_samples
set_coverage_samples
If coverage samples are specified, and there is hardware support, we use coverage multisampling.
Definition frameBufferProperties.h:135
FrameBufferProperties::is_basic
bool is_basic() const
Returns true if the properties are extremely basic.
Definition frameBufferProperties.cxx:345
Texture
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72
frameBufferProperties.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.