1.複製十行
#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMouseFunc(mouse);///+
glutMainLoop();
}
2.+一行
glutMouseFunc(mouse);///+
3.點茶壺會出現Hello Mouse
void mouse(int button, int state, int x, int y)
{
printf("HelloMouse!\n");
}
4.print座標printf("%d %d %d %d\n", button, state, x, y);
5.printf 程式
if(state==GLUT_DOWN)
printf("glVertex2f((%d-150)/150.0, -(%d-150)/150.0;\n", x, y);
8.copy line46 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
line49 glPushMatrix();
line54 glPopMatrix();
9.copy glMouse
float teapotX = 0, teapotY = 0;
void mouse(int button, int state, int x, int y)
{
teapotX = (x-150)/150.0;
teapotY = -(y-150)/150.0;
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glPopMatrix();///偷
glTranslatef(teapotX, teapotY, 0);
glutSolidTeapot( 0.3 );
glutSolidTeapot(0.3);
glutSwapBuffers();
}
1. 右手比讚
2.轉動軸為拇指
轉動方向為其他拇指的轉動方向
3.對y軸轉 比個讚
x軸 拇指向右
-y軸 倒讚
11. copy translatef
+float angle = 0;
glRotatef(angle, 0, 0, 1);
void motion(int x, int y)
{
angle = x;
display();
}
13.copy last file
沒有留言:
張貼留言