創辦一個github帳號
github.com
登入後進去repo創立一個2021graphics
將week03opengl跟week03glut上傳上去
-----------------------------------------------------------------------------------------
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,0);
glutSolidSphere(0.5, 30, 30);
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week03-circle");
glutDisplayFunc( display );
glutMainLoop();
}
-----------------------------------------------------------------------------------------
#include <GL/glut.h>
#include <math.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,0,0);
glBegin(GL_POLYGON);
for(int i=0; i<30; i++){
float a = 3.1415926 * 2 / 30 *i;
glVertex2f(0.5 + 0.1*cos(a), 0.2*sin(a) );
}
glEnd();
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week03-circle");
glutDisplayFunc( display );
glutMainLoop();
}
沒有留言:
張貼留言