Panda3D
graphicsPipe.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file graphicsPipe.h
10  * @author mike
11  * @date 1997-01-09
12  */
13 
14 #ifndef GRAPHICSPIPE_H
15 #define GRAPHICSPIPE_H
16 
17 #include "pandabase.h"
18 
19 #include "graphicsDevice.h"
20 #include "typedReferenceCount.h"
21 #include "pointerTo.h"
22 #include "lightMutex.h"
23 
24 class GraphicsEngine;
25 class GraphicsOutput;
26 class GraphicsWindow;
27 class GraphicsBuffer;
30 class WindowProperties;
31 class Texture;
32 class WindowHandle;
33 class DisplayInformation;
34 
35 /**
36  * An object to create GraphicsOutputs that share a particular 3-D API.
37  * Normally, there will only be one GraphicsPipe in an application, although
38  * it is possible to have multiple of these at once if there are multiple
39  * different API's available in the same machine.
40  *
41  * Often, the GraphicsPipe corresponds to a physical output device, hence the
42  * term "pipe", but this is not necessarily the case.
43  *
44  * The GraphicsPipe is used by the GraphicsEngine object to create and destroy
45  * windows; it keeps ownership of the windows it creates.
46  *
47  * M. Asad added new/interim functionality where GraphicsPipe now contains a
48  * device interface to directx/opengl which will be used to handle multiple
49  * windows from same device.
50  *
51  */
52 class EXPCL_PANDA_DISPLAY GraphicsPipe : public TypedReferenceCount {
53 protected:
54  GraphicsPipe();
55  GraphicsPipe(const GraphicsPipe &copy) = delete;
56  GraphicsPipe &operator = (const GraphicsPipe &copy) = delete;
57 
58 PUBLISHED:
59  virtual ~GraphicsPipe();
60 
61  enum OutputTypes {
62  OT_window = 0x0001,
63  OT_fullscreen_window = 0x0002,
64  OT_buffer = 0x0004,
65  OT_texture_buffer = 0x0008,
66  };
67 
68  enum BufferCreationFlags {
69  // Flags that control what type of output is returned.
70  BF_refuse_parasite = 0x0001,
71  BF_require_parasite = 0x0002,
72  BF_refuse_window = 0x0004,
73  BF_require_window = 0x0008,
74  BF_require_callback_window = 0x0010,
75 
76  // Miscellaneous control flags.
77  BF_can_bind_color = 0x0040, // Need capability: bind the color bitplane to a tex.
78  BF_can_bind_every = 0x0080, // Need capability: bind all bitplanes to a tex.
79  BF_resizeable = 0x0100, // Buffer should allow set_size.
80  BF_size_track_host = 0x0200, // Buffer should track the host size.
81  BF_rtt_cumulative = 0x0400, // Buffer supports cumulative render-to-texture.
82  BF_fb_props_optional = 0x0800, // FrameBufferProperties can be ignored.
83  BF_size_square = 0x1000, // x_size must equal y_size (e.g. for cube maps)
84  BF_size_power_2 = 0x2000, // x_size and y_size must each be a power of two
85  BF_can_bind_layered = 0x4000, // Need capability: support RTM_bind_layered.
86  };
87 
88  INLINE bool is_valid() const;
89  INLINE int get_supported_types() const;
90  INLINE bool supports_type(int flags) const;
91 
92  INLINE int get_display_width() const;
93  INLINE int get_display_height() const;
94  MAKE_PROPERTY(display_width, get_display_width);
95  MAKE_PROPERTY(display_height, get_display_height);
96 
97  DisplayInformation *get_display_information();
98  MAKE_PROPERTY(display_information, get_display_information);
99 
100  virtual void lookup_cpu_data();
101 
102  virtual std::string get_interface_name() const=0;
103  MAKE_PROPERTY(interface_name, get_interface_name);
104 
105 public:
106  enum PreferredWindowThread {
107  PWT_app,
108  PWT_draw
109  };
110  virtual PreferredWindowThread get_preferred_window_thread() const;
111 
112  INLINE GraphicsDevice *get_device() const;
113  virtual PT(GraphicsDevice) make_device(void *scrn = nullptr);
114 
115  virtual PT(GraphicsStateGuardian) make_callback_gsg(GraphicsEngine *engine);
116 
117 protected:
118  virtual void close_gsg(GraphicsStateGuardian *gsg);
119 
120  virtual PT(GraphicsOutput) make_output(const std::string &name,
121  const FrameBufferProperties &fb_prop,
122  const WindowProperties &win_prop,
123  int flags,
124  GraphicsEngine *engine,
126  GraphicsOutput *host,
127  int retry,
128  bool &precertify);
129 
130  LightMutex _lock;
131 
132  bool _is_valid;
133  int _supported_types;
134  int _display_width;
135  int _display_height;
136  PT(GraphicsDevice) _device;
137 
138  DisplayInformation *_display_information;
139 
140  static const int strip_properties[];
141 
142 public:
143 
144  static TypeHandle get_class_type() {
145  return _type_handle;
146  }
147  static void init_type() {
148  TypedReferenceCount::init_type();
149  register_type(_type_handle, "GraphicsPipe",
150  TypedReferenceCount::get_class_type());
151  }
152  virtual TypeHandle get_type() const {
153  return get_class_type();
154  }
155  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
156 
157 private:
158  static TypeHandle _type_handle;
159  friend class GraphicsEngine;
160 };
161 
162 #include "graphicsPipe.I"
163 
164 #endif /* GRAPHICSPIPE_H */
This class contains various display information.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:34
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An offscreen buffer for rendering into.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:52
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the various different classes that represent the result of a frame of render...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An abstract device object that is part of Graphics Pipe.
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:81
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:39