Panda3D

drawableRegion.h

00001 // Filename: drawableRegion.h
00002 // Created by:  drose (11Jul02)
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 DRAWABLEREGION_H
00016 #define DRAWABLEREGION_H
00017 
00018 #include "pandabase.h"
00019 #include "luse.h"
00020 #include "renderBuffer.h"
00021 #include "typedWritableReferenceCount.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : DrawableRegion
00025 // Description : This is a base class for GraphicsWindow (actually,
00026 //               GraphicsOutput) and DisplayRegion, both of which are
00027 //               conceptually rectangular regions into which drawing
00028 //               commands may be issued.  Sometimes you want to deal
00029 //               with a single display region, and sometimes you want
00030 //               to deal with the whole window at once, particularly
00031 //               for issuing clear commands and capturing screenshots.
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDA_DISPLAY DrawableRegion {
00034 public:
00035   INLINE DrawableRegion();
00036   INLINE DrawableRegion(const DrawableRegion &copy);
00037   INLINE void operator = (const DrawableRegion &copy);
00038   virtual ~DrawableRegion();
00039 
00040   INLINE void copy_clear_settings(const DrawableRegion &copy);
00041 
00042 PUBLISHED:
00043   // It seems awkward to have this type, and also
00044   // RenderBuffer::Type.  However, the fact that RenderBuffer::Type
00045   // is a bitmask makes it awfully awkward to work with.
00046   enum RenderTexturePlane {
00047     RTP_stencil=0,
00048     RTP_depth_stencil=1,
00049     RTP_color,
00050     RTP_aux_rgba_0,
00051     RTP_aux_rgba_1,
00052     RTP_aux_rgba_2,
00053     RTP_aux_rgba_3,
00054     RTP_aux_hrgba_0,
00055     RTP_aux_hrgba_1,
00056     RTP_aux_hrgba_2,
00057     RTP_aux_hrgba_3,
00058     RTP_aux_float_0,
00059     RTP_aux_float_1,
00060     RTP_aux_float_2,
00061     RTP_aux_float_3,
00062     RTP_depth,
00063     RTP_COUNT
00064   };
00065 
00066   INLINE void set_clear_color_active(bool clear_color_active);
00067   INLINE bool get_clear_color_active() const;
00068   
00069   INLINE void set_clear_depth_active(bool clear_depth_active);
00070   INLINE bool get_clear_depth_active() const;
00071  
00072   INLINE void set_clear_stencil_active(bool clear_stencil_active);
00073   INLINE bool get_clear_stencil_active() const;
00074 
00075   INLINE void set_clear_color(const LColor &color);
00076   INLINE const LColor &get_clear_color() const;
00077 
00078   INLINE void set_clear_depth(PN_stdfloat depth);
00079   INLINE PN_stdfloat get_clear_depth() const;
00080 
00081   INLINE void set_clear_stencil(unsigned int stencil);
00082   INLINE unsigned int get_clear_stencil() const;
00083 
00084   virtual void set_clear_active(int n, bool clear_aux_active);
00085   virtual bool get_clear_active(int n) const;
00086 
00087   virtual void set_clear_value(int n, const LColor &clear_value);
00088   virtual const LColor &get_clear_value(int n) const;
00089   
00090   virtual void disable_clears();
00091   virtual bool is_any_clear_active() const;
00092 
00093   virtual void set_pixel_zoom(PN_stdfloat pixel_zoom);
00094   INLINE PN_stdfloat get_pixel_zoom() const;
00095   INLINE PN_stdfloat get_pixel_factor() const;
00096   virtual bool supports_pixel_zoom() const;
00097 
00098   static int get_renderbuffer_type(int plane);
00099   
00100 public:
00101   INLINE int get_screenshot_buffer_type() const;
00102   INLINE int get_draw_buffer_type() const;
00103 
00104 protected:
00105   INLINE void update_pixel_factor();
00106   virtual void pixel_factor_changed();
00107 
00108 protected:
00109   int _screenshot_buffer_type;
00110   int _draw_buffer_type;
00111 
00112 private:
00113   bool    _clear_active[RTP_COUNT];
00114   LColor  _clear_value[RTP_COUNT];
00115 
00116   PN_stdfloat _pixel_zoom;
00117   PN_stdfloat _pixel_factor;
00118 };
00119 
00120 
00121 #include "drawableRegion.I"
00122 
00123 #endif
 All Classes Functions Variables Enumerations