Panda3D
pandaFramework.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file pandaFramework.I
10  * @author drose
11  * @date 2002-04-02
12  */
13 
14 /**
15  * Returns the GraphicsEngine that is used to render all the windows in the
16  * framework. Normally there's no reason for user code to mess with this.
17  */
20  if (_engine == nullptr) {
21  _engine = GraphicsEngine::get_global_ptr();
22  PT(GenericAsyncTask) task = new GenericAsyncTask("igloop", task_igloop, this);
23  task->set_sort(50);
24  _task_mgr.add(task);
25  }
26  return _engine;
27 }
28 
29 /**
30  * Returns the root of the data graph. This is the graph of nodes that is
31  * traversed to control the inputs from user devices like the mouse and
32  * keyboard.
33  */
34 INLINE const NodePath &PandaFramework::
35 get_data_root() const {
36  return _data_root;
37 }
38 
39 /**
40  * Returns the EventHandler object that serves events in the framework. This
41  * is primarily used to dispatch on keypresses and such.
42  */
45  return _event_handler;
46 }
47 
48 /**
49  * Returns the Task Manager object that manages tasks in the framework.
50  */
53  return _task_mgr;
54 }
55 
56 /**
57  * Specifies the title that is set for all subsequently created windows.
58  */
59 INLINE void PandaFramework::
60 set_window_title(const std::string &title) {
61  _window_title = title;
62 }
63 
64 /**
65  * Returns the number of windows that are currently open.
66  */
67 INLINE int PandaFramework::
68 get_num_windows() const {
69  return _windows.size();
70 }
71 
72 /**
73  * Returns the nth window currently open.
74  */
76 get_window(int n) const {
77  nassertr(n >= 0 && n < (int)_windows.size(), nullptr);
78  return _windows[n];
79 }
80 
81 /**
82  * Closes the indicated WindowFramework window and removes it from the list.
83  */
84 INLINE void PandaFramework::
86  int n = find_window(wf);
87  if (n >= 0) {
88  close_window(n);
89  }
90 }
91 
92 /**
93  * Returns the current state of the wireframe flag.
94  */
95 INLINE bool PandaFramework::
96 get_wireframe() const {
97  return _wireframe_enabled;
98 }
99 
100 /**
101  * Returns the current state of the texture flag.
102  */
103 INLINE bool PandaFramework::
104 get_texture() const {
105  return _texture_enabled;
106 }
107 
108 /**
109  * Returns the current state of the two_sided flag.
110  */
111 INLINE bool PandaFramework::
112 get_two_sided() const {
113  return _two_sided_enabled;
114 }
115 
116 /**
117  * Returns the current state of the lighting flag.
118  */
119 INLINE bool PandaFramework::
120 get_lighting() const {
121  return _lighting_enabled;
122 }
123 
124 /**
125  * Returns the current state of the perpixel flag.
126  */
127 INLINE bool PandaFramework::
128 get_perpixel() const {
129  return _perpixel_enabled;
130 }
131 
132 /**
133  * Returns the current background type setting.
134  */
135 INLINE WindowFramework::BackgroundType PandaFramework::
137  return _background_type;
138 }
139 
140 /**
141  * Returns true if any node is highlighted, false otherwise.
142  */
143 INLINE bool PandaFramework::
144 has_highlight() const {
145  return !_highlight.is_empty();
146 }
147 
148 /**
149  * Returns the currently highlighted node, if any, or an empty NodePath if no
150  * node is highlighted.
151  */
152 INLINE const NodePath &PandaFramework::
153 get_highlight() const {
154  return _highlight;
155 }
156 
157 /**
158  * Returns the RecorderController that has been associated with the
159  * PandaFramework, if any, or NULL if none has (the normal case).
160  *
161  * If a RecorderController is associated, it will presumably be used for
162  * recording user input to a session file, or for playing back the user input
163  * from a previously-recorded session.
164  */
166 get_recorder() const {
167  return _recorder;
168 }
169 
170 /**
171  * Assigns a RecorderController with the PandaFramework. This should be
172  * called before any windows are opened. The subsequently opened windows will
173  * register their user inputs with the recorder.
174  *
175  * If a RecorderController is associated, it will presumably be used for
176  * recording user input to a session file, or for playing back the user input
177  * from a previously-recorded session.
178  */
179 INLINE void PandaFramework::
181  _recorder = recorder;
182 }
183 
184 /**
185  * Sets the flag that indicates it is time for the application to exit. The
186  * application will actually exit at the end of the current frame.
187  */
188 INLINE void PandaFramework::
190  _exit_flag = true;
191 }
192 
193 /**
194  * Resets the exit flag after it has previously been set.
195  */
196 INLINE void PandaFramework::
198  _exit_flag = false;
199 }
int get_num_windows() const
Returns the number of windows that are currently open.
WindowFramework::BackgroundType get_background_type() const
Returns the current background type setting.
A class to monitor events from the C++ side of things.
Definition: eventHandler.h:37
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:188
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
int find_window(const GraphicsOutput *win) const
Returns the index of the first WindowFramework object found that references the indicated GraphicsOut...
bool get_perpixel() const
Returns the current state of the perpixel flag.
This encapsulates the data that is normally associated with a single window, or with a single display...
void set_exit_flag()
Sets the flag that indicates it is time for the application to exit.
const NodePath & get_highlight() const
Returns the currently highlighted node, if any, or an empty NodePath if no node is highlighted.
const NodePath & get_data_root() const
Returns the root of the data graph.
bool get_lighting() const
Returns the current state of the lighting flag.
void clear_exit_flag()
Resets the exit flag after it has previously been set.
void add(AsyncTask *task)
Adds the indicated task to the active queue.
static AsyncTask::DoneStatus task_igloop(GenericAsyncTask *task, void *data)
Called once per frame to render the scene.
bool has_highlight() const
Returns true if any node is highlighted, false otherwise.
Associates a generic C-style function pointer with an AsyncTask object.
AsyncTaskManager & get_task_mgr()
Returns the Task Manager object that manages tasks in the framework.
void close_window(int n)
Closes the nth window and removes it from the list.
EventHandler & get_event_handler()
Returns the EventHandler object that serves events in the framework.
void set_recorder(RecorderController *recorder)
Assigns a RecorderController with the PandaFramework.
void set_window_title(const std::string &title)
Specifies the title that is set for all subsequently created windows.
RecorderController * get_recorder() const
Returns the RecorderController that has been associated with the PandaFramework, if any,...
This object manages the process of recording the user's runtime inputs to a bam file so that the sess...
This class is the main interface to controlling the render process.
GraphicsEngine * get_graphics_engine()
Returns the GraphicsEngine that is used to render all the windows in the framework.
bool get_two_sided() const
Returns the current state of the two_sided flag.
WindowFramework * get_window(int n) const
Returns the nth window currently open.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
bool get_wireframe() const
Returns the current state of the wireframe flag.
bool get_texture() const
Returns the current state of the texture flag.