TextRenderer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /* This class extends the font rendering code in AntTweakBar
  9. so that it can be used to render text at arbitrary 3D positions */
  10. #ifndef IGL_TEXT_RENDERER_H
  11. #define IGL_TEXT_RENDERER_H
  12. #include <igl/igl_inline.h>
  13. #include <map>
  14. #include <nanogui/opengl.h>
  15. namespace igl
  16. {
  17. class TextRenderer
  18. {
  19. public:
  20. IGL_INLINE TextRenderer();
  21. IGL_INLINE virtual int Init();
  22. IGL_INLINE virtual int Shut();
  23. IGL_INLINE void BeginDraw(const Eigen::Matrix4f &view, const Eigen::Matrix4f &proj,
  24. const Eigen::Vector4f &_viewport, float _object_scale);
  25. IGL_INLINE void EndDraw();
  26. IGL_INLINE void DrawText(Eigen::Vector3d pos, Eigen::Vector3d normal, const std::string &text);
  27. protected:
  28. std::map<std::string, void *> m_textObjects;
  29. Eigen::Matrix4f view_matrix, proj_matrix;
  30. Eigen::Vector4f viewport;
  31. float object_scale;
  32. float mPixelRatio;
  33. NVGcontext *ctx;
  34. };
  35. }
  36. #ifndef IGL_STATIC_LIBRARY
  37. # include "TextRenderer.cpp"
  38. #endif
  39. #endif