Jump to content
  • Advertisement
Sign in to follow this  

OpenGL mouse

This topic is 2928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I tried to drew a square in the mouse position.
I got from the wndproc the position of the mouse.
the problam that my room's size is (640,480)
and the ogl room is (13.0f, 13.0f).

so when I got from the windows the position of the mouse I can't use it in the OpenGl room...

to fix the problem I tried this code:
xPos = xPos/(640.0f/13.0f)-6.5f;
yPos = -yPos/(480.0f/13.0f) +6.5f;

Now it works, the square is in the position mouse...
but it has a litlle [font="Arial,"]deviation.[/font][font="Arial,"]..[/font]
[font="Arial,"] [/font]
[font="Arial,"]as the mouse closer to the edge of the window, the deviation became bigger...[/font]
[font="Arial,"]In the middle of the window, it doesn't have deviation...[/font]
[font="Arial,"] [/font]
[font="Arial,"]someone know what's wrong with my code?[/font]
[font="Arial,"]know other way to do it?[/font]
[font="Arial,"] [/font]
[font="Arial,"]thanks a lot[/font]

Share this post

Link to post
Share on other sites
Whats the "room"? is it the window size? I think the titlebar sometimes gets included in the height. Does this deviation occur on both axis(up/down, left/right) or only up/down. If its just up/down then it might be the titlebars height. You could then account for that (subtracting it from your height (480).

You could also change the projection to be more appropriate - instead of being 13/13 it could be 640/480.

Share this post

Link to post
Share on other sites
room, I mean the rendering size I don't know what it's name...

glTranslatef(0.0f, 0.0f, -13.0f);
glBegin(GL_POLYGON); //create polygon
glVertex3f( xPos-0.6, yPos-0.5, 0.0f); //down left
glVertex3f( xPos-0.6, yPos+1.5, 0.0f); //up left
glVertex3f( xPos+0.6, yPos+1.5, 0.0f); //up right
glVertex3f( xPos+0.6, yPos-0.5, 0.0f); //down right

because the gltransltef,
when I write the -13.0f
it maked the room 13.0f*13.0f
that what I mean is room size...

[color="#1C2837"]I don't understand how to use this function...
[color="#1C2837"]can you give an exmpale?
[color="#1c2837"]and it's happand in all the 4 sizes

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!