Panda3D
 All Classes Functions Variables Enumerations
wdxGraphicsBuffer8.h
00001 // Filename: wdxGraphicsBuffer8.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 wdxGraphicsBuffer8_H
00016 #define wdxGraphicsBuffer8_H
00017 
00018 #include "pandabase.h"
00019 #include "graphicsBuffer.h"
00020 #include "dxgsg8base.h"
00021 
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : wdxGraphicsBuffer8
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 wdxGraphicsBuffer8 : public GraphicsBuffer {
00034 public:
00035   wdxGraphicsBuffer8(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 ~wdxGraphicsBuffer8();
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 
00049   virtual void process_events();
00050 
00051 protected:
00052   virtual void close_buffer();
00053   virtual bool open_buffer();
00054 
00055 private:
00056   bool save_bitplanes();
00057   bool rebuild_bitplanes();
00058   void restore_bitplanes();
00059   static void process_1_event();
00060 
00061   int _cube_map_index;
00062   DXGraphicsStateGuardian8 *_dxgsg;
00063   IDirect3DSurface8 *_saved_color_buffer;
00064   IDirect3DSurface8 *_saved_depth_buffer;
00065   D3DSURFACE_DESC    _saved_color_desc;
00066   D3DSURFACE_DESC    _saved_depth_desc;
00067   IDirect3DSurface8 *_color_backing_store;
00068   IDirect3DSurface8 *_depth_backing_store;
00069   int _backing_sizex;
00070   int _backing_sizey;
00071 
00072   wdxGraphicsBuffer8 **_this;
00073 
00074 public:
00075   static TypeHandle get_class_type() {
00076     return _type_handle;
00077   }
00078   static void init_type() {
00079     GraphicsBuffer::init_type();
00080     register_type(_type_handle, "wdxGraphicsBuffer8",
00081                   GraphicsBuffer::get_class_type());
00082   }
00083   virtual TypeHandle get_type() const {
00084     return get_class_type();
00085   }
00086   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00087 
00088 private:
00089   static TypeHandle _type_handle;
00090 
00091   friend class DXGraphicsStateGuardian8;
00092   friend class DXTextureContext8;
00093 };
00094 
00095 #endif
 All Classes Functions Variables Enumerations