frameBufferProperties.h

00001 // Filename: frameBufferProperties.h
00002 // Created by:  drose (27Jan03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef FRAMEBUFFERPROPERTIES_H
00016 #define FRAMEBUFFERPROPERTIES_H
00017 
00018 #include "pandabase.h"
00019 #include "pnotify.h"
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //       Class : FrameBufferProperties
00023 // Description : A container for the various kinds of properties we
00024 //               might ask to have on a graphics frameBuffer before we
00025 //               create a GSG.
00026 ////////////////////////////////////////////////////////////////////
00027 class EXPCL_PANDA_DISPLAY FrameBufferProperties {
00028 
00029 private:
00030   enum FrameBufferProperty {
00031     // This section has to start with "depth" and end with "accum"
00032     FBP_depth_bits,
00033     FBP_color_bits,
00034     FBP_alpha_bits,
00035     FBP_stencil_bits,
00036     FBP_accum_bits,
00037 
00038     // This section has to start with "rgba" and end with "float"
00039     FBP_aux_rgba,
00040     FBP_aux_hrgba,
00041     FBP_aux_float,
00042 
00043     // This section can be in any order.
00044     FBP_multisamples,
00045     FBP_coverage_samples,
00046     FBP_back_buffers,
00047     FBP_indexed_color,
00048     FBP_rgb_color,
00049     FBP_stereo,
00050     FBP_force_hardware,
00051     FBP_force_software,
00052     
00053     // This is a sentinel value.
00054     FBP_COUNT
00055   };
00056   
00057   int _property[FBP_COUNT];
00058   int _specified[FBP_COUNT];
00059 
00060 PUBLISHED:
00061 
00062   // Individual queries.
00063   INLINE int get_depth_bits() const;
00064   INLINE int get_color_bits() const;
00065   INLINE int get_alpha_bits() const;
00066   INLINE int get_stencil_bits() const;
00067   INLINE int get_accum_bits() const;
00068   INLINE int get_aux_rgba() const;
00069   INLINE int get_aux_hrgba() const;
00070   INLINE int get_aux_float() const;
00071   INLINE int get_multisamples() const;
00072   INLINE int get_coverage_samples() const;
00073   INLINE int get_back_buffers() const;
00074   INLINE int get_indexed_color() const;
00075   INLINE int get_rgb_color() const;
00076   INLINE int get_stereo() const;
00077   INLINE int get_force_hardware() const;
00078   INLINE int get_force_software() const;
00079 
00080   // Individual assigners.
00081   INLINE void set_depth_bits(int n);
00082   INLINE void set_color_bits(int n);
00083   INLINE void set_alpha_bits(int n);
00084   INLINE void set_stencil_bits(int n);
00085   INLINE void set_accum_bits(int n);
00086   INLINE void set_aux_rgba(int n);
00087   INLINE void set_aux_hrgba(int n);
00088   INLINE void set_aux_float(int n);
00089   INLINE void set_multisamples(int n);
00090   INLINE void set_coverage_samples(int n);
00091   INLINE void set_back_buffers(int n);
00092   INLINE void set_indexed_color(int n);
00093   INLINE void set_rgb_color(int n);
00094   INLINE void set_stereo(int n);
00095   INLINE void set_force_hardware(int n);
00096   INLINE void set_force_software(int n);
00097 
00098   // Other.
00099 
00100   FrameBufferProperties();
00101   INLINE FrameBufferProperties(const FrameBufferProperties &copy);
00102   INLINE ~FrameBufferProperties();
00103   void operator = (const FrameBufferProperties &copy);
00104   static const FrameBufferProperties &get_default();
00105   bool operator == (const FrameBufferProperties &other) const;
00106   INLINE bool operator != (const FrameBufferProperties &other) const;
00107 
00108   void clear();
00109   void set_all_specified();
00110   bool subsumes(const FrameBufferProperties &other) const;
00111   void add_properties(const FrameBufferProperties &other);
00112   void output(ostream &out) const;
00113   void set_one_bit_per_channel();
00114   
00115   bool is_stereo() const;
00116   bool is_single_buffered() const;
00117   int get_quality(const FrameBufferProperties &reqs) const;
00118   bool is_any_specified() const;
00119   bool is_basic() const;
00120   int get_aux_mask() const;
00121   int get_buffer_mask() const;
00122   bool verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const;
00123 };
00124 
00125 INLINE ostream &operator << (ostream &out, const FrameBufferProperties &properties);
00126 
00127 #include "frameBufferProperties.I"
00128 
00129 #endif