Panda3D
wdxGraphicsBuffer9.h
1 // Filename: wdxGraphicsBuffer9.h
2 // Created by: drose (08Feb04)
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 wdxGraphicsBuffer9_H
16 #define wdxGraphicsBuffer9_H
17 
18 #include "pandabase.h"
19 #include "graphicsBuffer.h"
20 #include "dxgsg9base.h"
21 #include "dxTextureContext9.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : wdxGraphicsBuffer9
25 // Description : An offscreen render buffer. In OpenGL under Windows,
26 // this simply renders into a window that is never made
27 // visible. There's a Windows interface for rendering
28 // into a DIB, but this puts restrictions on the kind of
29 // pixelformat we can use, and thus makes it difficult
30 // to support one GSG rendering into an offscreen buffer
31 // and also into a window.
32 ////////////////////////////////////////////////////////////////////
33 class EXPCL_PANDADX wdxGraphicsBuffer9 : public GraphicsBuffer {
34 public:
36  const string &name,
37  const FrameBufferProperties &fb_prop,
38  const WindowProperties &win_prop,
39  int flags,
41  GraphicsOutput *host);
42  virtual ~wdxGraphicsBuffer9();
43 
44  virtual INLINE bool get_supports_render_texture() const;
45 
46  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
47  virtual void end_frame(FrameMode mode, Thread *current_thread);
48 
49  virtual void select_target_tex_page(int page);
50 
51  virtual void process_events();
52 
53  virtual bool share_depth_buffer(GraphicsOutput *graphics_output);
54  virtual void unshare_depth_buffer();
55 
56  void register_shared_depth_buffer(GraphicsOutput *graphics_output);
57  void unregister_shared_depth_buffer(GraphicsOutput *graphics_output);
58 
59 protected:
60  virtual void close_buffer();
61  virtual bool open_buffer();
62 
63 private:
64  bool save_bitplanes();
65  bool rebuild_bitplanes();
66  void restore_bitplanes();
67  static void process_1_event();
68 
69  int _cube_map_index;
71  IDirect3DSurface9 *_saved_color_buffer;
72  IDirect3DSurface9 *_saved_depth_buffer;
73  D3DSURFACE_DESC _saved_color_desc;
74  D3DSURFACE_DESC _saved_depth_desc;
75  IDirect3DSurface9 *_color_backing_store;
76  IDirect3DSurface9 *_depth_backing_store;
77  int _backing_sizex;
78  int _backing_sizey;
79 
80  wdxGraphicsBuffer9 *_shared_depth_buffer;
81  list <wdxGraphicsBuffer9 *> _shared_depth_buffer_list;
82 
83  wdxGraphicsBuffer9 **_this;
84 
85 public:
86  static TypeHandle get_class_type() {
87  return _type_handle;
88  }
89  static void init_type() {
90  GraphicsBuffer::init_type();
91  register_type(_type_handle, "wdxGraphicsBuffer9",
92  GraphicsBuffer::get_class_type());
93  }
94  virtual TypeHandle get_type() const {
95  return get_class_type();
96  }
97  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
98 
99 private:
100  bool _debug;
101  static TypeHandle _type_handle;
102 
103  friend class DXGraphicsStateGuardian9;
104  friend class DXTextureContext9;
105 };
106 
107 #include "wdxGraphicsBuffer9.I"
108 
109 #endif
A GraphicsStateGuardian for rendering into DirectX9 contexts.
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame...
virtual void select_target_tex_page(int page)
Called internally when the window is in render-to-a-texture mode and we are in the process of renderi...
virtual void process_events()
Honor any requests recently made via request_open() or request_close().
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An offscreen render buffer.
An offscreen buffer for rendering into.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
virtual bool get_supports_render_texture() const
Returns true if this particular GraphicsOutput can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.
This is a base class for the various different classes that represent the result of a frame of render...
A thread; that is, a lightweight process.
Definition: thread.h:51
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...
virtual void unshare_depth_buffer()
Discontinue sharing the depth buffer.
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame...
virtual bool share_depth_buffer(GraphicsOutput *graphics_output)
Will attempt to use the depth buffer of the input graphics_output.