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.

161 lines
4.1 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. __try {
  95. memcpy(&(((char*)m_pData) [startIndex*m_vertSize]),verts,count*m_vertSize);
  96. }
  97. __except(1,1){
  98. return E_FAIL;
  99. }
  100. return S_OK;
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. STDMETHODIMP C_dxj_Direct3dVertexBuffer7Object::getVertices(
  104. /* [in] */ long startIndex,
  105. /* [in] */ long count,
  106. /* [in] */ void __RPC_FAR *verts)
  107. {
  108. if (!m_vertSize) {
  109. return E_FAIL;
  110. }
  111. if (!m_pData) {
  112. return E_FAIL;
  113. }
  114. __try {
  115. memcpy(verts,&( ((char*)m_pData) [startIndex*m_vertSize]),count*m_vertSize);
  116. }
  117. __except(1,1){
  118. return E_FAIL;
  119. }
  120. return S_OK;
  121. }
  122. /////////////////////////////////////////////////////////////////////////////