1.
1-1:
程式碼:
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glRectf(0.5,0.5,-0.5,-0.5);///Rect=四邊形、gl=opengl(開始畫)、f=浮點數
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week13");
glutDisplayFunc(display);
glutMainLoop();
}
1-2:
程式碼:
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);
glRectf(0.5,0.5,-0.5,-0.5);
glPushMatrix();
///glTranslatef(x,y,z);
///glRotatef(angle,0,0,1);
glTranslatef(x2,y2,z2);
glColor3f(1,0,0);
glRectf(0.5,0.5,1.0,0.7);
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week13");
glutDisplayFunc(display);
glutMainLoop();
}


沒有留言:
張貼留言