paul@manray.asd.sgi.com (Paul Haeberli) (09/26/90)
What follows is a 53 line paint program that compiles
and runs on an IRIS workstation. Could someone put
together a simple example program for the NeXT machine
that does something similar?
I think this might be an instructive example for people
who want to write simple graphics applications for the
NeXT machine.
Thanks for your help!!!
paul haeberli
415-962-3665
/*
* dinkypaint -
* A trivial paint program for IRIS workstations.
*
* to make this:
*
* cc dinkypaint.c -o dinkypaint -lgl_s
*
* paul haeberli - 1990
*/
#include "gl.h"
#include "device.h"
main()
{
int xpos, ypos;
keepaspect(1,1);
winopen("paint");
RGBmode();
gconfig();
RGBcolor(200,200,200);
clear();
RGBcolor(0,0,0);
qdevice(LEFTMOUSE);
qdevice(MIDDLEMOUSE);
while(1) {
if(getbutton(LEFTMOUSE)) { /* if leftmouse down, paint */
getmousepos(&xpos,&ypos);
RGBcolor(0,0,0);
circfi(xpos,ypos,5);
}
if(getbutton(MIDDLEMOUSE)) { /* if middle button down clear */
RGBcolor(200,200,200);
clear();
}
}
}
getmousepos(x,y)
int *x, *y;
{
short devs[2];
short vals[2];
int xorg, yorg;
getorigin(&xorg,&yorg); /* get origin of window */
devs[0] = MOUSEX;
devs[1] = MOUSEY;
getdev(2,devs,vals); /* read mouse pos atomically */
*x = vals[0]-xorg;
*y = vals[1]-yorg;
}