Pangolin: 1 - Hello pangolin

Share:
## 目标: - 创建窗口 - 放置一个立方体 ## Source Code ```cpp #include #include <pangolin/pangolin.h> int main(int argc, char** argv) { pangolin::CreateWindowAndBind("Main", 640, 480); glEnable(GL_DEPTH_TEST); // Define Projection and initial ModelView matrix pangolin::OpenGlRenderState s_cam( pangolin::ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100), pangolin::ModelViewLookAt(-2, 2, -2, 0, 0, 0, pangolin::AxisY)); // Create Interactive View in window pangolin::Handler3D handler(s_cam); pangolin::View& d_cam = pangolin::CreateDisplay() .SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f / 480.0f) .SetHandler(&handler); while (!pangolin::ShouldQuit()) { // Clear screen and activate view to render into glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); d_cam.Activate(s_cam); // Render OpenGL Cube pangolin::glDrawColouredCube(); // Swap frames and Process Events pangolin::FinishFrame(); } return 0; } ``` ## 重要的函数 ### ProjectionMatrix ```cpp OpenGlMatrixSpec pangolin::ProjectionMatrix( int w, int h, double fu, double fv, double u0, double v0, double zNear, double zFar ) ``` ### ModelViewLookAt ```cpp OpenGlMatrix pangolin::ModelViewLookAt( double ex, double ey, double ez, double lx, double ly, double lz, double ux, double uy, double uz ) ``` ### Handler3D ```cpp Handler3D (OpenGlRenderState &cam_state, AxisDirection enforce_up=AxisNone, float trans_scale=0.01f) ``` ### CreateDisplay ```cpp View & pangolin::CreateDisplay() ``` Create unnamed display managed by pangolin (automatically deleted) ## pangolin::View Struct Reference - http://docs.ros.org/fuerte/api/pangolin_wrapper/html/structpangolin_1_1Widget.html ```cpp View & SetBounds (Attach bottom, Attach top, Attach left, Attach right, bool keep_aspect=false) View & SetBounds (Attach bottom, Attach top, Attach left, Attach right, double aspect) ``` Set bounds for the View using mixed fractional / pixel coordinates (OpenGl view coordinates) ### View::SetHandler ```cpp View & pangolin::View::SetHandler ( Handler * handler ) ``` Designate handler for accepting mouse / keyboard input.

No comments