OpenGL Super Bible! Page 57 We have chosen (Cpanel web hosting)

OpenGL Super Bible! Page 57 We have chosen ChangeSize as a descriptive name for this function and will use that name for our future examples. The ChangeSize() function will receive the new width and height whenever the window size changes. We can use this information to modify the mapping of our desired coordinate system to real screen coordinates, with the help of two OpenGL functions: glViewport() and glOrtho(). Listing 3-3 shows our previous example modified to account for various window sizes and dimensions. Only the changed main() function and our new ChangeSize() function are shown. Listing 3-3 Scaling in OpenGL // Scale.c // Scaling an OpenGL Window. // Called by AUX Library when the window has changed size void CALLBACK ChangeSize(GLsizei w, GLsizei h) { // Prevent a divide by zero if(h == 0) h = 1; // Set Viewport to window dimensions glViewport(0, 0, w, h); // Reset coordinate system glLoadIdentity(); // Establish clipping volume (left, right, bottom, top, near, far) if (w <= h) glOrtho (0.0f, 250.0f, 0.0f, 250.0f*h/w, 1.0, -1.0); else glOrtho (0.0f, 250.0f*w/h, 0.0f, 250.0f, 1.0, -1.0); } void main(void) { // Set up and initialize AUX window auxInitDisplayMode(AUX_SINGLE | AUX_RGBA); auxInitPosition(100,100,250,250); auxInitWindow("Scaling Window"); // Set function to call when window changes size auxReshapeFunc(ChangeSize); // Set function to call when window needs updating auxMainLoop(RenderScene); } Now, when you change the size or dimensions of the window, the square will change size as well. A much larger window will have a much larger square and a much smaller window will have a much smaller square. If you make the window long horizontally, the square will
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

Leave a Reply