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

WindowFramework Class Reference

This encapsulates the data that is normally associated with a single window that we've opened. More...

#include <windowFramework.h>

Inheritance diagram for WindowFramework:

TypedReferenceCount TypedObject ReferenceCount List of all members.

Public Types

enum  BackgroundType {
  BT_other = 0, BT_default, BT_gray, BT_black,
  BT_none
}

Public Member Functions

virtual ~WindowFramework ()
PandaFrameworkget_panda_framework () const
 Returns a pointer to the associated PandaFramework object.

GraphicsWindowget_graphics_window () const
 Returns a pointer to the underlying GraphicsWindow object.

const NodePathget_camera_group ()
 Returns the node above the collection of 3-d cameras in the scene graph.

int get_num_cameras () const
 Returns the number of 3-d cameras associated with the window.

Cameraget_camera (int n) const
 Returns the nth camera associated with the window.

const NodePathget_render ()
 Returns the root of the 3-d scene graph.

const NodePathget_render_2d ()
 Returns the root of the 2-d scene graph.

const NodePathget_aspect_2d ()
 Returns the node under the 2-d scene graph that is scaled to suit the window's aspect ratio.

const NodePathget_mouse ()
 Returns the node in the data graph corresponding to the mouse associated with this window.

void enable_keyboard ()
 Creates a ButtonThrower to listen to button presses and throw them as events.

void setup_trackball ()
 Sets up the mouse to trackball around the camera.

void center_trackball (const NodePath &object)
 Centers the trackball on the indicated object, and scales the trackball motion suitably.

bool load_models (const NodePath &parent, int argc, char *argv[], int first_arg=1)
 Loads up all the model files listed in the indicated argument list.

bool load_models (const NodePath &parent, const pvector< Filename > &files)
 Loads up all the model files listed in the indicated argument list.

NodePath load_model (const NodePath &parent, Filename filename)
 Loads up the indicated model and returns the new NodePath, or the empty NodePath if the model could not be loaded.

NodePath load_default_model (const NodePath &parent)
 Loads our favorite blue triangle.

void loop_animations ()
 Looks for characters and their matching animation files in the scene graph; binds and loops any matching animations found.

void set_wireframe (bool enable)
 Forces wireframe state (true) or restores default rendering (false).

void set_texture (bool enable)
 Forces textures off (false) or restores default rendering (true).

void set_two_sided (bool enable)
 Forces two-sided rendering (true) or restores default rendering (false).

void set_one_sided_reverse (bool enable)
 Toggles one-sided reverse mode.

void set_lighting (bool enable)
 Turns lighting on (true) or off (false).

void set_background_type (BackgroundType type)
 Sets the background of the window to one of the pre-canned background types (or to BT_other, which indicates the user intends to set up his own special background mode).

bool get_wireframe () const
 Returns the current state of the wireframe flag.

bool get_texture () const
 Returns the current state of the texture flag.

bool get_two_sided () const
 Returns the current state of the two_sided flag.

bool get_one_sided_reverse () const
 Returns the current state of the one_sided_reverse flag.

bool get_lighting () const
 Returns the current state of the lighting flag.

BackgroundType get_background_type () const
 Returns the current background type setting.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.

bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.

int get_ref_count () const
 Returns the current reference count.

int ref () const
 Explicitly increments the reference count.

int unref () const
 Explicitly decrements the reference count.

void test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.


Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Protected Member Functions

 WindowFramework (PandaFramework *panda_framework)
GraphicsWindowopen_window (const WindowProperties &props, GraphicsEngine *engine, GraphicsPipe *pipe)
 Opens the actual window.

void close_window ()
 Closes the window.

PointerTo< Cameramake_camera ()
 Makes a new 3-d camera for the window.

void setup_lights ()
 Makes light nodes and attaches them to the camera for viewing the scene.


Private Types

typedef pvector< PointerTo<
Camera > > 
Cameras

Private Member Functions

PointerTo< PandaNodeload_image_as_model (const Filename &filename)
 Loads the indicated image file as a texture, and creates a polygon to render it.


Private Attributes

PandaFramework_panda_framework
PointerTo< GraphicsWindow_window
NodePath _camera_group
Cameras _cameras
NodePath _render
NodePath _render_2d
NodePath _aspect_2d
AnimControlCollection _anim_controls
NodePath _mouse
PointerTo< Trackball_trackball
AmbientLight_alight
DirectionalLight_dlight
bool _got_keyboard
bool _got_trackball
bool _got_lights
bool _wireframe_enabled
bool _texture_enabled
bool _two_sided_enabled
bool _one_sided_reverse_enabled
bool _lighting_enabled
BackgroundType _background_type

Static Private Attributes

TypeHandle _type_handle

Friends

class PandaFramework

Detailed Description

This encapsulates the data that is normally associated with a single window that we've opened.

Definition at line 51 of file windowFramework.h.


Member Typedef Documentation

typedef pvector< PointerTo< Camera > > WindowFramework::Cameras [private]
 

Definition at line 121 of file windowFramework.h.


Member Enumeration Documentation

enum WindowFramework::BackgroundType
 

Enumeration values:
BT_other 
BT_default 
BT_gray 
BT_black 
BT_none 

Definition at line 87 of file windowFramework.h.

Referenced by PandaFramework::event_C(), get_two_sided(), and PandaFramework::get_wireframe().


Constructor & Destructor Documentation

WindowFramework::WindowFramework PandaFramework panda_framework  )  [protected]
 

Definition at line 69 of file windowFramework.cxx.

References _background_type, _got_lights, _got_trackball, _lighting_enabled, _one_sided_reverse_enabled, _texture_enabled, _two_sided_enabled, _wireframe_enabled, and BT_default.

WindowFramework::~WindowFramework  )  [virtual]
 

Definition at line 94 of file windowFramework.cxx.

References _window, GraphicsEngine::make_gsg(), GraphicsEngine::make_window(), nassertr, NULL, and PT.


Member Function Documentation

void WindowFramework::center_trackball const NodePath object  ) 
 

Centers the trackball on the indicated object, and scales the trackball motion suitably.

Definition at line 394 of file windowFramework.cxx.

Referenced by PandaFramework::do_enable_default_keys().

void WindowFramework::close_window  )  [protected]
 

Closes the window.

This is normally called from PandaFramework::close_window().

Definition at line 142 of file windowFramework.cxx.

References _lighting_enabled.

Referenced by PandaFramework::find_window().

void WindowFramework::enable_keyboard  ) 
 

Creates a ButtonThrower to listen to button presses and throw them as events.

Definition at line 332 of file windowFramework.cxx.

References _trackball, and tball2cam.

Referenced by event_W().

virtual TypeHandle WindowFramework::force_init_type void   )  [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Definition at line 159 of file windowFramework.h.

const NodePath & WindowFramework::get_aspect_2d  ) 
 

Returns the node under the 2-d scene graph that is scaled to suit the window's aspect ratio.

Definition at line 274 of file windowFramework.cxx.

References _mouse, _panda_framework, _window, data_root, PandaFramework::get_data_root(), NodePath::is_empty(), and nassertr.

WindowFramework::BackgroundType WindowFramework::get_background_type  )  const [inline]
 

Returns the current background type setting.

Definition at line 160 of file windowFramework.I.

Referenced by PandaFramework::event_C().

Camera * WindowFramework::get_camera int  n  )  const [inline]
 

Returns the nth camera associated with the window.

Definition at line 81 of file windowFramework.I.

References _texture_enabled, and INLINE.

const NodePath & WindowFramework::get_camera_group  ) 
 

Returns the node above the collection of 3-d cameras in the scene graph.

This node may be moved around to represent the viewpoint.

Definition at line 175 of file windowFramework.cxx.

References _render_2d, and NodePath::is_empty().

Referenced by set_one_sided_reverse().

TypeHandle WindowFramework::get_class_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Definition at line 148 of file windowFramework.h.

GraphicsWindow * WindowFramework::get_graphics_window  )  const [inline]
 

Returns a pointer to the underlying GraphicsWindow object.

Definition at line 49 of file windowFramework.I.

References _cameras, and INLINE.

Referenced by PandaFramework::find_window().

bool WindowFramework::get_lighting  )  const [inline]
 

Returns the current state of the lighting flag.

Definition at line 147 of file windowFramework.I.

Referenced by PandaFramework::make_default_pipe().

const NodePath & WindowFramework::get_mouse  ) 
 

Returns the node in the data graph corresponding to the mouse associated with this window.

Definition at line 310 of file windowFramework.cxx.

References _got_keyboard.

int WindowFramework::get_num_cameras  )  const [inline]
 

Returns the number of 3-d cameras associated with the window.

A window usually has only one camera, but it may have multiple cameras if there are multiple display regions within the window.

Definition at line 68 of file windowFramework.I.

References _wireframe_enabled, and INLINE.

bool WindowFramework::get_one_sided_reverse  )  const [inline]
 

Returns the current state of the one_sided_reverse flag.

Definition at line 134 of file windowFramework.I.

Referenced by PandaFramework::make_window_framework().

PandaFramework * WindowFramework::get_panda_framework  )  const [inline]
 

Returns a pointer to the associated PandaFramework object.

Definition at line 34 of file windowFramework.I.

References _window, and INLINE.

int ReferenceCount::get_ref_count  )  const [inline, inherited]
 

Returns the current reference count.

Definition at line 183 of file referenceCount.I.

Referenced by RenderState::determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture().

const NodePath & WindowFramework::get_render  ) 
 

Returns the root of the 3-d scene graph.

Definition at line 191 of file windowFramework.cxx.

References _render_2d, and _window.

Referenced by event_W().

const NodePath & WindowFramework::get_render_2d  ) 
 

Returns the root of the 2-d scene graph.

Definition at line 210 of file windowFramework.cxx.

References _render_2d.

bool WindowFramework::get_texture  )  const [inline]
 

Returns the current state of the texture flag.

Definition at line 108 of file windowFramework.I.

References _lighting_enabled, and INLINE.

bool WindowFramework::get_two_sided  )  const [inline]
 

Returns the current state of the two_sided flag.

Definition at line 121 of file windowFramework.I.

References _background_type, BackgroundType, and INLINE.

Referenced by PandaFramework::main_loop().

virtual TypeHandle WindowFramework::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Definition at line 156 of file windowFramework.h.

int TypedObject::get_type_index  )  const [inline, inherited]
 

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

bool WindowFramework::get_wireframe  )  const [inline]
 

Returns the current state of the wireframe flag.

Definition at line 95 of file windowFramework.I.

References _one_sided_reverse_enabled, and INLINE.

void WindowFramework::init_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Definition at line 151 of file windowFramework.h.

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is the indicated type exactly.

Definition at line 101 of file typedObject.I.

Referenced by PT(), and CollisionNode::xform().

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is or derives from the indicated type.

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

NodePath WindowFramework::load_default_model const NodePath parent  ) 
 

Loads our favorite blue triangle.

This is intended to provide some default geometry to have *something* to look at for testing, when no other models are provided.

Definition at line 601 of file windowFramework.cxx.

PointerTo< PandaNode > WindowFramework::load_image_as_model const Filename filename  )  [private]
 

Loads the indicated image file as a texture, and creates a polygon to render it.

Returns the new model.

Definition at line 950 of file windowFramework.cxx.

NodePath WindowFramework::load_model const NodePath parent,
Filename  filename
 

Loads up the indicated model and returns the new NodePath, or the empty NodePath if the model could not be loaded.

Definition at line 542 of file windowFramework.cxx.

References NULL, and tex.

bool WindowFramework::load_models const NodePath parent,
const pvector< Filename > &  files
 

Loads up all the model files listed in the indicated argument list.

Returns true if all models loaded successfully, or false if at least one of them had an error.

Definition at line 512 of file windowFramework.cxx.

References nout.

bool WindowFramework::load_models const NodePath parent,
int  argc,
char *  argv[],
int  first_arg = 1
 

Loads up all the model files listed in the indicated argument list.

If first_arg is supplied, it is the first argument in the list to consider.

Returns true if all models loaded successfully, or false if at least one of them had an error.

Definition at line 485 of file windowFramework.cxx.

References NULL.

void WindowFramework::loop_animations  ) 
 

Looks for characters and their matching animation files in the scene graph; binds and loops any matching animations found.

Definition at line 654 of file windowFramework.cxx.

PointerTo< Camera > WindowFramework::make_camera  )  [protected]
 

Makes a new 3-d camera for the window.

Definition at line 878 of file windowFramework.cxx.

GraphicsWindow * WindowFramework::open_window const WindowProperties props,
GraphicsEngine engine,
GraphicsPipe pipe
[protected]
 

Opens the actual window.

This is normally called only from PandaFramework::open_window().

Definition at line 109 of file windowFramework.cxx.

References _window.

int ReferenceCount::ref  )  const [inline, inherited]
 

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 225 of file referenceCount.I.

Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering().

void WindowFramework::set_background_type WindowFramework::BackgroundType  type  ) 
 

Sets the background of the window to one of the pre-canned background types (or to BT_other, which indicates the user intends to set up his own special background mode).

Definition at line 831 of file windowFramework.cxx.

References PointerToArray< int >::empty_array(), Texture::FT_linear, Texture::FT_linear_mipmap_linear, PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), NULL, PT, PointerToArray< TexCoordf >::push_back(), PointerToArray< Vertexf >::push_back(), PointerToArray< int >::push_back(), Texture::read(), PNMImageHeader::read_header(), Geom::set_coords(), Geom::set_lengths(), Texture::set_magfilter(), Texture::set_minfilter(), Geom::set_num_prims(), tex, and TexCoordf.

Referenced by PandaFramework::event_C().

void WindowFramework::set_lighting bool  enable  ) 
 

Turns lighting on (true) or off (false).

Definition at line 796 of file windowFramework.cxx.

Referenced by PandaFramework::make_default_pipe().

void WindowFramework::set_one_sided_reverse bool  enable  ) 
 

Toggles one-sided reverse mode.

In this mode, the front sides of one-sided polygons are culled instead of the back side.

Definition at line 767 of file windowFramework.cxx.

References _cameras, _window, NodePath::attach_new_node(), get_camera_group(), WindowProperties::get_x_size(), WindowProperties::get_y_size(), WindowProperties::has_size(), PT, and Lens::set_film_size().

Referenced by PandaFramework::make_window_framework().

void WindowFramework::set_texture bool  enable  ) 
 

Forces textures off (false) or restores default rendering (true).

Definition at line 708 of file windowFramework.cxx.

void WindowFramework::set_two_sided bool  enable  ) 
 

Forces two-sided rendering (true) or restores default rendering (false).

Definition at line 735 of file windowFramework.cxx.

References _window, BT_black, BT_default, BT_gray, and BT_none.

Referenced by PandaFramework::main_loop().

void WindowFramework::set_wireframe bool  enable  ) 
 

Forces wireframe state (true) or restores default rendering (false).

Definition at line 673 of file windowFramework.cxx.

References _one_sided_reverse_enabled.

void WindowFramework::setup_lights  )  [protected]
 

Makes light nodes and attaches them to the camera for viewing the scene.

Definition at line 920 of file windowFramework.cxx.

void WindowFramework::setup_trackball  ) 
 

Sets up the mouse to trackball around the camera.

Definition at line 362 of file windowFramework.cxx.

Referenced by event_W().

void ReferenceCount::test_ref_count_integrity  )  const [inline, inherited]
 

Does some easy checks to make sure that the reference count isn't completely bogus.

Definition at line 328 of file referenceCount.I.

References INLINE.

Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount().

int ReferenceCount::unref  )  const [inline, inherited]
 

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 293 of file referenceCount.I.

References INLINE.

Referenced by RenderState::determine_bin_index(), and RenderEffects::determine_show_bounds().


Friends And Related Function Documentation

friend class PandaFramework [friend]
 

Definition at line 164 of file windowFramework.h.


Member Data Documentation

AmbientLight* WindowFramework::_alight [private]
 

Definition at line 132 of file windowFramework.h.

AnimControlCollection WindowFramework::_anim_controls [private]
 

Definition at line 127 of file windowFramework.h.

NodePath WindowFramework::_aspect_2d [private]
 

Definition at line 126 of file windowFramework.h.

BackgroundType WindowFramework::_background_type [private]
 

Definition at line 145 of file windowFramework.h.

Referenced by get_two_sided(), and WindowFramework().

NodePath WindowFramework::_camera_group [private]
 

Definition at line 120 of file windowFramework.h.

Cameras WindowFramework::_cameras [private]
 

Definition at line 122 of file windowFramework.h.

Referenced by get_graphics_window(), and set_one_sided_reverse().

DirectionalLight* WindowFramework::_dlight [private]
 

Definition at line 133 of file windowFramework.h.

bool WindowFramework::_got_keyboard [private]
 

Definition at line 135 of file windowFramework.h.

Referenced by get_mouse().

bool WindowFramework::_got_lights [private]
 

Definition at line 137 of file windowFramework.h.

Referenced by WindowFramework().

bool WindowFramework::_got_trackball [private]
 

Definition at line 136 of file windowFramework.h.

Referenced by WindowFramework().

bool WindowFramework::_lighting_enabled [private]
 

Definition at line 143 of file windowFramework.h.

Referenced by close_window(), get_texture(), and WindowFramework().

NodePath WindowFramework::_mouse [private]
 

Definition at line 129 of file windowFramework.h.

Referenced by get_aspect_2d().

bool WindowFramework::_one_sided_reverse_enabled [private]
 

Definition at line 142 of file windowFramework.h.

Referenced by get_wireframe(), set_wireframe(), and WindowFramework().

PandaFramework* WindowFramework::_panda_framework [private]
 

Definition at line 117 of file windowFramework.h.

Referenced by get_aspect_2d().

NodePath WindowFramework::_render [private]
 

Definition at line 124 of file windowFramework.h.

NodePath WindowFramework::_render_2d [private]
 

Definition at line 125 of file windowFramework.h.

Referenced by get_camera_group(), get_render(), and get_render_2d().

bool WindowFramework::_texture_enabled [private]
 

Definition at line 140 of file windowFramework.h.

Referenced by get_camera(), and WindowFramework().

PointerTo< Trackball > WindowFramework::_trackball [private]
 

Definition at line 130 of file windowFramework.h.

Referenced by enable_keyboard().

bool WindowFramework::_two_sided_enabled [private]
 

Definition at line 141 of file windowFramework.h.

Referenced by WindowFramework().

TypeHandle WindowFramework::_type_handle [static, private]
 

Reimplemented from TypedReferenceCount.

Definition at line 58 of file windowFramework.cxx.

PointerTo< GraphicsWindow > WindowFramework::_window [private]
 

Definition at line 118 of file windowFramework.h.

Referenced by get_aspect_2d(), get_panda_framework(), get_render(), open_window(), set_one_sided_reverse(), set_two_sided(), and ~WindowFramework().

bool WindowFramework::_wireframe_enabled [private]
 

Definition at line 139 of file windowFramework.h.

Referenced by get_num_cameras(), and WindowFramework().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:56:27 2003 for Panda by doxygen1.3