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  PN_stdfloat get_display_zoom() const;
95  MAKE_PROPERTY(display_width, get_display_width);
96  MAKE_PROPERTY(display_height, get_display_height);
97  MAKE_PROPERTY(display_zoom, get_display_zoom);
98 
99  DisplayInformation *get_display_information();
100  MAKE_PROPERTY(display_information, get_display_information);
101 
102  virtual void lookup_cpu_data();
103 
104  virtual std::string get_interface_name() const=0;
105  MAKE_PROPERTY(interface_name, get_interface_name);
106 
107 public:
108  enum PreferredWindowThread {
109  PWT_app,
110  PWT_draw
111  };
112  virtual PreferredWindowThread get_preferred_window_thread() const;
113 
114  INLINE GraphicsDevice *get_device() const;
115  virtual PT(GraphicsDevice) make_device(void *scrn = nullptr);
116 
117  virtual PT(GraphicsStateGuardian) make_callback_gsg(GraphicsEngine *engine);
118 
119 protected:
120  void set_detected_display_zoom(PN_stdfloat zoom);
121 
122  virtual void close_gsg(GraphicsStateGuardian *gsg);
123 
124  virtual PT(GraphicsOutput) make_output(const std::string &name,
125  const FrameBufferProperties &fb_prop,
126  const WindowProperties &win_prop,
127  int flags,
128  GraphicsEngine *engine,
130  GraphicsOutput *host,
131  int retry,
132  bool &precertify);
133 
134  LightMutex _lock;
135 
136  bool _is_valid;
137  int _supported_types;
138  int _display_width;
139  int _display_height;
140  PT(GraphicsDevice) _device;
141 
142  DisplayInformation *_display_information;
143 
144  static const int strip_properties[];
145 
146 public:
147 
148  static TypeHandle get_class_type() {
149  return _type_handle;
150  }
151  static void init_type() {
152  TypedReferenceCount::init_type();
153  register_type(_type_handle, "GraphicsPipe",
154  TypedReferenceCount::get_class_type());
155  }
156  virtual TypeHandle get_type() const {
157  return get_class_type();
158  }
159  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
160 
161 private:
162  static TypeHandle _type_handle;
163  friend class GraphicsEngine;
164 };
165 
166 #include "graphicsPipe.I"
167 
168 #endif /* GRAPHICSPIPE_H */
This class contains various display information.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
An offscreen buffer for rendering into.
An abstract device object that is part of Graphics Pipe.
This class is the main interface to controlling the render process.
This is a base class for the various different classes that represent the result of a frame of render...
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:52
Encapsulates all the communication with a particular instance of a given rendering backend.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:41
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
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:34
A container for the various kinds of properties we might ask to have on a graphics window before we o...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.