// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "project.h" #include "../project.h" #include "gl.h" #include "glu.h" #include IGL_INLINE int igl::opengl2::project( const double objX, const double objY, const double objZ, double* winX, double* winY, double* winZ) { using namespace std; // Put model, projection, and viewport matrices into double arrays double MV[16]; double P[16]; int VP[4]; glGetDoublev(GL_MODELVIEW_MATRIX, MV); glGetDoublev(GL_PROJECTION_MATRIX, P); glGetIntegerv(GL_VIEWPORT, VP); int ret = gluProject(objX,objY,objZ,MV,P,VP,winX,winY,winZ); return ret; } template IGL_INLINE int igl::opengl2::project( const Eigen::PlainObjectBase & obj, Eigen::PlainObjectBase & win) { assert(obj.size() >= 3); Eigen::Vector3d dobj(obj(0),obj(1),obj(2)); Eigen::Vector3d dwin; int ret = igl::opengl2::project(dobj(0),dobj(1),dobj(2), &dwin.data()[0], &dwin.data()[1], &dwin.data()[2]); win(0) = dwin(0); win(1) = dwin(1); win(2) = dwin(2); return ret; } template IGL_INLINE Derivedobj igl::opengl2::project( const Eigen::PlainObjectBase & obj) { Derivedobj win; igl::opengl2::project(obj,win); return win; } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation template int igl::opengl2::project, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template int igl::opengl2::project, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template int igl::opengl2::project, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); #endif