Jump to content
  • Advertisement
Sign in to follow this  
Shai

n00bish question regarding mouse cursor

This topic is 5152 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

Basically I just want a quad constantly following the cursor. Normally I'd just use gluUnproject to get the world coords and get it over with. However some parts of the screen are empty and some have stuff in them. Now when I use gluUnproject and move from a part with stuff in it to an empty part, I end up with world coords turning into screen coords - which is obviously a problem. The easy way out would be to just draw a huge quad *way* in the background, but I feel like that's cheating. anyone got any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
The problem is that in gluUnProject you must supply the (winx,winy,winz) coordinates, but the mouse only gives you (winx,winy),so you can't "cheat" here, you must find a way to supply a certain winz value.

How will you do that, it depends on what you want to do. You can either use a fixed z value between[0,1], so that the quad remains "locked" in a certain depth or draw a plane for instance in the screen and make the quad move along that plane. As I said, it all depends on how you want your program to do this thing, sit down, think about it, and implement it. One idea is to read the zbuffer as you do now, but every time save the zvalue to a variable.If there is "stuff" the screen(z<1) , use the value to gluUnproject, if the pixel is "invalid"(z=1), use the last valid z-value, until you hit a "valid" pixel again.

Share this post


Link to post
Share on other sites
perhaps use glOrtho(..) and draw the object like so, or use unproject prehaps use the near clip plane Zvalue (ie not the value u pass for gluPerspective(.,.,near,) for z

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!