vogle.h
/*
* vogle.h
*
* Modified by Th. Ullrich, 12/01/96 14:26:11
* Prepared C++ version (prototypes an extern linkage)
*
*/
#include <X11/Xlib.h>
/*
* default location for font library
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef PC /* Stupid pox head crap */
#define FONTLIB "c:\\lib\\hershey\\"
#ifndef __OS2__ /* BCOS2 defines malloc as a void pointer */
char *malloc();
#endif
#endif
extern char *vallocate();
#ifndef FONTLIB
#define FONTLIB "/usr/local/lib/hershey/"
#endif
/*
* standard colour indices
*/
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7
/*
* Hershey text justification
*/
#define V_XCENTERED 1
#define V_YCENTERED 2
#define V_LEFT 4 /* The default */
#define V_RIGHT 8
#define V_TOP 16
#define V_BOTTOM 32 /* The default */
/*
* Line thickness
*/
#define THIN 0
#define THICK 1
/*
* when (if ever) we need the precision
*/
#ifdef DOUBLE
#define float double
#endif
/*
* How to convert degrees to radians
*/
#ifndef PI
#define PI 3.14159265358979
#endif
#define D2R (PI / 180.0)
/*
* miscellaneous typedefs and type defines
*/
typedef float Vector[4];
typedef float Matrix[4][4];
typedef float Tensor[4][4][4];
/*
* when register variables get us into trouble
*/
#ifdef NOREGISTER
#define register
#endif
/*
* max number of vertices in a ploygon
*/
#define MAXVERTS 128
/*
* max number of characters in a font name
*/
#define FONTNAMELEN 256
/*
* object definitions
*/
#define MAXENTS 101 /* size of object table */
#define MAXTOKS 100 /* num. of tokens alloced at once in
an object */
/*
* functions which can appear in objects
*/
#define ARC 1
#define BOXTEXT 2
#define CALLOBJ 3
#define CENTERTEXT 4
#define CIRCLE 5
#define CLEAR 6
#define COLOR 7
#define DRAW 8
#define DRAWCHAR 9
#define DRAWSTR 10
#define FIXEDWIDTH 11
#define VFONT 12
#define HATCHANG 13
#define HATCHPITCH 14
#define LOADMATRIX 15
#define MAPCOLOR 16
#define MOVE 17
#define MULTMATRIX 18
#define POLY 19
#define POLYFILL 20
#define POLYHATCH 21
#define POPATTRIBUTES 22
#define POPMATRIX 23
#define POPVIEWPORT 24
#define PUSHATTRIBUTES 25
#define PUSHMATRIX 26
#define PUSHVIEWPORT 27
#define RCURVE 28
#define RPATCH 29
#define SECTOR 30
#define TEXTANG 31
#define TEXTSIZE 32
#define VIEWPORT 33
#define BACKBUFFER 34
#define FRONTBUFFER 35
#define SWAPBUFFER 36
#define BACKFACING 37
#define TRANSLATE 38
#define ROTATE 39
#define SCALE 40
#define VFLUSH 41
/*
* data types for object tokens
*/
typedef union tk {
int i;
float f;
} Token;
typedef struct tls {
int count;
Token *toks;
struct tls *next;
} TokList;
/*
* attributes
*/
typedef struct {
unsigned char *style,
*dashp,
fill,
hatch,
backface,
justify,
backbuf,
exvp,
fixedwidth;
int color;
int softtext;
float fontheight;
float fontwidth;
float hatchcos,
hatchsin,
hatchpitch;
float textcos,
textsin;
float dash,
adist;
char font[FONTNAMELEN];
} Attribute;
/*
* viewport
*/
typedef struct vp {
float left;
float right;
float bottom;
float top;
} Viewport;
/*
* stacks
*/
typedef struct ms { /* Matrix stack entries */
Matrix m;
struct ms *back;
} Mstack;
typedef struct as { /* Attribute stack entries */
Attribute a;
struct as *back;
} Astack;
typedef struct vs { /* Viewport stack entries */
Viewport v;
struct vs *back;
} Vstack;
/*
* vogle device structures
*/
typedef struct dev {
char *devname; /* name of device */
char *large, /* name of large font */
*small; /* name of small font */
int (*Vbackb)(), /* Set drawing in back buffer */
(*Vchar)(), /* Draw a hardware character */
(*Vcheckkey)(), /* Ckeck if a key was hit */
(*Vclear)(), /* Clear the screen to current color */
(*Vcolor)(), /* Set current color */
(*Vdraw)(), /* Draw a line */
(*Vexit)(), /* Exit graphics */
(*Vfill)(), /* Fill a polygon */
(*Vfont)(), /* Set hardware font */
(*Vfrontb)(), /* Set drawing in front buffer */
(*Vgetkey)(), /* Wait for and get the next key hit */
(*Vinit)(), /* Initialise the device */
(*Vlocator)(), /* Get mouse/cross hair position */
(*Vmapcolor)(), /* Set color indicies */
(*Vsetlw)(), /* Set line thickness */
(*Vstring)(), /* Draw a hardware string */
(*Vswapb)(), /* Swap front and back buffers */
(*Vsync)(); /* Syncronise the display */
} DevEntry;
typedef struct vdev {
char initialised,
clipoff,
inobject,
inpolygon,
upset, /* is up vector set */
cpVvalid, /* is the current device position valid */
sync, /* Do we syncronise the display */
inbackbuffer, /* are we in the backbuffer */
clipplanes; /* active clipping planes */
void (*pmove)(), /* Polygon moves */
(*pdraw)(); /* Polygon draws */
TokList *tokens; /* ptr to list of tokens for current object */
Mstack *transmat; /* top of transformation stack */
Astack *attr; /* top of attribute stack */
Vstack *viewport; /* top of viewport stack */
float hheight, hwidth; /* hardware character height, width */
Vector cpW, /* current postion in world coords */
cpWtrans, /* current world coords transformed */
upvector; /* world up */
int depth, /* # bit planes on screen */
maxVx, minVx,
maxVy, minVy,
sizeX, sizeY, /* size of square on screen */
sizeSx, sizeSy, /* side in x, side in y (# pixels) */
cpVx, cpVy;
DevEntry dev;
} Device;
extern Device vdevice; /* device structure */
#define V_X 0 /* x axis in cpW */
#define V_Y 1 /* y axis in cpW */
#define V_Z 2 /* z axis in cpW */
#define V_W 3 /* w axis in cpW */
/*
* function definitions
*/
/*
* allocate memory
*/
extern char *vallocate();
/*
* arc routines
*/
extern void arcprecision();
extern void arc(double, double, double, double, double);
extern void circle(double, double, double);
extern void circleprecision(int);
extern void sector(double, double, double, double, double);
/*
* attr routines
*/
extern void popattributes();
extern void pushattributes();
/*
* curve routines
*/
extern void curve(float [4][4]);
extern void rcurve(float [4][4]);
extern void curven(int, float [4][4]);
extern void drcurve();
extern void curvebasis(float [4][4]);
extern void curveprecision(int);
/*
* draw routines
*/
extern void draw(double, double, double);
extern void draw2(double, double);
extern void rdraw(double, double, double);
extern void rdraw2(double, double);
extern void sdraw2(double, double);
extern void rsdraw2(double, double);
extern void setdash(double);
extern void dashline();
extern void linestyle(char *);
/*
* device routines
*/
extern void clear();
extern void color(int);
extern int getdepth();
extern int getkey();
extern int checkkey();
extern int getplanes();
extern int locator(float*, float*);
extern int slocator(float*, float*);
extern void mapcolor(int, int, int, int);
extern void vinit(char*);
extern void vexit();
extern void verror();
extern void voutput(char*);
extern void vnewdev(char*);
extern void pushdev(char*);
extern void popdev();
extern char *vgetdev(char*);
/*
* mapping routines
*/
extern int WtoVx();
extern int WtoVy();
extern void VtoWxy();
extern void CalcW2Vcoeffs();
/*
* general matrix and vector routines
*/
extern void mult4x4();
extern void copymatrix();
extern void identmatrix();
extern void copytranspose();
extern void multvector();
extern void copyvector();
extern void premultvector();
/*
* matrix stack routines
*/
extern void getmatrix();
extern void popmatrix();
extern void loadmatrix();
extern void pushmatrix();
extern void multmatrix();
extern Matrix *getmstackaddress();
/*
* move routines
*/
extern void move(double, double, double);
extern void move2(double, double);
extern void rmove(double, double, double);
extern void rmove2(double, double);
extern void smove2(double, double);
extern void rsmove2(double, double);
/*
* object routines
*/
extern int isobj(int);
extern int genobj();
extern void delobj(int);
extern void makeobj(int);
extern void loadobj(int, char*);
extern void saveobj(int, char*);
extern void callobj(int);
extern void closeobj();
extern int getopenobj();
extern Token *newtokens();
/*
* patch routines.
*/
extern void patch(float [4][4], float [4][4], float [4][4]);
extern void rpatch(float [4][4], float [4][4], float [4][4], float [4][4]);
extern void drpatch();
extern void patchbasis(float [4][4], float [4][4]);
extern void patchcurves(int, int);
extern void patchprecision(int, int);
extern void transformtensor();
/*
* point routines
*/
extern void point(double, double, double);
extern void point2(double, double);
extern void spoint2();
/*
* polygon routines.
*/
extern void poly(int, float points[][3]);
extern void poly2(int, float [][2]);
extern void hatchang(double);
extern void makepoly();
extern void polyfill(int);
extern void closepoly();
extern void polyhatch(int);
extern void hatchpitch(double);
extern void backface(int);
extern void backfacedir(int);
/*
* rectangle routine
*/
extern void rect(double, double, double, double);
/*
* tensor routines
*/
extern void multtensor();
extern void copytensor();
extern void premulttensor();
extern void copytensortrans();
/*
* text routines
*/
extern int hershfont();
extern void font(char*);
extern void boxfit(double, double, int);
extern void boxtext(double, double, double, double, char*);
extern void drawstr(char*);
extern void textang();
extern int numchars();
extern void drawchar(char);
extern void textsize(double, double);
extern float strlength(char*);
extern float sstrlength();
extern void centertext(int);
extern void xcentertext();
extern void ycentertext();
extern void fixedwidth(int);
extern void topjustify();
extern void bottomjustify();
extern void leftjustify();
extern void rightjustify();
extern void textjustify(unsigned);
extern void getcharsize(char, float*, float*);
extern void getfontsize(float*, float*);
extern float getfontwidth();
extern float getfontheight();
/*
* transformation routines
*/
extern void scale(double, double, double);
extern void translate(double, double, double);
extern void rotate(double, char);
/*
* window definition routines
*/
extern void ortho(double, double, double, double, double, double);
extern void ortho2(double, double, double, double);
extern void lookat(double, double, double, double, double, double, double);
extern void window(double, double, double, double, double, double);
extern void polarview(double, double, double, double);
extern void perspective(double, double, double, double);
extern void up(double, double, double);
/*
* routines for manipulating the viewport
*/
extern void viewport(double, double, double, double);
extern void getviewport(float*, float*, float*, float*);
extern void popviewport();
extern void pushviewport();
/*
* routines for retrieving the graphics position
*/
extern void getgp(float*, float*, float*);
extern void getgpt(float*, float*, float*, float*);
extern void getgp2(float*, float*);
extern void sgetgp2(float*, float*);
/*
* routines for retrieving the aspect details of the device
*/
extern float getaspect();
extern void getfactors(float*, float*);
extern void getdisplaysize(float*, float*);
extern void expandviewport();
extern void unexpandviewport();
/*
* routines for handling the buffering
*/
extern int backbuffer();
extern void frontbuffer();
extern int swapbuffers();
/*
* routines for window sizing and positioning
*/
extern void prefsize(int, int);
extern void prefposition(int, int);
/*
* Misc control routines
*/
extern void clip();
extern void quickclip();
extern void clipping(int);
extern void vsetflush(int);
extern void vflush();
extern void yobbarays();
/*
* X11 interface (added tu)
*/
void vo_xt_window(Display*, Window, int, int);
void vo_xt_set_win(Display*, Window, int, int);
void vo_xt_win_size(int, int);
Display* vo_xt_get_display();
Window vo_xt_get_window();
#ifdef __cplusplus
}
#endif /* __cplusplus */