Panda3D
 All Classes Functions Variables Enumerations
tinyXGraphicsPipe.cxx
1 // Filename: tinyXGraphicsPipe.cxx
2 // Created by: drose (03May08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "pandabase.h"
16 #ifdef HAVE_X11
17 
18 #include "tinyXGraphicsPipe.h"
19 #include "tinyXGraphicsWindow.h"
20 #include "tinyGraphicsStateGuardian.h"
21 #include "tinyGraphicsBuffer.h"
22 #include "config_tinydisplay.h"
23 #include "frameBufferProperties.h"
24 
25 TypeHandle TinyXGraphicsPipe::_type_handle;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: TinyXGraphicsPipe::Constructor
29 // Access: Public
30 // Description:
31 ////////////////////////////////////////////////////////////////////
32 TinyXGraphicsPipe::
33 TinyXGraphicsPipe(const string &display) : x11GraphicsPipe(display) {
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: TinyXGraphicsPipe::Destructor
38 // Access: Public, Virtual
39 // Description:
40 ////////////////////////////////////////////////////////////////////
41 TinyXGraphicsPipe::
42 ~TinyXGraphicsPipe() {
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: TinyXGraphicsPipe::get_interface_name
47 // Access: Published, Virtual
48 // Description: Returns the name of the rendering interface
49 // associated with this GraphicsPipe. This is used to
50 // present to the user to allow him/her to choose
51 // between several possible GraphicsPipes available on a
52 // particular platform, so the name should be meaningful
53 // and unique for a given platform.
54 ////////////////////////////////////////////////////////////////////
55 string TinyXGraphicsPipe::
56 get_interface_name() const {
57  return "TinyPanda";
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: TinyXGraphicsPipe::pipe_constructor
62 // Access: Public, Static
63 // Description: This function is passed to the GraphicsPipeSelection
64 // object to allow the user to make a default
65 // TinyXGraphicsPipe.
66 ////////////////////////////////////////////////////////////////////
67 PT(GraphicsPipe) TinyXGraphicsPipe::
68 pipe_constructor() {
69  return new TinyXGraphicsPipe;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: TinyXGraphicsPipe::make_output
74 // Access: Protected, Virtual
75 // Description: Creates a new window on the pipe, if possible.
76 ////////////////////////////////////////////////////////////////////
77 PT(GraphicsOutput) TinyXGraphicsPipe::
78 make_output(const string &name,
79  const FrameBufferProperties &fb_prop,
80  const WindowProperties &win_prop,
81  int flags,
82  GraphicsEngine *engine,
84  GraphicsOutput *host,
85  int retry,
86  bool &precertify) {
87  TinyGraphicsStateGuardian *tinygsg = 0;
88  if (gsg != 0) {
89  DCAST_INTO_R(tinygsg, gsg, NULL);
90  }
91 
92  // First thing to try: a TinyXGraphicsWindow
93 
94  // We check _is_valid only in this case. The pipe will be invalid
95  // if it can't contact the X server, but that shouldn't prevent the
96  // creation of an offscreen buffer.
97  if (retry == 0 && _is_valid) {
98  if (((flags&BF_require_parasite)!=0)||
99  ((flags&BF_refuse_window)!=0)||
100  ((flags&BF_resizeable)!=0)||
101  ((flags&BF_size_track_host)!=0)||
102  ((flags&BF_rtt_cumulative)!=0)||
103  ((flags&BF_can_bind_color)!=0)||
104  ((flags&BF_can_bind_every)!=0)) {
105  return NULL;
106  }
107  return new TinyXGraphicsWindow(engine, this, name, fb_prop, win_prop,
108  flags, gsg, host);
109  }
110 
111  // Second thing to try: a TinyGraphicsBuffer
112 
113  // No need to check _is_valid here. We can create an offscreen
114  // buffer even if the pipe is not technically valid.
115  if (retry == 1) {
116  if (((flags&BF_require_parasite)!=0)||
117  ((flags&BF_require_window)!=0)) {
118  return NULL;
119  }
120  return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host);
121  }
122 
123  // Nothing else left to try.
124  return NULL;
125 }
126 
127 #endif // HAVE_X11
This graphics pipe represents the interface for creating graphics windows on an X-based client...
An offscreen graphics buffer.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
This is a base class for the various different classes that represent the result of a frame of render...
Encapsulates all the communication with a particular instance of a given rendering backend...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
An interface to the TinyPanda software rendering code within this module.