1. Drawing with OpenGL

Kool! Thanks! I can't try it out now, but I sure will soon!

Btw, that thing with the GL and GLU units in FPC is quite interesting! Now I'm warned! lol

I hadn't even asked cos I thought it was not possible to do that, since a point in the screen is an infinite line in a 3D matrix...

But obviously (and fortunately!) ppl are a lot smarter, and they found a way! I saw it requires to input the window coordinates plus a Z coordinate.
So that Z coordinate, is it the depth out of the screen (so negative for into the screen) regardless of the transformations you have made to your matrix; is it like the depth buffer you talked about, in which case I guess it would be positive into the screen, right?; or is it the z coordinate of your matrix?
If it's the latter, then what if you rotate the matrix so that the z axis is 'parallel' to the screen, wouldn't that make it undefined?

thanks for this extended help! :wink:

2. Drawing with OpenGL

The winZ coordinate that must be passed to gluUnProject is a depth buffer value. You can get it by using glRedPixels with GL_DEPTH_COMPONENT parameter:
Code:
`glReadPixels&#40;screenX,screenY,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,@wz&#41;;`
Another possibility that can be used for picking objects, is to call gluUnproject with minimal and maximal values of depth buffer which are zero and one. As a result you get two points from which you construct a ray and see if it intersects any objects.

3. The right one is this dear
Procedure Matrix_to_Win; var model, proj, Winx,Winy,Winz &#58; PGLdouble; Matrixx,Matrixy,Matrixz &#58; real; view &#58; PGLint; begin &#123;view &#58;= 0; model &#58;= GL_MODELVIEW; proj &#58;= GL_PROJECTION;&#125; Winx &#58;= 0; Winy &#58;= 0; Winz &#58;= 0; Matrixx &#58;= 0; Matrixy &#58;= 0; Matrixz &#58;= 0; glGetDoublev&#40;GL_MODELVIEW_MATRIX, model&#41;; glGetDoublev&#40;GL_PROJECTION_MATRIX, proj&#41;; glGetIntegerv&#40;GL_VIEWPORT, view&#41;; gluProject&#40;Matrixx, Matrixy, Matrixz, model, proj, view, Winx, Winy, Winz&#41;; end;

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•