/* NOTE: 1. This program is to create a window and... 2. Clear the area of that window with some color */ # include void ClearWindow(void) { // What ever color we see, it is a combination of red, green and blue // for black ==> red = green = blue = 0.0 // for white ==> red = green = blue = 1.0 // for yellow ==> red = green = 1.0, blue = 0.0 // play with these values and see how the output changes // min value = 0.0 & max value is 1.0 float red = 1.0; float green = 1.0; float blue = 0.0; float opacity = 1.0; // No.. it is not the opacity of the window // opacity is also called as alpha. // If you know alpha but not opacity of a window - I'm sorry for the extra confusion // If you know none - Don't worry; just ignore them // If you know both - why the hell are you reading this? read GPU GEMS instead // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // OK : Let's call some functions - enough with these variables // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // tell to opengl that we want this color combination // to be stored as the clear color glClearColor(red, green, blue, opacity); // since opengl knows what is the color to be used to clear the window, // we can tell opengl to clear the color buffer "NOW" glClear(GL_COLOR_BUFFER_BIT); // YES.. there are other buffers as well. // and buffer is a memory block where data is stored. // For more information on buffers, // make sure that you read my "Introduction to Computer Graphics" // which is in my "To do list" as on... 24th Sep 2010 (the day when I wrote this) // I'm not sure when/if it will be completed // or if it is already comleted by the time you read this // Will clean up the comments as well once I'm done with all the tutorials // As of now, I'm yet to start that tutorial. // So... don't ask me what a color buffer is } int main(int argc, char** argv) { const int left = 100; const int top = 100; const int width = 256; const int height = 256; const char* windowTitle = "I'm back"; glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(width, height); glutInitWindowPosition(left, top); glutCreateWindow(windowTitle); //NEW FUNCTION in this tutorial's main function glutDisplayFunc(ClearWindow); glutMainLoop(); return 0; } /* Exercise: Accept command line option to select the clear color. eg: ./a.out yellow should change the clear color to yellow */ // // MORAL of this tutorial: // ~~~~~~~~~~~~~~~~~~~~~~~~ // The best way to lead a happy life is to ignore as much as you can //