forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpandaFramework.h
More file actions
220 lines (174 loc) · 6.71 KB
/
pandaFramework.h
File metadata and controls
220 lines (174 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file pandaFramework.h
* @author drose
* @date 2002-04-02
*/
#ifndef PANDAFRAMEWORK_H
#define PANDAFRAMEWORK_H
#include "pandabase.h"
#include "config_framework.h"
#include "windowFramework.h"
#include "nodePath.h"
#include "eventHandler.h"
#include "graphicsPipe.h"
#include "graphicsEngine.h"
#include "graphicsWindow.h"
#include "recorderController.h"
#include "pointerTo.h"
#include "asyncTaskManager.h"
#include "genericAsyncTask.h"
#include "pvector.h"
/**
* This class serves to provide a high-level framework for basic applications
* that use Panda in simple ways (like opening a window to view models, etc.).
*/
class EXPCL_FRAMEWORK PandaFramework {
public:
PandaFramework();
virtual ~PandaFramework();
void open_framework();
void open_framework(int &argc, char **&argv);
void close_framework();
GraphicsPipe *get_default_pipe();
INLINE GraphicsEngine *get_graphics_engine();
INLINE const NodePath &get_data_root() const;
INLINE EventHandler &get_event_handler();
INLINE AsyncTaskManager &get_task_mgr();
NodePath get_mouse(GraphicsOutput *window);
void remove_mouse(const GraphicsOutput *window);
void define_key(const std::string &event_name,
const std::string &description,
EventHandler::EventCallbackFunction *function,
void *data);
INLINE void set_window_title(const std::string &title);
virtual void get_default_window_props(WindowProperties &props);
WindowFramework *open_window();
WindowFramework *open_window(GraphicsPipe *pipe,
GraphicsStateGuardian *gsg = nullptr);
WindowFramework *open_window(const WindowProperties &props, int flags,
GraphicsPipe *pipe = nullptr,
GraphicsStateGuardian *gsg = nullptr);
INLINE int get_num_windows() const;
INLINE WindowFramework *get_window(int n) const;
int find_window(const GraphicsOutput *win) const;
int find_window(const WindowFramework *wf) const;
void close_window(int n);
INLINE void close_window(WindowFramework *wf);
void close_all_windows();
bool all_windows_closed() const;
NodePath &get_models();
void report_frame_rate(std::ostream &out) const;
void reset_frame_rate();
void set_wireframe(bool enable);
void set_texture(bool enable);
void set_two_sided(bool enable);
void set_lighting(bool enable);
void set_perpixel(bool enable);
void set_background_type(WindowFramework::BackgroundType type);
INLINE bool get_wireframe() const;
INLINE bool get_texture() const;
INLINE bool get_two_sided() const;
INLINE bool get_lighting() const;
INLINE bool get_perpixel() const;
INLINE WindowFramework::BackgroundType get_background_type() const;
static int hide_collision_solids(NodePath node);
static int show_collision_solids(NodePath node);
void set_highlight(const NodePath &node);
void clear_highlight();
INLINE bool has_highlight() const;
INLINE const NodePath &get_highlight() const;
INLINE RecorderController *get_recorder() const;
INLINE void set_recorder(RecorderController *recorder);
void enable_default_keys();
virtual bool do_frame(Thread *current_thread);
void main_loop();
INLINE void set_exit_flag();
INLINE void clear_exit_flag();
public:
static LoaderOptions _loader_options;
protected:
virtual PT(WindowFramework) make_window_framework();
virtual void make_default_pipe();
virtual void do_enable_default_keys();
bool clear_text();
public:
static void event_esc(const Event *, void *data);
static void event_f(const Event *, void *data);
static void event_w(const Event *, void *data);
static void event_t(const Event *, void *data);
static void event_b(const Event *, void *data);
static void event_i(const Event *, void *data);
static void event_l(const Event *, void *data);
static void event_p(const Event *, void *data);
static void event_c(const Event *, void *data);
static void event_a(const Event *, void *data);
static void event_C(const Event *, void *data);
static void event_B(const Event *, void *data);
static void event_L(const Event *, void *data);
static void event_A(const Event *, void *data);
static void event_h(const Event *, void *data);
static void event_arrow_up(const Event *, void *data);
static void event_arrow_down(const Event *, void *data);
static void event_arrow_left(const Event *, void *data);
static void event_arrow_right(const Event *, void *data);
static void event_S(const Event *, void *data);
static void event_f9(const Event *, void *data);
static void event_comma(const Event *, void *data);
static void event_question(const Event * event, void *data);
static void event_window_event(const Event *, void *data);
static AsyncTask::DoneStatus task_data_loop(GenericAsyncTask *task, void *data);
static AsyncTask::DoneStatus task_event(GenericAsyncTask *task, void *data);
static AsyncTask::DoneStatus task_clear_screenshot_text(GenericAsyncTask *task, void *data);
static AsyncTask::DoneStatus task_igloop(GenericAsyncTask *task, void *data);
static AsyncTask::DoneStatus task_record_frame(GenericAsyncTask *task, void *data);
static AsyncTask::DoneStatus task_play_frame(GenericAsyncTask *task, void *data);
static AsyncTask::DoneStatus task_clear_text(GenericAsyncTask *task, void *data);
static AsyncTask::DoneStatus task_garbage_collect(GenericAsyncTask *task, void *data);
private:
bool _is_open;
bool _made_default_pipe;
std::string _window_title;
PT(GraphicsPipe) _default_pipe;
PT(GraphicsEngine) _engine;
NodePath _data_root;
EventHandler &_event_handler;
AsyncTaskManager &_task_mgr;
typedef pvector< PT(WindowFramework) > Windows;
Windows _windows;
typedef pmap< const GraphicsOutput *, NodePath > Mouses;
Mouses _mouses;
NodePath _models;
// For counting frame rate.
double _start_time;
int _frame_count;
bool _wireframe_enabled;
bool _texture_enabled;
bool _two_sided_enabled;
bool _lighting_enabled;
bool _perpixel_enabled;
WindowFramework::BackgroundType _background_type;
NodePath _highlight;
NodePath _highlight_wireframe;
bool _default_keys_enabled;
bool _exit_flag;
class KeyDefinition {
public:
std::string _event_name;
std::string _description;
};
typedef pvector<KeyDefinition> KeyDefinitions;
KeyDefinitions _key_definitions;
NodePath _help_text;
NodePath _screenshot_text;
PT(RecorderController) _recorder;
friend class WindowFramework;
};
#include "pandaFramework.I"
#endif