TextRenderer.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* This class extends the font rendering code in AntTweakBar
  2. so that it can be used to render text at arbitrary 3D positions */
  3. #ifndef IGL_TEXT_RENDERER_H
  4. #define IGL_TEXT_RENDERER_H
  5. #include <igl/igl_inline.h>
  6. #include <igl/viewer/OpenGL_shader.h>
  7. namespace igl
  8. {
  9. class TextRenderer : public CTwGraphOpenGLCore
  10. {
  11. public:
  12. IGL_INLINE TextRenderer();
  13. IGL_INLINE virtual int Init();
  14. IGL_INLINE virtual int Shut();
  15. IGL_INLINE void BeginDraw(const Eigen::Matrix4f &view, const Eigen::Matrix4f &proj,
  16. const Eigen::Vector4f &_viewport, float _object_scale);
  17. IGL_INLINE void EndDraw();
  18. IGL_INLINE void DrawText(Eigen::Vector3d pos, Eigen::Vector3d normal, const std::string &text);
  19. protected:
  20. igl::OpenGL_shader m_shader;
  21. std::map<std::string, void *> m_textObjects;
  22. GLuint m_shaderHandleBackup;
  23. GLuint m_TriTexUniLocationDepth;
  24. Eigen::Matrix4f view_matrix, proj_matrix;
  25. Eigen::Vector4f viewport;
  26. float object_scale;
  27. };
  28. }
  29. #ifndef IGL_STATIC_LIBRARY
  30. # include "TextRenderer.cpp"
  31. #endif
  32. #endif