Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actualmynameisnafe

Posted 03 February 2013 - 08:49 AM

Okay, it's broken. Theres a lot of code here! Please help

 

It's basically the one from opengl-tutorial.com. Using glm but not glfw.

 

The camera kind of works but doesn't.. it's jerky and when I go left with the mouse it goes and looks up etc.. when I go up it goes down..

all sorts of crazy

 

If we can fix this maybe we can fix the keyboard input :/

 

void UpdateFromMouse( int w, int h, int mousex, int mousey )
		{	
			/*
				Handle the mouse input
			*/
			_mx = mousex;		_my = mousey;

			m_horizontalAngle += m_mouseSpeed * m_frameTime * float( w / 2 - _mx );
			m_verticalAngle   += m_mouseSpeed * m_frameTime * float( h / 2 - _my );

			m_direction = glm::vec3
			(
				cos( m_verticalAngle ) * sin( m_horizontalAngle ),
				sin( m_verticalAngle ),
				cos( m_verticalAngle ) * cos( m_horizontalAngle )
			);

			m_right = glm::vec3
			(
				sin( m_horizontalAngle - 3.14f / 2.0f ),
				0,
				cos( m_horizontalAngle - 3.14f / 2.0f )
			);

			m_up = glm::cross( m_right, m_direction );

			/*
				Update the view matrix
			*/
			m_viewMatrix = glm::lookAt( position, position + m_direction, m_up );
		}

 

 


#3mynameisnafe

Posted 03 February 2013 - 08:48 AM

Okay, it's broken. Theres a lot of code here! Please help

It's basically the one from opengl-tutorial.com. Using glm but not glfw. The camera kind of works but doesn't.. it's jerky and when I go left with the mouse it goes and looks up etc.. when I go up it goes down.. all sorts of crazy

If we can fix this maybe we can fix the keyboard input :/

case WM_LBUTTONDOWN: 		{			mDown = true;			ShowCursor(false);			SetCapture(hWnd);					// capture the mouse.  				GetCursorPos(&cPos);					// store cursor position			SetCursorPos(screenWidth / 2, screenHeight / 2);	// reset to some default position							return 0;		}					case WM_LBUTTONUP: 		{			if ( mDown )			{				mDown = false;							SetCursorPos(cPos.x, cPos.y);			// set the cursor to its position				ShowCursor(true);				// show it				ReleaseCapture();				// release the capture														}			 return 0;		}case WM_MOUSEMOVE:		{			if( mDown )			{				GetCursorPos(&currentPos); // screen coords				disp.x = currentPos.x -  screenWidth / 2;				disp.y = currentPos.y -  screenHeight / 2;				/*	Update the Camera 	*/				m_GFX->mainCam->UpdateFromMouse( screenWidth, screenHeight, disp.x, disp.y );				SetCursorPos(screenWidth / 2, screenHeight / 2);				return 0;			}		}
void UpdateFromMouse( int w, int h, int mousex, int mousey )		{				/*				Handle the mouse input			*/			_mx = mousex;		_my = mousey;			m_horizontalAngle += m_mouseSpeed * m_frameTime * float( w / 2 - _mx );			m_verticalAngle   += m_mouseSpeed * m_frameTime * float( h / 2 - _my );			m_direction = glm::vec3			(				cos( m_verticalAngle ) * sin( m_horizontalAngle ),				sin( m_verticalAngle ),				cos( m_verticalAngle ) * cos( m_horizontalAngle )			);			m_right = glm::vec3			(				sin( m_horizontalAngle - 3.14f / 2.0f ),				0,				cos( m_horizontalAngle - 3.14f / 2.0f )			);			m_up = glm::cross( m_right, m_direction );			/*				Update the view matrix			*/			m_viewMatrix = glm::lookAt( position, position + m_direction, m_up );		}

#2mynameisnafe

Posted 03 February 2013 - 08:48 AM

Okay, it's broken. Theres a lot of code here! Please help

It's basically the one from opengl-tutorial.com. Using glm but not glfw. The camera kind of works but doesn't.. it's jerky and when I go left with the mouse it goes and looks up etc.. when I go up it goes down.. all sorts of crazy

If we can fix this maybe we can fix the keyboard input :/

case WM_LBUTTONDOWN: 		{			mDown = true;			ShowCursor(false);			SetCapture(hWnd);					// capture the mouse.  				GetCursorPos(&cPos);					// store cursor position			SetCursorPos(screenWidth / 2, screenHeight / 2);	// reset to some default position							return 0;		}					case WM_LBUTTONUP: 		{			if ( mDown )			{				mDown = false;							SetCursorPos(cPos.x, cPos.y);			// set the cursor to its position				ShowCursor(true);				// show it				ReleaseCapture();				// release the capture														}			 return 0;		}case WM_MOUSEMOVE:		{			if( mDown )			{				GetCursorPos(&currentPos); // screen coords				disp.x = currentPos.x -  screenWidth / 2;				disp.y = currentPos.y -  screenHeight / 2;				/*	Update the Camera 	*/				m_GFX->mainCam->UpdateFromMouse( screenWidth, screenHeight, disp.x, disp.y );				SetCursorPos(screenWidth / 2, screenHeight / 2);				return 0;			}		}
void UpdateFromMouse( int w, int h, int mousex, int mousey )		{				/*				Handle the mouse input			*/			_mx = mousex;		_my = mousey;			m_horizontalAngle += m_mouseSpeed * m_frameTime * float( w / 2 - _mx );			m_verticalAngle   += m_mouseSpeed * m_frameTime * float( h / 2 - _my );			m_direction = glm::vec3			(				cos( m_verticalAngle ) * sin( m_horizontalAngle ),				sin( m_verticalAngle ),				cos( m_verticalAngle ) * cos( m_horizontalAngle )			);			m_right = glm::vec3			(				sin( m_horizontalAngle - 3.14f / 2.0f ),				0,				cos( m_horizontalAngle - 3.14f / 2.0f )			);			m_up = glm::cross( m_right, m_direction );			/*				Update the view matrix			*/			m_viewMatrix = glm::lookAt( position, position + m_direction, m_up );		}

#1mynameisnafe

Posted 03 February 2013 - 08:46 AM

Okay, it's broken. Theres a lot of code here! Please help

 

It's basically the one from opengl-tutorial.com. Using glm but not glfw. The camera kind of works but doesn't.. it's jerky and when I go left with the mouse it goes and looks up etc.. when I go up it goes down.. all sorts of crazy

 

If we can fix this maybe we can fix the keyboard input :/

 

 

case WM_LBUTTONDOWN: 
		{
			mDown = true;
			ShowCursor(false);

			SetCapture(hWnd);					// capture the mouse.  	
			GetCursorPos(&cPos);					// store cursor position
			SetCursorPos(screenWidth / 2, screenHeight / 2);	// reset to some default position
				
			return 0;
		}
			
		case WM_LBUTTONUP: 
		{
			if ( mDown )
			{
				mDown = false;	
		
				SetCursorPos(cPos.x, cPos.y);			// set the cursor to its position
				ShowCursor(true);				// show it
				ReleaseCapture();				// release the capture
											
			}
			 return 0;
		}

case WM_MOUSEMOVE:
		{
			if( mDown )
			{
				GetCursorPos(&currentPos); // screen coords

				disp.x = currentPos.x -  screenWidth / 2;
				disp.y = currentPos.y -  screenHeight / 2;

				/*	Update the Camera 	*/
				m_GFX->mainCam->UpdateFromMouse( screenWidth, screenHeight, disp.x, disp.y );

				SetCursorPos(screenWidth / 2, screenHeight / 2);
				return 0;
			}
		}

 

void UpdateFromMouse( int w, int h, int mousex, int mousey )
		{	
			/*
				Handle the mouse input
			*/
			_mx = mousex;		_my = mousey;

			m_horizontalAngle += m_mouseSpeed * m_frameTime * float( w / 2 - _mx );
			m_verticalAngle   += m_mouseSpeed * m_frameTime * float( h / 2 - _my );

			m_direction = glm::vec3
			(
				cos( m_verticalAngle ) * sin( m_horizontalAngle ),
				tan( m_verticalAngle ),
				cos( m_verticalAngle ) * cos( m_horizontalAngle )
			);

			m_right = glm::vec3
			(
				sin( m_horizontalAngle - 3.14f / 2.0f ),
				0,
				cos( m_horizontalAngle - 3.14f / 2.0f )
			);

			m_up = glm::cross( m_right, m_direction );

			/*
				Update the view matrix
			*/
			m_viewMatrix = glm::lookAt( position, position + m_direction, m_up );
		}

 


PARTNERS