找出比較好的作品




Hw 02 :
Step 1: 打開GLUT
Step 2;
打上程式碼,並執行。
在執行後的綠色視窗上面用滑鼠點出想要的圖形
#include <GL/glut.h>
#include <stdio.h>
void mouse(int button, int state,int x,int y)
{
if(state==GLUT_DOWN)
printf(" glVertex2f( (%d-150)/150.0, -(%d-150)/150.0 ); \n",x,y);
}
void display()
{
glClearColor(150/255.0,170/255.0,55/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
glColor3ub(175,193,81);
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}

Step 3:
複製小黑窗內的資料,在視窗上按又鍵>>編輯>>標記,框起所有資料,按Enter。

Step 4:
將複製的東西貼到CodeBlocks,並在前面加上glBegin(GL_POLYGON);,最後面加上glEnd();

Hw 03:
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
void mouse(int button, int state,int x,int y)
{
if(state==GLUT_DOWN)
printf(" glVertex2f( (%d-150)/150.0, -(%d-150)/150.0 ); \n",x,y);
}
void display()
{
glClearColor(255/255.0,255/255.0,255/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
glColor3ub(100,150,220);
glPushMatrix();
glBegin(GL_POLYGON);
for(float angle=0; angle<3.14159265357989*2; angle +=0.1)
{
glVertex2f( 0.5*cos(angle), 0.5*sin(angle));
}
glEnd();
glPopMatrix();
glPushMatrix();
glTranslatef(-0.5,0.5,0);
glBegin(GL_POLYGON);
for(float angle=0; angle<3.14159265357989*2; angle +=0.1)
{
glVertex2f( 0.3*cos(angle), 0.3*sin(angle));
}
glEnd();
glPopMatrix();
glPushMatrix();
glTranslatef(0.5,0.5,0);
glBegin(GL_POLYGON);
for(float angle=0; angle<3.14159265357989*2; angle +=0.1)
{
glVertex2f( 0.3*cos(angle), 0.3*sin(angle));
}
glEnd();
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}

Hw 04:
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
float nowX=0, nowY=0,now=0;
void mouse(int button, int state,int x,int y)
{
nowX=(x-150)/150.0;
nowY=(y-150)/150.0;
now+=0.1;
}
void display()
{
glClearColor(255/255.0,255/255.0,255/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
glColor3ub(100,150,220);
glPushMatrix();
glBegin(GL_POLYGON);
for(float angle=0; angle<3.14159265357989*2; angle +=0.1)
{
glVertex2f( 0.5*cos(angle), 0.5*sin(angle));
}
glEnd();
glPopMatrix();
glColor3ub(125,161,31);
glPushMatrix();
glBegin(GL_POLYGON);
glVertex2f(nowX,nowY);
for(float angle=0; angle<now; angle +=0.1)
{
glVertex2f( nowX+0.3*cos(angle), nowY+0.3*sin(angle));
}
glEnd();
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}
沒有留言:
張貼留言