- function TfrmDraw.GetSelectBufferHit: Integer;
 - var
 - SelectBuffer : array[0..512] of TGLUInt;
 - Viewport : opengl12.TVector4i;
 - Hits,i : Integer;
 - HitZValue : TGLUInt;
 - Hit : TGLUInt;
 - begin
 - glGetIntegerv(GL_VIEWPORT, @viewport);
 - glSelectBuffer(512, @SelectBuffer);
 - glRenderMode(GL_SELECT);
 - glInitNames;
 - glPushName(0);
 - glMatrixMode(GL_PROJECTION);
 - glPushMatrix;
 - glLoadIdentity;
 - gluPickMatrix(mx, viewport[3]-my, 2.0, 2.0, viewport);
 - gluPerspective(45.0, ClientWidth/ClientHeight, 0.1, 100);
 - DrawRoom;
 - glMatrixMode(GL_PROJECTION);
 - glPopMatrix;
 - Hits := glRenderMode(GL_RENDER);
 - DeactivateRenderingContext;
 - Hit := High(TGLUInt);
 - HitZValue := High(TGLUInt);
 - for i := 0 to Hits-1 do
 - if SelectBuffer[(i*4)+1] < HitZValue then begin
 - Hit := SelectBuffer[(i*4)+3];
 - HitZValue := SelectBuffer[(i*4)+1];
 - end;
 - Result := Hit;
 - glMatrixMode(GL_MODELVIEW);
 - end;
 

