[HOpenGL] get Scale of the window in HOpenGL?

Sven Panne Sven.Panne at aedion.de
Mon Jun 1 12:34:36 EDT 2009


Am Samstag, 30. Mai 2009 22:49:20 schrieb yu yang:
> I want to move one object to the border of window, then go back to the
> start point. Does anyone one have an idea to implement it ? Thank you!

Let your viewport fill the whole window, tracking changes in the window size 
via GLUT's reshape callback:

   reshape :: ReshapeCallback
   reshape size@(Size w h) = do
      viewport $= (Position 0 0, size)
      <setup your projection matrix using w and h>

 Then you can use

   ...
   (position, size) <- get viewport
   ...

in your rendering code to get the available window area. Then you'll have to 
apply the inverses of your projection matrix and your modelview matrix to this 
area to get the object coordinates you want.

Depending on what you exactly want to achieve, it might be possible to setup 
your modelview matrix and your projection matrix in such a way that you get a 
1:1 mapping between object coordinates and window coordinates, so you don't 
have to apply the inverses.

Cheers,
   S.



More information about the HOpenGL mailing list