PDA

View Full Version : Rotate view with mouse



Ralf Euser
05-01-2007, 07:55 AM
Hi all,

I have currently made a basic OpenGL 3D cube in a scene. I now want to rotate this cube by mouse dragging it? How can I do this. "glRotate" doesn't seem to work very correct.... :confused:

Greets,

Ralf

Darren Taylor
05-01-2007, 08:59 AM
It probably won't if you're only trying to do it with one line of code. Have you tried it like:

// rotate around the x axis
glRotatef(rot_x,1.0f,0.0f,0.0f);
// rotate around the y axis
glRotatef(rot_y,0.0f,1.0f,0.0f);
// rotate around the z axis
glRotatef(rot_z,0.0f,0.0f,1.0f);

Where rot_x, rot_y, rot_z are floats indicating how much you want to rotate around each axis?

If this doesn't work, you'll need to post your code to show us what's going wrong.

Daz.