Эх сурвалжийг харах

c++ style functions

Former-commit-id: 2e0b25ba975b3223ae2a5d0ce05269ec5728ee12
Alec Jacobson 10 жил өмнө
parent
commit
092242f822

+ 10 - 10
include/igl/viewer/Viewer.h

@@ -112,16 +112,16 @@ namespace igl
     IGL_INLINE void resize(int w,int h);
 
 
-    // C-style callbacks
-    bool (*callback_init)(Viewer& viewer);
-    bool (*callback_pre_draw)(Viewer& viewer);
-    bool (*callback_post_draw)(Viewer& viewer);
-    bool (*callback_mouse_down)(Viewer& viewer, int button, int modifier);
-    bool (*callback_mouse_up)(Viewer& viewer, int button, int modifier);
-    bool (*callback_mouse_move)(Viewer& viewer, int mouse_x, int mouse_y);
-    bool (*callback_mouse_scroll)(Viewer& viewer, float delta_y);
-    bool (*callback_key_down)(Viewer& viewer, unsigned char key, int modifiers);
-    bool (*callback_key_up)(Viewer& viewer, unsigned char key, int modifiers);
+    // C++-style functions
+    std::function<bool(Viewer& viewer)> callback_init;
+    std::function<bool(Viewer& viewer)> callback_pre_draw;
+    std::function<bool(Viewer& viewer)> callback_post_draw;
+    std::function<bool(Viewer& viewer, int button, int modifier)> callback_mouse_down;
+    std::function<bool(Viewer& viewer, int button, int modifier)> callback_mouse_up;
+    std::function<bool(Viewer& viewer, int mouse_x, int mouse_y)> callback_mouse_move;
+    std::function<bool(Viewer& viewer, float delta_y)> callback_mouse_scroll;
+    std::function<bool(Viewer& viewer, unsigned char key, int modifiers)> callback_key_down;
+    std::function<bool(Viewer& viewer, unsigned char key, int modifiers)> callback_key_up;
 
     // Pointers to per-callback data
     void* callback_init_data;

+ 6 - 6
include/igl/viewer/ViewerCore.cpp

@@ -317,12 +317,12 @@ IGL_INLINE void igl::ViewerCore::draw(ViewerData& data, OpenGL_state& opengl, bo
 }
 
 IGL_INLINE void igl::ViewerCore::draw_buffer(ViewerData& data,
-                            OpenGL_state& opengl,
-                            bool update_matrices,
-                            Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& R,
-                            Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& G,
-                            Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& B,
-                            Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& A)
+  OpenGL_state& opengl,
+  bool update_matrices,
+  Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& R,
+  Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& G,
+  Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& B,
+  Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic>& A)
 {
   assert(R.rows() == G.rows() && G.rows() == B.rows() && B.rows() == A.rows());
   assert(R.cols() == G.cols() && G.cols() == B.cols() && B.cols() == A.cols());