Panda3D

wdxGraphicsBuffer9.h

00001 // Filename: wdxGraphicsBuffer9.h
00002 // Created by:  drose (08Feb04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef wdxGraphicsBuffer9_H
00016 #define wdxGraphicsBuffer9_H
00017 
00018 #include "pandabase.h"
00019 #include "graphicsBuffer.h"
00020 #include "dxgsg9base.h"
00021 #include "dxTextureContext9.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : wdxGraphicsBuffer9
00025 // Description : An offscreen render buffer.  In OpenGL under Windows,
00026 //               this simply renders into a window that is never made
00027 //               visible.  There's a Windows interface for rendering
00028 //               into a DIB, but this puts restrictions on the kind of
00029 //               pixelformat we can use, and thus makes it difficult
00030 //               to support one GSG rendering into an offscreen buffer
00031 //               and also into a window.
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDADX wdxGraphicsBuffer9 : public GraphicsBuffer {
00034 public:
00035   wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe,
00036                      const string &name,
00037                      const FrameBufferProperties &fb_prop,
00038                      const WindowProperties &win_prop,
00039                      int flags,
00040                      GraphicsStateGuardian *gsg,
00041                      GraphicsOutput *host);
00042   virtual ~wdxGraphicsBuffer9();
00043 
00044   virtual bool begin_frame(FrameMode mode, Thread *current_thread);
00045   virtual void end_frame(FrameMode mode, Thread *current_thread);
00046 
00047   virtual void select_cube_map(int cube_map_index);
00048   virtual void process_events();
00049 
00050   virtual bool share_depth_buffer(GraphicsOutput *graphics_output);
00051   virtual void unshare_depth_buffer();
00052 
00053   void register_shared_depth_buffer(GraphicsOutput *graphics_output);
00054   void unregister_shared_depth_buffer(GraphicsOutput *graphics_output);
00055 
00056 protected:
00057   virtual void close_buffer();
00058   virtual bool open_buffer();
00059 
00060 private:
00061   bool save_bitplanes();
00062   bool rebuild_bitplanes();
00063   void restore_bitplanes();
00064   static void process_1_event();
00065 
00066   int _cube_map_index;
00067   DXGraphicsStateGuardian9 *_dxgsg;
00068   IDirect3DSurface9 *_saved_color_buffer;
00069   IDirect3DSurface9 *_saved_depth_buffer;
00070   D3DSURFACE_DESC    _saved_color_desc;
00071   D3DSURFACE_DESC    _saved_depth_desc;
00072   IDirect3DSurface9 *_color_backing_store;
00073   IDirect3DSurface9 *_depth_backing_store;
00074   int _backing_sizex;
00075   int _backing_sizey;
00076 
00077   wdxGraphicsBuffer9 *_shared_depth_buffer;
00078   list <wdxGraphicsBuffer9 *> _shared_depth_buffer_list;
00079 
00080   wdxGraphicsBuffer9 **_this;
00081 
00082 public:
00083   static TypeHandle get_class_type() {
00084     return _type_handle;
00085   }
00086   static void init_type() {
00087     GraphicsBuffer::init_type();
00088     register_type(_type_handle, "wdxGraphicsBuffer9",
00089                   GraphicsBuffer::get_class_type());
00090   }
00091   virtual TypeHandle get_type() const {
00092     return get_class_type();
00093   }
00094   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00095 
00096 private:
00097   bool _debug;
00098   static TypeHandle _type_handle;
00099 
00100   friend class DXGraphicsStateGuardian9;
00101   friend class DXTextureContext9;
00102 };
00103 
00104 #endif
 All Classes Functions Variables Enumerations