TextRenderer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_OPENGL_GLFW_TEXT_RENDERER_H
  9. #define IGL_OPENGL_GLFW_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 opengl
  18. {
  19. namespace glfw
  20. {
  21. class TextRenderer
  22. {
  23. public:
  24. IGL_INLINE TextRenderer();
  25. IGL_INLINE virtual int Init();
  26. IGL_INLINE virtual int Shut();
  27. IGL_INLINE void BeginDraw(const Eigen::Matrix4f &view,const Eigen::Matrix4f &proj,
  28. const Eigen::Vector4f &_viewport,float _object_scale);
  29. IGL_INLINE void EndDraw();
  30. IGL_INLINE void DrawText(Eigen::Vector3d pos,Eigen::Vector3d normal,const std::string &text);
  31. protected:
  32. std::map<std::string,void *> m_textObjects;
  33. Eigen::Matrix4f view_matrix,proj_matrix;
  34. Eigen::Vector4f viewport;
  35. float object_scale;
  36. float mPixelRatio;
  37. NVGcontext *ctx;
  38. };
  39. }
  40. }
  41. }
  42. #ifndef IGL_STATIC_LIBRARY
  43. # include "TextRenderer.cpp"
  44. #endif
  45. #endif
  46. #endif