Browse Source

support multimon

cxgeorge 24 years ago
parent
commit
44ef6c44ba

+ 5 - 8
panda/src/dxgsg/Sources.pp

@@ -12,18 +12,15 @@
     putil linmath sgraph mathutil pnmimage event
     
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx     
+  
+  #define INSTALL_HEADERS \
+    config_dxgsg.h dxGraphicsStateGuardian.I dxGraphicsStateGuardian.h \
+    dxTextureContext.h dxGeomNodeContext.h dxGeomNodeContext.I
 
   #define SOURCES \
-    config_dxgsg.h dxGraphicsStateGuardian.I \
-    dxGraphicsStateGuardian.cxx dxGraphicsStateGuardian.h \
-    dxSavedFrameBuffer.I dxSavedFrameBuffer.h \
-    dxTextureContext.h dxGeomNodeContext.h dxGeomNodeContext.I
+    dxGraphicsStateGuardian.cxx dxSavedFrameBuffer.I dxSavedFrameBuffer.h $[INSTALL_HEADERS]
     
   #define INCLUDED_SOURCES \
     config_dxgsg.cxx dxSavedFrameBuffer.cxx dxTextureContext.cxx dxGeomNodeContext.cxx
-    
-  #define INSTALL_HEADERS \
-    config_dxgsg.h dxGraphicsStateGuardian.I dxGraphicsStateGuardian.h \
-    dxSavedFrameBuffer.I dxSavedFrameBuffer.h dxTextureContext.h
 
 #end lib_target

+ 19 - 19
panda/src/dxgsg/dxGraphicsStateGuardian.I

@@ -30,12 +30,12 @@ enable_line_smooth(bool val) {
     _line_smooth_enabled = val;
   #ifdef NDEBUG
     {
-        if(val && (_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
+        if(val && (scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
            dxgsg_cat.error() << "no HW support for line smoothing!!\n";
     }
   #endif
 
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, (DWORD)val);
   }
 }
 
@@ -47,7 +47,7 @@ enable_line_smooth(bool val) {
 INLINE void DXGraphicsStateGuardian::
 enable_lighting(bool val) {
   if (_lighting_enabled != val) {
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_LIGHTING, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_LIGHTING, (DWORD)val);
     if(_lighting_enabled = val)
       _lighting_enabled_this_frame = true;
   }
@@ -64,14 +64,14 @@ enable_dither(bool val) {
 
   #ifdef _DEBUG
     {
-        if(val && !(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
+        if(val && !(scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
            dxgsg_cat.error() << "no HW support for color dithering!!\n";
         return;
     }
   #endif
 
     _dither_enabled = val;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
   }
 }
 
@@ -84,7 +84,7 @@ INLINE void DXGraphicsStateGuardian::
 enable_stencil_test(bool val) {
   if (_stencil_test_enabled != val) {
     _stencil_test_enabled = val;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, (DWORD)val);
   }
 }
 
@@ -112,12 +112,12 @@ enable_clip_plane(int clip_plane, bool val)
     {
     _clip_plane_enabled[clip_plane] = val;
     DWORD  ClipPlaneBits;
-    _d3dDevice->GetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , &ClipPlaneBits);
+    scrn.pD3DDevice->GetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , &ClipPlaneBits);
     if (val)
         ClipPlaneBits |= 1 << clip_plane;
     else
         ClipPlaneBits &= ~(1 << clip_plane);
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , ClipPlaneBits);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , ClipPlaneBits);
     }
 }
 
@@ -130,7 +130,7 @@ INLINE void DXGraphicsStateGuardian::
 enable_blend(bool val) {
   if (_blend_enabled != val) {
     _blend_enabled = val;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)val);
   }
 }
 
@@ -143,7 +143,7 @@ INLINE void DXGraphicsStateGuardian::
 set_shademode(D3DSHADEMODE val) {
   if (_CurShadeMode != val) {
     _CurShadeMode = val;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, (DWORD)val);
   }
 }
 
@@ -151,7 +151,7 @@ INLINE void DXGraphicsStateGuardian::
 enable_primitive_clipping(bool val) {
   if (_clipping_enabled != val) {
     _clipping_enabled = val;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_CLIPPING, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPING, (DWORD)val);
   }
 }
 
@@ -164,7 +164,7 @@ INLINE void DXGraphicsStateGuardian::
 enable_fog(bool val) {
   if ((_fog_enabled != val) && (_doFogType!=None)) {
     _fog_enabled = val;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
   }
 }
 
@@ -178,7 +178,7 @@ enable_alpha_test(bool val )
 {
   if (_alpha_test_enabled != val) {
     _alpha_test_enabled = val;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, (DWORD)val);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, (DWORD)val);
   }
 }
 
@@ -195,7 +195,7 @@ call_dxLightModelAmbient( const Colorf& color)
 #ifdef GSG_VERBOSE
     dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
 #endif
-    _d3dDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
+    scrn.pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
                 D3DRGBA(color[0], color[1], color[2], color[3]));
   }
 }
@@ -242,8 +242,8 @@ call_dxAlphaFunc(D3DCMPFUNC func, DWORD ref)
     }
     dxgsg_cat.debug() << ref << ")" << endl;
 #endif
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, ref);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, ref);
   }
 }
 
@@ -254,7 +254,7 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
   if (_blend_source_func != sfunc)
     {
     _blend_source_func = sfunc;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
 #ifdef GSG_VERBOSE
     dxgsg_cat.debug() << "dxSrcBlendFunc(";
     switch (sfunc)
@@ -296,7 +296,7 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
   if ( _blend_dest_func != dfunc)
     {
     _blend_dest_func = dfunc;
-    _d3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
+    scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
 #ifdef GSG_VERBOSE
     dxgsg_cat.debug() << "dxDstBlendFunc(";
     switch (dfunc)
@@ -338,7 +338,7 @@ INLINE void DXGraphicsStateGuardian::
 enable_zwritemask(bool val) {
     if (_depth_write_enabled != val) {
         _depth_write_enabled = val;
-        _d3dDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, val);
+        scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, val);
     }
 }
 

File diff suppressed because it is too large
+ 231 - 191
panda/src/dxgsg/dxGraphicsStateGuardian.cxx


+ 54 - 19
panda/src/dxgsg/dxGraphicsStateGuardian.h

@@ -40,9 +40,32 @@
 
 #include "dxGeomNodeContext.h"
 #include "dxTextureContext.h"
+#include <vector>
 
 extern char * ConvD3DErrorToString(const HRESULT &error);   // defined in wdxGraphicsPipe.cxx
 
+typedef struct {
+      LPDIRECT3DDEVICE7 pD3DDevice;
+      LPDIRECTDRAW7     pDD;
+      LPDIRECT3D7       pD3D;
+      LPDIRECTDRAWSURFACE7 pddsPrimary,pddsBack,pddsZBuf;
+      HWND              hWnd;
+      HMONITOR          hMon;
+      DWORD             dwRenderWidth,dwRenderHeight,dwFullScreenBitDepth;
+      RECT              view_rect,clip_rect;
+      DWORD             MaxAvailVidMem;
+      bool              bIsLowVidMemCard;
+      bool              bIsTNLDevice;
+      ushort            depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly
+      ushort            CardIDNum;  // its posn in DisplayArray, for dbgprint purposes
+      DDDEVICEIDENTIFIER2 DXDeviceID;
+      D3DDEVICEDESC7    D3DDevDesc;
+#ifdef USE_TEXFMTVEC
+      DDPixelFormatVec  TexPixFmts;
+#endif
+} DXScreenData;
+// typedef vector<DXScreenData> ScreenDataVector;
+
 class PlaneNode;
 class Light;
 
@@ -61,7 +84,7 @@ INLINE ostream &operator << (ostream &out, GLenum v) {
 
 #define DX_DECLARE_CLEAN(type, var) \
     type var;                       \
-    ZeroMemory(&var, sizeof(type));  \
+    ZeroMemory(&var, sizeof(type)); \
     var.dwSize = sizeof(type);
 
 // #define DEBUG_RELEASES
@@ -123,6 +146,8 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
   friend class wdxGraphicsWindow;
+  friend class wdxGraphicsPipe;
+  friend class wdxGraphicsWindowGroup;
   friend class DXTextureContext;
 
 public:
@@ -227,10 +252,15 @@ public:
 
 public:
   // recreate_tex_callback needs these to be public
-  LPDIRECT3DDEVICE7 _d3dDevice;
+  LPDIRECT3DDEVICE7 _pCurD3DDevice;  //this needs to be set every device iteration
+  LPDIRECTDRAW7 _pDD;
+  DXScreenData scrn;
+
+#ifndef USE_TEXFMTVEC
   LPDDPIXELFORMAT   _pTexPixFmts;
   int               _cNumTexPixFmts;
-  D3DDEVICEDESC7    _D3DDevDesc;
+#endif
+//  D3DDEVICEDESC7    _D3DDevDesc;
 
 protected:
   void free_pointers();            // free local internal buffers
@@ -249,15 +279,23 @@ protected:
 
   bool                  _dx_ready;
   HRESULT               _last_testcooplevel_result;
+
+/*
+  moved to per display data
   bool                  _bIsTNLDevice;
   LPDIRECTDRAWSURFACE7  _back;
   LPDIRECTDRAWSURFACE7  _zbuf;
-  LPDIRECT3D7           _d3d;
   LPDIRECTDRAWSURFACE7  _pri;
+
+  LPDIRECT3D7           _d3d;
   LPDIRECTDRAW7         _pDD;
+  RECT              _view_rect;
+  RECT              clip_rect;  
+*/
+  LPDIRECT3D7           _pCurD3D7;
+  LPDIRECTDRAW7         _pCurDD;
+  bool                  _bShowFPSMeter;
 
-  RECT                _view_rect;
-  RECT                clip_rect;
   HDC               _front_hdc;
   DXTextureContext  *_pCurTexContext;
 
@@ -326,7 +364,6 @@ protected:
   Colorf _issued_color;           // WBD ADDED
   D3DCOLOR _issued_color_D3DCOLOR;           // WBD ADDED
   D3DCOLOR _d3dcolor_clear_value;
-
   D3DSHADEMODE _CurShadeMode;
 
   bool _bDrawPrimDoSetupVertexBuffer;       // if true, draw methods just copy vertex data into pCurrentGeomContext
@@ -367,10 +404,7 @@ protected:
   bool _fog_enabled;
 /*  
   TODO: cache fog state
-  float _fog_start;
-  float _fog_end;
-  float _fog_density;
-  float _fog_color;
+  float _fog_start,_fog_end,_fog_density,float _fog_color;
 */    
   float      _alpha_func_ref;
   D3DCMPFUNC _alpha_func;
@@ -395,7 +429,6 @@ protected:
   int _decal_level;
 
   RenderModeProperty::Mode _current_fill_mode;  //poinr/wireframe/solid
-
   GraphicsChannel *_panda_gfx_channel;  // cache the 1 channel dx supports
 
   // Cur Texture State
@@ -449,12 +482,13 @@ public:
   static void init_type(void);
   virtual TypeHandle get_type(void) const;
   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-  LPDIRECT3DDEVICE7 GetD3DDevice()  {  return _d3dDevice; }
-  LPDIRECTDRAW7 GetDDInterface()  {  return _pDD; }
-  LPDIRECTDRAWSURFACE7 GetBackBuffer()  {  return _back; }
+/*
+  LPDIRECT3DDEVICE7 GetD3DDevice()  {  return scrn.pD3DDevice; }
+  LPDIRECTDRAW7 GetDDInterface()  {  return scrn.pDD; }
+  LPDIRECTDRAWSURFACE7 GetBackBuffer()  {  return scrn.pddsBackBuffer; }
   LPDIRECTDRAWSURFACE7 GetZBuffer()  {  return _zbuf; }
-  INLINE void  Set_HDC(HDC hdc)  {  _front_hdc = hdc;  }
+*/  
+//  INLINE void Set_HDC(HDC hdc)  {  _front_hdc = hdc;  }
   void adjust_view_rect(int x, int y);
   INLINE void SetDXReady(bool stat)  {  _dx_ready = stat; }
   INLINE bool GetDXReady(void)  { return _dx_ready;}
@@ -469,13 +503,14 @@ public:
   void  show_frame();
   void  show_full_screen_frame();
   void  show_windowed_frame();
-  void  dx_init(  LPDIRECTDRAW7     context,
+/*  void  dx_init(  LPDIRECTDRAW7     context,
           LPDIRECTDRAWSURFACE7  pri,
           LPDIRECTDRAWSURFACE7  back,
           LPDIRECTDRAWSURFACE7  zbuf,
           LPDIRECT3D7          d3d,
           LPDIRECT3DDEVICE7    d3dDevice,
-          RECT  viewrect);
+          RECT  viewrect); */
+  void dx_init(void);
   
   friend HRESULT CALLBACK EnumTexFmtsCallback( LPDDPIXELFORMAT pddpf, VOID* param );
 

+ 29 - 11
panda/src/dxgsg/dxTextureContext.cxx

@@ -971,24 +971,38 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
 //       gets the attributes of the texture from the bitmap, creates the
 //       texture, and then copies the bitmap into the texture.
 //-----------------------------------------------------------------------------
-LPDIRECTDRAWSURFACE7 DXTextureContext::
-CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts, LPD3DDEVICEDESC7 pD3DDevDesc) {
+LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, 
+#ifdef USE_TEXFMTVEC
+                                        DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
+#else
+                                        int cNumTexPixFmts, DDPIXELFORMAT *pTexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
+#endif
+   {
     HRESULT hr;
-    int i;
-    PixelBuffer *pbuf = _texture->_pbuffer;
-    int cNumAlphaBits;     //  number of alpha bits in texture pixfmt
-
+    int i,cNumAlphaBits;     //  number of alpha bits in texture pixfmt
     DDPIXELFORMAT *pDesiredPixFmt;
     LPDIRECTDRAWSURFACE7 pddsRender;
     LPDIRECTDRAW7        pDD = NULL;
+    ConversionType ConvNeeded;
 
-    DDPIXELFORMAT TexFmtsArr[MAX_DX_TEXPIXFMTS];
+    assert(_texture!=NULL);
 
-    ConversionType ConvNeeded;
+    PixelBuffer *pbuf = _texture->_pbuffer;
+
+#ifdef USE_TEXFMTVEC
+    int cNumTexPixFmts=TexturePixelFormats.size();
+#endif
+    DDPIXELFORMAT *pTexPixFmts = new DDPIXELFORMAT[cNumTexPixFmts];
 
     // make local copy of array so I can muck with it during searches for this texture fmt
-    memcpy(TexFmtsArr,pTexPixFmts,cNumTexPixFmts*sizeof(DDPIXELFORMAT));
-    pTexPixFmts=TexFmtsArr;
+    // (such as marking pixfmts that no search will be interested in)
+    // probably should do this faster way
+
+#ifdef USE_TEXFMTVEC
+    memcpy(pTexPixFmts,&TexturePixelFormats[0],cNumTexPixFmts*sizeof(DDPIXELFORMAT));
+#else
+    memcpy(pTexPixFmts,pTexFmts,cNumTexPixFmts*sizeof(DDPIXELFORMAT));
+#endif
 
     // bpp indicates requested fmt, not pixbuf fmt
     DWORD bpp = get_bits_per_pixel(pbuf->get_format(), &cNumAlphaBits);
@@ -1128,7 +1142,8 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
 
     szErrorMsg = "CreateTexture failed: couldn't find compatible Tex DDPIXELFORMAT!\n";
 
-    dxgsg_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
+    if(dxgsg_cat.is_spam())
+        dxgsg_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
 
     // Mark formats I dont want to deal with
     for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
@@ -1583,6 +1598,8 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
     // Done with DDraw
     pDD->Release();
 
+    delete [] pTexPixFmts;
+
     // Return the newly created texture
     return _surface;
 
@@ -1595,6 +1612,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
         _surface = NULL;
     }
 
+    delete [] pTexPixFmts;
     return NULL;
 }
 

+ 14 - 2
panda/src/dxgsg/dxTextureContext.h

@@ -38,7 +38,13 @@
 #include <texture.h>
 #include <textureContext.h>
 
+//#define USE_TEXFMTVEC  // doesnt work now, crashes in destructor
+
+#ifdef USE_TEXFMTVEC
+typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
+#else
 #define MAX_DX_TEXPIXFMTS 20    // should be enough for any card
+#endif
 
 ////////////////////////////////////////////////////////////////////
 //   Class : DXTextureContext
@@ -55,8 +61,14 @@ public:
   LPDIRECTDRAWSURFACE7  _surface;
   Texture *_tex;            // ptr to parent, primarily for access to namestr
 
-  LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, 
-                                     LPDDPIXELFORMAT pTexPixFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
+//  static is_unused_texpixelformat(DDPIXELFORMAT *)
+
+#ifdef USE_TEXFMTVEC
+  LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
+#else
+  LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, DDPIXELFORMAT *pTexFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
+#endif
+
   bool _bHasMipMaps;
   DWORD _PixBufConversionType;  // enum ConversionType
 

+ 0 - 1
panda/src/wdxdisplay/config_wdxdisplay.cxx

@@ -29,7 +29,6 @@ ConfigureFn(config_wdxdisplay) {
   init_libwdxdisplay();
 }
 
-int dx_use_multimon = config_wdxdisplay.GetInt("dx-multimon", 1);
 bool dx_force_16bpp_zbuffer = config_wdxdisplay.GetBool("dx-force-16bpp-zbuffer", false);
 bool bResponsive_minimized_fullscreen_window = config_wdxdisplay.GetBool("responsive-minimized-fullscreen-window",false);
 bool dx_preserve_fpu_state = config_wdxdisplay.GetBool("dx-preserve-fpu-state", false);

+ 0 - 1
panda/src/wdxdisplay/config_wdxdisplay.h

@@ -28,7 +28,6 @@ NotifyCategoryDecl(wdxdisplay, EXPCL_PANDADX, EXPTP_PANDADX);
 extern bool bResponsive_minimized_fullscreen_window;
 extern bool dx_force_16bpp_zbuffer;
 extern bool dx_preserve_fpu_state;
-extern int dx_use_multimon;
 extern Filename get_icon_filename();
 extern Filename get_mono_cursor_filename();
 extern Filename get_color_cursor_filename();

+ 1 - 1
panda/src/wdxdisplay/wdxGraphicsPipe.cxx

@@ -101,7 +101,7 @@ find_window(HWND win) {
     int num_windows = get_num_windows();
     for(int w = 0; w < num_windows; w++) {
         wdxGraphicsWindow *window = DCAST(wdxGraphicsWindow, get_window(w));
-        if(window->_mwindow == win)
+        if(window->_dxgsg->scrn.hWnd == win)
             return window;
     }
     return NULL;

File diff suppressed because it is too large
+ 579 - 363
panda/src/wdxdisplay/wdxGraphicsWindow.cxx


+ 67 - 27
panda/src/wdxdisplay/wdxGraphicsWindow.h

@@ -30,14 +30,26 @@
 #undef WINDOWS_LEAN_AND_MEAN
 #include <d3d.h>
 
+#include "dxGraphicsStateGuardian.h"
 
 ////////////////////////////////////////////////////////////////////
 // Defines
 ////////////////////////////////////////////////////////////////////
 class wdxGraphicsPipe;
+class wdxGraphicsWindowGroup;
 
-const int WDXWIN_CONFIGURE =    4;
-const int WDXWIN_EVENT =    8;
+const int WDXWIN_CONFIGURE = 4;
+const int WDXWIN_EVENT = 8;
+
+typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID  *lplpDD, REFIID  iid,IUnknown FAR *pUnkOuter);
+
+typedef struct {
+   char    szDriver[MAX_DDDEVICEID_STRING];
+   char    szDescription[MAX_DDDEVICEID_STRING];
+   GUID    guidDeviceIdentifier;
+   HMONITOR hMon;
+} DXDeviceInfo;
+typedef vector<DXDeviceInfo> DXDeviceInfoVec;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : wdxGraphicsWindow
@@ -46,31 +58,29 @@ const int WDXWIN_EVENT =    8;
 class EXPCL_PANDADX wdxGraphicsWindow : public GraphicsWindow {
  friend class DXGraphicsStateGuardian;
  friend class DXTextureContext;
+ friend class wdxGraphicsWindowGroup;
 
 public:
   wdxGraphicsWindow(GraphicsPipe* pipe);
-  wdxGraphicsWindow(GraphicsPipe* pipe,
-             const GraphicsWindow::Properties& props);
-  virtual ~wdxGraphicsWindow(void);
+  wdxGraphicsWindow(GraphicsPipe* pipe,const GraphicsWindow::Properties& props);
+
+  // this constructor will not initialize the wdx stuff, only the panda graphicswindow stuff
+  wdxGraphicsWindow(GraphicsPipe* pipe,const GraphicsWindow::Properties& props,wdxGraphicsWindowGroup *pParentGroup);
 
+  virtual ~wdxGraphicsWindow(void);
   virtual bool supports_update() const;
   virtual void update(void);
   virtual void end_frame( void );
 
   virtual TypeHandle get_gsg_type() const;
   static GraphicsWindow* make_wdxGraphicsWindow(const FactoryParams &params);
-  void CreateScreenBuffersAndDevice(DWORD dwRenderWidth, DWORD dwRenderHeight,
-                                    LPDIRECTDRAW7 pDD,LPDIRECT3D7 pD3DI,
-                                    D3DDEVICEDESC7 *pD3DDevDesc);
 
   LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
   void process_events(void);
 
   INLINE bool mouse_entry_enabled(void) { return _mouse_entry_enabled; }
   INLINE bool mouse_motion_enabled(void) { return _mouse_motion_enabled; }
-  INLINE bool mouse_passive_motion_enabled(void) {
-    return _mouse_passive_motion_enabled;
-  }
+  INLINE bool mouse_passive_motion_enabled(void) { return _mouse_passive_motion_enabled; }
   void handle_window_move( int x, int y );
   void handle_mouse_motion( int x, int y );
   void handle_mouse_entry( int state, HCURSOR hMouseCursor );
@@ -79,8 +89,6 @@ public:
   void dx_setup();
   virtual void begin_frame( void );
   void show_frame();
-  DXGraphicsStateGuardian *_dxgsg;
-  
   virtual void resize(unsigned int xsize,unsigned int ysize);
   virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
   virtual int get_depth_bitwidth(void);
@@ -88,31 +96,30 @@ public:
 protected:
   void CreateScreenBuffersAndDevice(LPDIRECTDRAW7 pDD,LPDIRECT3D7 pD3DI);
   ButtonHandle lookup_key(WPARAM wparam) const;
-  virtual void config( void );
+//  virtual void config(void);
+  void config_single_window(void);
+  void config_window(wdxGraphicsWindowGroup *pParentGroup);
+  void finish_window_setup(void);
+  bool search_for_device(int devnum,DXDeviceInfo *pDevinfo);
   void setup_colormap(void);
 
   void enable_mouse_input(bool val);
   void enable_mouse_motion(bool val);
   void enable_mouse_passive_motion(bool val);
   void enable_mouse_entry(bool val);
-  void check_for_color_cursor_support(void);
-  DDDEVICEIDENTIFIER2 _DXDeviceID;
 
 public:
-  HWND              _mwindow;
-  HWND              _hOldForegroundWindow;  
-  UINT_PTR          _PandaPausedTimer;
-
+  UINT_PTR _PandaPausedTimer;
+  DXGraphicsStateGuardian *_dxgsg;
+  void CreateScreenBuffersAndDevice(DXScreenData &Display);
+  
 private:
+  wdxGraphicsWindowGroup *_pParentWindowGroup;
   HDC               _hdc;
   HPALETTE          _colormap;
   typedef enum { NotAdjusting,MovingOrResizing,Resizing } WindowAdjustType;
-  WindowAdjustType _WindowAdjustingType;
-  bool              _bIsLowVidMemCard;
-  DWORD             _MaxAvailVidMem;
-  bool    _bLoadedCustomCursor;
-  HCURSOR _hMouseCursor;
-  bool    _bSizeIsMaximized;
+  WindowAdjustType  _WindowAdjustingType;
+  bool              _bSizeIsMaximized;
   bool              _mouse_input_enabled;
   bool              _mouse_motion_enabled;
   bool              _mouse_passive_motion_enabled;
@@ -122,7 +129,6 @@ private:
   bool              _active_minimized_fullscreen;
   bool              _return_control_to_app;
   int               _depth_buffer_bpp;
-  HINSTANCE         _hDDraw_DLL;
 
 public:
   static TypeHandle get_class_type(void);
@@ -140,6 +146,40 @@ private:
   static TypeHandle _type_handle;
 };
 
+// this class really belongs in panda, not here
+class EXPCL_PANDADX wdxGraphicsWindowGroup {
+// group of windows are all created at the same time
+    friend class wdxGraphicsWindow;
+
+PUBLISHED: 
+    wdxGraphicsWindowGroup(GraphicsPipe *,const GraphicsWindow::Properties&);
+    wdxGraphicsWindowGroup(GraphicsPipe *,const GraphicsWindow::Properties&,const GraphicsWindow::Properties&);
+    wdxGraphicsWindowGroup(GraphicsPipe *,const GraphicsWindow::Properties&,const GraphicsWindow::Properties&,
+                           const GraphicsWindow::Properties&);
+public:
+    wdxGraphicsWindowGroup(wdxGraphicsWindow *OneWindow);
+    // dont publish variable length one, since FFI wont support it
+    wdxGraphicsWindowGroup(GraphicsPipe *pipe,int num_windows,GraphicsWindow::Properties *WinPropArray);
+    ~wdxGraphicsWindowGroup();
+    void SetCoopLevelsAndDisplayModes(void);
+public:
+    void CreateWindows(void);
+    void make_windows(GraphicsPipe *,int num_windows,GraphicsWindow::Properties *pWinPropArray);
+    void initWindowGroup(void);
+
+    pvector<wdxGraphicsWindow *> _windows;
+    DXDeviceInfoVec *_pDeviceInfoVec;  // only used during init to store valid devices
+    HWND      _hParentWindow;
+    HINSTANCE _hDDrawDLL;
+    HWND      _hOldForegroundWindow;  
+    HCURSOR   _hMouseCursor;
+    bool      _bLoadedCustomCursor;
+    bool      _bClosingAllWindows;
+    int       _numMonitors;
+    LPDIRECTDRAWCREATEEX    _pDDCreateEx;
+    DXDeviceInfoVec _DeviceInfoVec;
+};
+
 extern void set_global_parameters(void);
 extern void restore_global_parameters(void);
 

Some files were not shown because too many files changed in this diff