home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / SVGALIB / _SVGALIB.TAR / usr / include / vgagl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-18  |  5.5 KB  |  177 lines

  1. /* Graphics Library headerfile */
  2.  
  3. #ifndef VGAGL_H
  4. #define VGAGL_H
  5.  
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10.  
  11. /* Graphics context */
  12.  
  13. #define CONTEXT_VIRTUAL        0x0
  14. #define CONTEXT_PAGED        0x1
  15. #define CONTEXT_LINEAR        0x2
  16. #define CONTEXT_MODEX        0x3
  17. #define CONTEXT_PLANAR16    0x4
  18.  
  19. #define MODEFLAG_PAGEFLIPPING_CAPABLE        0x01
  20. #define MODEFLAG_TRIPLEBUFFERING_CAPABLE    0x02
  21. #define MODEFLAG_PAGEFLIPPING_ENABLED        0x04
  22. #define MODEFLAG_TRIPLEBUFFERING_ENABLED    0x08
  23. #define MODEFLAG_FLIPPAGE_BANKALIGNED        0x10
  24. #define MODEFLAG_32BPP_SHIFT8            0x20
  25.  
  26. typedef struct {
  27.     int (*driver_setpixel_func)(int, int, int);
  28.     int (*driver_getpixel_func)(int, int);
  29.     int (*driver_hline_func)(int, int, int, int);
  30.     int (*driver_fillbox_func)(int, int, int, int, int);
  31.     int (*driver_putbox_func)(int, int, int, int, void *, int);
  32.     int (*driver_getbox_func)(int, int, int, int, void *, int);
  33.     int (*driver_putboxmask_func)(int, int, int, int, void *);
  34.     int (*driver_putboxpart_func)(int, int, int, int, int, int, void *,
  35.         int, int);
  36.     int (*driver_getboxpart_func)(int, int, int, int, int, int, void *,
  37.         int, int);
  38.     int (*driver_copybox_func)(int, int, int, int, int, int);
  39. } framebufferfunctions;
  40.  
  41. typedef struct {
  42.     unsigned char modetype;        /* virtual, paged, linear, mode X */
  43.     unsigned char modeflags;    /* or planar16 */
  44.     unsigned char dummy;
  45.     unsigned char flippage;
  46.     int width;        /* width in pixels */
  47.     int height;        /* height in pixels */
  48.     int bytesperpixel;    /* bytes per pixel (1, 2, 3, or 4) */
  49.     int colors;        /* number of colors */
  50.     int bitsperpixel;    /* bits per pixel (8, 15, 16 or 24) */
  51.     int bytewidth;        /* length of a scanline in bytes */
  52.     char *vbuf;        /* address of framebuffer */
  53.     int clip;        /* clipping enabled? */
  54.     int clipx1;        /* top-left coordinate of clip window */
  55.     int clipy1;
  56.     int clipx2;        /* bottom-right coordinate of clip window */
  57.     int clipy2;
  58.     framebufferfunctions ff;
  59. } GraphicsContext;
  60.  
  61. extern GraphicsContext currentcontext;
  62.  
  63. #define BYTESPERPIXEL (currentcontext.bytesperpixel)
  64. #define BYTEWIDTH (currentcontext.bytewidth)
  65. #define WIDTH (currentcontext.width)
  66. #define HEIGHT (currentcontext.height)
  67. #define VBUF (currentcontext.vbuf)
  68. #define MODETYPE (currentcontext.modetype)
  69. #define MODEFLAGS (currentcontext.modeflags)
  70. #define BITSPERPIXEL (currentcontext.bitsperpixel)
  71. #define COLORS (currentcontext.colors)
  72.  
  73. #define __clip (currentcontext.clip)
  74. #define __clipx1 (currentcontext.clipx1)
  75. #define __clipy1 (currentcontext.clipy1)
  76. #define __clipx2 (currentcontext.clipx2)
  77. #define __clipy2 (currentcontext.clipy2)
  78.  
  79.  
  80. /* Configuration */
  81.  
  82. int gl_setcontextvga( int m );
  83. int gl_setcontextvgavirtual( int m );
  84. void gl_setcontextvirtual( int w, int h, int bpp, int bitspp, void *vbuf );
  85. void gl_setcontextwidth( int w );
  86. void gl_setcontextheight( int h );
  87. void gl_setcontext( GraphicsContext *gc );
  88. void gl_getcontext( GraphicsContext *gc );
  89. void gl_freecontext( GraphicsContext *gc );
  90.  
  91. /* Line drawing */
  92.  
  93. void gl_setpixel( int x, int y, int c);
  94. void gl_setpixelrgb( int x, int y, int r, int g, int b );
  95. int gl_getpixel( int x, int y );
  96. void gl_getpixelrgb( int x, int y, int *r, int *g, int *b );
  97. int gl_rgbcolor( int r, int g, int b );
  98. void gl_hline( int x1, int y, int x2, int c );
  99. void gl_line( int x1, int y1, int x2, int y2, int c );
  100. void gl_circle( int x, int y, int r, int c );
  101.  
  102. /* Box (bitmap) functions */
  103.  
  104. void gl_fillbox( int x, int y, int w, int h, int c );
  105. void gl_getbox( int x, int y, int w, int h, void *dp );
  106. void gl_putbox( int x, int y, int w, int h, void *dp );
  107. void gl_putboxpart( int x, int y, int w, int h, int bw, int bh, void *b,
  108.     int xo, int yo );
  109. void gl_putboxmask( int x, int y, int w, int h, void *dp );
  110. void gl_copybox( int x1, int y1, int w, int h, int x2, int y2 );
  111. void gl_copyboxtocontext( int x1, int y1, int w, int h, GraphicsContext *gc,
  112.     int x2, int y2 );
  113. void gl_copyboxfromcontext( GraphicsContext *gc, int x1, int y1, int w, int h,
  114.     int x2, int y2 );
  115. /* The following functions only work in 256-color modes: */
  116. void gl_compileboxmask( int w, int h, void *sdp, void *ddp );
  117. int gl_compiledboxmasksize( int w, int h, void *sdp );
  118. void gl_putboxmaskcompiled( int x, int y, int w, int h, void *dp );
  119.  
  120. /* Miscellaneous */
  121.  
  122. void gl_clearscreen( int c );
  123. void gl_scalebox( int w1, int h1, void *sb, int w2, int h2, void *db );
  124. void gl_setdisplaystart( int x, int y );
  125. void gl_enableclipping();
  126. void gl_setclippingwindow( int x1, int y1, int x2, int y2 );
  127. void gl_disableclipping();
  128.  
  129. /* Screen buffering */
  130.  
  131. void gl_copyscreen( GraphicsContext *gc );
  132. void gl_setscreenoffset( int o );
  133. int gl_enablepageflipping( GraphicsContext *gc );
  134.  
  135. /* Text */
  136.  
  137. /* Writemode flags. */
  138. #define WRITEMODE_OVERWRITE 0
  139. #define WRITEMODE_MASKED 1
  140. #define FONT_EXPANDED 0
  141. #define FONT_COMPRESSED 2
  142.  
  143. void gl_expandfont( int fw, int fh, int c, void *sfdp, void *dfdp );
  144. void gl_setfont( int fw, int fh, void *fdp );
  145. void gl_colorfont( int fw, int fh, int c, void *fdp );
  146. void gl_setwritemode( int wm );
  147. void gl_write( int x, int y, char *s );
  148. void gl_writen( int x, int y, int n, char *s );
  149. void gl_setfontcolors( int bg, int fg);
  150.  
  151. extern unsigned char *gl_font8x8;    /* compressed 8x8 font */
  152.  
  153. /* 256-color Palette */
  154.  
  155. typedef struct {
  156.     struct {
  157.         unsigned char red;    /* 6-bit values */
  158.         unsigned char green;
  159.         unsigned char blue;
  160.     } color[256];
  161. } Palette;
  162.  
  163. void gl_setpalettecolor( int c, int r, int b, int g );
  164. void gl_getpalettecolor( int c, int *r, int *b, int *g );
  165. void gl_setpalettecolors( int s, int n, void *dp );
  166. void gl_getpalettecolors( int s, int n, void *dp );
  167. void gl_setpalette( void *p );
  168. void gl_getpalette( void *p );
  169. void gl_setrgbpalette();
  170.  
  171.  
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175.  
  176. #endif
  177.