2024年5月30日 星期四

ttcc

 1.1 .從上課軟體下載freeglut




 2.將壓縮檔解壓到桌面

3.點開freeglut後復製其連結


4.點開lib後將freeglut.a復製


5.改名為libglut32.a (124KB)


6.新增專案week15

7.增加 doremifasol

8.新增專案weeek15-2_PlaySound_empty


9.換音樂
10.回到week15-1


11.新增專案week15-3_CMP3_MCI

12.新增專案week15-4_mouse_motion_translate_rotate
#include <GL/glut.h>
float angleX[10]={},angleY[10]={};
float teapotX=0,teapotY=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(teapotX,teapotY,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();

}
int oldX=0,oldY=0;
void mouse(int button,int state,int x,int y)
{
    oldX=x;
    oldY=y;
}
void motion(int x, int y)
{
    teapotX += (x-oldX)/150.0;
    teapotY -= (y-oldY)/150.0;
    oldX=x;
    oldY=y;
    glutPostRedisplay();
}
int main(int argc,char*argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week15-4");
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);

    glutMainLoop();
}
#include <GL/glut.h>
#include <stdio.h>
float angleX[10]={},angleY[10]={};
float teapotX=0,teapotY=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(teapotX,teapotY,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();

}
int oldX=0,oldY=0;
void mouse(int button,int state,int x,int y)
{
    oldX=x;
    oldY=y;
}
void motion(int x, int y)
{
    teapotX += (x-oldX)/150.0;
    teapotY -= (y-oldY)/150.0;
    printf("glTranslatef(%.3f, %.3f, 0);\n", teapotX, teapotY);
    oldX=x;
    oldY=y;
    glutPostRedisplay();
}
int main(int argc,char*argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week15-4");
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);

    glutMainLoop();
}

#include <GL/glut.h>
#include <stdio.h>
float angleX[10]={},angleY[10]={};
float teapotX=0,teapotY=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glutSolidSphere(0.02,30,30);
    glPushMatrix();
        glTranslatef(teapotX,teapotY,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();

}
int oldX=0,oldY=0;
void mouse(int button,int state,int x,int y)
{
    oldX=x;
    oldY=y;
}
void motion(int x, int y)
{
    teapotX += (x-oldX)/150.0;
    teapotY -= (y-oldY)/150.0;
    printf("glTranslatef(%.3f, %.3f, 0);\n", teapotX, teapotY);
    oldX=x;
    oldY=y;
    glutPostRedisplay();
}
int main(int argc,char*argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week15-4");
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);

    glutMainLoop();
}
新增中點
#include <GL/glut.h>
#include <stdio.h>
float angleX[10]={},angleY[10]={};
float teapotX=0,teapotY=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glutSolidSphere(0.02,30,30);
    glPushMatrix();
        glRotatef(angleX[0], 0, 0, 1);
        glTranslatef(-0.520,-0.133,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();

}
int oldX=0,oldY=0;
void mouse(int button,int state,int x,int y)
{
    oldX=x;
    oldY=y;
}
void motion(int x, int y)
{
    //teapotX += (x-oldX)/150.0;
    //teapotY -= (y-oldY)/150.0;
    //printf("glTranslatef(%.3f, %.3f, 0);\n", teapotX, teapotY);
    angleX[0] += (x-oldX);
    oldX=x;
    oldY=y;
    glutPostRedisplay();
}
int main(int argc,char*argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week15-4");
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);

    glutMainLoop();
}



沒有留言:

張貼留言