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.

157 lines
3.7 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: liunk.c
  6. * Content: Direct3DLight IUnknown implementation
  7. *@@BEGIN_MSINTERNAL
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 10/12/95 stevela Initial rev with this header.
  13. *@@END_MSINTERNAL
  14. *
  15. ***************************************************************************/
  16. #include "pch.cpp"
  17. #pragma hdrstop
  18. /*
  19. * D3DLight_QueryInterface
  20. */
  21. #undef DPF_MODNAME
  22. #define DPF_MODNAME "Direct3DLight::QueryInterface"
  23. HRESULT D3DAPI DIRECT3DLIGHTI::QueryInterface(REFIID riid, LPVOID* ppvObj)
  24. {
  25. /*
  26. * validate parms
  27. */
  28. TRY
  29. {
  30. if (!VALID_DIRECT3DLIGHT_PTR(this)) {
  31. D3D_ERR( "Invalid Direct3DLight pointer" );
  32. return DDERR_INVALIDOBJECT;
  33. }
  34. if (!VALID_OUTPTR(ppvObj)) {
  35. D3D_ERR( "Invalid pointer to pointer" );
  36. return DDERR_INVALIDPARAMS;
  37. }
  38. }
  39. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  40. {
  41. D3D_ERR( "Exception encountered validating parameters" );
  42. return DDERR_INVALIDPARAMS;
  43. }
  44. if (!VALID_OUTPTR(ppvObj)) {
  45. return (DDERR_INVALIDPARAMS);
  46. }
  47. *ppvObj = NULL;
  48. if(IsEqualIID(riid, IID_IUnknown) ||
  49. IsEqualIID(riid, IID_IDirect3DLight) )
  50. {
  51. AddRef();
  52. *ppvObj = static_cast<LPVOID>(static_cast<LPDIRECT3DLIGHT>(this));
  53. return (D3D_OK);
  54. }
  55. return (E_NOINTERFACE);
  56. } /* D3DLight_QueryInterface */
  57. /*
  58. * D3DLight_AddRef
  59. */
  60. #undef DPF_MODNAME
  61. #define DPF_MODNAME "Direct3DLight::AddRef"
  62. ULONG D3DAPI DIRECT3DLIGHTI::AddRef()
  63. {
  64. DWORD rcnt;
  65. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  66. // Release in the destructor
  67. /*
  68. * validate parms
  69. */
  70. TRY
  71. {
  72. if (!VALID_DIRECT3DLIGHT_PTR(this)) {
  73. D3D_ERR( "Invalid Direct3DLight pointer" );
  74. return 0;
  75. }
  76. }
  77. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  78. {
  79. D3D_ERR( "Exception encountered validating parameters" );
  80. return 0;
  81. }
  82. this->refCnt++;
  83. rcnt = this->refCnt;
  84. return (rcnt);
  85. } /* D3DLight_AddRef */
  86. /*
  87. * D3DLight_Release
  88. *
  89. */
  90. #undef DPF_MODNAME
  91. #define DPF_MODNAME "Direct3DLight::Release"
  92. ULONG D3DAPI DIRECT3DLIGHTI::Release()
  93. {
  94. DWORD lastrefcnt;
  95. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  96. // Release in the destructor
  97. /*
  98. * validate parms
  99. */
  100. TRY
  101. {
  102. if (!VALID_DIRECT3DLIGHT_PTR(this)) {
  103. D3D_ERR( "Invalid Direct3DLight pointer" );
  104. return 0;
  105. }
  106. }
  107. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  108. {
  109. D3D_ERR( "Exception encountered validating parameters" );
  110. return 0;
  111. }
  112. /*
  113. * decrement the ref count. if we hit 0, free the object
  114. */
  115. this->refCnt--;
  116. lastrefcnt = this->refCnt;
  117. if( lastrefcnt == 0 )
  118. {
  119. delete this;
  120. return 0;
  121. }
  122. return lastrefcnt;
  123. } /* D3DLight_Release */
  124. DIRECT3DLIGHTI::~DIRECT3DLIGHTI()
  125. {
  126. /* remove us from our viewport's list of lights */
  127. if (this->lpD3DViewportI) {
  128. CIRCLE_QUEUE_DELETE(&this->lpD3DViewportI->lights, this, light_list);
  129. this->lpD3DViewportI->numLights--;
  130. this->lpD3DViewportI->bLightsChanged = TRUE;
  131. }
  132. /* remove us from the Direct3D object list of lights */
  133. LIST_DELETE(this, list);
  134. this->lpDirect3DI->numLights--;
  135. }