TextRenderer.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include <TwOpenGLCore.h>
  8. #include <map>
  9. namespace igl
  10. {
  11. class TextRenderer : public CTwGraphOpenGLCore
  12. {
  13. public:
  14. IGL_INLINE TextRenderer();
  15. IGL_INLINE virtual int Init();
  16. IGL_INLINE virtual int Shut();
  17. IGL_INLINE void BeginDraw(const Eigen::Matrix4f &view, const Eigen::Matrix4f &proj,
  18. const Eigen::Vector4f &_viewport, float _object_scale);
  19. IGL_INLINE void EndDraw();
  20. IGL_INLINE void DrawText(Eigen::Vector3d pos, Eigen::Vector3d normal, const std::string &text);
  21. protected:
  22. igl::OpenGL_shader m_shader;
  23. std::map<std::string, void *> m_textObjects;
  24. GLuint m_shaderHandleBackup;
  25. GLuint m_TriTexUniLocationDepth;
  26. Eigen::Matrix4f view_matrix, proj_matrix;
  27. Eigen::Vector4f viewport;
  28. float object_scale;
  29. };
  30. }
  31. #ifndef IGL_STATIC_LIBRARY
  32. # include "TextRenderer.cpp"
  33. #endif
  34. #endif