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.

229 lines
7.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmviewport2obj.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 "d3drmViewport2Obj.h"
  15. //#include "d3dViewport3Obj.h"
  16. #include "d3drmPickedArrayObj.h"
  17. #include "d3drmFrame3Obj.h"
  18. #include "d3drmDevice3Obj.h"
  19. //CONSTRUCTOR(_dxj_Direct3dRMViewport2, {});
  20. //DESTRUCTOR(_dxj_Direct3dRMViewport2, {});
  21. C_dxj_Direct3dRMViewport2Object::C_dxj_Direct3dRMViewport2Object(){
  22. m__dxj_Direct3dRMViewport2=NULL;
  23. parent=NULL;
  24. pinterface=NULL;
  25. creationid = ++g_creationcount;
  26. DPF1(1,"Constructor Creation Direct3dRMViewport2[%d] \n",g_creationcount);
  27. nextobj = g_dxj_Direct3dRMViewport2;
  28. g_dxj_Direct3dRMViewport2 = (void *)this;
  29. }
  30. C_dxj_Direct3dRMViewport2Object::~C_dxj_Direct3dRMViewport2Object(){
  31. DPF1(1,"Destructor Direct3dRMViewport2 [%d] \n",creationid);
  32. C_dxj_Direct3dRMViewport2Object *prev=NULL;
  33. for(C_dxj_Direct3dRMViewport2Object *ptr=(C_dxj_Direct3dRMViewport2Object *)g_dxj_Direct3dRMViewport2;
  34. ptr;
  35. ptr=(C_dxj_Direct3dRMViewport2Object *)ptr->nextobj)
  36. {
  37. if(ptr == this)
  38. {
  39. if(prev)
  40. prev->nextobj = ptr->nextobj;
  41. else
  42. g_dxj_Direct3dRMViewport2 = (void*)ptr->nextobj;
  43. break;
  44. }
  45. prev = ptr;
  46. }
  47. if(m__dxj_Direct3dRMViewport2){
  48. int count = IUNK(m__dxj_Direct3dRMViewport2)->Release();
  49. DPF1(1,"DirectX real IDirect3dRMViewport2 Ref count [%d] \n",count);
  50. if(count==0){
  51. m__dxj_Direct3dRMViewport2 = NULL;
  52. }
  53. }
  54. if (parent)
  55. IUNK(parent)->Release();
  56. }
  57. DWORD C_dxj_Direct3dRMViewport2Object::InternalAddRef(){
  58. DWORD i;
  59. i=CComObjectRoot::InternalAddRef();
  60. DPF2(1,"Direct3dRMViewport2[%d] AddRef %d \n",creationid,i);
  61. return i;
  62. }
  63. DWORD C_dxj_Direct3dRMViewport2Object::InternalRelease(){
  64. DWORD i;
  65. i=CComObjectRoot::InternalRelease();
  66. DPF2(1,"Direct3dRMViewport2 [%d] Release %d \n",creationid,i);
  67. return i;
  68. }
  69. GETSET_OBJECT(_dxj_Direct3dRMViewport2);
  70. CLONE_R(_dxj_Direct3dRMViewport2,Direct3DRMViewport2);
  71. GETNAME_R(_dxj_Direct3dRMViewport2);
  72. SETNAME_R(_dxj_Direct3dRMViewport2);
  73. GETCLASSNAME_R(_dxj_Direct3dRMViewport2);
  74. ADDDESTROYCALLBACK_R(_dxj_Direct3dRMViewport2);
  75. DELETEDESTROYCALLBACK_R(_dxj_Direct3dRMViewport2);
  76. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMViewport2, clear, Clear,long,(DWORD))
  77. PASS_THROUGH1_R(_dxj_Direct3dRMViewport2, setBack, SetBack, d3dvalue)
  78. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMViewport2, setAppData, SetAppData, long,(DWORD));
  79. PASS_THROUGH1_R(_dxj_Direct3dRMViewport2, setFront, SetFront, d3dvalue)
  80. PASS_THROUGH1_R(_dxj_Direct3dRMViewport2, setField, SetField, d3dvalue)
  81. PASS_THROUGH1_R(_dxj_Direct3dRMViewport2, setUniformScaling, SetUniformScaling, long);
  82. PASS_THROUGH_CAST_4_R(_dxj_Direct3dRMViewport2, configure, Configure, long,(long),long,(long),long,(DWORD),long,(DWORD));
  83. PASS_THROUGH_CAST_4_R(_dxj_Direct3dRMViewport2, forceUpdate, ForceUpdate, long,(DWORD),long,(DWORD),long,(DWORD),long,(DWORD));
  84. PASS_THROUGH4_R(_dxj_Direct3dRMViewport2, setPlane, SetPlane, d3dvalue, d3dvalue, d3dvalue, d3dvalue);
  85. PASS_THROUGH4_R(_dxj_Direct3dRMViewport2, getPlane, GetPlane, D3DVALUE*, D3DVALUE*, D3DVALUE*, D3DVALUE*);
  86. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMViewport2, setProjection, SetProjection, d3drmProjectionType, (enum _D3DRMPROJECTIONTYPE));
  87. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getHeight, GetHeight, long)
  88. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getWidth, GetWidth, long)
  89. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getAppData, GetAppData, long);
  90. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getUniformScaling, GetUniformScaling, long);
  91. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getX, GetX, long);
  92. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getY, GetY, long);
  93. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getField, GetField, d3dvalue);
  94. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getBack, GetBack, d3dvalue);
  95. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getFront, GetFront, d3dvalue);
  96. GET_DIRECT_R(_dxj_Direct3dRMViewport2, getProjection, GetProjection, d3drmProjectionType);
  97. //RETURN_NEW_ITEM2_R(_dxj_Direct3dRMViewport2,pick,Pick,_dxj_Direct3dRMPickArray,long,long)
  98. //#define RETURN_NEW_ITEM2_R(c,m,m2,oc,t1,t2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,I##oc **rv){typedef_##oc lp;\
  99. // if( m_##c->m2(v1,v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  100. // return S_OK;}
  101. /////////////////////////////////////////////////////////////////////////////
  102. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::pick(long x, long y, I_dxj_Direct3dRMPickArray **rv)
  103. {
  104. HRESULT hr;
  105. LPDIRECT3DRMPICKEDARRAY pArray=NULL;
  106. //MANBUGS 18014 pick can GPF is mesbuilder.enable is set to renderable (as opposed to pickable)
  107. //
  108. __try{
  109. hr= m__dxj_Direct3dRMViewport2->Pick(x,y,&pArray);
  110. }
  111. __except(0,0){
  112. return E_FAIL;
  113. }
  114. if FAILED(hr) return hr;
  115. INTERNAL_CREATE(_dxj_Direct3dRMPickArray,pArray,rv);
  116. return hr;
  117. }
  118. /////////////////////////////////////////////////////////////////////////////
  119. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::transform(D3dRMVector4d* dst, D3dVector* src)
  120. {
  121. if(! (dst && src) )
  122. return E_POINTER;
  123. return m__dxj_Direct3dRMViewport2->Transform( (D3DRMVECTOR4D*)dst, (D3DVECTOR *)src );
  124. }
  125. /////////////////////////////////////////////////////////////////////////////
  126. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::inverseTransform(D3dVector* dst, D3dRMVector4d* src)
  127. {
  128. if(! (dst && src) )
  129. return E_POINTER;
  130. return m__dxj_Direct3dRMViewport2->InverseTransform( (D3DVECTOR *)dst, (D3DRMVECTOR4D*)src );
  131. }
  132. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::getCamera(I_dxj_Direct3dRMFrame3 **cam)
  133. {
  134. HRESULT hr;
  135. IDirect3DRMFrame3 *realframe=NULL;
  136. hr= m__dxj_Direct3dRMViewport2->GetCamera(&realframe);
  137. if FAILED(hr) return hr;
  138. INTERNAL_CREATE(_dxj_Direct3dRMFrame3,(IDirect3DRMFrame3*)realframe,cam);
  139. return hr;
  140. }
  141. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::setCamera(I_dxj_Direct3dRMFrame3 *cam)
  142. {
  143. HRESULT hr;
  144. IDirect3DRMFrame3 *realframe=NULL;
  145. cam->InternalGetObject((IUnknown**)&realframe);
  146. hr= m__dxj_Direct3dRMViewport2->SetCamera((IDirect3DRMFrame3*)realframe);
  147. return hr;
  148. }
  149. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::getDevice(I_dxj_Direct3dRMDevice3 **dev)
  150. {
  151. HRESULT hr;
  152. IDirect3DRMDevice3 *realdev=NULL;
  153. hr= m__dxj_Direct3dRMViewport2->GetDevice(&realdev);
  154. if FAILED(hr) return hr;
  155. INTERNAL_CREATE(_dxj_Direct3dRMDevice3,(IDirect3DRMDevice3*)realdev,dev);
  156. return hr;
  157. }
  158. #if 0
  159. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::getDirect3DViewport(I_dxj_Direct3dViewport3 **vp)
  160. {
  161. HRESULT hr;
  162. IDirect3DViewport *realvp=NULL;
  163. IDirect3DViewport *realvp3=NULL;
  164. hr= m__dxj_Direct3dRMViewport2->GetDirect3DViewport(&realvp);
  165. if FAILED(hr) return hr;
  166. hr = realvp->QueryInterface(IID_IDirect3DViewport3,(void**)&realvp3);
  167. INTERNAL_CREATE(_dxj_Direct3dViewport3,realvp3,vp);
  168. return hr;
  169. }
  170. #endif
  171. STDMETHODIMP C_dxj_Direct3dRMViewport2Object::render(I_dxj_Direct3dRMFrame3 *frame)
  172. {
  173. HRESULT hr;
  174. if (frame==NULL) return E_INVALIDARG;
  175. IDirect3DRMFrame3 *realframe= NULL;
  176. frame->InternalGetObject((IUnknown**)&realframe);
  177. hr= m__dxj_Direct3dRMViewport2->Render(realframe);
  178. #ifdef _X86_
  179. _asm FINIT
  180. #endif
  181. return hr;
  182. }