-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix off-by-one bug and cleanup GL calls #113
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,6 @@ void DrawTrajectory(vector<Isometry3d, Eigen::aligned_allocator<Isometry3d>> pos | |
// create pangolin window and plot the trajectory | ||
pangolin::CreateWindowAndBind("Trajectory Viewer", 1024, 768); | ||
glEnable(GL_DEPTH_TEST); | ||
glEnable(GL_BLEND); | ||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
|
||
pangolin::OpenGlRenderState s_cam( | ||
pangolin::ProjectionMatrix(1024, 768, 500, 500, 512, 389, 0.1, 1000), | ||
|
@@ -52,12 +50,12 @@ void DrawTrajectory(vector<Isometry3d, Eigen::aligned_allocator<Isometry3d>> pos | |
.SetBounds(0.0, 1.0, 0.0, 1.0, -1024.0f / 768.0f) | ||
.SetHandler(new pangolin::Handler3D(s_cam)); | ||
|
||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); | ||
glLineWidth(2); | ||
Comment on lines
+53
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These do not change so we don't need to reset them every loop iteration |
||
while (pangolin::ShouldQuit() == false) { | ||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||
d_cam.Activate(s_cam); | ||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); | ||
glLineWidth(2); | ||
for (size_t i = 0; i < poses.size(); i++) { | ||
for (size_t i = 0; i < poses.size(); ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: ++i is more efficient |
||
// 画每个位姿的三个坐标轴 | ||
Vector3d Ow = poses[i].translation(); | ||
Vector3d Xw = poses[i] * (0.1 * Vector3d(1, 0, 0)); | ||
|
@@ -76,7 +74,7 @@ void DrawTrajectory(vector<Isometry3d, Eigen::aligned_allocator<Isometry3d>> pos | |
glEnd(); | ||
} | ||
// 画出连线 | ||
for (size_t i = 0; i < poses.size(); i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Off by one error here since we're drawing a line from i -> i + 1 |
||
for (size_t i = 0; i < poses.size() - 1; ++i) { | ||
glColor3f(0.0, 0.0, 0.0); | ||
glBegin(GL_LINES); | ||
auto p1 = poses[i], p2 = poses[i + 1]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need alpha blending in this example