OpenGL Super Bible! Page 51 Actually Clear Now

OpenGL Super Bible! Page 51 Actually Clear Now that we have told OpenGL what color to use for clearing, we need an instruction to do the actual clearing. This accomplished by the line glClear(GL_COLOR_BUFFER_BIT); The glClear() function clears a particular buffer or combination of buffers. A buffer is a storage area for image information. The red, green, and blue components of a drawing actually have separate buffers, but they are usually collectively referred to as the color buffer. Buffers are a powerful feature of OpenGL and will be covered in detail in Chapter 15. For the next several chapters, all you really need to understand is that the color buffer is where the displayed image is stored internally, and that clearing the buffer with glClear removes the drawing from the window. Flush That Queue Our final OpenGL function call comes next: glFlush(); This line causes any unexecuted OpenGL commands to be executed we have two at this point: glClearColor() and glClear(). Internally, OpenGL uses a rendering pipeline that processes commands sequentially. OpenGL commands and statements often are queued up until the OpenGL server processes several requests at once. This improves performance, especially when constructing complex objects. Drawing is accelerated because the slower graphics hardware is accessed less often for a given set of drawing instructions. (When Win32 was first introduced, this same concept was added to the Windows GDI to improve graphics performance under Windows NT.) In our short program, the glFlush() function simply tells OpenGL that it should proceed with the drawing instructions supplied thus far before waiting for any more drawing commands. The last bit of code for this example // Stop and wait for a keypress cprintf(”Press any key to close the Windown”); getch(); } displays a message in the console window and stops the program until you press a key, at which point the program is terminated and the window is destroyed.
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services

Leave a Reply