Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  1. //====== Copyright c 1996-2007, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef DXINCLUDEIMPL_H
  9. #define DXINCLUDEIMPL_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. FileCache s_incFileCache;
  14. struct DxIncludeImpl : public ID3DXInclude
  15. {
  16. STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes)
  17. {
  18. CachedFileData *pFileData = s_incFileCache.Get( pFileName );
  19. if ( !pFileData || !pFileData->IsValid() )
  20. return E_FAIL;
  21. *ppData = pFileData->GetDataPtr();
  22. *pBytes = pFileData->GetDataLen();
  23. pFileData->UpdateRefCount( +1 );
  24. return S_OK;
  25. }
  26. STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData,
  27. LPCVOID *ppData, UINT *pBytes,
  28. /* OUT */ LPSTR pFullPath, DWORD cbFullPath)
  29. {
  30. if ( pFullPath && cbFullPath ) strncpy( pFullPath, pFileName, cbFullPath );
  31. return Open( IncludeType, pFileName, pParentData, ppData, pBytes );
  32. }
  33. STDMETHOD(Close)(THIS_ LPCVOID pData)
  34. {
  35. if ( CachedFileData *pFileData = CachedFileData::GetByDataPtr( pData ) )
  36. pFileData->UpdateRefCount( -1 );
  37. return S_OK;
  38. }
  39. };
  40. DxIncludeImpl s_incDxImpl;
  41. #endif // #ifndef DXINCLUDEIMPL_H