One. 架設GLUT架構 (Teapot) (review)
(1) 滑鼠動作
void mouse(int botton, int state, int x, int y)
{
printf("%d %d %d %d\n",botton,state,x,y);
}
(2) 換顏色
void mouse(int botton, int state, int x, int y)
{
printf("%d %d %d %d\n",botton,state,x,y);
glColor3f(x /500.0, 1, y / 500.0);
glutPostRedisplay();
}
2. glutMotionFunc(); ///可移動換顏色
void motion(int x, int y)
{
printf("%d %d\n",x,y);
glColor3f(x /500.0, 1, y / 500.0);
glutPostRedisplay();
}
Three. Shape
Using Sine & Cosine to draw a circle
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_POLYGON);
for(float angle=0 ; angle < 3.141592 * 2 ; angle+=0.001){
glVertex2f(cos(angle),sin(angle));
}
glEnd();
glutSwapBuffers();
}
void mouse(int botton, int state, int x, int y)
{
printf("%d %d %d %d\n",botton,state,x,y);
}
void motion(int x, int y)
{
printf("%d %d\n",x,y);
glColor3f(x /500.0, 1, y / 500.0);
glutPostRedisplay();
}
Three. Shape
Using Sine & Cosine to draw a circle
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_POLYGON);
for(float angle=0 ; angle < 3.141592 * 2 ; angle+=0.001){
glVertex2f(cos(angle),sin(angle));
}
glEnd();
glutSwapBuffers();
}





沒有留言:
張貼留言