/* In the following code we are going to begin our study of the graphics pipeline by creating and rendering a bitmap. 1. Set up the wb array with 2 entries as shown in class, 1 black and 1 white. 2. Fill the check array, it will be a 64 bit by 64 bit bitmap. Note that the bytes are 8 bits in the horizontal direction, so you have to specify 8 positions horizontally and 64 vertically. You'll end up with something which looks like an 8x8 black and white checkerboard, where the squares would be 1 byte (8 bit) white or black squares. 3. Don't change the loops, but modify the glRasterPos2i and glBitmap calls so it renders one checkerboard in the bottom left of the window. 4. Modify the loops so that it completely fills in the window with a checkerboard. */ #include #include using namespace std; void myInit( void ) { // attributes glClearColor(0, 0, 0, 0); glColor3f(1, 1, 1); // viewing glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, 256, 0.0, 256); glMatrixMode(GL_MODELVIEW); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); GLubyte wb[2]={0x00,0xff}; GLubyte check[512]; int i,j; for (i=0; i<64; i++) for (j=0; j<8; j++) check[i*8+j] = wb[(i/8+j)%2]; for (j=0; j<4; j++) { for (i=0; i<4; i++) { glRasterPos2i(64*i,64*j); glBitmap(64,64,0,0,0,0, check); } } glFlush(); } void main(int argc , char ** argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(256,256); glutInitWindowPosition(90,90); glutCreateWindow("Bitmap"); glutDisplayFunc(display); myInit(); glutMainLoop(); }