1.:jsyeh.org/3dcg10
2.下載[data] [win32] [glut32.dll]
3.開啟win32=>shapes
POINTS
LINE_LOOP
TRIANGLE_FAN
TRIANGLE_STRIP
Homework2
程式碼:
#include<GL/glut.h> //標頭檔
void display()
{
glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.70);//顏色
glVertex3f(0.0,0.0,0.0);//點1
glVertex3f(1.0,0.0,0.0);//點2
glVertex3f(1.0,1.0,0.0);//點3
glEnd();
//glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc, argv); //引入程式
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH); //雙視窗
glutCreateWindow("hello 3D"); //視窗名稱
glutDisplayFunc(display); //展示
glutMainLoop();
}
Homework3
#include <GL/glut.h>
void display()
{
glClearColor(144/255.0,168/255.0,56/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(192/255.0,215/255.0,0.7/255.0);
glVertex3f((95-100)/100.0,-(49-100)/100.0,0.0);
glVertex3f((17-100)/100.0,-(106-100)/100.0,0.0);
glVertex3f((93-100)/100.0,-(165-100)/100.0,0.0);
glVertex3f((174-100)/100.0,-(103-100)/100.0,0.0);
glEnd();
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Hello 3D");
glutDisplayFunc(display);
glutMainLoop();
}

#include <GL/glut.h>
void display()
{
glClearColor(144/255.0,168/255.0,56/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(192/255.0,215/255.0,0.7/255.0);
glVertex3f((95-100)/100.0,-(49-100)/100.0,0.0);
glVertex3f((17-100)/100.0,-(106-100)/100.0,0.0);
glVertex3f((93-100)/100.0,-(165-100)/100.0,0.0);
glVertex3f((174-100)/100.0,-(103-100)/100.0,0.0);
glEnd();
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Hello 3D");
glutDisplayFunc(display);
glutMainLoop();
}

Homework4
#include <GL/glut.h>
#include <stdio.h>
void mouse(int button,int state, int x,int y)
{
if(state==GLUT_DOWN)
printf("glVertex3f((%d-100)/100.0,(%d-100)/100.0,0.0\n",x,y);
}
void display()
{
glClearColor(144/255.0,168/255.0,56/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(192/255.0,215/255.0,0.7/255.0);
glVertex3f((95-100)/100.0,-(49-100)/100.0,0.0);
glVertex3f((17-100)/100.0,-(106-100)/100.0,0.0);
glVertex3f((93-100)/100.0,-(165-100)/100.0,0.0);
glVertex3f((174-100)/100.0,-(103-100)/100.0,0.0);
glEnd();
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Hello 3D");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}
#include <GL/glut.h>
#include <stdio.h>
void mouse(int button,int state, int x,int y)
{
if(state==GLUT_DOWN)
printf("glVertex3f((%d-100)/100.0,(%d-100)/100.0,0.0\n",x,y);
}
void display()
{
glClearColor(144/255.0,168/255.0,56/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(192/255.0,215/255.0,0.7/255.0);
glVertex3f((95-100)/100.0,-(49-100)/100.0,0.0);
glVertex3f((17-100)/100.0,-(106-100)/100.0,0.0);
glVertex3f((93-100)/100.0,-(165-100)/100.0,0.0);
glVertex3f((174-100)/100.0,-(103-100)/100.0,0.0);
glEnd();
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Hello 3D");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}

沒有留言:
張貼留言