00001 // Filename: graphicsEngine.I 00002 // Created by: drose (24Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: GraphicsEngine::set_auto_flip 00022 // Access: Published 00023 // Description: Set this flag true to indicate the GraphicsEngine 00024 // should automatically cause windows to sync and flip 00025 // at the end of render_frame(). 00026 // 00027 // This only applies to a single-threaded rendering 00028 // model. In the presence of threading, the windows are 00029 // never auto-flipped, regardless of this flag. 00030 // 00031 // This only affects the timing of when the flip occurs. 00032 // If this is true (the default), the flip occurs before 00033 // render_frame() returns. If this is false, the flip 00034 // occurs whenever flip_frame() is called, or at the 00035 // beginning of the next call to render_frame(), if 00036 // flip_frame() is never called. 00037 //////////////////////////////////////////////////////////////////// 00038 INLINE void GraphicsEngine:: 00039 set_auto_flip(bool auto_flip) { 00040 // We don't bother with the mutex here. It's just a bool, after 00041 // all. 00042 _auto_flip = auto_flip; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: GraphicsEngine::get_auto_flip 00047 // Access: Published 00048 // Description: Returns the current setting for the auto-flip flag. 00049 // See set_auto_flip. 00050 //////////////////////////////////////////////////////////////////// 00051 INLINE bool GraphicsEngine:: 00052 get_auto_flip() const { 00053 // We don't bother with the mutex here. It's just a bool, after 00054 // all. 00055 return _auto_flip; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: GraphicsEngine::make_gsg 00060 // Access: Published 00061 // Description: Creates a new gsg using the indicated GraphicsPipe 00062 // and returns it. The GraphicsEngine does not 00063 // officially own the pointer to the gsg; but if any 00064 // windows are created using this GSG, the 00065 // GraphicsEngine will own the pointers to these 00066 // windows, which in turn will own the pointer to the 00067 // GSG. 00068 // 00069 // There is no explicit way to release a GSG, but it 00070 // will be destructed when all windows that reference it 00071 // are destructed, and the draw thread that owns the GSG 00072 // runs one more time. 00073 // 00074 // This flavor of make_gsg() uses the default 00075 // threading model, specified via set_threading_model(). 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE PT(GraphicsStateGuardian) GraphicsEngine:: 00078 make_gsg(GraphicsPipe *pipe) { 00079 return make_gsg(pipe, get_frame_buffer_properties(), get_threading_model()); 00080 } 00081 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: GraphicsEngine::make_window 00085 // Access: Published 00086 // Description: Creates a new window using the indicated 00087 // GraphicsStateGuardian and returns it. The 00088 // GraphicsEngine becomes the owner of the window; it 00089 // will persist at least until remove_window() is called 00090 // later. 00091 //////////////////////////////////////////////////////////////////// 00092 INLINE GraphicsWindow *GraphicsEngine:: 00093 make_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { 00094 return make_window(pipe, gsg, get_threading_model()); 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: GraphicsEngine::close_gsg 00099 // Access: Published 00100 // Description: Calls GraphicsPipe::close_gsg() on the indicated pipe 00101 // and GSG. This function mainly exists to allow 00102 // GraphicsEngine::WindowRenderer to call the protected 00103 // method GraphicsPipe::close_gsg(). 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE void GraphicsEngine:: 00106 close_gsg(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { 00107 pipe->close_gsg(gsg); 00108 }