Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 343 Vote(s) - 3.36 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Algorithm to zoom into mouse(OpenGL)

#1
I have an OpenGL scene with a top left coordinate system. When I glScale it zooms in from (0,0) the top left. I want it to zoom in from the mouse's coordinate (relative to the OGL frame). How is this done?
Thanks
Reply

#2
I believe this can be done in four steps:

1. Find the mouse's x and y coordinates using whatever function your windowing system (i.e. GLUT or SDL) has for that, and use gluUnProject to get the object coordinates that correspond to those window coordinates
2. Translate by (x,y,0) to put the origin at those coordinates
3. Scale by your desired vector (i,j,k)
4. Translate by (-x,-y,0) to put the origin back at the top left

Reply

#3
I did a smooth zoom in using glortho . The skeleton of my solution is

glortho(initial viewport x,y & size)<br/>
glcalllist(my display list)<br/>
render<br/>
.<br/>
.<br/>
loop to gradually go to final viewrport coordinates/size . Implement your timing and FPS requirements<br/>
.<br/>
.<br/>
glortho(final viewport x,y & size)<br/>
glcalllist(my display list)<br/>
render<br/>

I hope you get the general idea. There are few other methods to acheive this, but I find glortho the method the easiest to comprehend.



Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through