/*
 * Tradurre le chiamate alla DIGS library in quelli alla libreria VOGLE
 *
 * Da DIGS, usiamo:
 *	openpl()
 *	closepl()
 *	space(0, 0, 4096, 4096)
 *	line(x1, y1, x2, y2)
 * e	cont(x, y)
 */

#include <stdlib.h>	/* for getenv() */
#include <stdio.h>	/* for fputs() */
#include <vogle.h>

#define DIGSMAX 4096

/* Convert coordinates in DIGS format (0..4096) in vogle formato (-1.0..1.0) */
#define d2v(x) ((float)(x - DIGSMAX/2) / (DIGSMAX/2))

openpl()
{
	char *device;
	
	device = getenv("VDEVICE");
	if (device == NULL) {
		if (getenv("DISPLAY") != NULL) {
			device = "X11";
		} else {
			fputs("You must specify the output device type in environment variable VDEVICE.\n", stderr);
			exit(1);
		}
	}

	vinit(device);
	/*
	color(BLACK);
	clear();
	*/
}

closepl()
{
	vexit();
}

space(x1, y1, x2, y2)
{
}

line(x1, y1, x2, y2)
{
	smove2(d2v(x1), d2v(y1));
	sdraw2(d2v(x2), d2v(y2));
}

cont(x, y)
{
	sdraw2(d2v(x), d2v(y));
}
