Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


mouse in OpenGL

This topic is 5827 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''m new in OpenGl and now i''m trying to do a bezier patch modeler. i want to move the control points with mouse. there are some control points, control polygon.. i want to click on control point and move it with mouse.. how to do such think? any hint? link? demo? tutorial? anythink... r.

Share this post

Link to post
Share on other sites
Don''t know of a tutorial, but here''s a hint.

It''s a 3D editor, right? Problem is, the mouse position doesn''t correspond to a single point in 3D. It corresponds to a line. To find the equation of this line, you can call gluUnProject() twice, with two different values of winz. Pass the mouse position as winx and winy. That will give you two 3D points that the picking line passes through. Now, a simple (but somewhat inefficient) way would be to loop through all control points and calculate the distance to the line for each one of them. Then use the closest control point.

Another approach would be to use selection buffers. Check out glSelectBuffer() and glRenderMode().

"Oh no, not again" - Agrajag

Share this post

Link to post
Share on other sites
I''m not sure exactly how new you are, but here''s some extra info incase you were also reffering to this:

To get the mouse coords in your win32 application create two integer variables:

int mousePosX;
int mousePosY;

Then, in your WndProc, handle the WM_MOUSEMOVE message like so:


// The coords are stored in the hi and low order lParam

mousePosX = LOWORD(lParam);
mousePosY = HIWORD(lParam);



As for the rest of the information you were seeking, I think LNK2001 did a good job of explaining it. As he said, the functions you will want to research are:


The "official" way of doing picking in OpenGL is to use the following set of functions


"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I''m reaching up and reaching out. I''m reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one''s been. We''ll ride the spiral to the end and may just go where no one''s been." - Maynard James Keenan
Name: TheBlackJester
Team: Wildfire Studios

O A.D.
The Last Alliance

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!