forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphicsEngine.I
More file actions
174 lines (162 loc) · 6.34 KB
/
graphicsEngine.I
File metadata and controls
174 lines (162 loc) · 6.34 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
/**
* 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 graphicsEngine.I
* @author drose
* @date 2002-02-24
*/
/**
* Returns a ReMutex object that is held by the GraphicsEngine during the
* entire call to render_frame(). While you hold this lock you can be
* confident that no part of the frame will be rendered (at least by the app
* thread).
*/
INLINE const ReMutex &GraphicsEngine::
get_render_lock() const {
return _public_lock;
}
/**
* Set this flag true to indicate the GraphicsEngine should automatically
* cause windows to sync and flip as soon as they have finished drawing,
* rather than waiting for all of the windows to finish drawing first so they
* can flip together.
*
* This only affects the timing of when the flip occurs. If this is true (the
* default), the flip occurs before render_frame() returns. If this is false,
* the flip occurs whenever flip_frame() is called, or at the beginning of the
* next call to render_frame(), if flip_frame() is never called.
*/
INLINE void GraphicsEngine::
set_auto_flip(bool auto_flip) {
// We don't bother with the mutex here. It's just a bool, after all.
_auto_flip = auto_flip;
}
/**
* Returns the current setting for the auto-flip flag. See set_auto_flip.
*/
INLINE bool GraphicsEngine::
get_auto_flip() const {
// We don't bother with the mutex here. It's just a bool, after all.
return _auto_flip;
}
/**
* Set this flag true to indicate the GraphicsEngine should start portal
* culling
*/
INLINE void GraphicsEngine::
set_portal_cull(bool value) {
// We don't bother with the mutex here. It's just a bool, after all.
_portal_enabled = value;
}
/**
* Returns the current setting for the portal culling flag.
*/
INLINE bool GraphicsEngine::
get_portal_cull() const {
// We don't bother with the mutex here. It's just a bool, after all.
return _portal_enabled;
}
/**
* Sets the Loader object that will be assigned to every GSG created with this
* GraphicsEngine. See GraphicsStateGuardian::set_loader().
*/
INLINE void GraphicsEngine::
set_default_loader(Loader *loader) {
_default_loader = loader;
}
/**
* Returns the Loader object that will be assigned to every GSG created with
* this GraphicsEngine. See GraphicsStateGuardian::set_loader().
*/
INLINE Loader *GraphicsEngine::
get_default_loader() const {
return _default_loader;
}
/**
* Calls GraphicsPipe::close_gsg() on the indicated pipe and GSG. This
* function mainly exists to allow GraphicsEngine::WindowRenderer to call the
* protected method GraphicsPipe::close_gsg().
*/
INLINE void GraphicsEngine::
close_gsg(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) {
pipe->close_gsg(gsg);
}
/**
* Syntactic shorthand for make_output. This is the preferred way to create
* an offscreen buffer, when you already have an onscreen window or another
* buffer to start with. For the first parameter, pass an existing
* GraphicsOutput object, e.g. the main window; this allows the buffer to
* adapt itself to that window's framebuffer properties, and allows maximum
* sharing of resources.
*/
INLINE GraphicsOutput *GraphicsEngine::
make_buffer(GraphicsOutput *host, const std::string &name,
int sort, int x_size, int y_size) {
GraphicsOutput *result = make_output(host->get_pipe(), name, sort,
FrameBufferProperties(),
WindowProperties::size(x_size, y_size),
GraphicsPipe::BF_refuse_window |
GraphicsPipe::BF_fb_props_optional,
host->get_gsg(), host);
return result;
}
/**
* Syntactic shorthand for make_output. This flavor accepts a GSG rather than
* a GraphicsOutput as the first parameter, which is too limiting and
* disallows the possibility of creating a ParasiteBuffer if the user's
* graphics hardware prefers that. It also attempts to request specific
* framebuffer properties and may therefore do a poorer job of sharing the GSG
* between the old buffer and the new.
*
* For these reasons, this variant is a poor choice unless you are creating an
* offscreen buffer for the first time, without an onscreen window already in
* existence. If you already have an onscreen window, you should use the
* other flavor of make_buffer() instead, which accepts a GraphicsOutput as
* the first parameter.
*/
INLINE GraphicsOutput *GraphicsEngine::
make_buffer(GraphicsStateGuardian *gsg, const std::string &name,
int sort, int x_size, int y_size) {
FrameBufferProperties fb_props = FrameBufferProperties::get_default();
fb_props.set_back_buffers(0);
fb_props.set_stereo(0);
fb_props.set_accum_bits(0);
fb_props.set_multisamples(0);
fb_props.set_force_hardware(0);
fb_props.set_force_software(0);
GraphicsOutput *result = make_output(gsg->get_pipe(), name, sort,
fb_props,
WindowProperties::size(x_size, y_size),
GraphicsPipe::BF_refuse_window |
GraphicsPipe::BF_fb_props_optional,
gsg, nullptr);
return result;
}
/**
* Syntactic shorthand for make_buffer.
*/
INLINE GraphicsOutput *GraphicsEngine::
make_parasite(GraphicsOutput *host, const std::string &name,
int sort, int x_size, int y_size) {
GraphicsOutput *result = make_output(host->get_pipe(), name, sort,
FrameBufferProperties(),
WindowProperties::size(x_size, y_size),
GraphicsPipe::BF_require_parasite |
GraphicsPipe::BF_fb_props_optional,
host->get_gsg(), host);
return result;
}
/**
* Deprecated variant of dispatch_compute() which takes only a ShaderAttrib
* instead of a whole RenderState.
*/
void GraphicsEngine::
dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, GraphicsStateGuardian *gsg) {
CPT(RenderState) state = RenderState::make(sattr);
dispatch_compute(work_groups, state, gsg);
}