Panda3D

wdxGraphicsWindow9.h

00001 // Filename: wdxGraphicsWindow9.h
00002 // Created by:  mike (09Jan97)
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 WDXGRAPHICSWINDOW9_H
00016 #define WDXGRAPHICSWINDOW9_H
00017 
00018 #include "pandabase.h"
00019 #include "winGraphicsWindow.h"
00020 #include "dxGraphicsStateGuardian9.h"
00021 #include "dxInput9.h"
00022 #include "wdxGraphicsPipe9.h"
00023 
00024 class wdxGraphicsPipe9;
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : wdxGraphicsWindow9
00028 // Description : A single graphics window for rendering DirectX under
00029 //               Microsoft Windows.
00030 ////////////////////////////////////////////////////////////////////
00031 class EXPCL_PANDADX wdxGraphicsWindow9 : public WinGraphicsWindow {
00032 public:
00033   wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe,
00034                      const string &name,
00035                      const FrameBufferProperties &fb_prop,
00036                      const WindowProperties &win_prop,
00037                      int flags,
00038                      GraphicsStateGuardian *gsg,
00039                      GraphicsOutput *host);
00040   virtual ~wdxGraphicsWindow9();
00041 
00042   virtual bool begin_frame(FrameMode mode, Thread *current_thread);
00043   virtual void end_frame(FrameMode mode, Thread *current_thread);
00044   virtual void end_flip();
00045 
00046   virtual int verify_window_sizes(int numsizes, int *dimen);
00047 
00048 protected:
00049   virtual void close_window();
00050   virtual bool open_window();
00051   virtual void reset_window(bool swapchain);
00052 
00053   virtual void fullscreen_restored(WindowProperties &properties);
00054   virtual void handle_reshape();
00055   virtual bool do_fullscreen_resize(int x_size, int y_size);
00056 
00057 private:
00058   struct DXDeviceInfo {
00059     UINT cardID;
00060     char szDriver[MAX_DEVICE_IDENTIFIER_STRING];
00061     char szDescription[MAX_DEVICE_IDENTIFIER_STRING];
00062     GUID guidDeviceIdentifier;
00063     DWORD VendorID, DeviceID;
00064     LARGE_INTEGER _driver_version;
00065     HMONITOR _monitor;
00066   };
00067   typedef pvector<DXDeviceInfo> DXDeviceInfoVec;
00068 
00069   bool create_screen_buffers_and_device(DXScreenData &display,
00070                                         bool force_16bpp_zbuffer);
00071 
00072   bool choose_device();
00073   bool consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info);
00074 
00075   bool reset_device_resize_window(UINT new_xsize, UINT new_ysize);
00076   void init_resized_window();
00077   void make_current();
00078   static int D3DFMT_to_DepthBits(D3DFORMAT fmt);
00079   static bool is_badvidmem_card(D3DADAPTER_IDENTIFIER9 *pDevID);
00080 
00081   DXGraphicsStateGuardian9 *_dxgsg;
00082   DXScreenData _wcontext;
00083 
00084   int _depth_buffer_bpp;
00085   bool _awaiting_restore;
00086 
00087 public:
00088   static TypeHandle get_class_type() {
00089     return _type_handle;
00090   }
00091   static void init_type() {
00092     WinGraphicsWindow::init_type();
00093     register_type(_type_handle, "wdxGraphicsWindow9",
00094                   WinGraphicsWindow::get_class_type());
00095   }
00096   virtual TypeHandle get_type() const {
00097     return get_class_type();
00098   }
00099   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00100 
00101 private:
00102   static TypeHandle _type_handle;
00103   friend class wdxGraphicsPipe9;
00104 };
00105 
00106 
00107 #include "wdxGraphicsWindow9.I"
00108 
00109 #endif
 All Classes Functions Variables Enumerations