Page 42 OpenGL Super Bible! Clean Code Many

Page 42 OpenGL Super Bible! Clean Code Many C/C++ compilers for Windows assume that any floating-point literal value is of type double unless explicitly told otherwise via the suffix mechanism. When using literals for floating point arguments, if you don t specify that these arguments are of type float instead of double, the compiler will issue a warning while compiling because it detects that you are passing a double to a function defined to accept only floats, resulting in a possible loss of precision. As our OpenGL programs grow, these warnings will quickly number in the hundreds and will make it difficult to find any real syntax errors. You can turn these warnings off using the appropriate compiler options but we advise against this. It s better to write clean, portable code the first time. So clean up those warning messages by cleaning up the code (in this case, by explicitly using the float type) not by disabling potentially useful warnings. Additionally, you may be tempted to use the functions that accept double- precision floating point arguments, rather than go to all the bother of specifying your literals as floats. However, OpenGL uses floats internally, and using anything other than the single-precision floating point functions will add a performance bottleneck, as the values are converted to floats anyway before being processed by OpenGL. The AUX Library For the remainder of this chapter, you will learn to use the Auxiliary (AUX) library as a way to learn OpenGL. The AUX library was created to facilitate the learning and writing of OpenGL programs without being distracted by the minutiae of your particular environment, be it UNIX, Windows, or whatever. You don t write final code when using AUX; it is more of a preliminary staging ground for testing your ideas. A lack of basic GUI features limits the library s use for building useful applications. A set of core AUX functions is available on nearly every implementation of OpenGL. These functions handle window creation and manipulation, as well as user input. Other functions draw some complete 3D figures as wireframe or solid objects. By using the AUX library to create and manage the window and user interaction, and OpenGL to do the drawing, it is possible to write programs that create fairly complex renderings. You can move these programs to different environments with a recompile. In addition to the core functions, each environment that implements an AUX library also implements some other helper functions to enable system-specific operations such as buffer swapping and image loading. The more your code relies on these additional AUX library functions, the less portable your code will be. On the other hand, by making full use of these functions you can create fantastic scenes that will amaze your friends and even the family dog without having to learn all the gritty details of Windows programming.
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