Week04
## week04_mouse_glscalef
1.安裝freeglut,同時把lib\libfreeglut.a 複製成 libglut32.a
2.flie-new-project, glut 專案
3.程式碼
#include <GL/glut.h>
void display()
{
glClearColor(1,1,0.9,1); ///顏色
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0);
glutSolidTeapot( 0.3 );
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week04_mouse_glScalef");
glutDisplayFunc(display);
glutMainLoop();
}
- file_new_ project, GLUT專案 week04_translate_rotate_scale
#include <GL/glut.h>
float teapotX = 0.5,teapotY = 0;
float angle = 0;
float s = 0.3;
void display()
{///設定 顏色
glClearColor(1,1,0.9,1);///顏色R,G,B,A
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0);
glPushMatrix();///備份矩陣
glRotatef(angle++,0,0,1);
glTranslatef(teapotX,teapotY,0);
glScalef(s,s,s);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
s = 1 + (x-150)/150.0;
display();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week04_mouse_glScalef");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
沒有留言:
張貼留言