week03
從老師給的網址( https://jsyeh.org/3dcg10/ )下載windows.zip和data.zip,解壓縮後把data資料夾中的data放入windows的資料夾,後開啟windows裡的Transformation.exe
利用gist.github.com的功能讓程式碼在部落格有顏色(.cpp)glPushMatrix ( ) ; ///備份矩陣glTranslatef ( 0.5 , 0.5 , 0 ) ; ///改變矩陣
glPopMatrix ( ) ; ///還原矩陣
glTranslatef ( X , Y , Z ) ; ///照著 X , Y , Z 移動
void mouse( int button , int state , int x , int y ) ///滑鼠的函式
{
X = ( x - 150 ) / 150.0 ;
Y = - ( y - 150 ) / 150.0 ;
}
glutMouseFunc(mouse) ; ///設定好 mouse 函式
glBegin(GL_LINE_LOOP);
#include <GL/glut.h>
float angle = 0 ;
void display()
{
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f(1,0,0);
glPushMatrix();
glRotatef(angle,0,0,1) ;
glTranslatef(0.8,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glColor3f(0,1,0);
glPushMatrix();
glTranslatef(0.8,0,0);
glRotatef (angle*1.5,0,0,1) ;
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
angle++ ;
}
int main(int argc,char*argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week03");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言