TextRenderer.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Wenzel Jacob <wenzel@inf.ethz.ch>
  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. #ifndef IGL_VIEWER_TEXT_RENDERER_H
  9. #define IGL_VIEWER_TEXT_RENDERER_H
  10. #ifdef IGL_VIEWER_WITH_NANOGUI
  11. #include <Eigen/Dense>
  12. #include <igl/igl_inline.h>
  13. #include <map>
  14. struct NVGcontext;
  15. namespace igl
  16. {
  17. namespace viewer
  18. {
  19. class TextRenderer
  20. {
  21. public:
  22. IGL_INLINE TextRenderer();
  23. IGL_INLINE virtual int Init();
  24. IGL_INLINE virtual int Shut();
  25. IGL_INLINE void BeginDraw(const Eigen::Matrix4f &view,const Eigen::Matrix4f &proj,
  26. const Eigen::Vector4f &_viewport,float _object_scale);
  27. IGL_INLINE void EndDraw();
  28. IGL_INLINE void DrawText(Eigen::Vector3d pos,Eigen::Vector3d normal,const std::string &text);
  29. protected:
  30. std::map<std::string,void *> m_textObjects;
  31. Eigen::Matrix4f view_matrix,proj_matrix;
  32. Eigen::Vector4f viewport;
  33. float object_scale;
  34. float mPixelRatio;
  35. NVGcontext *ctx;
  36. };
  37. }
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. # include "TextRenderer.cpp"
  41. #endif
  42. #endif
  43. #endif