Panda3D
|
00001 // Filename: graphicsEngine.I 00002 // Created by: drose (24Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: GraphicsEngine::set_auto_flip 00018 // Access: Published 00019 // Description: Set this flag true to indicate the GraphicsEngine 00020 // should automatically cause windows to sync and flip 00021 // as soon as they have finished drawing, rather than 00022 // waiting for all of the windows to finish drawing 00023 // first so they can flip together. 00024 // 00025 // This only affects the timing of when the flip occurs. 00026 // If this is true (the default), the flip occurs before 00027 // render_frame() returns. If this is false, the flip 00028 // occurs whenever flip_frame() is called, or at the 00029 // beginning of the next call to render_frame(), if 00030 // flip_frame() is never called. 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE void GraphicsEngine:: 00033 set_auto_flip(bool auto_flip) { 00034 // We don't bother with the mutex here. It's just a bool, after 00035 // all. 00036 _auto_flip = auto_flip; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: GraphicsEngine::get_auto_flip 00041 // Access: Published 00042 // Description: Returns the current setting for the auto-flip flag. 00043 // See set_auto_flip. 00044 //////////////////////////////////////////////////////////////////// 00045 INLINE bool GraphicsEngine:: 00046 get_auto_flip() const { 00047 // We don't bother with the mutex here. It's just a bool, after 00048 // all. 00049 return _auto_flip; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: GraphicsEngine::set_portal_cull 00054 // Access: Published 00055 // Description: Set this flag true to indicate the GraphicsEngine 00056 // should start portal culling 00057 //////////////////////////////////////////////////////////////////// 00058 INLINE void GraphicsEngine:: 00059 set_portal_cull(bool value) { 00060 // We don't bother with the mutex here. It's just a bool, after 00061 // all. 00062 _portal_enabled = value; 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: GraphicsEngine::get_portal_cull 00067 // Access: Published 00068 // Description: Returns the current setting for the portal culling flag. 00069 //////////////////////////////////////////////////////////////////// 00070 INLINE bool GraphicsEngine:: 00071 get_portal_cull() const { 00072 // We don't bother with the mutex here. It's just a bool, after 00073 // all. 00074 return _portal_enabled; 00075 } 00076 00077 //////////////////////////////////////////////////////////////////// 00078 // Function: GraphicsEngine::set_default_loader 00079 // Access: Public 00080 // Description: Sets the Loader object that will be assigned to every 00081 // GSG created with this GraphicsEngine. See 00082 // GraphicsStateGuardian::set_loader(). 00083 //////////////////////////////////////////////////////////////////// 00084 INLINE void GraphicsEngine:: 00085 set_default_loader(Loader *loader) { 00086 _default_loader = loader; 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: GraphicsEngine::get_default_loader 00091 // Access: Public, Virtual 00092 // Description: Returns the Loader object that will be assigned to 00093 // every GSG created with this GraphicsEngine. See 00094 // GraphicsStateGuardian::set_loader(). 00095 //////////////////////////////////////////////////////////////////// 00096 INLINE Loader *GraphicsEngine:: 00097 get_default_loader() const { 00098 return _default_loader; 00099 } 00100 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: GraphicsEngine::close_gsg 00103 // Access: Published 00104 // Description: Calls GraphicsPipe::close_gsg() on the indicated pipe 00105 // and GSG. This function mainly exists to allow 00106 // GraphicsEngine::WindowRenderer to call the protected 00107 // method GraphicsPipe::close_gsg(). 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE void GraphicsEngine:: 00110 close_gsg(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { 00111 pipe->close_gsg(gsg); 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: GraphicsEngine::make_buffer 00116 // Access: Published 00117 // Description: Syntactic shorthand for make_output. This is the 00118 // preferred way to create an offscreen buffer, when you 00119 // already have an onscreen window or another buffer to 00120 // start with. For the first parameter, pass an 00121 // existing GraphicsOutput object, e.g. the main window; 00122 // this allows the buffer to adapt itself to that 00123 // window's framebuffer properties, and allows maximum 00124 // sharing of resources. 00125 //////////////////////////////////////////////////////////////////// 00126 INLINE GraphicsOutput *GraphicsEngine:: 00127 make_buffer(GraphicsOutput *host, const string &name, 00128 int sort, int x_size, int y_size) { 00129 GraphicsOutput *result = make_output(host->get_pipe(), name, sort, 00130 FrameBufferProperties(), 00131 WindowProperties::size(x_size, y_size), 00132 GraphicsPipe::BF_refuse_window | 00133 GraphicsPipe::BF_fb_props_optional, 00134 host->get_gsg(), host); 00135 return result; 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: GraphicsEngine::make_buffer 00140 // Access: Published 00141 // Description: Syntactic shorthand for make_output. This flavor 00142 // accepts a GSG rather than a GraphicsOutput as the 00143 // first parameter, which is too limiting and disallows 00144 // the possibility of creating a ParasiteBuffer if the 00145 // user's graphics hardware prefers that. It also 00146 // attempts to request specific framebuffer properties 00147 // and may therefore do a poorer job of sharing the GSG 00148 // between the old buffer and the new. 00149 // 00150 // For these reasons, this variant is a poor choice 00151 // unless you are creating an offscreen buffer for the 00152 // first time, without an onscreen window already in 00153 // existence. If you already have an onscreen window, 00154 // you should use the other flavor of make_buffer() 00155 // instead, which accepts a GraphicsOutput as the first 00156 // parameter. 00157 //////////////////////////////////////////////////////////////////// 00158 INLINE GraphicsOutput *GraphicsEngine:: 00159 make_buffer(GraphicsStateGuardian *gsg, const string &name, 00160 int sort, int x_size, int y_size) { 00161 FrameBufferProperties fb_props = FrameBufferProperties::get_default(); 00162 fb_props.set_back_buffers(0); 00163 fb_props.set_stereo(0); 00164 fb_props.set_accum_bits(0); 00165 fb_props.set_multisamples(0); 00166 fb_props.set_force_hardware(0); 00167 fb_props.set_force_software(0); 00168 GraphicsOutput *result = make_output(gsg->get_pipe(), name, sort, 00169 fb_props, 00170 WindowProperties::size(x_size, y_size), 00171 GraphicsPipe::BF_refuse_window | 00172 GraphicsPipe::BF_fb_props_optional, 00173 gsg, NULL); 00174 return result; 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function: GraphicsEngine::make_parasite 00179 // Access: Published 00180 // Description: Syntactic shorthand for make_buffer. 00181 //////////////////////////////////////////////////////////////////// 00182 INLINE GraphicsOutput *GraphicsEngine:: 00183 make_parasite(GraphicsOutput *host, const string &name, 00184 int sort, int x_size, int y_size) { 00185 GraphicsOutput *result = make_output(host->get_pipe(), name, sort, 00186 FrameBufferProperties(), 00187 WindowProperties::size(x_size, y_size), 00188 GraphicsPipe::BF_require_parasite | 00189 GraphicsPipe::BF_fb_props_optional, 00190 host->get_gsg(), host); 00191 return result; 00192 }