/opengles/src/RasterizerState.cpp

http://ftk.googlecode.com/ · C++ · 98 lines · 41 code · 18 blank · 39 comment · 18 complexity · 53c3b502be7b1a4524ddba2b49405668 MD5 · raw file

  1. // ==========================================================================
  2. //
  3. // RasterizerState Rasterizer State Class for 3D Rendering Library
  4. //
  5. // The rasterizer state maintains all the state information
  6. // that is necessary to determine the details of the
  7. // next primitive to be scan-converted.
  8. //
  9. // --------------------------------------------------------------------------
  10. //
  11. // 10-10-2003 Hans-Martin Will initial version
  12. //
  13. // --------------------------------------------------------------------------
  14. //
  15. // Copyright (c) 2004, Hans-Martin Will. All rights reserved.
  16. //
  17. // Redistribution and use in source and binary forms, with or without
  18. // modification, are permitted provided that the following conditions are
  19. // met:
  20. //
  21. // * Redistributions of source code must retain the above copyright
  22. // notice, this list of conditions and the following disclaimer.
  23. // * Redistributions in binary form must reproduce the above copyright
  24. // notice, this list of conditions and the following disclaimer in the
  25. // documentation and/or other materials provided with the distribution.
  26. //
  27. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  31. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  32. // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  35. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  37. // THE POSSIBILITY OF SUCH DAMAGE.
  38. //
  39. // ==========================================================================
  40. #include "stdafx.h"
  41. #include "RasterizerState.h"
  42. using namespace EGL;
  43. RasterizerState :: RasterizerState():
  44. m_ShadingModel(ShadeModelSmooth),
  45. m_SampleCoverage(EGL_ONE),
  46. m_InvertSampleCoverage(false)
  47. {
  48. }
  49. bool RasterizerState :: CompareCommon(const RasterizerState& other) const {
  50. if (!(m_ShadingModel == other.m_ShadingModel) ||
  51. !(m_Fog == other.m_Fog) ||
  52. !(m_DepthTest == other.m_DepthTest)) {
  53. return false;
  54. }
  55. for (size_t unit = 0; unit < EGL_NUM_TEXTURE_UNITS; ++unit) {
  56. if (!(m_Texture[unit] == other.m_Texture[unit]))
  57. return false;
  58. }
  59. return
  60. m_Mask == other.m_Mask &&
  61. m_Alpha == other.m_Alpha &&
  62. m_Blend == other.m_Blend &&
  63. m_ScissorTest == other.m_ScissorTest &&
  64. m_LogicOp == other.m_LogicOp &&
  65. m_Stencil == other.m_Stencil &&
  66. m_SampleCoverage == other.m_SampleCoverage &&
  67. m_InvertSampleCoverage == other.m_InvertSampleCoverage;
  68. }
  69. bool RasterizerState :: ComparePoint(const RasterizerState& other) const {
  70. return m_Point == other.m_Point &&
  71. CompareCommon(other);
  72. }
  73. bool RasterizerState :: CompareLine(const RasterizerState& other) const {
  74. return m_Line == other.m_Line &&
  75. CompareCommon(other);
  76. }
  77. bool RasterizerState :: ComparePolygon(const RasterizerState& other) const {
  78. return m_Polygon == other.m_Polygon &&
  79. CompareCommon(other);
  80. }