Week_05
Class Work_01
Download three files (windows, data, glut.dll) and open Transformation.exe, right click and choose (Swap translate/rotate).
- Translatef : Axis be a center to do rotation.
- Rotatef : Model be a center to do rotation.



Class Work_02

Source Code:
#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(0,0,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0,1,0);
glColor3f(1,1,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("01370984");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
Class Work_03
What is Buffer?
A buffer is a data area shared by hardware devices or program processes that operate at different speeds or with different sets of priorities. The buffer allows each device or process to operate without being held up by the other.
Class Work_03
What is Buffer?
A buffer is a data area shared by hardware devices or program processes that operate at different speeds or with different sets of priorities. The buffer allows each device or process to operate without being held up by the other.
What is Double Buffer?
What is Matrix?
It is useful to be able to save the current transformation.
Class Work_04

Source Code:
Class Work_04

Source Code:
#include <GL/glut.h>
float rotX=0, rotY=0;
void display()
{
glClearColor(0,0,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0,1,0); /// rotX is Rotation angle
glRotatef(rotY, 1,0,0); /// rotY is Rotation angle
glColor3f(1,1,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);
glutCreateWindow("01370984");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}

沒有留言:
張貼留言