# OpenGL, where on screen will a point be?

Hi,

i’d like to calculate the Xs- and Ys-coordinates on the screen
where a point in 3D (x, y, z) will be drawn if i’d draw it with
certain camera settings.

So i’d like to calculate or find out some other way what OpenGL
does internally, the conversion from (x, y, z) to (Xs, Ys).

Best regards,
Torsten.

Torsten Mohr wrote:

Hi,

i’d like to calculate the Xs- and Ys-coordinates on the screen
where a point in 3D (x, y, z) will be drawn if i’d draw it with
certain camera settings.

So i’d like to calculate or find out some other way what OpenGL
does internally, the conversion from (x, y, z) to (Xs, Ys).

You can use gluProject().

Stephane

Take a look at the gluProject function.On Sat, Oct 08, 2005 at 05:04:25PM +0200, Torsten Mohr wrote:

Hi,

i’d like to calculate the Xs- and Ys-coordinates on the screen
where a point in 3D (x, y, z) will be drawn if i’d draw it with
certain camera settings.

So i’d like to calculate or find out some other way what OpenGL
does internally, the conversion from (x, y, z) to (Xs, Ys).

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Torsten.

## this i think is not an SDL issue, but an OpenGL one. for me the following Code worked:-

GLdouble projMat[16], modMat[16], viewPort[4]

glGetDoublev(GL_PROJECTION_MATRIX, projMat);
glGetDoublev(GL_MODELVIEW_MATRIX, modMat);
glGetIntegerv(GL_VIEWPORT, viewPort);

``````  GLdouble projectPos[3];
gluProject(x,
y,
z,
modMat,
projMat,
viewPort,
projectPos,
projectPos+1,
projectPos+2);
``````

now in projectPos there is your X-value
in porjectPos+1 there is the Y value,
and in projectPos+2 there should be the distance to the screen,
althought this never really worked for me

i hope, this helps you

greetings
Benjamin

Torsten Mohr wrote:

Hi,

i’d like to calculate the Xs- and Ys-coordinates on the screen
where a point in 3D (x, y, z) will be drawn if i’d draw it with
certain camera settings.

So i’d like to calculate or find out some other way what OpenGL
does internally, the conversion from (x, y, z) to (Xs, Ys).

Best regards, Torsten.

_______________________________________________ SDL mailing list
SDL at libsdl.org http://www.libsdl.org/mailman/listinfo/sdl

visit the worlds most furious open-source 3D-action game
http://www.orxonox.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iQIVAwUBQ0fuZK3dUaw0Ln2OAQJ9Bw/7BWZRzxdb/+q53GUl9kdBUwgxji7TC0ga
E2lXtBtA0YSzecXHtLf17irE95tctojmhUknTiUsmbnpXavPtT8AJC9bbzs9z90j
iFoUaISH8BJpmfMb/hubbW6T5h5iMpGfObGaJnU5XrzApHN1f1Shb9DQyBYssiLf
5Ql6hD9OPl602VaZtJ5wGCJgUG4d/C7+Vu579kOb2sMr9TMVH1/yTSFv/VmGlElT
r044GmY+8dsuddeaF5iLll05F793b2stuwDAU2ZIS5lNpXDBikxDrrmVs0oJhQwz
qIr/hGtE8SwgCOPQkljQ9DujWu//FcHtB05VlDaYuh63FoGSXzX0CYLQtehKXmLS
GPnTcS17UrTloTkLXyHhdhWLa5J8AtE26gFQ55ZGuXm+9caTT3J+8S/RuhY/tgjd
rCbR7yTGsSBTTA+BclNXmV8RYdVlb9QuhS3ZycMp2dzC4ZaiY1OO/ttvgDnEwnRV
iikKnrMnjsQOJVrof1uaUbcfmb/v6DQuKYE0V++Vrmh0HWVGSNNUaiTsRVBcnlE4
Zy4PyypKKve3RGgFqWDp4rSZKsy+5zq3worntuCdo+6XDnzxFUsM0Rpkkpx0ueVL
djAMHYlLRP09fpf2u1icA+zZgJ+3LuAlFE5PUsnDUp7pevTSVE7pJ4P2/8Cjk+1z
9sHDpt9Y6dM=
=26hR
-----END PGP SIGNATURE-----