Source code of Windows XP (NT5)
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.

223 lines
6.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmtextureinterobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmViewport2Obj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmTextureInterObj.h"
  15. #include "d3drmObjectArrayObj.h"
  16. extern void *g_dxj_Direct3dRMTextureInterpolator;
  17. C_dxj_Direct3dRMTextureInterpolatorObject::C_dxj_Direct3dRMTextureInterpolatorObject(){
  18. m__dxj_Direct3dRMTextureInterpolator=NULL;
  19. m__dxj_Direct3dRMTexture3=NULL;
  20. parent=NULL;
  21. pinterface=NULL;
  22. creationid = ++g_creationcount;
  23. DPF1(1,"Constructor Creation Direct3dRMTextureInterpolator[%d] \n",g_creationcount);
  24. nextobj = g_dxj_Direct3dRMTextureInterpolator;
  25. g_dxj_Direct3dRMTextureInterpolator = (void *)this;
  26. }
  27. C_dxj_Direct3dRMTextureInterpolatorObject::~C_dxj_Direct3dRMTextureInterpolatorObject(){
  28. DPF1(1,"Destructor Direct3dRMTextureInterpolator [%d] \n",creationid);
  29. C_dxj_Direct3dRMTextureInterpolatorObject *prev=NULL;
  30. for(C_dxj_Direct3dRMTextureInterpolatorObject *ptr=(C_dxj_Direct3dRMTextureInterpolatorObject *)g_dxj_Direct3dRMTextureInterpolator;
  31. ptr;
  32. ptr=(C_dxj_Direct3dRMTextureInterpolatorObject *)ptr->nextobj)
  33. {
  34. if(ptr == this)
  35. {
  36. if(prev)
  37. prev->nextobj = ptr->nextobj;
  38. else
  39. g_dxj_Direct3dRMTextureInterpolator = (void*)ptr->nextobj;
  40. break;
  41. }
  42. prev = ptr;
  43. }
  44. if(m__dxj_Direct3dRMTextureInterpolator){
  45. int count = IUNK(m__dxj_Direct3dRMTextureInterpolator)->Release();
  46. DPF1(1,"DirectX real IDirect3dRMTextureInterpolator Ref count [%d] \n",count);
  47. if(count==0){
  48. m__dxj_Direct3dRMTextureInterpolator = NULL;
  49. }
  50. }
  51. if (parent)
  52. IUNK(parent)->Release();
  53. if (m__dxj_Direct3dRMTexture3)
  54. m__dxj_Direct3dRMTexture3->Release();
  55. }
  56. DWORD C_dxj_Direct3dRMTextureInterpolatorObject::InternalAddRef(){
  57. DWORD i;
  58. i=CComObjectRoot::InternalAddRef();
  59. DPF2(1,"Direct3dRMTextureInterpolator[%d] AddRef %d \n",creationid,i);
  60. return i;
  61. }
  62. DWORD C_dxj_Direct3dRMTextureInterpolatorObject::InternalRelease(){
  63. DWORD i;
  64. i=CComObjectRoot::InternalRelease();
  65. DPF2(1,,"Direct3dRMTextureInterpolator [%d] Release %d \n",creationid,i);
  66. return i;
  67. }
  68. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::InternalGetObject(IUnknown **pUnk){
  69. *pUnk=(IUnknown*)m__dxj_Direct3dRMTextureInterpolator;
  70. return S_OK;
  71. }
  72. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::InternalSetObject(IUnknown *pUnk){
  73. HRESULT hr;
  74. m__dxj_Direct3dRMTextureInterpolator=(LPDIRECT3DRMINTERPOLATOR)pUnk;
  75. hr=pUnk->QueryInterface(IID_IDirect3DRMTexture3,(void**)&m__dxj_Direct3dRMTexture3);
  76. return hr;
  77. }
  78. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::attachObject( /* [in] */ I_dxj_Direct3dRMObject __RPC_FAR *rmObject){
  79. HRESULT hr;
  80. if (!rmObject) return E_INVALIDARG;
  81. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  82. LPDIRECT3DRMOBJECT pObj=NULL;
  83. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  84. if FAILED(hr) return hr;
  85. hr=m__dxj_Direct3dRMTextureInterpolator->AttachObject(pObj);
  86. if (pObj) pObj->Release();
  87. return hr;
  88. }
  89. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::detachObject( /* [in] */ I_dxj_Direct3dRMObject __RPC_FAR *rmObject){
  90. HRESULT hr;
  91. if (!rmObject) return E_INVALIDARG;
  92. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  93. LPDIRECT3DRMOBJECT pObj=NULL;
  94. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  95. if FAILED(hr) return hr;
  96. hr=m__dxj_Direct3dRMTextureInterpolator->DetachObject(pObj);
  97. if (pObj) pObj->Release();
  98. return hr;
  99. }
  100. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::getAttachedObjects( I_dxj_Direct3dRMObjectArray __RPC_FAR *__RPC_FAR *rmArray)
  101. {
  102. HRESULT hr;
  103. IDirect3DRMObjectArray *pArray=NULL;
  104. hr=m__dxj_Direct3dRMTextureInterpolator->GetAttachedObjects(&pArray);
  105. if FAILED(hr) return hr;
  106. INTERNAL_CREATE(_dxj_Direct3dRMObjectArray,pArray,rmArray);
  107. return S_OK;
  108. }
  109. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::setIndex( /* [in] */ float val){
  110. return m__dxj_Direct3dRMTextureInterpolator->SetIndex(val);
  111. }
  112. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::getIndex( float *val){
  113. if (!val) return E_INVALIDARG;
  114. *val=m__dxj_Direct3dRMTextureInterpolator->GetIndex();
  115. return S_OK;
  116. }
  117. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::interpolate( float val,
  118. I_dxj_Direct3dRMObject __RPC_FAR *rmObject,
  119. long options){
  120. HRESULT hr;
  121. LPDIRECT3DRMOBJECT pObj=NULL;
  122. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  123. //we need to validate some options here or rm goes bezerk with invalid values
  124. //note valid flags are
  125. // one of
  126. // D3DRMINTERPOLATION_CLOSED
  127. // D3DRMINTERPOLATION_OPEN -default
  128. // one of
  129. // D3DRMINTERPOLATION_NEAREST
  130. // D3DRMINTERPOLATION_SPLINE
  131. // D3DRMINTERPOLATION_LINEAR -default
  132. // D3DRMINTERPOLATION_VERTEXCOLOR - only on MeshInterpolator
  133. // D3DRMINTERPOLATION_SLERPNORMALS - not implemented
  134. // VALIDATE FLAGS
  135. DWORD opt2=0;
  136. UINT i4;
  137. if (options & D3DRMINTERPOLATION_CLOSED)
  138. opt2=D3DRMINTERPOLATION_CLOSED;
  139. else
  140. opt2=D3DRMINTERPOLATION_OPEN;
  141. if (options & D3DRMINTERPOLATION_NEAREST)
  142. opt2=opt2 | D3DRMINTERPOLATION_NEAREST;
  143. else if (options & D3DRMINTERPOLATION_SPLINE)
  144. opt2=opt2 | D3DRMINTERPOLATION_SPLINE;
  145. else
  146. opt2=opt2 | D3DRMINTERPOLATION_LINEAR;
  147. if (options & D3DRMINTERPOLATION_VERTEXCOLOR)
  148. opt2=opt2 | D3DRMINTERPOLATION_VERTEXCOLOR;
  149. if (pUnk){
  150. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  151. if FAILED(hr) return hr;
  152. }
  153. hr= m__dxj_Direct3dRMTextureInterpolator->Interpolate(val,pObj,(DWORD)opt2);
  154. if (pObj) i4=pObj->Release();
  155. return hr;
  156. }
  157. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::setDecalOrigin( long x, long y)
  158. {
  159. return m__dxj_Direct3dRMTexture3->SetDecalOrigin((DWORD)x,(DWORD)y);
  160. }
  161. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::setDecalSize( float x, float y)
  162. {
  163. return m__dxj_Direct3dRMTexture3->SetDecalSize(x,y);
  164. }
  165. HRESULT C_dxj_Direct3dRMTextureInterpolatorObject::setDecalTransparentColor( long c)
  166. {
  167. return m__dxj_Direct3dRMTexture3->SetDecalTransparentColor((DWORD)c);
  168. }