home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / voglw.zip / vogl.h < prev    next >
C/C++ Source or Header  |  1997-02-13  |  13KB  |  627 lines

  1.  
  2. #ifdef PC    /* Stupid pox head crap */
  3. char    *vallocate();
  4. char    *malloc();
  5. #endif
  6.  
  7. /*
  8.  * VOGL is always defined if a header file is from the 
  9.  * VOGL library. In cases where you do use some VOGL
  10.  * initialisation routines like vinit, just put #ifdef VOGL...
  11.  * around.
  12.  */
  13. #ifndef VOGL
  14. #define    VOGL
  15. #endif
  16.  
  17. #ifndef TRUE
  18. #define    TRUE    1
  19. #endif
  20.  
  21. #ifndef FALSE
  22. #define    FALSE    0
  23. #endif
  24.  
  25. /*
  26.  * Misc defines...
  27.  */
  28. #define    FLAT    0
  29. #define SMOOTH    1
  30. #define GD_XPMAX 1
  31. #define GD_YPMAX 2
  32.  
  33. /*
  34.  * standard colour indices
  35.  */
  36. #define    BLACK        0
  37. #define    RED        1
  38. #define    GREEN        2
  39. #define    YELLOW        3
  40. #define    BLUE        4
  41. #define    MAGENTA        5
  42. #define    CYAN        6
  43. #define    WHITE        7
  44.  
  45. /*
  46.  * when (if ever) we need the precision
  47.  */
  48. #ifdef DOUBLE
  49. #define    float    double
  50. #endif
  51.  
  52. /*
  53.  * How to convert degrees to radians
  54.  */
  55. #define    PI    3.14159265358979
  56. #define D2R    (PI / 180.0)
  57.  
  58. /*
  59.  * miscellaneous typedefs and type defines
  60.  */
  61. typedef float    Vector[4];
  62. typedef float    Matrix[4][4];
  63. typedef float    Tensor[4][4][4];
  64. typedef short    Angle;
  65. typedef float    Coord;
  66. typedef long    Icoord;
  67. typedef short    Scoord;
  68. typedef long    Object;
  69. typedef short    Screencoord;
  70. typedef long    Boolean;
  71. typedef unsigned short    Linestyle;
  72.  
  73. typedef unsigned short    Device;
  74.  
  75. typedef unsigned short    Colorindex;
  76.  
  77.  
  78. /*
  79.  * when register variables get us into trouble
  80.  */
  81. #ifdef NOREGISTER
  82. #define    register
  83. #endif
  84.  
  85. /*
  86.  * max number of vertices in a ploygon
  87.  */
  88. #define    MAXVERTS    128
  89.  
  90. /*
  91.  * object definitions
  92.  */
  93. #define MAXENTS        101        /* size of object table */
  94. #define    MAXTOKS        100        /* num. of tokens alloced at once in
  95.                        an object  */
  96.  
  97. /*
  98.  * Polygon fill modes for "polymode"
  99.  */
  100. #define PYM_POINT    0
  101. #define PYM_LINE    0
  102. #define PYM_FILL    1
  103. #define PYM_HOLLOW    1
  104.  
  105. /*
  106.  * functions which can appear in objects
  107.  */
  108. #define    ARC        1
  109. #define    CALLOBJ        3
  110. #define    CIRCLE        5
  111. #define    CLEAR        6
  112. #define    COLOR        7
  113. #define    DRAW        8
  114. #define    DRAWSTR        10
  115. #define    VFONT        12
  116. #define    LOADMATRIX    15
  117. #define    MAPCOLOR    16
  118. #define    MOVE        17
  119. #define    MULTMATRIX    18
  120. #define    POLY        19
  121. #define    POPATTRIBUTES    22
  122. #define    POPMATRIX    23
  123. #define    POPVIEWPORT    24
  124. #define    PUSHATTRIBUTES    25
  125. #define    PUSHMATRIX    26
  126. #define    PUSHVIEWPORT    27
  127. #define    RCURVE        28
  128. #define    RPATCH        29
  129. #define    SECTOR        30
  130. #define    VIEWPORT    33
  131. #define    BACKBUFFER    34
  132. #define    FRONTBUFFER    35
  133. #define    SWAPBUFFERS    36
  134. #define    BACKFACING    37
  135. #define    TRANSLATE    38
  136. #define    ROTATE        39
  137. #define    SCALE        40
  138.  
  139. #define    ARCF        41
  140. #define    CIRCF        42
  141. #define    POLYF        43
  142. #define    RECTF        44
  143. #define    POLYMODE    45
  144. #define    CMOV        46
  145. #define    LINESTYLE    47
  146. #define    LINEWIDTH    48
  147.  
  148. /*
  149.  * Non standard call...
  150.  */
  151. #define    VFLUSH        70
  152.  
  153. /*
  154.  * States for bgn* and end* calls
  155.  */
  156. #define    NONE        0    /* Just set current spot */
  157. #define    VPNT        1    /* Draw dots         */
  158. #define    VLINE        2    /* Draw lines         */
  159. #define    VCLINE        3    /* Draw closed lines     */
  160. #define    VPOLY        4    /* Draw a polygon      */
  161. #define VTMESH        5       /* Draw a triangular mesh*/
  162. #define VQSTRIP        6       /* Draw a quadralateral mesh*/
  163.  
  164. /*
  165.  * data types for object tokens
  166.  */
  167. typedef union tk {
  168.     int        i;
  169.     float        f;
  170. } Token;
  171.  
  172. typedef struct tls {
  173.     int        count;
  174.     Token        *toks;
  175.     struct tls    *next;
  176. } TokList;
  177.  
  178. /*
  179.  * double buffering modes.
  180.  */
  181. #define    SINGLE        1
  182.  
  183. /*
  184.  * attributes
  185.  */
  186. typedef struct {
  187.     char        backface,
  188.             mode;            /* Which mode are we in */
  189.     int        color;
  190.     int        fontnum;
  191.     Linestyle    ls;            
  192.     short        lw;            /* Linewidth */
  193. } Attribute;
  194.  
  195. /*
  196.  * viewport
  197.  */
  198. typedef struct vp {
  199.     float    left;
  200.     float    right;
  201.     float    bottom;
  202.     float    top;
  203. } Viewport; 
  204.  
  205. /*
  206.  * stacks
  207.  */
  208. typedef    struct    ms {    /* Matrix stack entries    */
  209.     Matrix        m;
  210.     struct    ms    *back;
  211. } Mstack;
  212.  
  213. typedef    struct    as {    /* Attribute stack entries */
  214.     Attribute    a;
  215.     struct    as    *back;
  216. } Astack;
  217.  
  218. typedef    struct    vs {    /* Viewport stack entries */
  219.     Viewport    v;
  220.     struct    vs    *back;
  221. } Vstack;
  222.  
  223. /*
  224.  * vogle device structures
  225.  */
  226. typedef struct dev {
  227.     char    *devname;        /* name of device */
  228.     char    *large,            /* name of large font */
  229.         *small;            /* name of small font */
  230.     int    (*Vbackb)(),        /* Set drawing in back buffer */
  231.         (*Vchar)(),        /* Draw a hardware character */
  232.         (*Vcheckkey)(),        /* Ckeck if a key was hit */
  233.         (*Vclear)(),        /* Clear the screen to current color */
  234.         (*Vcolor)(),        /* Set current color */
  235.         (*Vdraw)(),        /* Draw a line */
  236.         (*Vexit)(),        /* Exit graphics */
  237.         (*Vfill)(),        /* Fill a polygon */
  238.         (*Vfont)(),        /* Set hardware font */
  239.         (*Vfrontb)(),        /* Set drawing in front buffer */
  240.         (*Vgetkey)(),        /* Wait for and get the next key hit */
  241.         (*Vinit)(),        /* Initialise the device */
  242.         (*Vlocator)(),        /* Get mouse/cross hair position */
  243.         (*Vmapcolor)(),        /* Set color indicies */
  244.         (*Vsetls)(),        /* Set linestyle */
  245.         (*Vsetlw)(),        /* Set linewidth */
  246.         (*Vstring)(),        /* Draw a hardware string */
  247.         (*Vswapb)(),        /* Swap front and back buffers */
  248.         (*Vsync)();        /* Sync display */
  249. } DevEntry;
  250.  
  251. typedef struct vdev {
  252.     char        initialised,
  253.             clipoff,
  254.             inobject,
  255.             inpolygon,
  256.             fill,            /* polygon filling */
  257.             cpVvalid,        /* is the current device position valid */
  258.             sync,            /* Do we syncronise the display */
  259.             inbackbuffer,        /* are we in the backbuffer */
  260.             clipplanes;        /* active clipping planes */
  261.     void        (*pmove)(),        /* Polygon moves */
  262.             (*pdraw)();        /* Polygon draws */
  263.     TokList        *tokens;        /* ptr to list of tokens for current object */
  264.     Mstack        *transmat;        /* top of transformation stack */
  265.     Astack        *attr;            /* top of attribute stack */
  266.     Vstack        *viewport;        /* top of viewport stack */
  267.     float        hheight, hwidth;    /* hardware character height, width */
  268.     Vector        cpW,            /* current postion in world coords */
  269.             cpWtrans,        /* current world coords transformed */
  270.             upvector;        /* world up */
  271.     int        depth,            /* # bit planes on screen */
  272.             maxVx, minVx,
  273.             maxVy, minVy,
  274.             sizeX, sizeY,         /* size of square on screen */
  275.             sizeSx, sizeSy,        /* side in x, side in y (# pixels) */
  276.             cpVx, cpVy;
  277.     DevEntry    dev;
  278.     float        savex,            /* Where we started for v*() */
  279.             savey,
  280.             savez;
  281.     char        bgnmode;        /* What to do with v*() calls */
  282.     int        save;            /* Do we save 1st v*() point */
  283.  
  284.     char        *wintitle;        /* window title */
  285.  
  286.     char        *devname;        /* pointer to device name */
  287.  
  288.     Matrix        tbasis, ubasis, *bases; /* Patch stuff */
  289.     
  290.     char        *enabled;        /* pointer to enabled devices mask */
  291.     int        maxfontnum;
  292.  
  293.     char        alreadyread;        /* queue device stuff */
  294.     char        kbdmode;        /* are we in keyboard mode */
  295.     char        mouseevents;        /* are mouse events enabled */
  296.     char        kbdevents;        /* are kbd events enabled */
  297.     int        devno, data;
  298.  
  299.     int        concave;        /* concave polygons? */
  300. } VDevice;
  301.  
  302. extern VDevice    vdevice;        /* device structure */
  303.  
  304. #define    V_X    0            /* x axis in cpW */
  305. #define    V_Y    1            /* y axis in cpW */
  306. #define    V_Z    2            /* z axis in cpW */
  307. #define    V_W    3            /* w axis in cpW */
  308.  
  309. /*
  310.  * function definitions
  311.  */
  312.  
  313. /*
  314.  * arc routines
  315.  */
  316. extern void    arcprecision();
  317. extern void    circleprecision();
  318. extern void    arc();
  319. extern void    arcs();
  320. extern void    arci();
  321. extern void    arcf();
  322. extern void    arcfs();
  323. extern void    arcfi();
  324. extern void    circ();
  325. extern void    circs();
  326. extern void    circi();
  327. extern void    circf();
  328. extern void    circfs();
  329. extern void    circfi();
  330.  
  331. /*
  332.  * attr routines
  333.  */
  334. extern void    popattributes();
  335. extern void    pushattributes();
  336.  
  337. /*
  338.  * curve routines
  339.  */
  340. extern void    curvebasis();
  341. extern void    curveprecision();
  342. extern void    rcrv();
  343. extern void    crv();
  344. extern void    crvn();
  345. extern void    rcrvn();
  346. extern void    curveit();
  347.  
  348. /*
  349.  * draw routines
  350.  */
  351. extern void    draw();
  352. extern void    draws();
  353. extern void    drawi();
  354. extern void    draw2();
  355. extern void    draw2s();
  356. extern void    draw2i();
  357. extern void    rdr();
  358. extern void    rdrs();
  359. extern void    rdri();
  360. extern void    rdr2();
  361. extern void    rdr2s();
  362. extern void    rdr2i();
  363. extern void    bgnline();
  364. extern void    endline();
  365. extern void    bgnclosedline();
  366. extern void    endclosedline();
  367.  
  368. /*
  369.  * device routines
  370.  */
  371. extern void    qdevice();
  372. extern void    unqdevice();
  373. extern long    qread();
  374. extern void    qreset();
  375. extern long    qtest();
  376. extern Boolean    isqueued();
  377.  
  378. extern void    gexit();
  379. extern void    gconfig();
  380. extern void    shademodel();
  381. extern long    getgdesc();
  382. extern long    winopen();
  383. extern void    ginit();
  384. extern void    gconfig();
  385. extern long    getvaluator();
  386. extern Boolean    getbutton();
  387. extern void    getdev();
  388. extern void    clear();
  389. extern void    colorf();
  390. extern void    color();
  391. extern void    mapcolor();
  392. extern long    getplanes();
  393.  
  394. extern void    vinit();
  395. extern void    voutput();
  396. extern void    verror();
  397. extern void    vnewdev();
  398. extern char    *vgetdev();
  399.  
  400. /*
  401.  * mapping routines
  402.  */
  403. extern int    WtoVx();
  404. extern int    WtoVy();
  405. extern void    CalcW2Vcoeffs();
  406.  
  407. /*
  408.  * general matrix and vector routines
  409.  */
  410. extern void    mult4x4();
  411. extern void    copymatrix();
  412. extern void    identmatrix();
  413. extern void    copytranspose();
  414.  
  415. extern void    multvector();
  416. extern void    copyvector();
  417. extern void    premultvector();
  418.  
  419. /*
  420.  * matrix stack routines
  421.  */
  422. extern void    getmatrix();
  423. extern void    popmatrix();
  424. extern void    loadmatrix();
  425. extern void    pushmatrix();
  426. extern void    multmatrix();
  427.  
  428. /*
  429.  * move routines
  430.  */
  431. extern void    move();
  432. extern void    moves();
  433. extern void    movei();
  434. extern void    move2();
  435. extern void    move2s();
  436. extern void    move2i();
  437. extern void    rmv();
  438. extern void    rmvs();
  439. extern void    rmvi();
  440. extern void    rmv2();
  441. extern void    rmv2s();
  442. extern void    rmv2i();
  443.  
  444. /*
  445.  * object routines
  446.  */
  447. extern Boolean    isobj();
  448. extern long    genobj();
  449. extern void    delobj();
  450. extern void    makeobj();
  451. extern void    callobj();
  452. extern void    closeobj();
  453. extern long    getopenobj();
  454. extern Token    *newtokens();
  455.  
  456. /*
  457.  * patch routines.
  458.  */
  459. extern void    defbasis();
  460. extern void    patchbasis();
  461. extern void    patchcurves();
  462. extern void    patchprecision();
  463. extern void    patch();
  464. extern void    rpatch();
  465.  
  466. /*
  467.  * point routines
  468.  */
  469. extern void    pnt();
  470. extern void    pnts();
  471. extern void    pnti();
  472. extern void    pnt2();
  473. extern void    pnt2s();
  474. extern void    pnt2i();
  475. extern void    bgnpoint();
  476. extern void    endpoint();
  477.  
  478. /*
  479.  * v routines
  480.  */
  481. extern void    v4f();
  482. extern void    v3f();
  483. extern void    v2f();
  484. extern void    v4d();
  485. extern void    v3d();
  486. extern void    v2d();
  487. extern void    v4i();
  488. extern void    v3i();
  489. extern void    v2i();
  490. extern void    v4s();
  491. extern void    v3s();
  492. extern void    v2s();
  493.  
  494. /*
  495.  * polygon routines.
  496.  */
  497. extern void    concave();
  498. extern void    backface();
  499. extern void    frontface();
  500. extern void    polymode();
  501. extern void    poly2();
  502. extern void    poly2i();
  503. extern void    poly2s();
  504. extern void    polyi();
  505. extern void    polys();
  506. extern void    polf2();
  507. extern void    polf2i();
  508. extern void    polf2s();
  509. extern void    polfi();
  510. extern void    polfs();
  511. extern void    poly();
  512. extern void    polf();
  513. extern void    pmv();
  514. extern void    pmvi();
  515. extern void    pmv2i();
  516. extern void    pmvs();
  517. extern void    pmv2s();
  518. extern void    pmv2();
  519. extern void    pdr();
  520. extern void    rpdr();
  521. extern void    rpdr2();
  522. extern void    rpdri();
  523. extern void    rpdr2i();
  524. extern void    rpdrs();
  525. extern void    rpdr2s();
  526. extern void    rpmv();
  527. extern void    rpmv2();
  528. extern void    rpmvi();
  529. extern void    rpmv2i();
  530. extern void    rpmvs();
  531. extern void    rpmv2s();
  532. extern void    pdri();
  533. extern void    pdr2i();
  534. extern void    pdrs();
  535. extern void    pdr2s();
  536. extern void    pdr2();
  537. extern void    pclos();
  538. extern void    bgnpolygon();
  539. extern void    endpolygon();
  540.  
  541. /*
  542.  * rectangle routines
  543.  */
  544. extern void    rect();
  545. extern void    recti();
  546. extern void    rects();
  547. extern void    rectf();
  548. extern void    rectfi();
  549. extern void    rectfs();
  550.  
  551. /*
  552.  * tensor routines
  553.  */
  554. extern void multtensor();
  555. extern void copytensor();
  556. extern void premulttensor();
  557. extern void copytensortrans();
  558.  
  559. /*
  560.  * text routines
  561.  */
  562. extern void    font();
  563. extern void    charstr();
  564. extern void    cmov();
  565. extern void    cmov2();
  566. extern void    cmovi();
  567. extern void    cmovs();
  568. extern void    cmov2i();
  569. extern void    cmov2s();
  570. #ifdef OLD_GL
  571. extern long    getwidth();
  572. #endif
  573. extern long    getheight();
  574. extern long    strwidth();
  575. extern void    getcpos();
  576.  
  577. /*
  578.  * transformation routines
  579.  */
  580. extern void    scale();
  581. extern void    translate();
  582. extern void    rotate();
  583. extern void    rot();
  584.  
  585. /*
  586.  * window definition routines
  587.  */
  588. extern void    ortho();
  589. extern void    ortho2();
  590. extern void    lookat();
  591. extern void    window();
  592. extern void    polarview();
  593. extern void    perspective();
  594.  
  595. /*
  596.  * routines for manipulating the viewport
  597.  */
  598. extern void    viewport();
  599. extern void    popviewport();
  600. extern void    pushviewport();
  601.  
  602. /*
  603.  * routines for retrieving the graphics position
  604.  */
  605. extern void    getgp();
  606. extern void    getgpos();
  607.  
  608. /*
  609.  * routines for handling the buffering
  610.  */
  611. extern void    backbuffer();
  612. extern void    frontbuffer();
  613. extern void    swapbuffers();
  614. extern void    doublebuffer();
  615.  
  616. /*
  617.  * routines for window sizing and positioning
  618.  */
  619. extern void    prefsize();
  620. extern void    prefposition();
  621.  
  622. /*
  623.  * Misc control routines
  624.  */
  625. extern void    vsetflush();
  626. extern void    vflush();
  627.