Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/display/graphicsWindow.h

Go to the documentation of this file.
00001 // Filename: graphicsWindow.h
00002 // Created by:  mike (09Jan97)
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 GRAPHICSWINDOW_H
00020 #define GRAPHICSWINDOW_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "graphicsWindowInputDevice.h"
00025 #include "windowProperties.h"
00026 #include "graphicsChannel.h"
00027 #include "graphicsPipe.h"
00028 #include "displayRegion.h"
00029 #include "graphicsStateGuardian.h"
00030 #include "clearableRegion.h"
00031 
00032 #include "typedReferenceCount.h"
00033 #include "mouseData.h"
00034 #include "modifierButtons.h"
00035 #include "buttonEvent.h"
00036 #include "iterator_types.h"
00037 #include "notify.h"
00038 #include "pmutex.h"
00039 
00040 #include "pvector.h"
00041 #include "pdeque.h"
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //       Class : GraphicsWindow
00045 // Description : An output medium for receiving the results of
00046 //               rendering.  Typically this is a window on the
00047 //               computer desktop, but it may also be the entire
00048 //               desktop or console screen (i.e. a fullscreen window),
00049 //               or a window on another machine, or even a disk file.
00050 //
00051 //               The GraphicsWindow class handles all of the details
00052 //               about creating a window and its framebuffer, and
00053 //               managing the properties associated with the windowing
00054 //               system, such as position and size and keyboard/mouse
00055 //               input.  The actual rendering, and anything associated
00056 //               with the graphics context itself, is managed by the
00057 //               window's GraphicsStateGuardian.
00058 ////////////////////////////////////////////////////////////////////
00059 class EXPCL_PANDA GraphicsWindow : public TypedReferenceCount, public ClearableRegion {
00060 protected:
00061   GraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg);
00062 
00063 private:
00064   GraphicsWindow(const GraphicsWindow &copy);
00065   void operator = (const GraphicsWindow &copy);
00066 
00067 PUBLISHED:
00068   virtual ~GraphicsWindow();
00069 
00070   WindowProperties get_properties() const;
00071   WindowProperties get_requested_properties() const;
00072   void clear_rejected_properties();
00073   WindowProperties get_rejected_properties() const;
00074   void request_properties(const WindowProperties &requested_properties);
00075   INLINE bool is_closed() const;
00076   INLINE bool is_active() const;
00077   INLINE bool is_fullscreen() const;
00078 
00079   void set_window_event(const string &window_event);
00080   string get_window_event() const;
00081 
00082   INLINE GraphicsStateGuardian *get_gsg() const;
00083   INLINE GraphicsPipe *get_pipe() const;
00084 
00085   GraphicsChannel *get_channel(int index);
00086   void remove_channel(int index);
00087 
00088   int get_max_channel_index() const;
00089   bool is_channel_defined(int index) const;
00090 
00091   int get_num_display_regions() const;
00092   DisplayRegion *get_display_region(int n) const;
00093 
00094   // Mouse and keyboard routines
00095   int get_num_input_devices() const;
00096   string get_input_device_name(int device) const;
00097   bool has_pointer(int device) const;
00098   bool has_keyboard(int device) const;
00099 
00100 public:
00101   // No need to publish these.
00102   MouseData get_mouse_data(int device) const;
00103   bool has_button_event(int device) const;
00104   ButtonEvent get_button_event(int device);
00105 
00106   virtual int verify_window_sizes(int numsizes, int *dimen);
00107 
00108   PT(DisplayRegion) make_scratch_display_region(int x_size, int y_size) const;
00109 
00110 public:
00111   // These are not intended to be called directly by the user.
00112   INLINE void win_display_regions_changed();
00113 
00114 public:
00115   // It is an error to call any of the following methods from any
00116   // thread other than the draw thread.  These methods are normally
00117   // called by the GraphicsEngine.
00118   virtual bool begin_frame();
00119   void clear();
00120   virtual void end_frame();
00121 
00122   // This method is called in the draw thread prior to issuing any
00123   // drawing commands for the window.
00124   virtual void make_current();
00125   virtual void release_gsg();
00126 
00127   // These methods will be called within the app (main) thread.
00128   virtual void begin_flip();
00129   virtual void end_flip();
00130 
00131   // It is an error to call any of the following methods from any
00132   // thread other than the window thread.  These methods are normally
00133   // called by the GraphicsEngine.
00134   virtual void process_events();
00135   virtual void set_properties_now(WindowProperties &properties);
00136 
00137 protected:
00138   virtual void close_window();
00139   virtual bool open_window();
00140   virtual bool do_reshape_request(int x_origin, int y_origin,
00141                                   int x_size, int y_size);
00142 
00143   void declare_channel(int index, GraphicsChannel *chan);
00144 
00145   // It is an error to call any of the following methods from any
00146   // thread other than the window thread.
00147   void system_changed_properties(const WindowProperties &properties);
00148   void system_changed_size(int x_size, int y_size);
00149   
00150 protected:
00151   typedef vector_GraphicsWindowInputDevice InputDevices;
00152   InputDevices _input_devices;
00153   Mutex _input_lock;
00154 
00155   PT(GraphicsStateGuardian) _gsg;
00156   PT(GraphicsPipe) _pipe;
00157 
00158 private:
00159   INLINE void determine_display_regions() const;
00160   void do_determine_display_regions();
00161 
00162 protected:
00163   WindowProperties _properties;
00164 
00165 private:
00166   Mutex _lock; 
00167   // protects _channels, _display_regions, and _requested_properties.
00168 
00169   typedef pvector< PT(GraphicsChannel) > Channels;
00170   Channels _channels;
00171 
00172   typedef pvector<DisplayRegion *> DisplayRegions;
00173   DisplayRegions _display_regions;
00174   bool _display_regions_stale;
00175 
00176   WindowProperties _requested_properties;
00177   WindowProperties _rejected_properties;
00178   string _window_event;
00179   
00180 public:
00181   static TypeHandle get_class_type() {
00182     return _type_handle;
00183   }
00184   static void init_type() {
00185     TypedReferenceCount::init_type();
00186     register_type(_type_handle, "GraphicsWindow",
00187                   TypedReferenceCount::get_class_type());
00188   }
00189   virtual TypeHandle get_type() const {
00190     return get_class_type();
00191   }
00192   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00193 
00194 private:
00195   static TypeHandle _type_handle;
00196 
00197   friend class GraphicsPipe;
00198   friend class GraphicsEngine;
00199 };
00200 
00201 #include "graphicsWindow.I"
00202 
00203 #endif /* GRAPHICSWINDOW_H */

Generated on Fri May 2 00:36:34 2003 for Panda by doxygen1.3