CmOcclusionQuery.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 _HardwareOcclusionQuery__
  25. #define _HardwareOcclusionQuery__
  26. // Precompiler options
  27. #include "CmPrerequisites.h"
  28. namespace CamelotFramework {
  29. /** \addtogroup Core
  30. * @{
  31. */
  32. /** \addtogroup RenderSystem
  33. * @{
  34. */
  35. /**
  36. * This is a abstract class that that provides the interface for the query class for
  37. * hardware occlusion.
  38. *
  39. * @author Lee Sandberg
  40. * Updated on 13/8/2005 by Tuan Kuranes email: [email protected]
  41. */
  42. class CM_EXPORT OcclusionQuery
  43. {
  44. //----------------------------------------------------------------------
  45. // Public methods
  46. //--
  47. public:
  48. /**
  49. * Object public member functions
  50. */
  51. /**
  52. * Default object constructor
  53. *
  54. */
  55. OcclusionQuery();
  56. /**
  57. * Object destructor
  58. */
  59. virtual ~OcclusionQuery();
  60. /**
  61. * Starts the hardware occlusion query
  62. * @Remarks Simple usage: Create one or more OcclusionQuery object one per outstanding query or one per tested object
  63. * OcclusionQuery* m_pOcclusionQuery;
  64. * createOcclusionQuery( &m_pOcclusionQuery );
  65. * In the rendering loop:
  66. * Draw all occluders
  67. * m_pOcclusionQuery->startOcclusionQuery();
  68. * Draw the polygons to be tested
  69. * m_pOcclusionQuery->endOcclusionQuery();
  70. *
  71. * Results must be pulled using:
  72. * UINT m_uintNumberOfPixelsVisable;
  73. * pullOcclusionQuery( &m_dwNumberOfPixelsVisable );
  74. *
  75. */
  76. virtual void beginOcclusionQuery() = 0;
  77. /**
  78. * Ends the hardware occlusion test
  79. */
  80. virtual void endOcclusionQuery() = 0;
  81. /**
  82. * Pulls the hardware occlusion query.
  83. * @note Waits until the query result is available; use isStillOutstanding
  84. * if just want to test if the result is available.
  85. * @retval NumOfFragments will get the resulting number of fragments.
  86. * @return True if success or false if not.
  87. */
  88. virtual bool pullOcclusionQuery(unsigned int* NumOfFragments) = 0;
  89. /**
  90. * Let's you get the last pixel count with out doing the hardware occlusion test
  91. * @return The last fragment count from the last test.
  92. * Remarks This function won't give you new values, just the old value.
  93. */
  94. unsigned int getLastQuerysPixelcount() const { return mPixelCount; }
  95. /**
  96. * Lets you know when query is done, or still be processed by the Hardware
  97. * @return true if query isn't finished.
  98. */
  99. virtual bool isStillOutstanding(void) = 0;
  100. //----------------------------------------------------------------------
  101. // protected members
  102. //--
  103. protected :
  104. // numbers of visible pixels determined by last query
  105. unsigned int mPixelCount;
  106. // is query hasn't yet returned a result.
  107. bool mIsQueryResultStillOutstanding;
  108. };
  109. /** @} */
  110. /** @} */
  111. }
  112. #endif