#week15-1
安裝freeglut,開新專案
#include<windows.h> 第一行
把檔案放在 C:\,就可用 C:/檔名.wav
int main(...)
{
PlaySound("檔名.wav", NULL,SND_ASYNC); A代表不同不等待
}
最後變成
PlaySound("C/Do.wav", NULL, SND_SYNC);
PlaySound("C/Re.wav", NULL, SND_SYNC);
PlaySound("C/Mi.wav", NULL, SND_SYNC);
PlaySound("C/Fa.wav", NULL, SND_SYNC);
PlaySound("C/Sol.wav", NULL, SND_SYNC);
PlaySound("C/mykbeat.wav", NULL, SND_ASYNC);A代表不同步不等待
#week15-2
開新專案,把程式碼全刪
#include <windows.h>
int main()
{
PlaySound("C/mykbeat.wav", NULL, SND_ASYNC); 不等待
printf("請輸入一個整數:");
int n;
scanf(%d, &n);卡住
}
#week15-3
開新專案,加上
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
int main(...)
{
myMP3.Load("song.mp3");
myMP3.Play();
}
#week15-4
開新專案貼11行程式
最後
#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);
glRotatef(angleX[0], 0, 0, 1);
glTranslatef(-0.507, -0.127, 0);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
int oldX = 0, oldY = 0;
void mouse(int butten, 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_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week15-4");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutMainLoop();
}
沒有留言:
張貼留言