About glGet()
I want to render some lamps , so I use glGetLightfv() to get the position of a lamp.But I find that the first time when I use the function glGetLightfv()spend much more time then the others.
The glut is used in the project. The display() function is like this:
for(int i=0;i<light_num;i++)
{
glGetLightfv(GL_LIGHT0,GL_POSITION,ltPosition);
......move coord to ltPosition
......renfer the lamp
}
The image is correct.
The time spending for rendering each lamp:
0.079584
0.000152
0.000132
0.000122
0.000113
0.000122
0.000123
0.000117
What result this?Are there some details I forget to set?
You might find it easier to keep the positions of your lamps stored elsewhere (a customised 'light' structure or a simple array would work), that way you've always got access to them and there's no need to keep asking where they are when you want to do things with them.
As for it taking longer the first time, it's not something you're going to avoid, regardless of what you try. If it kept happening every few frames or something, then you'd have something to complain about, but otherwise, don't worry about it. If you feel it's really that horrible, try implementing a simple loading screen before you start rendering everything, and you might find it disappears (the first frame always takes a bit of time to render, but after that, it's usually fine).
As for it taking longer the first time, it's not something you're going to avoid, regardless of what you try. If it kept happening every few frames or something, then you'd have something to complain about, but otherwise, don't worry about it. If you feel it's really that horrible, try implementing a simple loading screen before you start rendering everything, and you might find it disappears (the first frame always takes a bit of time to render, but after that, it's usually fine).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement