Page 332 OpenGL Super (Web design portfolio) Bible! Listing 9-7 The
Page 332 OpenGL Super Bible! Listing 9-7 The rendering function from the WAVEY example program // Called to draw scene void RenderScene(void) { float normal[3]; // Storage for calculate normal float v[4][3]; // Storage for rectangle coordinates float lastY; // Left-hand side of rectangle float nextY; // Right-hand side of rectangle float temp; // Temporary storage for swapping float x; // X coordinate storage // Menu state specifies if wireframe or not if(iState == WIRE) glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); // Menu state specifies if smooth or flat shading if(iState == SMOOTH || iState == AVERAGE) glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Reset viewing volume and viewport ChangeSize(lastWidth,lastHeight); // Rotate the image according to accumulated angle set // by the arrow key handlers glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); // Set surface color to blue glRGB(0,0,255); // Initialize the y steppings lastY = 0.0f; nextY = 10.0f; // Loop through x coordinate from left to right, build // a rectangle with alternating slopes upward and downward for(x = -60.0f; x < 60.0f; x+= 20.0f) { // 1st Vertices v[0][0] = x; // X coord for left v[0][1] = lastY; v[0][2] = 50.0f; // Z coord for back // 2nd vertices v[1][0] = x; // X coord for left v[1][1] = lastY; v[1][2] = - 50.0f; // Z coord for front
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.