Page 60 OpenGL (Florida web design) Super Bible! Figure 3-9 Cartesian

Page 60 OpenGL Super Bible! Figure 3-9 Cartesian space Just before the code using glOrtho(), you ll notice a single call to glLoadIdentity(). This is needed because glOrtho() doesn t really establish the clipping volume, but rather modifies the existing clipping volume. It multiplies the matrix that describes the current clipping volume by the matrix that describes the clipping volume described in its arguments. The discussion of matrix manipulations and coordinate transformations is in Chapter 7. For now, you just need to know that glLoadIdentity() serves to reset the coordinate system to unity before any matrix manipulations are performed. Without this reset every time glOrtho() is called, each successive call to glOrtho() could result in a further corruption of our intended clipping volume, which may not even display our rectangle. Keeping a Square Square The following code does the actual work of keeping our square square. if (w <= h) glOrtho (0, 250, 0, 250*h/w, 1.0, -1.0); else glOrtho (0, 250*w/h, 0, 250, 1.0, -1.0); Our clipping volume (visible coordinate space) is modified so that the left-hand side is always at x = 0. The right-hand side extends to 250 unless the window is wider than it is tall. In that case, the right-hand side is extended by the aspect ratio of the window. The bottom is
Note: If you are looking for cheap webhost to host and run your apache application check Vision apache web hosting services

Leave a Reply