Here's a sample code. Rotate the camera according to the mouse movement values every loop. The CamSpeed variable is a mouse sensitivity adjustment which can be configured according to the user's preference.
In this sample code I'm using the dbCameraAngleX/Y commands to get the current rotation of the camera, but in the original code where I took the example from, the rotation angles and the CamSpeed were stored as data members of the camera class.
void RotateCamera(int MouseDiffX, int MouseDiffY)
{
static float CamSpeed = 0.5;
float RotX = dbCameraAngleX();
float RotY = dbCameraAngleY();
RotX = dbWrapValue(RotX + float(MouseDiffY) * CamSpeed);
RotY = dbWrapValue(RotY + float(MouseDiffX) * CamSpeed);
dbRotateCamera(RotX, RotY, 0);
}
// calling the function from the main loop:
void DarkGDK ( void ) {
dbHideMouse();
while (LoopGDK())
{
dbPositionMouse(dbScreenWidth()/2, dbScreenHeight()/2);
RotateCamera(dbMouseMoveX(), dbMouseMoveY());
dbSync();
}
}
The "hide mouse" and "position mouse" commands are optional but they make it look better. Of course the screen centre position can also be stored in variables instead of using the screen width/height functions every loop.