/* boxcirc.c:
A simple example which draw a 2d box and circle, press ESCape key to exit. */
#include <gl/gl.h> #include <gl/device.h>
main() {
int dev,val;
initialize();
while (TRUE) { if (qtest()) { dev = qread(&val); if (dev == ESCKEY) { gexit(); exit(); } else if (dev == REDRAW) { reshapeviewport(); drawboxcirc(); } } } }
initialize() {
int gid;
prefposition(XMAXSCREEN/4, XMAXSCREEN*3/4, YMAXSCREEN/4, YMAXSCREEN*3/4);
gid = winopen("boxcirc"); qdevice(ESCKEY); qdevice(REDRAW); qenter(REDRAW,gid);
}
drawboxcirc() {
pushmatrix(); translate(200.0, 200.0, 0.0); color(BLACK); clear(); color(BLUE); recti(0, 0, 100, 100); color(RED); circi(50, 50, 50); popmatrix();
}
The circ subroutine , clear subroutine , color or colorf subroutine .