glVertex2i(xp[0],wh-yp[0]); glEnd(); draw_mode=0; count=0;
}
break; case(RECTANGLE): if(count == 0) {
count++; xp[0] = x; yp[0] = y;
}
else
{
if(fill) glBegin(GL_POLYGON); else glBegin(GL_LINE_LOOP); glVertex!i(x,wh-y); glVertex2i(x,wh-yp[0]); glVertex2i(xp[0],wh-yp[0]); glVertex2i(xp[0],wh-y); glEnd(); draw_mode=0; count=0;
}
break; case (TRIANGLE): switch(count) {
case(0):
count++;
xp[0] = x;
yp[0] = y; break ;
case(l) : count++; xp[l] = x;
yp[i] = y;
break; case(2) :

A. 6. Программа рисования

if(fill) glBegin(GL_POLYGON); else glBegin(GL_LINE_LOOP);
glVertex2i(xp[0],wh-yp[0]);
glVertex2i(xp[1],wh-yp[1]);
glVertex2i(x,wh-y); glEnd(); draw_mode=0; count=0;
}
break; case(POINTS): {
drawSquare(x,y); count++;
}
break;
case(TEXT): {
rx=x; ry=wh-y;
glRasterPos2i(rx,ry); count=0;
}
}
glPopAttrib(); glFlush();
}
}
/*.............----------........*/
int pick(int x, int y) {

у = wh - y;

if(y < wh-ww/10) return 0; else if(x < ww/10) return LINE; else if(x < ww/5) return RECTANGLE; else if(x < 3*ww/10) return TRIANGLE; else if(x < 2*ww/5) return POINTS; else if(x < ww/2) return TEXT; else return 0;
}
/*...........-......--.........*/
void screen_box(int x, int y, int s )
{
glBegin(GL_QUADS); glVertex2i(x, y); glVertex2i(x+s, y);

538 Приложение A. Демонстрационные программы

glVertex2i(x+s, y+s); glVertex2i(x, y+s); glEnd();
void right menu(int id)
if(id == 1) exit(); else display();
*/
void middle_menu(int id) }
void color menu(int id)
if(id == 1) {r = 1.0; g = 0.0; b = 0.0;}
else if(id == 2) {r = 0.0 g = 1.0 b = 0.0
else if(id == 3) {r = 0.0 g = 0.0 b = 1.0
else if(id == 4) {r = 0.0 g = 1.0 b = 1.0
else if(id == 5) {r = 1.0 g = 0.0 b = 1.0
else if(id == 6) {r = 1.0 g = 1.0 b = 0.0
else if(id == 7) {r = 1.0 g = 1.0 b = 1.0
else if(id == 8) {r = 0.0 g = 0.0 b = 0.0
void pixel menu(int id)
*/
if (id == 1) size = 2 * size; else if (size > 1) size = size/2;
*/
void fill menu(int id)
if (id == 1) fill = 1; else fill = 0;
/*_______________________________*/
void key(unsigned char k, int xx, int yy)
if(draw_mode!=TEXT) return; glColor3f(0.0,0.0,0.0); glRasterPos2i(rx,ry);

⇐ Предыдущая| |Следующая ⇒