model_proj_viewport.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "model_proj_viewport.h"
  9. #include "../opengl/OpenGL_convenience.h"
  10. template <typename Derivedmodel, typename Derivedproj, typename Derivedviewport>
  11. IGL_INLINE void igl::opengl2::model_proj_viewport(
  12. Eigen::PlainObjectBase<Derivedmodel> & model,
  13. Eigen::PlainObjectBase<Derivedproj> & proj,
  14. Eigen::PlainObjectBase<Derivedviewport> & viewport)
  15. {
  16. Eigen::Matrix4d MV,P;
  17. Eigen::Vector4i VPi;
  18. glGetDoublev(GL_MODELVIEW_MATRIX,MV.data());
  19. glGetDoublev(GL_PROJECTION_MATRIX,P.data());
  20. glGetIntegerv(GL_VIEWPORT,VPi.data());
  21. viewport = VPi.cast<typename Derivedviewport::Scalar>();
  22. model = MV.cast<typename Derivedmodel::Scalar>();
  23. proj = P.cast<typename Derivedproj::Scalar>();
  24. }
  25. #ifdef IGL_STATIC_LIBRARY
  26. // Explicit template specialization
  27. template void igl::opengl2::model_proj_viewport<Eigen::Matrix<double, 4, 4, 0, 4, 4>, Eigen::Matrix<double, 4, 4, 0, 4, 4>, Eigen::Matrix<double, 4, 1, 0, 4, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 4, 0, 4, 4> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 4, 0, 4, 4> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> >&);
  28. template void igl::opengl2::model_proj_viewport<Eigen::Matrix<float, 4, 4, 0, 4, 4>, Eigen::Matrix<float, 4, 4, 0, 4, 4>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 4, 0, 4, 4> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 4, 0, 4, 4> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 1, 0, 4, 1> >&);
  29. #endif