cp ~fran/student/* .
void setUpGLUT(int argc,char ** argv)
glutMouseFunc(mouse); glutIdleFunc(idle);
void mouse(int button,int state,int xMouse,int yMouse){
static int idling=TRUE;
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN){
idling=!idling;
if(idling)glutIdleFunc(idle);
else glutIdleFunc(NULL);
}
glutPostRedisplay();
}void idle(){
ra+=0.2;
if(ra>=360) ra=0;
glutPostRedisplay();
}NULL does not work, you need another include file at the top of the program.
#include <stdio.h>
(0,0,5.0). It is a point, not a vector.GLfloat spotDirection[]={-0.1,0.0,-1.0};glLightfv(GL_LIGHT4,GL_SPOT_DIRECTION,spotDirection); glLightf(GL_LIGHT4,GL_SPOT_CUTOFF,25.0); glLightf(GL_LIGHT4,GL_SPOT_EXPONENT,100.0); glLightf(GL_LIGHT4,GL_CONSTANT_ATTENUATION,1); glLightf(GL_LIGHT4,GL_LINEAR_ATTENUATION,0); glLightf(GL_LIGHT4,GL_QUADRATIC_ATTENUATION,0.5);
GL_SPOT_EXPONENT much smaller?
glutTimerFunc to turn the spotlight on and off automatically every second (1000 milliseconds).
setUpGLUT.
glutTimerFunc(1000,timer,0);
void timer(int id){
switch(id){
case 0: glEnable(GL_LIGHT4);
glutTimerFunc(1000,timer,1);
break;
case 1: glDisable(GL_LIGHT4);
glutTimerFunc(1000,timer,0);
break;
}
glutPostRedisplay();
}