zbuffer.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // deals with general manipulation and use of signed 16-bit z-buffers (0 = center)
  19. #ifndef ZBUFFER_H
  20. #define ZBUFFER_H
  21. //==================================================
  22. #include "Blue.h"
  23. #ifdef PATHS_IN_INCLUDES
  24. #include "ORANGE/QuickMath/FixedPoint.h" // for RFixedS32
  25. #include "ORANGE/color/colormatch.h" // for RFixedS32
  26. #else
  27. #include "FixedPoint.h" // for RFixedS32
  28. #include "ColorMatch.h" // for RFixedS32
  29. #endif
  30. //==================================================
  31. // Note that z-buffer assumes that positive z is
  32. // towards the viewer.
  33. //==================================================
  34. const short ZB_MIN_Z = -32768;
  35. class RZBuffer // a 16-bit signed z-buffer
  36. {
  37. public:
  38. short m_sW;
  39. short m_sH;
  40. long m_lP; // pitch in WORDS! (Not a real pitch!)
  41. short* m_pBuf; // for now, don't have great need for alignment!
  42. //----------------------------------------------
  43. void Init();
  44. RZBuffer();
  45. RZBuffer(short sW,short sH);
  46. short Create(short sW,short sH);
  47. ~RZBuffer();
  48. short Destroy();
  49. //----------------------------------------------
  50. void Clear(short sVal = ZB_MIN_Z);
  51. //----------------------------------------------
  52. // debugging stuff
  53. short* GetZPtr(short sX,short sY){return (m_pBuf + sX + m_lP*sY);}
  54. void TestHeight(RImage* pimDst,short sDepth,
  55. short sX,short sY,short sW,short sH);
  56. void Dump(RImage* pimDst,short sX,short sY,short sW,short sH,UCHAR* pZCol);
  57. };
  58. //==================================================
  59. //==================================================
  60. //==================================================
  61. //==================================================
  62. #endif