glutBitmapCharacter(GLUT_BITMAP_9_BY_15, k);
A. 6. Программа рисования
/*glutStrokeCharacter(GLUT_STROKE_ROMAN,i); */ rx+=glutBitmapWidth(GLUT_BITMAP_9_BY_15, к);
}
/*---------------.....-----------*/
void display() {
int shift=0;
glPushAttrib(GL_ALL_ATTRIB_BITS); glClearColor (0.8, 0.8, 0.8, 1.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); screen_box(0,wh-ww/10,ww/10); glColor3f(1.0, 0.0, 0.0); screen_box(ww/10,wh-ww/10,ww/10); glColor3f(0.0, 1.0, 0.0); screen_box(ww/5,wh-ww/10,ww/10); glColor3f(0.0, 0.0, 1.0); screen_box(3 *ww/10,wh-ww/10,ww/10); glColor3f(1.0, 1.0, 0.0); screen_box(2 *ww/5,wh-ww/10,ww/10); glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINES);
glVertex2i(wh/40,wh-ww/20);
glVertex2i(wh/40+ww/20,wh-ww/20); glEnd();
glBegin(GL_TRIANGLES);
glVertex2i(ww/5+ww/40,wh-ww/10+ww/40);
glVertex2i(ww/5+ww/20,wh-ww/40);
glVertex2i(ww/5+3*ww/40,wh-ww/10+ww/40); glEnd();
glPointSize(3.0);
glBegin(GL_P0INTS);
glVertex2i(3*ww/10+ww/20, wh-ww/20); glEnd();
glRasterPos2i(2*ww/5,wh-ww/20); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'A'); shift=glutBitmapWidth(GLUT_BITMAP_9_BY_15, 'A'); glRasterPos2i(2*ww/5+shift,wh-ww/20); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'В'); shift+=glutBitmapWidth(GLUT_BITMAP_9_BY_15, 'В'); glRasterPos2i(2*ww/5+shift,wh-ww/20); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'С'); glFlush(); glPopAttrib(); Приложение А. Демонстрационные программы
}
/* -............................*/
int main(int argc, char** argv) {
int cjnenu, p_menu, f_menu; glutlnit(&argc,argv);
glutlnitDisplayMode (GLUTJ3 INGLE | GLUT_RGB); glutCreateWindow("square"J; glutDisplayFunc(display); cjnenu = glutCreateMenu(color_menu); glutAddMenuEntry("Red", 1); glutAddMenuEntry("Green", 2); glutAddMenuEntry("Blue",3); glutAddMenuEntry("Cyan",4); glutAddMenuEntry("Magenta",5); glutAddMenuEntry("Yellow", 6); glutAddMenuEntry!"White", 7); glutAddMenuEntry("Black",8); p_menu = glutCreateMenu(pixeljnenu); glutAddMenuEntry("increase pixel size", 1); glutAddMenuEntry("decrease pixel size", 2); f_menu = glutCreateMenu(filljnenu); glutAddMenuEntry("fill on", 1); glutAddMenuEntry("fill off", 2); glutCreateMenu(rightjnenu); glutAddMenuEntry("quit",1); glutAddMenuEntry("clear",2); glutAttachMenu(GLUT JUGHTJBUTTON); glutCreateMenu(middlejnenu); glutAddSubMenu("Colors", cjnenu); glutAddSubMenu("Pixel Size", pjnenu); glutAddSubMenu("Fill", f_menu); glutAttachMenu(GLUT_MIDDLE_BUTTON); myinit ();