2.Mouse-Light打光
步驟一:打開glut專案擋
步驟二:尋找main中之 glLightfv函式
步驟三:尋找相關函式的宣告變數
步驟四:將GLfloat light_position[]函式前的const去除,才可以進行修正
步驟五:新增motion函式,並在main加入glutMotionFunc(motion);函式
void motion(int x, int y)
{
light_position[0]=(x-150*2)/150.0*2; //變更光源座標為滑鼠座標
light_position[1]=-(y-150)/150.0*2;
glLightfv(GL_LIGHT0,GL_POSITION,light_position); //重設光源
glutPostRedisplay();
}步驟六:編譯執行,完成!!!!





沒有留言:
張貼留言