//MouseButtonS // Drawing polyline // saving current point // T. Kosaka CS TNCT 2001 #include #include #include #include "drawShape2D.h" void userdraw(void); void display(void) { glClear( GL_COLOR_BUFFER_BIT); userdraw(); glutSwapBuffers(); } int NumberofPoints; point2D_t PointBuffer[4096]={{0,0}}; //マウスボタンが押された時に呼び出される関数 void onMouseButton(int button, int state, int x, int y_inv) { int y=480-y_inv-1; // device coordinate -> view coordinate switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_UP && NumberofPoints!=4096) { PointBuffer[NumberofPoints].x=x; PointBuffer[NumberofPoints].y=y; NumberofPoints++; } break; case GLUT_MIDDLE_BUTTON: // do nothing break; case GLUT_RIGHT_BUTTON: // do nothing break; default: break; } } void userdraw(void) { int i; color_t white={1.,1.,1.}; setColor(white); if (1