2017年10月26日 星期四

40147027S-Week07

改變光的投影:

  1. const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
    //為光源位置,去掉const,因為等下會改參數
  2. glutMotionFunc(montion);
    //增設一行motion指令
  3. void motion(int x, int y)
    //設定motion函式
    {
        light_position[0] = (x-150)/150*2;
        light_position[1] = -(y-150)/150*2;
        glLightfv(GL_LIGHT0, GL_POSITION, light_position);
        glutPostRedisplay();
    }

沒有留言:

張貼留言