/////////////////////////////////////////////////////////////////////////////// // // ## ###### // ###### ### // ## ############### Shark 3D Engine (www.shark3d.com) // ########## # # # // ######## Copyright (c) 1996-2006 Spinor GmbH. // ######### # # # All rights reserved. // ## ########## // ## // /////////////////////////////////////////////////////////////////////////////// //@cpp #ifndef S3D_DRV_DXBASE_H #define S3D_DRV_DXBASE_H #include "general/general_env.h" #include "drv/interf/drv_gfx.h" /////////////////////////////////////////////////////////////////////////////// #ifndef S3D_GENERAL_PLATFORM_XBOXFAMILY #ifndef S3D_DRV_D3D_DX8 #include #include // Check DX versions to ensure that an SDK is compiled and linked // against a well-defined DX version: // Important! If you change the version here, // then don't forget to change the verison // also in the documentation about - requirements. // Also important! If you support more than one version, // then you must add the version string to the S3D_GENERAL_AMBIT macro. #if DIRECT3D_VERSION != 0x0900 #pragma message( "Found DIRECT3D_VERSION = " \ S3D_GENERAL_STR(DIRECT3D_VERSION) ) #error Wrong DIRECT3D_VERSION. See the previous output line. #endif // Important! If you change the version here, // then don't forget to change the verison // also in the documentation about - requirements. // Also important! If you support more than one version, // then you must add the version string to the S3D_GENERAL_AMBIT macro. #if (D3D_SDK_VERSION & 0x7fffffff) != 32 #pragma message( "Found D3D_SDK_VERSION = " \ S3D_GENERAL_STR(D3D_SDK_VERSION) ) #error Wrong D3D_SDK_VERSION. See the previous output line. #endif // Important! If you change the version here, // then don't forget to change the verison // also in the documentation about - requirements. // Also important! If you support more than one version, // then you must add the version string to the S3D_GENERAL_AMBIT macro. #if D3DX_VERSION != 0x0902 #pragma message( "Found D3DX_VERSION = " \ S3D_GENERAL_STR(D3DX_VERSION) ) #error Wrong D3DX_VERSION. See the previous output line. #endif // Important! If you change the version here, // then don't forget to change the verison // also in the documentation about - requirements. // Also important! If you support more than one version, // then you must add the version string to the S3D_GENERAL_AMBIT macro. #if D3DX_SDK_VERSION != 31 // HE CAMBIADO ESTO PORQUE AQUÍ USO LA VERSION de Octubre DE D3DX #pragma message( "Found D3DX_SDK_VERSION = " \ S3D_GENERAL_STR(D3DX_SDK_VERSION) ) #error Wrong D3DX_SDK_VERSION. See the previous output line. #endif #endif #endif /////////////////////////////////////////////////////////////////////////////// //@ template class s3d_CDrvDxCom { public: //@ s3d_CDrvDxCom(); //@ s3d_CDrvDxCom(const s3d_CDrvDxCom &Com); //@ ~s3d_CDrvDxCom(); //@ void Reset(); //@ void operator=(T p); //@ void operator=(const s3d_CDrvDxCom &Com); //@ const T operator->() const; //@ operator const T() const; //@ T Get() const; //@ To use in QueryInterface functions or other functions // calling implicitely AddRef. T &EmptyRef(); private: __declspec(align(16)) T m_p; }; /////////////////////////////////////////////////////////////////////////////// //@ struct s3d_CDrvDxError: s3d_CDrvGfxError { }; /////////////////////////////////////////////////////////////////////////////// // Implementations: /////////////////////////////////////////////////////////////////////////////// template S3D_SYS_INLINE s3d_CDrvDxCom::s3d_CDrvDxCom() { m_p = 0; } template S3D_SYS_INLINE s3d_CDrvDxCom::s3d_CDrvDxCom(const s3d_CDrvDxCom &Com) { T p = Com.m_p; m_p = p; if(p) p->AddRef(); } template S3D_SYS_INLINE s3d_CDrvDxCom::~s3d_CDrvDxCom() { T pLast = m_p; if(pLast) pLast->Release(); } template S3D_SYS_INLINE void s3d_CDrvDxCom::Reset() { T pLast = m_p; if(pLast) { pLast->Release(); m_p = 0; } } template S3D_SYS_INLINE void s3d_CDrvDxCom::operator=(T p) { if(p) p->AddRef(); T pLast = m_p; if(pLast) pLast->Release(); m_p = p; } template S3D_SYS_INLINE void s3d_CDrvDxCom::operator=(const s3d_CDrvDxCom &Com) { T p = Com.m_p; if(p) p->AddRef(); T pLast = m_p; if(pLast) pLast->Release(); m_p = p; } template S3D_SYS_INLINE const T s3d_CDrvDxCom::operator->() const { return m_p; } template S3D_SYS_INLINE s3d_CDrvDxCom::operator const T() const { return m_p; } template S3D_SYS_INLINE T s3d_CDrvDxCom::Get() const { return m_p; } template S3D_SYS_INLINE T &s3d_CDrvDxCom::EmptyRef() { T pLast = m_p; if(pLast) { pLast->Release(); m_p = 0; } return m_p; } /////////////////////////////////////////////////////////////////////////////// #endif