[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] converting "object position" to "view position" in (py)opengl



The z doesn't matter, but the x and y are pixel coordinates like
pygame.mouse.get_pos().

Also, gluProject has defaults for the last 3 params, so they aren't needed.

On Wed, Jul 1, 2009 at 3:10 AM, Astan Chee<astan.chee@xxxxxxxxx> wrote:
> Thanks for that. How do I convert x,y,z to the x,y coordinates of a pygame
> surface window? Kinda like the coordinates that pygame.mouse.get_pos()
> returns?
> Thanks again
>
> Ian Mallett wrote:
>
> You'll definitely want to use glu somewhere.  gluLookAt(...) comes to
> mind...
>
> Anyway, for gluProject, try this (not tested, but should work)
>
> x,y,z = gluProject(object.x,object.y,object.z,\
> glGetDoublev(GL_MODELVIEW_MATRIX),glGetDoublev(GL_PROJECTION_MATRIX),\
> glGetIntegerv(GL_VIEWPORT))
>
> HTH,
> Ian
>