移動 glTranslatef
旋轉glRotatef
縮放glScalef

作業二
mouse轉動
(原圖)
(轉動後)
程式碼:
#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0, 1, 0);
glColor3f(1,0,0);
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("Hello 3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
課堂作業三
Q1.什麼是Buffer
Q2什麼是Double Buffer

程式碼:
#include <GL/glut.h>
float rotX=0,rotY=0;
void display()
{
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 1, 0, 0);
glRotatef(rotX, 0, 1, 0);
glColor3f(1,0,0);
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);
glutInitWindowSize(700,0);
glutCreateWindow("Hello 3D");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言