/opengles/src/MatrixStack.h

http://ftk.googlecode.com/ · C Header · 85 lines · 31 code · 18 blank · 36 comment · 0 complexity · 3f297b2d11d13cf0ebfbed4202238ef2 MD5 · raw file

  1. #ifndef EGL_MATRIX_STACK_H
  2. #define EGL_MATRIX_STACK_H 1
  3. // ==========================================================================
  4. //
  5. // MatrixStack.h Matrix Stack Class for 3D Rendering Library
  6. //
  7. // --------------------------------------------------------------------------
  8. //
  9. // 08-08-2003 Hans-Martin Will initial version
  10. // 10-04-2003 Hans-Martin Will rework against new matrix class
  11. //
  12. // --------------------------------------------------------------------------
  13. //
  14. // Copyright (c) 2004, Hans-Martin Will. All rights reserved.
  15. //
  16. // Redistribution and use in source and binary forms, with or without
  17. // modification, are permitted provided that the following conditions are
  18. // met:
  19. //
  20. // * Redistributions of source code must retain the above copyright
  21. // notice, this list of conditions and the following disclaimer.
  22. // * Redistributions in binary form must reproduce the above copyright
  23. // notice, this list of conditions and the following disclaimer in the
  24. // documentation and/or other materials provided with the distribution.
  25. //
  26. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  31. // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  36. // THE POSSIBILITY OF SUCH DAMAGE.
  37. //
  38. // ==========================================================================
  39. #include "OGLES.h"
  40. #include "fixed.h"
  41. #include "linalg.h"
  42. namespace EGL {
  43. class MatrixStack {
  44. public:
  45. MatrixStack(I32 maxStackElements = 2);
  46. ~MatrixStack();
  47. bool PopMatrix(void);
  48. bool PushMatrix(void);
  49. void MultMatrix(const Matrix4x4 &matrix);
  50. void LoadIdentity(void);
  51. void LoadMatrix(const Matrix4x4 &matrix);
  52. inline Matrix4x4 & CurrentMatrix() {
  53. return m_Stack[m_StackPointer];
  54. }
  55. inline I32 GetStackSize() const {
  56. return m_StackSize;
  57. }
  58. inline I32 GetCurrentStackSize() const {
  59. return m_StackPointer + 1;
  60. }
  61. private:
  62. Matrix4x4 *m_Stack;
  63. I32 m_StackPointer;
  64. I32 m_StackSize;
  65. };
  66. }
  67. #endif //ndef EGL_MATRIX_STACK_H