TextRenderer.h 1.4 KB

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