Implement fill rectangle with checkerboard pattern

Source: Internet
Author: User

Label:

//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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: