Panda3D
 All Classes Functions Variables Enumerations
graphicsPipe.h
1 // Filename: graphicsPipe.h
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 #ifndef GRAPHICSPIPE_H
16 #define GRAPHICSPIPE_H
17 
18 #include "pandabase.h"
19 
20 #include "graphicsDevice.h"
21 #include "typedReferenceCount.h"
22 #include "pointerTo.h"
23 #include "lightMutex.h"
24 #include "displayInformation.h"
25 
26 class GraphicsEngine;
27 class GraphicsOutput;
28 class GraphicsWindow;
29 class GraphicsBuffer;
32 class WindowProperties;
33 class Texture;
34 class WindowHandle;
35 
36 ////////////////////////////////////////////////////////////////////
37 // Class : GraphicsPipe
38 // Description : An object to create GraphicsOutputs that share a
39 // particular 3-D API. Normally, there will only be one
40 // GraphicsPipe in an application, although it is
41 // possible to have multiple of these at once if there
42 // are multiple different API's available in the same
43 // machine.
44 //
45 // Often, the GraphicsPipe corresponds to a physical
46 // output device, hence the term "pipe", but this is not
47 // necessarily the case.
48 //
49 // The GraphicsPipe is used by the GraphicsEngine object
50 // to create and destroy windows; it keeps ownership of
51 // the windows it creates.
52 //
53 // M. Asad added new/interim functionality where GraphicsPipe
54 // now contains a device interface to directx/opengl which
55 // will be used to handle multiple windows from same device.
56 //
57 ////////////////////////////////////////////////////////////////////
58 class EXPCL_PANDA_DISPLAY GraphicsPipe : public TypedReferenceCount {
59 protected:
60  GraphicsPipe();
61 private:
62  GraphicsPipe(const GraphicsPipe &copy);
63  void operator = (const GraphicsPipe &copy);
64 
65 PUBLISHED:
66  virtual ~GraphicsPipe();
67 
68  enum OutputTypes {
69  OT_window = 0x0001,
70  OT_fullscreen_window = 0x0002,
71  OT_buffer = 0x0004,
72  OT_texture_buffer = 0x0008,
73  };
74 
75  enum BufferCreationFlags {
76  // Flags that control what type of output is returned.
77  BF_refuse_parasite = 0x0001,
78  BF_require_parasite = 0x0002,
79  BF_refuse_window = 0x0004,
80  BF_require_window = 0x0008,
81  BF_require_callback_window = 0x0010,
82 
83  // Miscellaneous control flags.
84  BF_can_bind_color = 0x0040, // Need capability: bind the color bitplane to a tex.
85  BF_can_bind_every = 0x0080, // Need capability: bind all bitplanes to a tex.
86  BF_resizeable = 0x0100, // Buffer should allow set_size.
87  BF_size_track_host = 0x0200, // Buffer should track the host size.
88  BF_rtt_cumulative = 0x0400, // Buffer supports cumulative render-to-texture.
89  BF_fb_props_optional = 0x0800, // FrameBufferProperties can be ignored.
90  BF_size_square = 0x1000, // x_size must equal y_size (e.g. for cube maps)
91  BF_size_power_2 = 0x2000, // x_size and y_size must each be a power of two
92  BF_can_bind_layered = 0x4000, // Need capability: support RTM_bind_layered.
93  };
94 
95  INLINE bool is_valid() const;
96  INLINE int get_supported_types() const;
97  INLINE bool supports_type(int flags) const;
98 
99  INLINE int get_display_width() const;
100  INLINE int get_display_height() const;
101 
102  DisplayInformation *get_display_information();
103  virtual void lookup_cpu_data();
104 
105  virtual string get_interface_name() const=0;
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 = NULL);
116 
117  virtual PT(GraphicsStateGuardian) make_callback_gsg(GraphicsEngine *engine);
118 
119 protected:
120  virtual void close_gsg(GraphicsStateGuardian *gsg);
121 
122  virtual PT(GraphicsOutput) make_output(const string &name,
123  const FrameBufferProperties &fb_prop,
124  const WindowProperties &win_prop,
125  int flags,
126  GraphicsEngine *engine,
128  GraphicsOutput *host,
129  int retry,
130  bool &precertify);
131 
132  LightMutex _lock;
133 
134  bool _is_valid;
135  int _supported_types;
136  int _display_width;
137  int _display_height;
138  PT(GraphicsDevice) _device;
139 
140  DisplayInformation *_display_information;
141 
142  static const int strip_properties[];
143 
144 public:
145 
146  static TypeHandle get_class_type() {
147  return _type_handle;
148  }
149  static void init_type() {
150  TypedReferenceCount::init_type();
151  register_type(_type_handle, "GraphicsPipe",
152  TypedReferenceCount::get_class_type());
153  }
154  virtual TypeHandle get_type() const {
155  return get_class_type();
156  }
157  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
158 
159 private:
160  static TypeHandle _type_handle;
161  friend class GraphicsEngine;
162 };
163 
164 #include "graphicsPipe.I"
165 
166 #endif /* GRAPHICSPIPE_H */
This class contains various display information.
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:40
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
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.
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.
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...
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:45