00001 // Filename: graphicsLayer.h 00002 // Created by: drose (18Apr00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef GRAPHICSLAYER_H 00020 #define GRAPHICSLAYER_H 00021 00022 #include "pandabase.h" 00023 00024 #include "displayRegion.h" 00025 #include "typedReferenceCount.h" 00026 #include "pointerTo.h" 00027 #include "pmutex.h" 00028 #include "pvector.h" 00029 00030 class GraphicsChannel; 00031 class GraphicsWindow; 00032 class GraphicsPipe; 00033 class CullHandler; 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Class : GraphicsLayer 00037 // Description : A layer is a collection of non-overlapping 00038 // DisplayRegions within a Channel that will be rendered 00039 // together. When the channel renders, it will render 00040 // all of its layers in index number order; each layer 00041 // may overlap some or all of its DisplayRegions with 00042 // other layers, and they will be drawn sequentially 00043 // without clearing the framebuffer between layers. 00044 //////////////////////////////////////////////////////////////////// 00045 class EXPCL_PANDA GraphicsLayer : public TypedReferenceCount { 00046 private: 00047 GraphicsLayer(); 00048 GraphicsLayer(GraphicsChannel *channel); 00049 00050 private: 00051 GraphicsLayer(const GraphicsLayer ©); 00052 void operator = (const GraphicsLayer ©); 00053 00054 PUBLISHED: 00055 virtual ~GraphicsLayer(); 00056 00057 DisplayRegion *make_display_region(); 00058 DisplayRegion *make_display_region(float l, float r, 00059 float b, float t); 00060 00061 int get_num_drs() const; 00062 DisplayRegion *get_dr(int index) const; 00063 void remove_dr(int index); 00064 bool remove_dr(DisplayRegion *display_region); 00065 00066 GraphicsChannel *get_channel() const; 00067 GraphicsWindow *get_window() const; 00068 GraphicsPipe *get_pipe() const; 00069 00070 void set_active(bool active); 00071 INLINE bool is_active() const; 00072 00073 public: 00074 void channel_resized(int x, int y); 00075 00076 private: 00077 void win_display_regions_changed(); 00078 00079 Mutex _lock; 00080 GraphicsChannel *_channel; 00081 bool _is_active; 00082 00083 typedef pvector< PT(DisplayRegion) > DisplayRegions; 00084 DisplayRegions _display_regions; 00085 00086 00087 public: 00088 static TypeHandle get_class_type() { 00089 return _type_handle; 00090 } 00091 static void init_type() { 00092 TypedReferenceCount::init_type(); 00093 register_type(_type_handle, "GraphicsLayer", 00094 TypedReferenceCount::get_class_type()); 00095 } 00096 virtual TypeHandle get_type() const { 00097 return get_class_type(); 00098 } 00099 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00100 00101 private: 00102 static TypeHandle _type_handle; 00103 00104 friend class GraphicsChannel; 00105 friend class GraphicsWindow; 00106 friend class DisplayRegion; 00107 }; 00108 00109 #include "graphicsLayer.I" 00110 00111 #endif /* GRAPHICSLAYER_H */