Panda3D
 All Classes Functions Variables Enumerations
graphicsPipe.cxx
1 // Filename: graphicsPipe.cxx
2 // Created by: mike (09Jan97)
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 "graphicsPipe.h"
16 #include "graphicsWindow.h"
17 #include "graphicsBuffer.h"
18 #include "config_display.h"
19 #include "mutexHolder.h"
20 
21 TypeHandle GraphicsPipe::_type_handle;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: GraphicsPipe::Constructor
25 // Access: Protected
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 GraphicsPipe::
29 GraphicsPipe() :
30  _lock("GraphicsPipe")
31 {
32  // Initially, we assume the GraphicsPipe is valid. A derived class
33  // should set this to false if it determines otherwise.
34  _is_valid = true;
35 
36  // A derived class must indicate the kinds of GraphicsOutput objects
37  // it can create.
38  _supported_types = 0;
39 
40  _display_width = 0;
41  _display_height = 0;
42 
43  _display_information = new DisplayInformation ( );
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: GraphicsPipe::Copy Constructor
48 // Access: Private
49 // Description: Don't try to copy GraphicsPipes.
50 ////////////////////////////////////////////////////////////////////
51 GraphicsPipe::
52 GraphicsPipe(const GraphicsPipe &) {
53  _is_valid = false;
54  nassertv(false);
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: GraphicsPipe::Copy Assignment Operator
59 // Access: Private
60 // Description: Don't try to copy GraphicsPipes.
61 ////////////////////////////////////////////////////////////////////
62 void GraphicsPipe::
63 operator = (const GraphicsPipe &) {
64  nassertv(false);
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: GraphicsPipe::Destructor
69 // Access: Published
70 // Description:
71 ////////////////////////////////////////////////////////////////////
72 GraphicsPipe::
73 ~GraphicsPipe() {
74  delete _display_information;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: GraphicsPipe::get_preferred_window_thread
79 // Access: Public, Virtual
80 // Description: Returns an indication of the thread in which this
81 // GraphicsPipe requires its window processing to be
82 // performed: typically either the app thread (e.g. X)
83 // or the draw thread (Windows).
84 ////////////////////////////////////////////////////////////////////
85 GraphicsPipe::PreferredWindowThread
87  return PWT_draw;
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: GraphicsPipe::make_callback_gsg
92 // Access: Public, Virtual
93 // Description: This is called when make_output() is used to create a
94 // CallbackGraphicsWindow. If the GraphicsPipe can
95 // construct a GSG that's not associated with any
96 // particular window object, do so now, assuming the
97 // correct graphics context has been set up externally.
98 ////////////////////////////////////////////////////////////////////
100 make_callback_gsg(GraphicsEngine *engine) {
101  return NULL;
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: GraphicsPipe::make_device
106 // Access: Public, Virtual
107 // Description: Creates a new device for the pipe. Only DirectX uses
108 // this device, for other api's it is NULL.
109 ////////////////////////////////////////////////////////////////////
111 make_device(void *scrn) {
112  display_cat.error()
113  << "make_device() unimplemented by " << get_type() << "\n";
114  return NULL;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: GraphicsPipe::close_gsg
119 // Access: Protected, Virtual
120 // Description: This will be called in the draw thread (the same
121 // thread in which the GSG was created via make_gsg,
122 // above) to close the indicated GSG and free its
123 // associated graphics objects just before it is
124 // destructed. This method exists to provide a hook for
125 // the graphics pipe to do any necessary cleanup, if
126 // any.
127 ////////////////////////////////////////////////////////////////////
128 void GraphicsPipe::
129 close_gsg(GraphicsStateGuardian *gsg) {
130  if (gsg != (GraphicsStateGuardian *)NULL) {
131  gsg->close_gsg();
132  }
133 }
134 
135 ////////////////////////////////////////////////////////////////////
136 // Function: GraphicsPipe::make_output
137 // Access: Protected, Virtual
138 // Description: Creates a new window on the pipe, if possible.
139 ////////////////////////////////////////////////////////////////////
141 make_output(const string &name,
142  const FrameBufferProperties &fb_prop,
143  const WindowProperties &win_prop,
144  int flags,
145  GraphicsEngine *engine,
147  GraphicsOutput *host,
148  int retry,
149  bool &precertify) {
150  display_cat.error()
151  << get_type() << " cannot create buffers or windows.\n";
152  return NULL;
153 }
154 
155 ////////////////////////////////////////////////////////////////////
156 // Function: GraphicsPipe::get_display_information
157 // Access: Published
158 // Description: Gets the pipe's DisplayInformation.
159 ////////////////////////////////////////////////////////////////////
162  return _display_information;
163 }
164 
165 ////////////////////////////////////////////////////////////////////
166 // Function: GraphicsPipe::lookup_cpu_data
167 // Access: Public, Virtual
168 // Description: Looks up the detailed CPU information and stores it
169 // in _display_information, if supported by the OS.
170 // This may take a second or two.
171 ////////////////////////////////////////////////////////////////////
172 void GraphicsPipe::
174 }
This class contains various display information.
virtual PreferredWindowThread get_preferred_window_thread() const
Returns an indication of the thread in which this GraphicsPipe requires its window processing to be p...
DisplayInformation * get_display_information()
Gets the pipe&#39;s DisplayInformation.
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...
An abstract device object that is part of Graphics Pipe.
virtual void lookup_cpu_data()
Looks up the detailed CPU information and stores it in _display_information, if supported by the OS...
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...