Panda3D
wdxGraphicsBuffer9.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 wdxGraphicsBuffer9.h
10  * @author drose
11  * @date 2004-02-08
12  */
13 
14 #ifndef wdxGraphicsBuffer9_H
15 #define wdxGraphicsBuffer9_H
16 
17 #include "pandabase.h"
18 #include "graphicsBuffer.h"
19 #include "dxgsg9base.h"
20 #include "dxTextureContext9.h"
21 
22 /**
23  * An offscreen render buffer. In OpenGL under Windows, this simply renders
24  * into a window that is never made visible. There's a Windows interface for
25  * rendering into a DIB, but this puts restrictions on the kind of pixelformat
26  * we can use, and thus makes it difficult to support one GSG rendering into
27  * an offscreen buffer and also into a window.
28  */
29 class EXPCL_PANDADX wdxGraphicsBuffer9 : public GraphicsBuffer {
30 public:
32  const std::string &name,
33  const FrameBufferProperties &fb_prop,
34  const WindowProperties &win_prop,
35  int flags,
37  GraphicsOutput *host);
38  virtual ~wdxGraphicsBuffer9();
39 
40  virtual INLINE bool get_supports_render_texture() const;
41 
42  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
43  virtual void end_frame(FrameMode mode, Thread *current_thread);
44 
45  virtual void select_target_tex_page(int page);
46 
47  virtual void process_events();
48 
49  virtual bool share_depth_buffer(GraphicsOutput *graphics_output);
50  virtual void unshare_depth_buffer();
51 
52  void register_shared_depth_buffer(GraphicsOutput *graphics_output);
53  void unregister_shared_depth_buffer(GraphicsOutput *graphics_output);
54 
55 protected:
56  virtual void close_buffer();
57  virtual bool open_buffer();
58 
59 private:
60  bool save_bitplanes();
61  bool rebuild_bitplanes();
62  void restore_bitplanes();
63  static void process_1_event();
64 
65  int _cube_map_index;
67  IDirect3DSurface9 *_saved_color_buffer;
68  IDirect3DSurface9 *_saved_depth_buffer;
69  D3DSURFACE_DESC _saved_color_desc;
70  D3DSURFACE_DESC _saved_depth_desc;
71  IDirect3DSurface9 *_color_backing_store;
72  IDirect3DSurface9 *_depth_backing_store;
73  int _backing_sizex;
74  int _backing_sizey;
75 
76  wdxGraphicsBuffer9 *_shared_depth_buffer;
77  std::list <wdxGraphicsBuffer9 *> _shared_depth_buffer_list;
78 
79  wdxGraphicsBuffer9 **_this;
80 
81 public:
82  static TypeHandle get_class_type() {
83  return _type_handle;
84  }
85  static void init_type() {
86  GraphicsBuffer::init_type();
87  register_type(_type_handle, "wdxGraphicsBuffer9",
88  GraphicsBuffer::get_class_type());
89  }
90  virtual TypeHandle get_type() const {
91  return get_class_type();
92  }
93  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
94 
95 private:
96  bool _debug;
97  static TypeHandle _type_handle;
98 
99  friend class DXGraphicsStateGuardian9;
100  friend class DXTextureContext9;
101 };
102 
103 #include "wdxGraphicsBuffer9.I"
104 
105 #endif
A GraphicsStateGuardian for rendering into DirectX9 contexts.
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.
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:52
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
A thread; that is, a lightweight process.
Definition: thread.h:46
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...
virtual void unshare_depth_buffer()
Discontinue sharing the depth buffer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.