2016年5月23日 星期一

Week14

作業1:


#include <stdio.h>
FILE*fout=NULL,*fin=NULL;
int main(int argc,char **argv)
{
    if(fout==NULL)
        fout=fopen("output.txt","w+");///w寫檔案,R是讀檔案
    fprintf(fout,"HelloWorld");
}



作業2:

#include <GL/glut.h>
#include <stdio.h>
FILE*fout=NULL,*fin=NULL;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
void motion(int x, int y)
{
    if(fout=NULL) fout=fopen("output.txt","w+");
    fprintf(fout,"%d %d\n",x,y);
}
    int main(int argc,char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("3D");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();

}

沒有留言:

張貼留言