LiangliangNan / Easy3D

A lightweight, easy-to-use, and efficient C++ library for processing and rendering 3D data
GNU General Public License v3.0
1.35k stars 243 forks source link

Failed to use ModelPicker in QT_Viewer #151

Closed deepdarkbone closed 1 year ago

deepdarkbone commented 1 year ago

Hello! Thank you for your work. Based on Tutorial_204_Viewer_Qt I have built and run the qt_viewer successfully. I am trying to follow Tutorial_401_ModelPicker and use ModelPicker in overrided mousePressEvent in the qtviewer,but an error occurred

I see the following error messages while picking a model

E 31/01/2023 19:33:41.662 vertex_array_object.cpp:81] GL error:
       file: D:\MTRG_Software4.0\3rd_party\Easy3D-2.5.2\easy3d\renderer\vertex_array_object.cpp
       line: 81
       function: easy3d::VertexArrayObject::bind
       info: Invalid operation (The specified operation is not allowed in the current state)
E 31/01/2023 19:33:41.663 drawable.cpp:240] GL error:
        file: D:\MTRG_Software4.0\3rd_party\Easy3D-2.5.2\easy3d\renderer\drawable.cpp
        line: 240
        function: easy3d::Drawable::gl_draw
        info: Invalid operation (The specified operation is not allowed in the current state)

My code is as following, MyViewer Inherits form Viewer in Tutorial_204_Viewer

virtual void MyViewer::mousePressEvent(QMouseEvent* e) override;
void MyViewer::mousePressEvent(QMouseEvent* e) {
      int x = e->pos().x();
      int y = e->pos().y();
      ModelPicker picker(camera());
      auto model = picker.pick(models(), x, y);     //error occurred
      if (model)
          mark(model);

      QOpenGLWidget::mousePressEvent(e);
          update();
}

I find the error occurs in drawable_points when i debug, and I notice that some have reported the bug in drawable used in qtviewer. drawable->draw(camera()) I wonder how to solve the problem and use ModelPicker in qtviewer successfully.

Development/Running environment: