Skip to content

Commit

Permalink
Fix OpenGl state handling.
Browse files Browse the repository at this point in the history
Adjust pose grid scale to depth default view
Fix stream info caption alignment
Replace auto with explicit type in for_each (GCC 4.8)

Change-Id: I7d707a790aa03b547208c04b75e8e52a267c48c5
  • Loading branch information
ev-mp committed Jan 22, 2019
1 parent e9a491f commit 3adb61d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
62 changes: 31 additions & 31 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ namespace rs2
viewer.not_model.add_log("Stopping streaming");

// TODO - refactor tm2 from viewer to subdevice
for_each(stream_display_names.begin(), stream_display_names.end(), [&viewer](auto& kvp)
for_each(stream_display_names.begin(), stream_display_names.end(), [&viewer](std::pair<int, std::string> kvp)
{
if ("Pose" == kvp.second)
{
Expand Down Expand Up @@ -1452,7 +1452,7 @@ namespace rs2
viewer.not_model.add_log(ss.str());

// TODO - refactor tm2 from viewer to subdevice
for_each(stream_display_names.begin(), stream_display_names.end(), [&viewer](auto& kvp)
for_each(stream_display_names.begin(), stream_display_names.end(), [&viewer](std::pair<int, std::string> kvp)
{
if ("Pose" == kvp.second)
viewer.tm2.record_trajectory(true);
Expand Down Expand Up @@ -2642,11 +2642,11 @@ namespace rs2
switch (this->texture->currentGrid.unit)
{
case GRID_STEP_UNIT_METER:
newGrid.set(1.0f);
newGrid.set(1.f);
newGrid.set(GRID_STEP_UNIT_FEET);
break;
case GRID_STEP_UNIT_FEET:
newGrid.set(0.1f);
newGrid.set(1.f);
newGrid.set(GRID_STEP_UNIT_METER);
break;
}
Expand All @@ -2667,7 +2667,7 @@ namespace rs2
break;
case GRID_STEP_UNIT_FEET:
switchToUnit = "Meter";
switchToStep = 0.1f;
switchToStep = 1.f;
break;
}

Expand Down Expand Up @@ -2798,31 +2798,31 @@ namespace rs2

std::string res;
if (profile.as<rs2::video_stream_profile>())
res = to_string() << size.x << "x" << size.y << ", ";
label = to_string() << res << truncate_string(rs2_format_to_string(profile.format()),9) << ", FPS:";
res = to_string() << size.x << "x" << size.y << ", ";
label = to_string() << res << truncate_string(rs2_format_to_string(profile.format()),9) << ", ";
ImGui::Text("%s", label.c_str());
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("%s", rs2_format_to_string(profile.format()));
ImGui::SetTooltip("%s","Stream Resolution, Format");
}

ImGui::SameLine();

label = to_string() << std::setprecision(2) << std::fixed << fps.get_fps();
label = to_string() << "FPS: " << std::setprecision(2) << std::setw(7) << std::fixed << fps.get_fps();
ImGui::Text("%s", label.c_str());
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("FPS is calculated based on timestamps and not viewer time");
ImGui::SetTooltip("%s", "FPS is calculated based on timestamps and not viewer time");
}

ImGui::SameLine(170);
ImGui::SameLine();

label = to_string() << "Frame" << frame_number;
label = to_string() << " Frame: " << std::left << frame_number;
ImGui::Text("%s", label.c_str());

ImGui::SameLine(300);
ImGui::SameLine(270);

label = to_string() << "Time: " << std::fixed << std::setprecision(1) << timestamp;
label = to_string() << "Time: " << std::left << std::fixed << std::setprecision(1) << timestamp;
ImGui::Text("%s", label.c_str());
if (ImGui::IsItemHovered())
{
Expand Down Expand Up @@ -4465,12 +4465,13 @@ namespace rs2
uint32_t horizontal = boxHorizontalLength / 2;
uint32_t vertical = (boxVerticalLength-1) / 2;

glPushAttrib(GL_CURRENT_BIT);
glPushAttrib(GL_LINE_BIT);
glLineWidth(1.f);
glColor4f(0.4f, 0.4f, 0.4f, 1.f);
glBegin(GL_LINES);
glColor4f(0.2f, 0.2f, 0.2f, 0.8f);

glTranslatef(0, 0, -1);

// Render box grid
// Render the box grid
float currentYStep = boxVerticalAlignment * step;

for (uint8_t y = 0; y <= (boxVerticalLength-1); y++)
Expand Down Expand Up @@ -4500,16 +4501,16 @@ namespace rs2
}
currentZStep += step;
}

glEnd();
glPopAttrib(); // color
glPopAttrib(); // line width
}

void viewer_model::render_camera_mesh(int id)
{
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);


glBegin(GL_TRIANGLES);
auto& mesh = camera_mesh[id];
Expand Down Expand Up @@ -4565,13 +4566,12 @@ namespace rs2

glEnable(GL_DEPTH_TEST);

glLineWidth(1);

auto r1 = matrix4::identity();
auto r2 = matrix4::identity();

if (draw_plane)
{
glPushAttrib(GL_LINE_BIT);
glLineWidth(2);
glBegin(GL_LINES);

Expand All @@ -4592,6 +4592,7 @@ namespace rs2
}

glEnd();
glPopAttrib();
}

auto x = static_cast<float>(-M_PI / 2);
Expand Down Expand Up @@ -4657,20 +4658,13 @@ namespace rs2
}
}

glPopMatrix();

if (!pose)
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadMatrixf(r1 * view_mat);
glLineWidth(1); glLineWidth(1);
// Render "floor" grid
glLineWidth(1);
glBegin(GL_LINES);
glColor4f(0.4f, 0.4f, 0.4f, 1.f);

glTranslatef(0, 0, -1);

// Render "floor" grid
for (int i = 0; i <= 6; i++)
{
glVertex3i(i - 3, 1, 0);
Expand All @@ -4679,6 +4673,10 @@ namespace rs2
glVertex3i(3, 1, i);
}
glEnd();

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadMatrixf(r1 * view_mat);
texture_buffer::draw_axes(0.4f, 1);
glPopMatrix();
}
Expand Down Expand Up @@ -4823,6 +4821,8 @@ namespace rs2
glPopMatrix();
}

glPopMatrix();

glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
Expand Down
2 changes: 1 addition & 1 deletion common/rendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ namespace rs2
class pose_grid
{
public:
pose_grid() : step(0.1f), pixelStep(0.1f), unit(GRID_STEP_UNIT_METER), boxHorizontalLength(6), boxVerticalLength(1), boxVerticalAlignment(1) {}
pose_grid() : step(1.f), pixelStep(1.f), unit(GRID_STEP_UNIT_METER), boxHorizontalLength(12), boxVerticalLength(1), boxVerticalAlignment(1) {}

void set(pose_grid newGrid)
{
Expand Down

0 comments on commit 3adb61d

Please sign in to comment.