---------------------------------------------------------------------------------
Functions for 2D graphics
---------------------------------------------------------------------------------

int initgraph(unsigned int width,unsigned int height,int fullscr,const char *title)

Creates window and allocates memory for graphics. Use fullscr=1 for full screen.
Full screen works only with SDL 1.
----
void closegraph()

Closes window and frees memory allocated with initgraph().
----
void setcolor(unsigned char red,unsigned char green,unsigned char blue)

Sets current colour; red, green and blue must be between 0 and 255.
----
void setcolrnb(float f)

Sets current colour according to f: f=0 -> red; f=0.25 ->yellow; f=0.5 -> green;
f=0.75 -> cyan; f=1 -> blue; f must be between 0 and 1.
----
void setbgcolor(unsigned char red,unsigned char green,unsigned char blue)

Sets background colour.
----
void clearscreen()

Fills screen with background colour.
----
void display()

Displays the image on screen or writes "image.bmp", according to options selected
in "grconfig.h"
----
void scroll(int dy)

Scrolls vertically by dy pixels.
----
void dpoint(int x,int y)

Draws point with coordinates x and y and sets current coordinates to x and y.
Point with x=0 and y=0 is at the bottom left corner of the screen.
----
void dlinerel(int x,int y)

Draws line x pixels long and y pixels tall from current point and sets current
point to the end of the line.
----
void dlrspec(int dx,int dy,int n)

Draws line containing n pixels; dx and dy are the horizontal and vertical
distances between pixels.
----
void drectangle(int x,int y)

Draws rectangle x pixels long and y pixels tall from current point.
----
void dchar(char c,int x,int y,int bgr)

Draws character c at coordinates x and y; bgr=0 -> transparent background,
bgr=1 -> background filled with background colour.
----
void setchrsize(int i,int j)

Sets character size. Original size of a character is 7 by 8 pixels. The
horizontal size (7 pixels) is multiplied by i and the vertical size - by j.
----
void dtext(char *tx,int x,int y,int bgr)

Draws text at coordinates x and y.
----
void dtextscroll(char *tx,int x,int y,int bgr)

Draws text at the bottom of the screen and scrolls the screen at the end of each
line.
----
void dlineabs(float x1,float y1,float x2,float y2)

Draws line between points A(x1,y1) and B(x2,y2). Line can exceed the screen
limits.
----
void dtriangle(float x1,float y1,float x2,float y2,float x3,float y3)

Draws filled triangle determined by points A(x1,y1), B(x2,y2) and C(x3,y3).
Triangle can exceed the screen limits.
----
void dcircle(float x0,float y0,float r)

Draws circle with centre at C(x0,y0) and radius r. Circle can exceed the screen
limits.
----
void ddisc(float x0,float y0,float r)

Draws disc with centre at C(x0,y0) and radius r. Disc can also exceed the screen
limits.
----
void setpos(int x,int y)

Sets current coordinates to x and y.
----
void printw(const char *format, ...)

Prints text at the current position. Works like printf();
----
void printws(const char *format, ...)

Prints text at the bottom of the screen and scrolls the screen at the end of each
line. Works like printf();
----
void pause(int p)

Pauses p milliseconds.
----
char getch_graph()

Gets character from keyboard, which is printed at the current position.
----
char getch()

Gets character from keyboard, which is printed at the bottom of the screen.
----
void scanw(const char *format, ...)

Works like scanf(), prints text at current position.
----
void scanws(const char *format, ...)

Works like scanf(), prints text at the bottom of the screen and then scrolls.
----
int addmod2d()

Allocates memory for a 2D model, composed of lines and triangles. Returns
model number.
----
void freemod2d()

Frees memory allocated for all models.
----
void addpoint2d(float x,float y)

Adds point with coordinates x and y to the last model.
----
void addline2d(unsigned int p1,unsigned int p2)

Adds line between points p1 and p2 of the last model. First point is 0.
----
void addtriangle2d(unsigned int p1,unsigned int p2,unsigned int p3,float col)

Adds triangle between 3 points of the last model. First point is 0.
----
void drawmod2d(unsigned int nmod,float x0,float y0,float scale,float ang)

Draws model nmod (first model is 0) at coordinates x0 and y0, rotated by ang
radians and enlarged scale times. For original size and position, ang=0 and
scale=1.
----
void evmod2d(unsigned int n1,unsigned int n2,float *xmin,float *ymin,float *scale)

Finds optimal scale for drawing models n1 ... n2.
----
void drmod2dauto(unsigned int nmod)

Draws model nmod (first is 0) automatically scaled to fit the screen.

---------------------------------------------------------------------------------
Functions for sound
---------------------------------------------------------------------------------

void setvoice(unsigned int v,float freq,float vol)

Sets frequency and volume of voice v (v=0,1,2,3); vol should be between 0 and 1.

---------------------------------------------------------------------------------
Functions for 3D graphics
---------------------------------------------------------------------------------

Axes X, Y and Z are like this (not like in OpenGL):

^ X   __
|     /| Z
|    /
|   /
|  /
| /      Y
|-------->

void setlight3d(float amb,float hd,float dir,float dx,float dy,float dz)

Sets light parameters:
amb - intensity of 1st light, which has the same intensity in all directions;
hd - intensity of 2nd light, oriented in the direction of Z axis;
dir - intensity of 3rd light, with direction determined by dx,dy and dz.
----
int initgraph3d(float fov,float zmin,float zmax)

Initializes 3D graphics and allocates memory for Zbuffer.
----
void closegraph3d()

Frees memory allocated for Zbuffer, 3D models and 3D objects.
----
int addmod3d()

Allocates memory for 3D model, composed of triangles. Returns model number.
----
void mod3addtri(float x1,float y1,float z1,float x2,float y2,float z2,float x3,float y3,float z3)

Adds triangle to 3D model.
----
void mod3setcolor(unsigned int tr1,unsigned int tr2,float red,float green,float blue)

Sets colour of triangles tr1 ... tr2 (first triangle is 0) of the model.
----
void mod3setfullbr(unsigned int tr1,unsigned int tr2)

Makes triangles tr1 ... tr2 fullbright.
----
void mod3setvis(unsigned int tr1,unsigned int tr2,char vis,float xv,float yv,float zv)

Sets visibility of triangles tr1 ... tr2 of the model (first triangle is 0). If
vis='v', the triangles are visible from a point determined by xv, yv and zv and
if vis='i', the triangles are not visible from that point.
----
void freemod3d()

Frees memory allocated for all 3D models.
----
int readmod3d(const char *fname)

Reads 3D model from a file. In the file, and only in the file, the first vertex
is 1 and the first triangle is 1. Look in file "ic.m3d" for an example.
----
int rdmod3d3f(const char *fgeo,const char *fcol,const char *fcld);

Reads 3D model from 3 files. The 1st file specifies the geometry (vertex
coordinates and triangles), the 2nd specifies the colours and the 3rd is for
backface culling. The 2nd and 3rd file names can be "nul", in which case no
file is read. Ex.:

rdmod3d3f("file.geo","file.col","file.cld");
rdmod3d3f("file.geo","file.col","nul");
rdmod3d3f("file.geo","nul","nul";
----
float eval_mod(unsigned int i)

Returns radius of a sphere which includes model i.
----
int addobj3d(unsigned int nmod)

Allocates memory for a 3D object and associates it with model nmod. Returns
object number.
----
void setobj3dmod(unsigned int i,unsigned int nmod)

Assigns model nmod to object i.
----
void setobj3dpos(int i,float *pos)

Sets  position of object i; x=pos[0], y=pos[1], z=pos[2].
----
void setobj3drot(int i,float *rot)

Sets  rotation matrix of object i. The columns of the matrix are the unit vectors
of the object's local system.
----
void setobj3dscale(unsigned int i,float scale)

Sets scale of object i.
----
void setcampos(float *pos)

Sets position of camera.
----
void setcamrot(float *rot)

Sets rotation of camera.
----
void freeobj3d()

Frees memory allocated for all 3D objects.
----
int drawobj3d(unsigned int nob)

Draws a 3D object. Returns number of triangles drawn.
----
void drawobj3all()

Draws all 3D objects. Returns number of triangles drawn.
----
void transobj3d(int i,float x,float y,float z)

Translates object i by x, y and z.
----
void transcam(float x,float y,float z)

Translates camera by x, y and z.
----
void trlsobj3d(int i,float x,float y,float z)

Translates object i by x, y and z along the axes of its local system.
----
void trlscam(float x,float y,float z)

Translates camera by x, y and z along the axes of its local system.
----
void rotZobj3d(int i,float tt)
void rotZcam(float tt)
void rotYobj3d(int i,float tt)
void rotYcam(float tt)
void rotXobj3d(int i,float tt)
void rotXcam(float tt)
void rotABobj3d(int i,float dx,float dy,float dz,float tt)
void rotABcam(float dx,float dy,float dz,float tt)

These functions rotate object i or camera by tt radians around an axis
which passes through the origin of its local system, set with setobj3dpos(),
and is parallel to Z, Y, X or a vector determined by dx, dy and dz.
----
void drawfog3d(float zfog,float zmax)

Draws fog, which starts at zfog and resets the Zbuffer.
----
void drawbkg3d(flat zmax)

Sets colour of all points which are at a distance of at least zmax with the
background colour and resets the Zbuffer.
----
