week15
------------------------------------
week15-1_playsound
開新專案(File-New-Project),專案名稱為 "week15-1_PlaySound"
全刪,只寫一行
#include <windows.h>
#include <GL/glut.h>
int main()
{ PlaySound("filename.wav", NULL, SND_SYNC); ///等待播玩音樂,才結束 }
week15-2_CMP3_MCI
將老師給的 CMP3_MCI.h,放在 week15-2_CMP3_MCI 目錄裡
#include "CMP3_MCI.h" //記得要用雙引號,不能用角括號
#include <stdio.h> ///為了 scanf
CMP3_MCI myMP3; ///宣告一個變數,名字叫做 myMP3
int main()
{
myMP3.Load(".mp3");
myMP3.Play();
int a; ///幫忙卡住,程式不要快速結束
scanf("%d", &a);
}
----------------------------------------------
week15-3_mouse_motion_glTranslatef_glRotatef
#include <GL/glut.h>
float angleX[15] = {}, angleY[15] = {}; ///關節要夠用
void display()
{
//glClearColor(1,1,0,1); ///黃色背景
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(angleX[14]/150.0, angleY[14]/150.0, 0); ///拿來當成移動的變數
glRotatef(angleX[0], 1, 0, 0);
glRotatef(angleY[0], 0, 1, 0);
glPushMatrix();
glScalef(0.2, 0.2, 0.2);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
int angleID = 0, oldX = 0, oldY = 0;
void mouse(int button, int state, int x, int y)
{
oldX = x;
oldY = y;
}
void motion(int x, int y)
{
angleX[angleID] += x-oldX;
angleY[angleID] += y-oldY;
oldX = x;
oldY = y;
glutPostRedisplay();
}
void keyboard(unsigned char key, int x, int y)
{
if(key=='x') angleID = 14;
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week15");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
沒有留言:
張貼留言