用滑鼠調光源
建立GLUT專案,然後加入滑鼠調光源功能
程式碼:
GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f }; //將const刪掉
void motion(int x, int y)
{
light_position[0] = (x - 150) / 150.0 *2;
light_position[1] = (y - 150) / 150.0 *2;
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glutPostRedisplay();
}
int main(int argc, char *argv[])
{
......
glutMotionFunc(motion); //在main加入mouse motion函式
}
沒有留言:
張貼留言