We’ve developed an ActiveX animation control for a client using OpenGL, and it works great - You can request that an object moves at a velocity, and then the ActiveX control uses the system timer to process, animate and draw…
I’m pleased cause its my first OpenGL app ever! (Yes, I am a bit of a newbie!)
Its also my first ActiveX too - The reason being that this is to be integrated into a clients VB application later on. (our job is to simply provide a visual engine for a simulation system)
The viewport simply locks onto the object as it moves - Boring, I know, but there’s supposed to be a background later on.
Here’s the problem - If the system gets busy, the object in the middle of the view starts to skip forward and backwards intermittantly… Theoretically, this shouldn’t happen since the camera is supposed to lock on - Ideally, you’d think that the object would remain in the center of the view perfectly, right?
The ActiveX works by calling the openGL updates and processes on a timer event as follows:
// Clear the buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Update the object position using the time
// and a set velocity
// First we calculate the time to make sure
// our object will be at the correct pos.
// at the right time.
// Calculate the movement of the object
// to ensure we move the correct distance
move_step=velocity * move_mult;
// Update the objects x coordinate (move!)
ox += move_step;
// Draw the Object using OpenGL
glTranslatef(ox, oy, oz);
// Use the Objects ox,oy,oz to calculate and
// target the ‘camera’ (using gluLookAt)
// Camera is placed oy + 1 to be slightly
gluPerspective(45, 1, 1, 4000);
gluLookAt(ox, oy + 1, oz, ox, oy, oz, 0, 1, 0);
// Block any OpenGL until finished
// Draw the buffer to screen
Anyone got any ideas? Its almost like the camera/boat position do not match - Like somehow perhaps the ActiveX control is ‘skipping’ some code? Perhaps the last camera settings are being used? Hmmm…
Any help would be REALLY, REALLY appreciated before I tear my hair out!