| 271 | } |
| 272 | |
| 273 | void reshape(int x, int y) |
| 274 | { |
| 275 | float xScale; |
| 276 | float yScale; |
| 277 | |
| 278 | g_lastShapeX = x; |
| 279 | g_lastShapeY = y; |
| 280 | |
| 281 | // Check if shape is visible |
| 282 | if (x == 0 || y == 0) { |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | // Set a new projection matrix |
| 287 | glMatrixMode(GL_PROJECTION); |
| 288 | glLoadIdentity(); |
| 289 | |
| 290 | // Adjust fit |
| 291 | if (y > x) { |
| 292 | xScale = 1.0f; |
| 293 | yScale = (float)y / x; |
| 294 | } |
| 295 | else { |
| 296 | xScale = (float)x / y; |
| 297 | yScale = 1.0f; |
| 298 | } |
| 299 | |
| 300 | // Angle of view:40 degrees |
| 301 | // Near clipping plane distance: 10.0 (default) |
| 302 | // Far clipping plane distance: 10.0 (default) |
| 303 | if (g_bTenXZoom) { |
| 304 | glOrtho(-.15f * xScale, .15f * xScale, -.15f * yScale, .15f * yScale, -5.0f, 5.0f); |
| 305 | } |
| 306 | else { |
| 307 | glOrtho(-1.5f * xScale, 1.5f * xScale, -1.5f * yScale, 1.5f * yScale, -10.0f, 10.0f); |
| 308 | } |
| 309 | |
| 310 | // Use the whole window for rendering |
| 311 | glViewport(0, 0, x, y); |
| 312 | glMatrixMode(GL_MODELVIEW); |
| 313 | } |
| 314 | |
| 315 | void display(void) |
| 316 | { |