Page 378 OpenGL Super Bible! A Makeshift Benchmark (Simple web server)
Page 378 OpenGL Super Bible! A Makeshift Benchmark Our final program produces a fairly good representation of the metal bolt we set out to model. Consisting of over 1,700 triangles, this is the most complex example in this book so far. Comparatively speaking, however, this number of triangles isn t anywhere close to the largest number of polygons you ll encounter when composing larger scenes and more complex objects. In fact, the latest 3D accelerated graphics cards are rated at hundreds of thousands of triangles per second, and that s for the cheap ones! One of the goals of this chapter is to introduce you to using display lists to optimize rendering speed. Before we can get into a comparison of rendering speeds, however, we will need a way to measure this a benchmark. When we get into the subject of display lists, we want you to be able to see that there is a performance difference rather than just take our word for it. So let s modify our BOLT program slightly. Rather than spinning the object about its axes when arrow keys are pressed, we ll have it spin repeatedly around just the y-axis in particular. As you might imagine, this turns the program into a continual triangle-generator that we can use to more easily see differences in performance. Listing 10-8 is the changed RenderScene() function used for SPINBOLT. Listing 10-8 New RenderScene() function to spin bolt around the y-axis // Called to draw the entire bolt void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Make sure we have the correct matrix mode glMatrixMode(GL_MODELVIEW); // Rotate and translate the coordinate system glRotatef(5.0f, 0.0f, 1.0f, 0.0f); // Translate and render the head glTranslatef(0.0f, 0.0f, 55.0f); RenderHead(); // Translate back some and render the shaft and thread glTranslatef(0.0f, 0.0f, -15.0f); RenderShaft(); RenderThread(); // Translate back some again for next pass glTranslatef(0.0f, 0.0f, -40.0f); // Flush drawing commands gl Flush(); }
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.