Panda3D
graphicsEngine.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 graphicsEngine.I
10  * @author drose
11  * @date 2002-02-24
12  */
13 
14 /**
15  * Returns a ReMutex object that is held by the GraphicsEngine during the
16  * entire call to render_frame(). While you hold this lock you can be
17  * confident that no part of the frame will be rendered (at least by the app
18  * thread).
19  */
20 INLINE const ReMutex &GraphicsEngine::
21 get_render_lock() const {
22  return _public_lock;
23 }
24 
25 /**
26  * Set this flag true to indicate the GraphicsEngine should automatically
27  * cause windows to sync and flip as soon as they have finished drawing,
28  * rather than waiting for all of the windows to finish drawing first so they
29  * can flip together.
30  *
31  * This only affects the timing of when the flip occurs. If this is true (the
32  * default), the flip occurs before render_frame() returns. If this is false,
33  * the flip occurs whenever flip_frame() is called, or at the beginning of the
34  * next call to render_frame(), if flip_frame() is never called.
35  */
36 INLINE void GraphicsEngine::
37 set_auto_flip(bool auto_flip) {
38  // We don't bother with the mutex here. It's just a bool, after all.
39  _auto_flip = auto_flip;
40 }
41 
42 /**
43  * Returns the current setting for the auto-flip flag. See set_auto_flip.
44  */
45 INLINE bool GraphicsEngine::
46 get_auto_flip() const {
47  // We don't bother with the mutex here. It's just a bool, after all.
48  return _auto_flip;
49 }
50 
51 /**
52  * Set this flag true to indicate the GraphicsEngine should start portal
53  * culling
54  */
55 INLINE void GraphicsEngine::
56 set_portal_cull(bool value) {
57  // We don't bother with the mutex here. It's just a bool, after all.
58  _portal_enabled = value;
59 }
60 
61 /**
62  * Returns the current setting for the portal culling flag.
63  */
64 INLINE bool GraphicsEngine::
65 get_portal_cull() const {
66  // We don't bother with the mutex here. It's just a bool, after all.
67  return _portal_enabled;
68 }
69 
70 /**
71  * Sets the Loader object that will be assigned to every GSG created with this
72  * GraphicsEngine. See GraphicsStateGuardian::set_loader().
73  */
74 INLINE void GraphicsEngine::
75 set_default_loader(Loader *loader) {
76  _default_loader = loader;
77 }
78 
79 /**
80  * Returns the Loader object that will be assigned to every GSG created with
81  * this GraphicsEngine. See GraphicsStateGuardian::set_loader().
82  */
83 INLINE Loader *GraphicsEngine::
84 get_default_loader() const {
85  return _default_loader;
86 }
87 
88 /**
89  * Calls GraphicsPipe::close_gsg() on the indicated pipe and GSG. This
90  * function mainly exists to allow GraphicsEngine::WindowRenderer to call the
91  * protected method GraphicsPipe::close_gsg().
92  */
93 INLINE void GraphicsEngine::
94 close_gsg(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) {
95  pipe->close_gsg(gsg);
96 }
97 
98 /**
99  * Syntactic shorthand for make_output. This is the preferred way to create
100  * an offscreen buffer, when you already have an onscreen window or another
101  * buffer to start with. For the first parameter, pass an existing
102  * GraphicsOutput object, e.g. the main window; this allows the buffer to
103  * adapt itself to that window's framebuffer properties, and allows maximum
104  * sharing of resources.
105  */
107 make_buffer(GraphicsOutput *host, const std::string &name,
108  int sort, int x_size, int y_size) {
109  GraphicsOutput *result = make_output(host->get_pipe(), name, sort,
111  WindowProperties::size(x_size, y_size),
112  GraphicsPipe::BF_refuse_window |
113  GraphicsPipe::BF_fb_props_optional,
114  host->get_gsg(), host);
115  return result;
116 }
117 
118 /**
119  * Syntactic shorthand for make_output. This flavor accepts a GSG rather than
120  * a GraphicsOutput as the first parameter, which is too limiting and
121  * disallows the possibility of creating a ParasiteBuffer if the user's
122  * graphics hardware prefers that. It also attempts to request specific
123  * framebuffer properties and may therefore do a poorer job of sharing the GSG
124  * between the old buffer and the new.
125  *
126  * For these reasons, this variant is a poor choice unless you are creating an
127  * offscreen buffer for the first time, without an onscreen window already in
128  * existence. If you already have an onscreen window, you should use the
129  * other flavor of make_buffer() instead, which accepts a GraphicsOutput as
130  * the first parameter.
131  */
133 make_buffer(GraphicsStateGuardian *gsg, const std::string &name,
134  int sort, int x_size, int y_size) {
136  fb_props.set_back_buffers(0);
137  fb_props.set_stereo(0);
138  fb_props.set_accum_bits(0);
139  fb_props.set_multisamples(0);
140  fb_props.set_force_hardware(0);
141  fb_props.set_force_software(0);
142  GraphicsOutput *result = make_output(gsg->get_pipe(), name, sort,
143  fb_props,
144  WindowProperties::size(x_size, y_size),
145  GraphicsPipe::BF_refuse_window |
146  GraphicsPipe::BF_fb_props_optional,
147  gsg, nullptr);
148  return result;
149 }
150 
151 /**
152  * Syntactic shorthand for make_buffer.
153  */
155 make_parasite(GraphicsOutput *host, const std::string &name,
156  int sort, int x_size, int y_size) {
157  GraphicsOutput *result = make_output(host->get_pipe(), name, sort,
159  WindowProperties::size(x_size, y_size),
160  GraphicsPipe::BF_require_parasite |
161  GraphicsPipe::BF_fb_props_optional,
162  host->get_gsg(), host);
163  return result;
164 }
static const FrameBufferProperties & get_default()
Returns a FrameBufferProperties structure with all of the default values filled in according to the u...
set_default_loader
Sets the Loader object that will be assigned to every GSG created with this GraphicsEngine.
get_pipe
Returns the graphics pipe on which this GSG was created.
GraphicsOutput * make_parasite(GraphicsOutput *host, const std::string &name, int sort, int x_size, int y_size)
Syntactic shorthand for make_buffer.
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
Definition: loader.h:42
static WindowProperties size(const LVecBase2i &size)
Returns a WindowProperties structure with only the size specified.
GraphicsOutput * make_output(GraphicsPipe *pipe, const std::string &name, int sort, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg=nullptr, GraphicsOutput *host=nullptr)
Creates a new window (or buffer) and returns it.
set_auto_flip
Set this flag true to indicate the GraphicsEngine should automatically cause windows to sync and flip...
get_pipe
Returns the GraphicsPipe that this window is associated with.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:52
set_portal_cull
Set this flag true to indicate the GraphicsEngine should start portal culling.
This is a base class for the various different classes that represent the result of a frame of render...
GraphicsOutput * make_buffer(GraphicsOutput *host, const std::string &name, int sort, int x_size, int y_size)
Syntactic shorthand for make_output.
Encapsulates all the communication with a particular instance of a given rendering backend.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
get_gsg
Returns the GSG that is associated with this window.
A reentrant mutex.
Definition: reMutex.h:32