//graphic experiment One. CPP: Defines the entry point for the console application. //#include"stdafx.h"#include"gl/glut.h"StaticGlsizei IMode =0;voidInitial (void) {Glclearcolor (1.0f,1.0f,1.0f,1.0f); Glmatrixmode (gl_projection); Gluortho2d (0.0,200.0,0.0,150.0);}voidDisplay (void) {glclear (gl_color_buffer_bit); glcolor3f (0.0f,0.0f,0.0f); if(IMode = =1) {GLRECTF (50.0f,100.0f,150.0f,50.0f); } Else if(imode==2) {Glubyte fly[]= { 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00, }; Glenable (gl_polygon_stipple); Glpolygonstipple (fly); GLRECTF (50.0f,100.0f,150.0f,50.0f); } glutswapbuffers ();//Swap command Buffers}voidProcessmenu (intvalue) {IMode=value; Glutpostredisplay ();}intMainintargcChar*argv[]) {Glutinit (&argc, argv); Glutinitdisplaymode (glut_double| GLUT_RGB);//using dual-cache and RGB modelsGlutinitwindowsize ( -, -);//Specify the size of the windowGlutinitwindowposition ( -, -);//specify the position of the window on the screenGlutcreatewindow ("fill a rectangle with a checkerboard shape"); Glutcreatemenu (Processmenu); Glutaddmenuentry ("do not fill rectangles",1); Glutaddmenuentry ("Fill Rectangle",2); Glutattachmenu (Glut_right_button); Glutdisplayfunc (Display); Initial (); Glutmainloop ();//start the main glut time processing cycle return 0;}
View Code
Implement fill rectangle with checkerboard pattern