1.
首先下載data,win32跟glut32.dll,將data,win32解壓縮,把data跟glut32.dll放進win32,就可以執行裡面的東西惹~
今天開了一個Transformation,可以移動旋轉放大縮小物品
並弄清楚xyz軸的轉動方向
2.
目標 : 可以用滑鼠讓圖片旋轉
void motion(int x,int y) //mouse motion移動到哪
{
myAngle=x; //x轉動的值
}
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutMotionFunc(motion); //增加mouse motion函式,可以抓到滑鼠的動態
glutKeyboardFunc(key);
glutIdleFunc(idle);
float myAngle=0; //宣告角度變數
static void display(void)
{
const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
const double a = myAngle; //把我們要的角度放進去
3.
茶壺很失控
#include <GL/glut.h>
float myAngle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(myAngle,0,0,1);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
myAngle = x;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week 04 rotate");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}
float myAngle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(myAngle,0,0,1);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
myAngle = x;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week 04 rotate");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}
4.
#include <GL/glut.h>
float myAngle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(myAngle,0,0,1);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
int oldX=0;
void mouse(int button,int state,int x,int y)
{
if(state==GLUT_DOWN) oldX = x;
}
void motion(int x,int y)
{
myAngle += (x-oldX);
oldX = x;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week 04 rotate");
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutDisplayFunc(display);
glutMainLoop();
}






沒有留言:
張貼留言