Panda3D
|
00001 // Filename: tinyXGraphicsPipe.cxx 00002 // Created by: drose (03May08) 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 #include "pandabase.h" 00016 #ifdef HAVE_X11 00017 00018 #include "tinyXGraphicsPipe.h" 00019 #include "tinyXGraphicsWindow.h" 00020 #include "tinyGraphicsStateGuardian.h" 00021 #include "tinyGraphicsBuffer.h" 00022 #include "config_tinydisplay.h" 00023 #include "frameBufferProperties.h" 00024 00025 TypeHandle TinyXGraphicsPipe::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: TinyXGraphicsPipe::Constructor 00029 // Access: Public 00030 // Description: 00031 //////////////////////////////////////////////////////////////////// 00032 TinyXGraphicsPipe:: 00033 TinyXGraphicsPipe(const string &display) : x11GraphicsPipe(display) { 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: TinyXGraphicsPipe::Destructor 00038 // Access: Public, Virtual 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 TinyXGraphicsPipe:: 00042 ~TinyXGraphicsPipe() { 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: TinyXGraphicsPipe::get_interface_name 00047 // Access: Published, Virtual 00048 // Description: Returns the name of the rendering interface 00049 // associated with this GraphicsPipe. This is used to 00050 // present to the user to allow him/her to choose 00051 // between several possible GraphicsPipes available on a 00052 // particular platform, so the name should be meaningful 00053 // and unique for a given platform. 00054 //////////////////////////////////////////////////////////////////// 00055 string TinyXGraphicsPipe:: 00056 get_interface_name() const { 00057 return "TinyPanda"; 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: TinyXGraphicsPipe::pipe_constructor 00062 // Access: Public, Static 00063 // Description: This function is passed to the GraphicsPipeSelection 00064 // object to allow the user to make a default 00065 // TinyXGraphicsPipe. 00066 //////////////////////////////////////////////////////////////////// 00067 PT(GraphicsPipe) TinyXGraphicsPipe:: 00068 pipe_constructor() { 00069 return new TinyXGraphicsPipe; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: TinyXGraphicsPipe::make_output 00074 // Access: Protected, Virtual 00075 // Description: Creates a new window on the pipe, if possible. 00076 //////////////////////////////////////////////////////////////////// 00077 PT(GraphicsOutput) TinyXGraphicsPipe:: 00078 make_output(const string &name, 00079 const FrameBufferProperties &fb_prop, 00080 const WindowProperties &win_prop, 00081 int flags, 00082 GraphicsEngine *engine, 00083 GraphicsStateGuardian *gsg, 00084 GraphicsOutput *host, 00085 int retry, 00086 bool &precertify) { 00087 TinyGraphicsStateGuardian *tinygsg = 0; 00088 if (gsg != 0) { 00089 DCAST_INTO_R(tinygsg, gsg, NULL); 00090 } 00091 00092 // First thing to try: a TinyXGraphicsWindow 00093 00094 // We check _is_valid only in this case. The pipe will be invalid 00095 // if it can't contact the X server, but that shouldn't prevent the 00096 // creation of an offscreen buffer. 00097 if (retry == 0 && _is_valid) { 00098 if (((flags&BF_require_parasite)!=0)|| 00099 ((flags&BF_refuse_window)!=0)|| 00100 ((flags&BF_resizeable)!=0)|| 00101 ((flags&BF_size_track_host)!=0)|| 00102 ((flags&BF_rtt_cumulative)!=0)|| 00103 ((flags&BF_can_bind_color)!=0)|| 00104 ((flags&BF_can_bind_every)!=0)) { 00105 return NULL; 00106 } 00107 return new TinyXGraphicsWindow(engine, this, name, fb_prop, win_prop, 00108 flags, gsg, host); 00109 } 00110 00111 // Second thing to try: a TinyGraphicsBuffer 00112 00113 // No need to check _is_valid here. We can create an offscreen 00114 // buffer even if the pipe is not technically valid. 00115 if (retry == 1) { 00116 if (((flags&BF_require_parasite)!=0)|| 00117 ((flags&BF_require_window)!=0)) { 00118 return NULL; 00119 } 00120 return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); 00121 } 00122 00123 // Nothing else left to try. 00124 return NULL; 00125 } 00126 00127 #endif // HAVE_X11