Panda3D
pandaFramework.I
1 // Filename: pandaFramework.I
2 // Created by: drose (02Apr02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PandaFramework::get_graphics_engine
18 // Access: Public
19 // Description: Returns the GraphicsEngine that is used to render all
20 // the windows in the framework. Normally there's no
21 // reason for user code to mess with this.
22 ////////////////////////////////////////////////////////////////////
25  if (_engine == (GraphicsEngine *)NULL) {
26  _engine = GraphicsEngine::get_global_ptr();
27  PT(GenericAsyncTask) task = new GenericAsyncTask("igloop", task_igloop, this);
28  task->set_sort(50);
29  _task_mgr.add(task);
30  }
31  return _engine;
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: PandaFramework::get_data_root
36 // Access: Public
37 // Description: Returns the root of the data graph. This is the
38 // graph of nodes that is traversed to control the
39 // inputs from user devices like the mouse and keyboard.
40 ////////////////////////////////////////////////////////////////////
41 INLINE const NodePath &PandaFramework::
42 get_data_root() const {
43  return _data_root;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: PandaFramework::get_event_handler
48 // Access: Public
49 // Description: Returns the EventHandler object that serves events in
50 // the framework. This is primarily used to dispatch on
51 // keypresses and such.
52 ////////////////////////////////////////////////////////////////////
55  return _event_handler;
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: PandaFramework::get_task_mgr
60 // Access: Public
61 // Description: Returns the Task Manager object that manages tasks in
62 // the framework.
63 ////////////////////////////////////////////////////////////////////
66  return _task_mgr;
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: PandaFramework::set_window_title
71 // Access: Public
72 // Description: Specifies the title that is set for all subsequently
73 // created windows.
74 ////////////////////////////////////////////////////////////////////
75 INLINE void PandaFramework::
76 set_window_title(const string &title) {
77  _window_title = title;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: PandaFramework::get_num_windows
82 // Access: Public
83 // Description: Returns the number of windows that are currently
84 // open.
85 ////////////////////////////////////////////////////////////////////
86 INLINE int PandaFramework::
87 get_num_windows() const {
88  return _windows.size();
89 }
90 
91 ////////////////////////////////////////////////////////////////////
92 // Function: PandaFramework::get_window
93 // Access: Public
94 // Description: Returns the nth window currently open.
95 ////////////////////////////////////////////////////////////////////
97 get_window(int n) const {
98  nassertr(n >= 0 && n < (int)_windows.size(), NULL);
99  return _windows[n];
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: PandaFramework::close_window
104 // Access: Public
105 // Description: Closes the indicated WindowFramework window and
106 // removes it from the list.
107 ////////////////////////////////////////////////////////////////////
108 INLINE void PandaFramework::
110  int n = find_window(wf);
111  if (n >= 0) {
112  close_window(n);
113  }
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: PandaFramework::get_wireframe
118 // Access: Public
119 // Description: Returns the current state of the wireframe flag.
120 ////////////////////////////////////////////////////////////////////
121 INLINE bool PandaFramework::
122 get_wireframe() const {
123  return _wireframe_enabled;
124 }
125 
126 ////////////////////////////////////////////////////////////////////
127 // Function: PandaFramework::get_texture
128 // Access: Public
129 // Description: Returns the current state of the texture flag.
130 ////////////////////////////////////////////////////////////////////
131 INLINE bool PandaFramework::
132 get_texture() const {
133  return _texture_enabled;
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: PandaFramework::get_two_sided
138 // Access: Public
139 // Description: Returns the current state of the two_sided flag.
140 ////////////////////////////////////////////////////////////////////
141 INLINE bool PandaFramework::
142 get_two_sided() const {
143  return _two_sided_enabled;
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: PandaFramework::get_lighting
148 // Access: Public
149 // Description: Returns the current state of the lighting flag.
150 ////////////////////////////////////////////////////////////////////
151 INLINE bool PandaFramework::
152 get_lighting() const {
153  return _lighting_enabled;
154 }
155 
156 ////////////////////////////////////////////////////////////////////
157 // Function: PandaFramework::get_perpixel
158 // Access: Public
159 // Description: Returns the current state of the perpixel flag.
160 ////////////////////////////////////////////////////////////////////
161 INLINE bool PandaFramework::
162 get_perpixel() const {
163  return _perpixel_enabled;
164 }
165 
166 ////////////////////////////////////////////////////////////////////
167 // Function: PandaFramework::get_background_type
168 // Access: Public
169 // Description: Returns the current background type setting.
170 ////////////////////////////////////////////////////////////////////
171 INLINE WindowFramework::BackgroundType PandaFramework::
173  return _background_type;
174 }
175 
176 ////////////////////////////////////////////////////////////////////
177 // Function: PandaFramework::has_highlight
178 // Access: Public
179 // Description: Returns true if any node is highlighted, false
180 // otherwise.
181 ////////////////////////////////////////////////////////////////////
182 INLINE bool PandaFramework::
183 has_highlight() const {
184  return !_highlight.is_empty();
185 }
186 
187 ////////////////////////////////////////////////////////////////////
188 // Function: PandaFramework::get_highlight
189 // Access: Public
190 // Description: Returns the currently highlighted node, if any, or an
191 // empty NodePath if no node is highlighted.
192 ////////////////////////////////////////////////////////////////////
193 INLINE const NodePath &PandaFramework::
194 get_highlight() const {
195  return _highlight;
196 }
197 
198 ////////////////////////////////////////////////////////////////////
199 // Function: PandaFramework::get_recorder
200 // Access: Public
201 // Description: Returns the RecorderController that has been
202 // associated with the PandaFramework, if any, or NULL
203 // if none has (the normal case).
204 //
205 // If a RecorderController is associated, it will
206 // presumably be used for recording user input to a
207 // session file, or for playing back the user input from
208 // a previously-recorded session.
209 ////////////////////////////////////////////////////////////////////
211 get_recorder() const {
212  return _recorder;
213 }
214 
215 ////////////////////////////////////////////////////////////////////
216 // Function: PandaFramework::set_recorder
217 // Access: Public
218 // Description: Assigns a RecorderController with the PandaFramework.
219 // This should be called before any windows are opened.
220 // The subsequently opened windows will register their
221 // user inputs with the recorder.
222 //
223 // If a RecorderController is associated, it will
224 // presumably be used for recording user input to a
225 // session file, or for playing back the user input from
226 // a previously-recorded session.
227 ////////////////////////////////////////////////////////////////////
228 INLINE void PandaFramework::
230  _recorder = recorder;
231 }
232 
233 ////////////////////////////////////////////////////////////////////
234 // Function: PandaFramework::set_exit_flag
235 // Access: Public
236 // Description: Sets the flag that indicates it is time for the
237 // application to exit. The application will actually
238 // exit at the end of the current frame.
239 ////////////////////////////////////////////////////////////////////
240 INLINE void PandaFramework::
242  _exit_flag = true;
243 }
244 
245 ////////////////////////////////////////////////////////////////////
246 // Function: PandaFramework::clear_exit_flag
247 // Access: Public
248 // Description: Resets the exit flag after it has previously been
249 // set.
250 ////////////////////////////////////////////////////////////////////
251 INLINE void PandaFramework::
253  _exit_flag = false;
254 }
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:41
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:236
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 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&#39;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:165
bool get_wireframe() const
Returns the current state of the wireframe flag.
bool get_texture() const
Returns the current state of the texture flag.