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

panda/src/framework/windowFramework.h

Go to the documentation of this file.
00001 // Filename: windowFramework.h
00002 // Created by:  drose (02Apr02)
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 WINDOWFRAMEWORK_H
00020 #define WINDOWFRAMEWORK_H
00021 
00022 #include "pandabase.h"
00023 #include "nodePath.h"
00024 #include "camera.h"
00025 #include "graphicsWindow.h"
00026 #include "animControlCollection.h"
00027 #include "trackball.h"
00028 #include "filename.h"
00029 #include "pointerTo.h"
00030 #include "pvector.h"
00031 #include "typedReferenceCount.h"
00032 
00033 class PandaFramework;
00034 class AmbientLight;
00035 class DirectionalLight;
00036 class GraphicsEngine;
00037 class GraphicsPipe;
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //       Class : WindowFramework
00041 // Description : This encapsulates the data that is normally
00042 //               associated with a single window that we've opened.
00043 ////////////////////////////////////////////////////////////////////
00044 class EXPCL_FRAMEWORK WindowFramework : public TypedReferenceCount {
00045 protected:
00046   WindowFramework(PandaFramework *panda_framework);
00047 public:
00048   virtual ~WindowFramework();
00049 
00050 protected:
00051   GraphicsWindow *open_window(const WindowProperties &props,
00052                               GraphicsEngine *engine, GraphicsPipe *pipe);
00053   void close_window();
00054 
00055 public:
00056   INLINE PandaFramework *get_panda_framework() const;
00057   INLINE GraphicsWindow *get_graphics_window() const;
00058   const NodePath &get_camera_group();
00059 
00060   INLINE int get_num_cameras() const;
00061   INLINE Camera *get_camera(int n) const;
00062 
00063   const NodePath &get_render();
00064   const NodePath &get_render_2d();
00065   const NodePath &get_aspect_2d();
00066   const NodePath &get_mouse();
00067 
00068   void enable_keyboard();
00069   void setup_trackball();
00070   void center_trackball(const NodePath &object);
00071 
00072   bool load_models(const NodePath &parent,
00073                    int argc, char *argv[], int first_arg = 1);
00074   bool load_models(const NodePath &parent,
00075                    const pvector<Filename> &files);
00076   NodePath load_model(const NodePath &parent, Filename filename);
00077   NodePath load_default_model(const NodePath &parent);
00078   void loop_animations();
00079 
00080   enum BackgroundType {
00081     BT_other = 0,
00082     BT_default,
00083     BT_gray,
00084     BT_black,
00085     BT_none
00086   };
00087 
00088   void set_wireframe(bool enable);
00089   void set_texture(bool enable);
00090   void set_two_sided(bool enable);
00091   void set_one_sided_reverse(bool enable);
00092   void set_lighting(bool enable);
00093   void set_background_type(BackgroundType type);
00094 
00095   INLINE bool get_wireframe() const;
00096   INLINE bool get_texture() const;
00097   INLINE bool get_two_sided() const;
00098   INLINE bool get_one_sided_reverse() const;
00099   INLINE bool get_lighting() const;
00100   INLINE BackgroundType get_background_type() const;
00101 
00102 protected:
00103   PT(Camera) make_camera();
00104   void setup_lights();
00105 
00106 private:
00107   PT(PandaNode) load_image_as_model(const Filename &filename);
00108 
00109 private:
00110   PandaFramework *_panda_framework;
00111   PT(GraphicsWindow) _window;
00112 
00113   NodePath _camera_group;
00114   typedef pvector< PT(Camera) > Cameras;
00115   Cameras _cameras;
00116 
00117   NodePath _render;
00118   NodePath _render_2d;
00119   NodePath _aspect_2d;
00120   AnimControlCollection _anim_controls;
00121 
00122   NodePath _mouse;
00123   PT(Trackball) _trackball;
00124 
00125   AmbientLight *_alight;
00126   DirectionalLight *_dlight;
00127   
00128   bool _got_keyboard;
00129   bool _got_trackball;
00130   bool _got_lights;
00131 
00132   bool _wireframe_enabled;
00133   bool _texture_enabled;
00134   bool _two_sided_enabled;
00135   bool _one_sided_reverse_enabled;
00136   bool _lighting_enabled;
00137 
00138   BackgroundType _background_type;
00139 
00140 public:
00141   static TypeHandle get_class_type() {
00142     return _type_handle;
00143   }
00144   static void init_type() {
00145     TypedReferenceCount::init_type();
00146     register_type(_type_handle, "WindowFramework",
00147                   TypedReferenceCount::get_class_type());
00148   }
00149   virtual TypeHandle get_type() const {
00150     return get_class_type();
00151   }
00152   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00153 
00154 private:
00155   static TypeHandle _type_handle;
00156 
00157   friend class PandaFramework;
00158 };
00159 
00160 #include "windowFramework.I"
00161 
00162 #endif

Generated on Fri May 2 00:38:55 2003 for Panda by doxygen1.3