- procedure TOGLWindow.ResizeWindow(Width, Height : Integer);
- begin
- if (Height = 0) then begin // prevent divide by zero exception
- Height := 1;
- end;
- fWidth := Width;
- fHeight := Height;
- glViewport(0, 0, Width, Height); // Set the viewport for the OpenGL window
- glMatrixMode(GL_PROJECTION); // Change Matrix Mode to Projection
- glLoadIdentity(); // Reset View
- // Do the perspective calculations. Last value = max clipping depth
- gluPerspective(fFovy, Width / Height, fZNear, fZFar);
- glMatrixMode(GL_MODELVIEW); // Return to the modelview matrix
- glLoadIdentity(); // Reset View
- end;