Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/dxgsg7/dxgsg7base.h

Go to the documentation of this file.
00001 // Filename: dxTextureContext7.h
00002 // Created by:  drose (07Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef DXGSGBASE_H
00020 #define DXGSGBASE_H
00021 
00022 // include win32 defns for everything up to WinServer2003, and assume I'm smart enough to
00023 // use GetProcAddress for backward compat on w95/w98 for newer fns
00024 #define _WIN32_WINNT 0x0502
00025 
00026 #define WIN32_LEAN_AND_MEAN   // get rid of mfc win32 hdr stuff
00027 #ifndef STRICT
00028 // enable strict type checking in windows.h, see msdn
00029 #define STRICT
00030 #endif
00031 
00032 #include <windows.h>
00033 #include <ddraw.h>
00034 
00035 #define D3D_OVERLOADS   //  get D3DVECTOR '+' operator, etc from d3dtypes.h
00036 #include <d3d.h>
00037 #undef WIN32_LEAN_AND_MEAN
00038 
00039 #if DIRECT3D_VERSION != 0x0700
00040 #error DX7 headers not available, you need to install MS Platform SDK or DirectX 8+ SDK!
00041 #endif
00042 
00043 #include "pandabase.h"
00044 
00045 // disable nameless struct 'warning'
00046 #pragma warning (disable : 4201)
00047 
00048 //#define USE_TEXFMTVEC
00049 // USE_TEXFMTVEC caused crash on dealloc
00050 
00051 #ifdef USE_TEXFMTVEC
00052 typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
00053 #else
00054 #define MAX_DX_TEXPIXFMTS 20    // should be enough for any card
00055 #endif
00056 
00057 #define ISPOW2(X) (((X) & ((X)-1))==0)
00058 
00059 #define DX_DECLARE_CLEAN(type, var) \
00060     type var;                       \
00061     ZeroMemory(&var, sizeof(type)); \
00062     var.dwSize = sizeof(type);
00063 
00064 #define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
00065 #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
00066 #define SAFE_FREELIB(hDLL)   { if(hDLL!=NULL) { FreeLibrary(hDLL); hDLL = NULL; } }
00067 #define IS_VALID_PTR(PTR)  (!IsBadWritePtr(PTR,sizeof(void*)))
00068 
00069 // this is bDoDownToZero argument to RELEASE()
00070 #define RELEASE_DOWN_TO_ZERO true
00071 #define RELEASE_ONCE false
00072 
00073 #define DEBUG_RELEASES
00074 
00075 #ifdef DEBUG_RELEASES
00076 #define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)             \
00077    if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) {         \
00078         refcnt = (OBJECT)->Release();                           \
00079         MODULE##_cat.debug() << DBGSTR << " released, refcnt = " << refcnt << endl;  \
00080         if((bDoDownToZero) && (refcnt>0)) {                     \
00081               MODULE##_cat.warning() << DBGSTR << " released but still has a non-zero refcnt(" << refcnt << "), multi-releasing it down to zero!\n"; \
00082               do {                                \
00083                 refcnt = (OBJECT)->Release();     \
00084               } while(refcnt>0);                  \
00085         }                                         \
00086         (OBJECT) = NULL;                          \
00087       } else {                                    \
00088         MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl;  \
00089       } 
00090 
00091 #define PRINTREFCNT(OBJECT,STR)  {  (OBJECT)->AddRef();  dxgsg7_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
00092 #else
00093 #define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)     \
00094    if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) { \
00095         refcnt=(OBJECT)->Release();                     \
00096         if((bDoDownToZero) && (refcnt>0)) {             \
00097               MODULE##_cat.warning() << DBGSTR << " released but still has a non-zero refcnt(" << refcnt << "), multi-releasing it down to zero!\n"; \
00098               do {                                \
00099                 refcnt = (OBJECT)->Release();     \
00100               } while(refcnt>0);                  \
00101         }                                         \
00102         (OBJECT) = NULL;                          \
00103    }
00104 
00105 #define PRINTREFCNT(OBJECT,STR)  
00106 #endif    
00107 
00108 #ifdef DO_PSTATS
00109 #define DO_PSTATS_STUFF(XX) XX;
00110 #else
00111 #define DO_PSTATS_STUFF(XX)
00112 #endif
00113 
00114 const char *ConvD3DErrorToString(HRESULT error);
00115 
00116 typedef struct {
00117       LPDIRECT3DDEVICE7 pD3DDevice;
00118       LPDIRECTDRAW7     pDD;
00119       LPDIRECT3D7       pD3D;
00120       LPDIRECTDRAWSURFACE7 pddsPrimary,pddsBack,pddsZBuf;
00121       HWND              hWnd;
00122       HMONITOR          hMon;
00123       DWORD             dwRenderWidth,dwRenderHeight,dwFullScreenBitDepth;
00124       RECT              view_rect,clip_rect;
00125       DWORD             MaxAvailVidMem;
00126       bool              bIsLowVidMemCard;
00127       bool              bIsTNLDevice;
00128       bool              bIsSWRast;
00129       bool              bIsFullScreen;
00130       WORD              depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly
00131       WORD              CardIDNum;  // its posn in DisplayArray, for dbgprint purposes
00132       DDDEVICEIDENTIFIER2 DXDeviceID;
00133       D3DDEVICEDESC7    D3DDevDesc;
00134 #ifdef USE_TEXFMTVEC
00135       DDPixelFormatVec  TexPixFmts;
00136 #endif
00137 } DXScreenData;
00138 #endif
00139 

Generated on Fri May 2 00:37:03 2003 for Panda by doxygen1.3