CmD3D9HardwareOcclusionQuery.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef _D3D9HARWAREOCCLUSIONQUERY_H__
  25. #define _D3D9HARWAREOCCLUSIONQUERY_H__
  26. #include "CmD3D9Prerequisites.h"
  27. #include "CmHardwareOcclusionQuery.h"
  28. #include "CmD3D9Resource.h"
  29. namespace CamelotEngine {
  30. // If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered
  31. // if the first pass results has too few pixels visible.
  32. // Be sure to render all occluder first and whats out so the RenderQue don't switch places on
  33. // the occluding objects and the tested objects because it thinks it's more effective..
  34. /**
  35. * This is a class that is the DirectX9 implementation of
  36. * hardware occlusion testing.
  37. *
  38. * @author Lee Sandberg, email [email protected]
  39. *
  40. * Updated on 12/7/2004 by Chris McGuirk
  41. * Updated on 4/8/2005 by Tuan Kuranes email: [email protected]
  42. */
  43. class _OgreD3D9Export D3D9HardwareOcclusionQuery : public HardwareOcclusionQuery, public D3D9Resource
  44. {
  45. //----------------------------------------------------------------------
  46. // Public methods
  47. //--
  48. public:
  49. /**
  50. * Default object constructor
  51. *
  52. */
  53. D3D9HardwareOcclusionQuery();
  54. /**
  55. * Object destructor
  56. */
  57. ~D3D9HardwareOcclusionQuery();
  58. //------------------------------------------------------------------
  59. // Occlusion query functions (see base class documentation for this)
  60. //--
  61. void beginOcclusionQuery();
  62. void endOcclusionQuery();
  63. bool pullOcclusionQuery( unsigned int* NumOfFragments);
  64. unsigned int getLastQuerysPixelcount();
  65. bool isStillOutstanding(void);
  66. // Called immediately after the Direct3D device has been created.
  67. virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
  68. // Called before the Direct3D device is going to be destroyed.
  69. virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
  70. // Called immediately after the Direct3D device has entered a lost state.
  71. // This is the place to release non-managed resources.
  72. virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
  73. // Called immediately after the Direct3D device has been reset.
  74. // This is the place to create non-managed resources.
  75. virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
  76. private:
  77. void createQuery(IDirect3DDevice9* d3d9Device);
  78. void releaseQuery(IDirect3DDevice9* d3d9Device);
  79. //----------------------------------------------------------------------
  80. // private members
  81. //--
  82. private:
  83. typedef map<IDirect3DDevice9*, IDirect3DQuery9*>::type DeviceToQueryMap;
  84. typedef DeviceToQueryMap::iterator DeviceToQueryIterator;
  85. DeviceToQueryMap mMapDeviceToQuery;
  86. };
  87. }
  88. #endif