Browse Source

Fixing label stuff (#1876)

* Update ViewerCore.cpp

* Update ViewerData.h

adding label size

* init label_size
teseoch 3 years ago
parent
commit
cf46c31e8c

+ 2 - 2
include/igl/opengl/ViewerCore.cpp

@@ -363,9 +363,9 @@ IGL_INLINE void igl::opengl::ViewerCore::draw_labels(
   float width  = viewport(2);
   float width  = viewport(2);
   float height = viewport(3);
   float height = viewport(3);
   float text_shift_scale_factor = orthographic ? 0.01 : 0.03;
   float text_shift_scale_factor = orthographic ? 0.01 : 0.03;
-  float render_scale = orthographic ? 0.6 : 1.7;
+  float render_scale = (orthographic ? 0.6 : 1.7) * data.label_size;
   glUniform1f(glGetUniformLocation(data.meshgl.shader_text, "TextShiftFactor"), text_shift_scale_factor);
   glUniform1f(glGetUniformLocation(data.meshgl.shader_text, "TextShiftFactor"), text_shift_scale_factor);
-  glUniform3f(glGetUniformLocation(data.meshgl.shader_text, "TextColor"), 0, 0, 0);
+  glUniform3f(glGetUniformLocation(data.meshgl.shader_text, "TextColor"), data.label_color(0), data.label_color(1), data.label_color(2));
   glUniform2f(glGetUniformLocation(data.meshgl.shader_text, "CellSize"), 1.0f / 16, (300.0f / 384) / 6);
   glUniform2f(glGetUniformLocation(data.meshgl.shader_text, "CellSize"), 1.0f / 16, (300.0f / 384) / 6);
   glUniform2f(glGetUniformLocation(data.meshgl.shader_text, "CellOffset"), 0.5 / 256.0, 0.5 / 256.0);
   glUniform2f(glGetUniformLocation(data.meshgl.shader_text, "CellOffset"), 0.5 / 256.0, 0.5 / 256.0);
   glUniform2f(glGetUniformLocation(data.meshgl.shader_text, "RenderSize"), 
   glUniform2f(glGetUniformLocation(data.meshgl.shader_text, "RenderSize"), 

+ 1 - 0
include/igl/opengl/ViewerData.cpp

@@ -35,6 +35,7 @@ IGL_INLINE igl::opengl::ViewerData::ViewerData()
   use_matcap        (false),
   use_matcap        (false),
   point_size(30),
   point_size(30),
   line_width(0.5f),
   line_width(0.5f),
+  label_size(1),
   line_color(0,0,0,1),
   line_color(0,0,0,1),
   label_color(0,0,0.04,1),
   label_color(0,0,0.04,1),
   shininess(35.0f),
   shininess(35.0f),

+ 1 - 0
include/igl/opengl/ViewerData.h

@@ -276,6 +276,7 @@ public:
   float point_size;
   float point_size;
   // line_width is NOT SUPPORTED on Mac OS and Windows
   // line_width is NOT SUPPORTED on Mac OS and Windows
   float line_width;
   float line_width;
+  float label_size;
   Eigen::Matrix<float, 4, 1, Eigen::DontAlign> line_color;
   Eigen::Matrix<float, 4, 1, Eigen::DontAlign> line_color;
   Eigen::Matrix<float, 4, 1, Eigen::DontAlign> label_color;
   Eigen::Matrix<float, 4, 1, Eigen::DontAlign> label_color;