zu früh gefreut
jetzt hab ich die wahl:
entwede lösch ich ''glMatrixMode(GL_PROJECTION);'' und der erste klick
behauptet objekt 1 gefunden (egal wo ich hinklicke) zu haben und danach findet er niemehr was
oder ich lösch die zeile nich und es wird nie was gefunden
hier is mein quelltext:
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| procedure TForm1.DrawScene; begin glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); glLoadIdentity;
glinitnames; glpushname(0);
glRotate(-135,1,0,0); glRotate(-45,0,1,0); glTranslate(15,15,15); glloadname(1);
//objekt malen
SwapBuffers(h_DC); FPSTimer.Tag:= FPSTimer.Tag + 1; end; |
und
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34:
| function TForm1.GetSelectBufferHit : Integer; var SelectBuffer : array[0..512] of TGLUInt; Viewport : TVector4i; Hits,i : Integer; HitZValue : TGLUInt; Hit : TGLUInt; begin ActivateRenderingContext(h_DC, hRC); glGetIntegerv(GL_VIEWPORT, @viewport); glSelectBuffer(512, @SelectBuffer); glRenderMode(GL_SELECT); glInitNames; glPushName(0); glMatrixMode(GL_PROJECTION); <- besagte zeile glPushMatrix; glLoadIdentity; gluPickMatrix(mouse.CursorPos.x, screen.Height-mouse.CursorPos.y, 1.0, 1.0, viewport); gluPerspective(45.0, ClientWidth/ClientHeight, 0.1, 1000); DrawScene; 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; end; |
P.S. die form is full-screen