light position question

Started by
10 comments, last by mstein 21 years, 1 month ago
as the code is not in front of me, i really cannot remember, but i think my glutPostRedisplay IS in my display, NOT my timer, which would be way my lights for my car are updated everyframe (i do it from display when the car is drawn) and that the other lights are not updated every frame (i do it in timerFunc)

thanks you
Advertisement
okay, i got rid of my timer function, because i can have all of the same functionality built into the display function, and your right, it was holding back my FPS.

But my lights still do not update every frame drawn. I was wondering if anyone new how rand() worked. I believe I learned/heard once that rand() is based on time. Right now the light position updates once every second, and im getting 80 fps. I set the lights new position via a call to rand() as follows:


  class FlickerLight : public virtual Light {	public:		FlickerLight(GLenum gle) {			type = FLICKER;			srand(time(NULL));			light_id = gle;		}		FlickerLight() {};		~FlickerLight() {};		virtual void updatePosition() {			printf("light moved\n");						position[0] = (((float)(rand() % 200) / 200) * 2) - 1.0;			position[1] = (((float)(rand() % 200) / 200) * 2) - 1.0;			printf("%d\t%d\n", position[0], position[1]);			this->setPosition(this->position);			//glLightfv(light_id, GL_POSITION, position);		}};  


could it be that rand() is giving me the same number for a second at a time. It appears that when in the values that print out. I guess my question is why??? and how do i get around it. I dont need the light to change every frame, but more than once a second would be good.

This topic is closed to new replies.

Advertisement