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);
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week12_TRT");
glutIdleFunc(display);
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);
//glRotataf(angle,0,0,1);
//glTranslatef(x2,y2,z2);
glColor3f(1,0,0);
glRectf(0.5,0.5,1.0,0.3); (紅色方塊)
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week13_TRT");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言