Sign in to follow this  
assainator

sfml mouse coordinate problem

Recommended Posts

heey all, lately i was trying to use the mouse more in my app. I use sfml to handle input, graphics and display. i'm using the following code, the X code display's properly, tough the Y code stays at 512. even stranger is that the windows is only 500 pixels high.....
int main()
{

	//create a SFML window
	sf::Window App(sf::VideoMode(500, 500, 32), "gameUI test");

	//set opengl coordsystem
	glOrtho(-250.0f, 250.0f, -250.0f, 250.0f, 2.0f, -2.0f);

	//prepare openGL depth
	glClearDepth(1.f);
	glClearColor(0.f, 0.f, 0.f, 0.f);

	//enable depthbuffer use (wich we don't use)
	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);

	//prepare for 3d usage(but we only use 2d)
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(90.f, 1.f, 1.f, 500.f);

	//while the app is running
	while(App.IsOpened())
	{
		//get events
		sf::Event Event;
		while(App.GetEvent(Event))
		{

			//if escape is pressed, exit
			if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape)
			{
				App.Close();
			}
			else if(Event.Type == sf::Event::Closed)
			{
				App.Close();
			}
                         //if the mouse moves, output coords
			else if(Event.Type == sf::Event::MouseMoved)
			{


						printf("X: %i,              Y: %i\n", Event.MouseButton.X, Event.MouseButton.Y);

			}


		}
		//make the window the current render window (for use in multiple windows (wich we don't use))
		App.SetActive();

		//clear buffers
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glLoadIdentity();


		//display all changes
		App.Display();
	}

	return 1;
}

does anyone know what i'm doing wrong? thanks in advance, assainator

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