本文整理汇总了C++中Poly::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::Add方法的具体用法?C++ Poly::Add怎么用?C++ Poly::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/*----------------------------------------------------------------------------------------
*
*/
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(winw,winh);
glutInitWindowPosition(200,100);
glutCreateWindow("03 - Mouse Motion");
int size=3;
poly.Add(Vector2f(50*size,10*size));
poly.Add(Vector2f(50*size,130*size));
poly.Add(Vector2f(10*size,130*size));
poly.Add(Vector2f(10*size,90*size));
poly.Add(Vector2f(40*size,70*size));
poly.Add(Vector2f(10*size,50*size));
poly.Add(Vector2f(10*size,10*size));
glutDisplayFunc(Draw);
glutReshapeFunc(Resize);
glutMouseFunc(MouseButton);
glutMotionFunc(MouseMotion);
glutPassiveMotionFunc(MousePassiveMotion);
glutMainLoop();
}
示例2: MouseButton
/*----------------------------------------------------------------------------------------
* \brief This function is called whenever a mouse button is pressed or released
* \param button - GLUT_LEFT_BUTTON, GLUT_RIGHT_BUTTON, or GLUT_MIDDLE_BUTTON
* \param state - GLUT_UP or GLUT_DOWN depending on whether the mouse was released
* or pressed respectivly.
* \param x - the x-coord of the mouse cursor.
* \param y - the y-coord of the mouse cursor.
*/
void MouseButton(int button,int state,int x, int y)
{
/*
* update the mouse position
*/
TheMouse.x = x;
TheMouse.y = y;
/*
* has the button been pressed or released?
*/
if (state == GLUT_DOWN)
{
/*
* This holds the location of the first mouse click
*/
if ( !(TheMouse.lmb || TheMouse.mmb || TheMouse.rmb) )
{
TheMouse.xpress = x;
TheMouse.ypress = y;
poly.Add(Vector2f(x,winh-y));
poly.Shrink(20);
}
/*
* Which button was pressed?
*/
switch(button)
{
case GLUT_LEFT_BUTTON:
TheMouse.lmb = 1;
break;
case GLUT_MIDDLE_BUTTON:
poly.vert.clear();
poly.shrink.clear();
TheMouse.mmb = 1;
break;
case GLUT_RIGHT_BUTTON:
TheMouse.rmb = 1;
break;
}
}
else
{
/*
* Which button was released?
*/
switch(button)
{
case GLUT_LEFT_BUTTON:
TheMouse.lmb = 0;
break;
case GLUT_MIDDLE_BUTTON:
TheMouse.mmb = 0;
break;
case GLUT_RIGHT_BUTTON:
TheMouse.rmb = 0;
break;
}
}
/*
* Force a redraw of the screen. If we later want interactions with the mouse
* and the 3D scene, we will need to redraw the changes.
*/
glutPostRedisplay();
}