Sign in to follow this  

Choppy SDL mouse input

Recommended Posts

Here is my camera rotate-by-mouse function:
void Camera::setViewByMouse(dimension2d<unsigned int> screenSize, vector2di vMousePos) {				
	int middleX = screenSize.width  >> 1;			
	int middleY = screenSize.height >> 1;				
	float angleY = 0.0f;							
	float angleZ = 0.0f;							
	static float currentRotX = 0.0f;
	if((vMousePos.x == middleX) && (vMousePos.y == middleY)) 
	angleY = (float)((middleX - vMousePos.x))/1000.0f;		
	angleZ = (float)((middleY - vMousePos.y))/1000.0f;		

	currentRotX -= angleZ;  

	if(currentRotX > 1.45f) {
		currentRotX = 1.45f;
	else if(currentRotX < -1.45f) {
		currentRotX = -1.45f;
	else {
		vector3df vAxis = (m_vTarget - m_vPos).crossProduct(m_vUp);

		rotateView(angleZ, vAxis.x, vAxis.y, vAxis.z);
		rotateView(angleY, 0, 1, 0);
	SDL_WarpMouse(middleX, middleY);

I get the cursor location with (in a seperate class):

	           	m_vMousePos.x = event.motion.x;

				m_vMousePos.y = event.motion.y;

But the results are very choppy. The framerate is over 100 the whole time, so it has nothing to do with the framerate. Any ideas?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this