Leaked source code of windows server 2003
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.

163 lines
4.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3dvertexbuffer7obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3dMaterialObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3dVertexBuffer7Obj.h"
  15. CONSTRUCTOR(_dxj_Direct3dVertexBuffer7, {m_pData=NULL;m_vertSize=0;});
  16. DESTRUCTOR(_dxj_Direct3dVertexBuffer7, {});
  17. GETSET_OBJECT(_dxj_Direct3dVertexBuffer7);
  18. /////////////////////////////////////////////////////////////////////////////
  19. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::getVertexBufferDesc(
  20. /* [out][in] */ D3dVertexBufferDesc __RPC_FAR *desc)
  21. {
  22. HRESULT hr;
  23. ((D3DVERTEXBUFFERDESC*)desc)->dwSize=sizeof(D3DVERTEXBUFFERDESC);
  24. hr=m__dxj_Direct3dVertexBuffer7->GetVertexBufferDesc((D3DVERTEXBUFFERDESC*)desc);
  25. return hr;
  26. }
  27. /////////////////////////////////////////////////////////////////////////////
  28. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::processVertices(
  29. /* [in] */ long vertexOp,
  30. /* [in] */ long destIndex,
  31. /* [in] */ long count,
  32. /* [in] */ I_dxj_Direct3dVertexBuffer7 __RPC_FAR *srcBuffer,
  33. /* [in] */ long srcIndex,
  34. /* [in] */ I_dxj_Direct3dDevice7 __RPC_FAR *dev,
  35. long flags
  36. )
  37. {
  38. HRESULT hr;
  39. if (!srcBuffer) return E_INVALIDARG;
  40. if (!dev) return E_INVALIDARG;
  41. DO_GETOBJECT_NOTNULL( LPDIRECT3DVERTEXBUFFER7, realBuffer, srcBuffer);
  42. DO_GETOBJECT_NOTNULL( LPDIRECT3DDEVICE7, realDev, dev);
  43. hr=m__dxj_Direct3dVertexBuffer7->ProcessVertices(
  44. (DWORD) vertexOp,
  45. (DWORD) destIndex,
  46. (DWORD) count,
  47. realBuffer,
  48. (DWORD) srcIndex,
  49. realDev,
  50. (DWORD) flags);
  51. return hr;
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::lock(
  55. /* [in] */ long flags)
  56. {
  57. HRESULT hr;
  58. hr=m__dxj_Direct3dVertexBuffer7->Lock((DWORD) flags, &m_pData,NULL);
  59. return hr;
  60. }
  61. /////////////////////////////////////////////////////////////////////////////
  62. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::setVertexSize( /* [in] */ long n)
  63. {
  64. m_vertSize=(DWORD)n;
  65. return S_OK;
  66. }
  67. /////////////////////////////////////////////////////////////////////////////
  68. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::unlock()
  69. {
  70. HRESULT hr;
  71. hr=m__dxj_Direct3dVertexBuffer7->Unlock();
  72. m_pData=NULL;
  73. return hr;
  74. }
  75. /////////////////////////////////////////////////////////////////////////////
  76. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::optimize(
  77. /* [in] */ I_dxj_Direct3dDevice7 __RPC_FAR *dev
  78. )
  79. {
  80. HRESULT hr;
  81. if (!dev) return E_INVALIDARG;
  82. DO_GETOBJECT_NOTNULL( LPDIRECT3DDEVICE7, realdev, dev);
  83. hr=m__dxj_Direct3dVertexBuffer7->Optimize(realdev,(DWORD) 0);
  84. return hr;
  85. }
  86. /////////////////////////////////////////////////////////////////////////////
  87. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::setVertices(
  88. /* [in] */ long startIndex,
  89. /* [in] */ long count,
  90. /* [in] */ void __RPC_FAR *verts)
  91. {
  92. if (!m_vertSize) return E_FAIL;
  93. if (!m_pData) return E_FAIL;
  94. if (!verts) return E_INVALIDARG;
  95. __try {
  96. memcpy(&(((char*)m_pData) [startIndex*m_vertSize]),verts,count*m_vertSize);
  97. }
  98. __except(1,1){
  99. return E_FAIL;
  100. }
  101. return S_OK;
  102. }
  103. /////////////////////////////////////////////////////////////////////////////
  104. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::getVertices(
  105. /* [in] */ long startIndex,
  106. /* [in] */ long count,
  107. /* [in] */ void __RPC_FAR *verts)
  108. {
  109. if (!m_vertSize) {
  110. return E_FAIL;
  111. }
  112. if (!m_pData) {
  113. return E_FAIL;
  114. }
  115. if (!verts) return E_INVALIDARG;
  116. __try {
  117. memcpy(verts,&( ((char*)m_pData) [startIndex*m_vertSize]),count*m_vertSize);
  118. }
  119. __except(1,1){
  120. return E_FAIL;
  121. }
  122. return S_OK;
  123. }
  124. /////////////////////////////////////////////////////////////////////////////