Business web hosting - OpenGL Super Bible! Page 53 The Rendering Function
OpenGL Super Bible! Page 53 The Rendering Function Next, you ll see we have created the function RenderScene(). // Called by AUX library to draw scene void CALLBACK RenderScene(void) { …} This is where we have moved all code that does the actual drawing in the window. The process of drawing with OpenGL is often referred to as rendering, so we used that descriptive name. In later examples we ll be putting most of our drawing code in this function. Make note of the CALLBACK statement in the function declaration. This is required because we re going to tell the AUX library to call this function whenever the window needs updating. Callback functions are simply functions that you write, which the AUX library will be calling in your behalf. You ll see how this works later. Drawing a Rectangle Previously, all our program did was clear the screen. We ve added the following two lines of drawing code: // Set current drawing color to red // R G B glColor3f(1.0f, 0.0f, 0.0f); // Draw a filled rectangle with current color glRectf(100.0f, 150.0f, 150.0f, 100.0f); These lines set the color used for future drawing operations (lines and filling) with the call to glColor3f(). Then glRectf() draws a filled rectangle. The glColor3f() function selects a color in the same manner as glClearColor(), but no alpha translucency component needs to be specified: void glColor3f(GLfloat red, GLfloat green, GLfloat blue); The glRectf () function takes floating point arguments, as denoted by the trailing f. The number of arguments is not used in the function name because all glRect variations take four arguments. The four arguments of glRectf(), void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp web hosting services