Hi guys,

 I'm trying to implement a trackall but I can't make it work. I have two class, my Trackball and my View class. Actualy, When I clic and move my mouse, my rotation work well. but when I clic again, my cube is always coming back at my starting position to make the new rotation. Any ideas?


Not quite sure what your asking, but sounds like your not adding up your movements. In opengl, the movements are cummulative, till the next frame, then the matrix is reset, so any movements done from the last frame wont show.

So if you are rotating a box the proper way is like this.

Begin Render Loop:
//gl setup stuff, like clearing buffer

glRotate(1,0,0, rotvalue);

//draw box

End Render Loop:

Does this help?

If you do a google search for
virtual trackball opengl
you will find a pdf document from a cs class at stanford, (sorry, i dont have the link). There, the idea is nicely explained and I remember there is plenty sample code available also. This seems to be a standard cs homework assignment i guess ;-).
Good luck

There’s a nice trackball.c in the GLUT sources using quaternions. Using this carefully means you have a better rotate controller than many professional apps.

Maybe You can use gltb.cpp and gltb.h,It’s a very nice function that has realized the trackball model.
Hope can help you!