http://2016graphicsS.blogspot.com/
把DATA跟GLUT32.DLL放到WINDOW裡面
縮放.旋轉

按右鍵SWAP

判斷Translatef與Rotatef 轉動的差別
Translatef是軸的原點為轉動的中心點
Rotatef是以物件為轉動的中心點
Buffer是記憶體緩衝區
Double (Buffers)是多一倍的遮蔽,增加緩衝時間
Push:將資料放入記憶體中
Pop:將資料從記憶體中彈出
What is the Matrix in this code?
glRotatef () , glColor3f () , glSolidTeapot ()
Push:將資料放入記憶體中
Pop:將資料從記憶體中彈出
What is the Matrix in this code?
glRotatef () , glColor3f () , glSolidTeapot ()
接下來是左右旋轉的茶壺
#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0,1,0);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
rotX = x;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
///glutMouseFunc(mouse);
glutMainLoop();
}

以下是增加上下旋轉的
#include <GL/glut.h>
float rotX=0,rotY=0;
void display()
{
glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotY, 1,0,0);
glRotatef(rotX, 0,1,0);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
rotX = x; rotY = y;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
///glutMouseFunc(mouse);
glutMainLoop();
}

再來360度旋轉
#include <GL/glut.h>
float rotX=0,rotY=0;
void display()
{
glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotY, 1,0,0);
glRotatef(rotX, 0,1,0);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
rotX = x; rotY = y;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
glutInitWindowSize(600,600);
glutInitWindowPosition(700,0);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
///glutMouseFunc(mouse);
glutMainLoop();
}

沒有留言:
張貼留言