4 Replies Latest reply on Feb 28, 2018 2:56 AM by TrayJ

    Point Cloud Example

    TrayJ

      Hi,

       

      I am just trying to run the point cloud example that comes with the binary sdk 2.1 (most recent binary) install in visual studio but I am getting a build error to do with a function it is using in example.cpp. (Does not take 4 arguments)

       

      draw_pointcloud(app.width(), app.height(), app_state, points);

       

      The function in example.cpp is as follows which only takes 3 parameters. Am I missing something? Is there a problem with the binary install 2.1 SDK? Anyone able to shine a light on this? Thanks

       

      // Handles all the OpenGL calls needed to display the point cloud
      void draw_pointcloud(window& app, glfw_state& app_state, rs2::points& points)
      {
          if (!points)
              return;

          // OpenGL commands that prep screen for the pointcloud
          glPopMatrix();
          glPushAttrib(GL_ALL_ATTRIB_BITS);

          float width = app.width(), height = app.height();

          glClearColor(153.f / 255, 153.f / 255, 153.f / 255, 1);
          glClear(GL_DEPTH_BUFFER_BIT);

          glMatrixMode(GL_PROJECTION);
          glPushMatrix();
          gluPerspective(60, width / height, 0.01f, 10.0f);

          glMatrixMode(GL_MODELVIEW);
          glPushMatrix();
          gluLookAt(0, 0, 0, 0, 0, 1, 0, -1, 0);

          glTranslatef(0, 0, +0.5f + app_state.offset_y*0.05f);
          glRotated(app_state.pitch, 1, 0, 0);
          glRotated(app_state.yaw, 0, 1, 0);
          glTranslatef(0, 0, -0.5f);

          glPointSize(width / 640);
          glEnable(GL_DEPTH_TEST);
          glEnable(GL_TEXTURE_2D);
          glBindTexture(GL_TEXTURE_2D, app_state.tex.get_gl_handle());
          float tex_border_color[] = { 0.8f, 0.8f, 0.8f, 0.8f };
          glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, tex_border_color);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0x812F); // GL_CLAMP_TO_EDGE
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 0x812F); // GL_CLAMP_TO_EDGE
          glBegin(GL_POINTS);


          /* this segment actually prints the pointcloud */
          auto vertices = points.get_vertices();              // get vertices
          auto tex_coords = points.get_texture_coordinates(); // and texture coordinates
          for (int i = 0; i < points.size(); i++)
          {
              if (vertices[i].z)
              {
                  // upload the point and texture coordinates only for points we have depth data for
                  glVertex3fv(vertices[i]);
                  glTexCoord2fv(tex_coords[i]);
              }
          }

          // OpenGL cleanup
          glEnd();
          glPopMatrix();
          glMatrixMode(GL_PROJECTION);
          glPopMatrix();
          glPopAttrib();
          glPushMatrix();
      }