Chciałem edytować pierwszy wpis ale się nie dało, jeśli mogę prosić admina o przyklejenie tekstu.
type
TGLPoint3D = array [1..3] of Double;
function GetOGLPos(const cX, cY: Integer): TGLPoint3D;
var
viewport: array [1..4] of Integer;
modelview: array [1..16] of Double;
projection: array [1..16] of Double;
winZ: Single;
X, Y: Integer;
begin
X:= cX;
Y:= cY;
glGetDoublev( GL_MODELVIEW_MATRIX, @modelview );
glGetDoublev( GL_PROJECTION_MATRIX, @projection );
glGetIntegerv( GL_VIEWPORT, @viewport );
// In Delphi A Y Value Of 0 Returns An Unknown Value
// I Discovered This While I Was Testing A Crosshair
if( Y = 0 )then Y := 1;
// glReadPixels( X, -Y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, @winZ );
glReadPixels( X, -Y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, @winZ );
gluUnProject( X, viewport[4]-Y, winZ,
@modelview, @projection, @viewport,
Result[1], Result[2], Result[3]);
end;
Następnie jest wywołanie GLPoint3D:= GetOGLPos(apnM.x,apnM.y);
// współrzędne myszy z TPanel na wejsciu
procedure TkSia.Draw_Matma(const apnM: TpnM);
var
GLPoint3D: TGLPoint3D;
x,y,z: Double;
begin //
// kolor tła ColorPicking - zawartość bufora koloru
glClearColor( 0.0, 0.0, 0.0, 0.0 );
// glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT); // czyszczenie buforów
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); // czyszczenie buforów
Draw_svMainQuads(); // od 0,0,0 do 100,100,0 wyświetlane są
GLPoint3D:= GetOGLPos(apnM.x,apnM.y);
x:= GLPoint3D[1];
y:= GLPoint3D[2];
z:= GLPoint3D[3];
Gfrm.StBar.Panels[3].Text:=
' '+FloatToStr(X)+' '+FloatToStr(Y)+' '+FloatToStr(Z);
// glColor3f(R/255,G/255,B/255);
glColor3f(128*cColFF,192*cColFF,255*cColFF);
glBegin(GL_QUADS);
glVertex3f( x , y, 0.4);
glVertex3f( x+1 , y, 0.4);
glVertex3f( x+1 , y+1 , 0.4);
glVertex3f( x , y+1 , 0.4);
glEnd();
end;