fbio.h

Go to the documentation of this file.
00001 /*                         F B I O . H
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 2005-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 /** \addtogroup libfb */
00022 /*@{*/
00023 /** @file fbio.h
00024  *@brief
00025  *  BRL-CAD Framebuffer Library I/O Interfaces
00026  *
00027  *  @par Source
00028  *      BRL-CAD Open Source
00029  *
00030  *  $Header: /cvsroot/brlcad/brlcad/include/fbio.h,v 1.9 2006/09/18 05:24:07 lbutler Exp $
00031  */
00032 
00033 #ifndef __FBIO_H__
00034 #define __FBIO_H__
00035 
00036 #ifdef USE_PROTOTYPES
00037 #       define  FB_ARGS(args)                   args
00038 #else
00039 #       define  FB_ARGS(args)                   ()
00040 #endif
00041 
00042 #ifndef FB_EXPORT
00043 #   if defined(_WIN32) && !defined(__CYGWIN__) && defined(BRLCAD_DLL)
00044 #      ifdef FB_EXPORT_DLL
00045 #         define FB_EXPORT __declspec(dllexport)
00046 #      else
00047 #         define FB_EXPORT __declspec(dllimport)
00048 #      endif
00049 #   else
00050 #      define FB_EXPORT
00051 #   endif
00052 #endif
00053 
00054 
00055 /**
00056  *                      R G B p i x e l
00057  *
00058  *  Format of disk pixels is .pix raw image files.
00059  *  Formerly used as arguments to many of the library routines,
00060  *  but has fallen into disuse due to the difficulties with
00061  *  ANSI function prototypes, and the fact that arrays are not
00062  *  real types in C.  The most notable problem is that of passing
00063  *  a pointer to an array of RGBpixel.  It looks doubly dimensioned,
00064  *  but isn't.
00065  */
00066 typedef unsigned char RGBpixel[3];
00067 
00068 #define RED     0
00069 #define GRN     1
00070 #define BLU     2
00071 
00072 /**
00073  *                      C o l o r M a p
00074  *
00075  *  These generic color maps have up to 16 bits of significance,
00076  *  left-justified in a short.  Think of this as fixed-point values
00077  *  from 0 to 1.
00078  */
00079 typedef struct  {
00080         unsigned short cm_red[256];
00081         unsigned short cm_green[256];
00082         unsigned short cm_blue[256];
00083 } ColorMap;
00084 
00085 
00086 #define PIXEL_NULL      (unsigned char *) 0
00087 #define RGBPIXEL_NULL   (unsigned char *) 0
00088 #define COLORMAP_NULL   (ColorMap *) 0
00089 #define FBIO_NULL       (FBIO *) 0
00090 
00091 #define FB_MAGIC        0xfbfb00fb
00092 #define FB_CK_FBIO(_p)  FB_CKMAG(_p, FB_MAGIC, "FBIO" )
00093 
00094 
00095 /**
00096  *                      F B I O
00097  *@brief
00098  *  A frame-buffer IO structure.
00099  *
00100  *  One of these is allocated for each active framebuffer.
00101  *  A pointer to this structure is the first argument to all
00102  *  the library routines.
00103  */
00104 typedef struct FBIO_ {
00105         long    if_magic;
00106         /* Static information: per device TYPE. */
00107         int     (*if_open)FB_ARGS((struct FBIO_ *ifp, char *file, int width, int height));              /**< @brief open device         */
00108         int     (*if_close)FB_ARGS((struct FBIO_ *ifp));                                /**< @brief close device                */
00109         int     (*if_clear)FB_ARGS((struct FBIO_ *ifp, unsigned char *pp));             /**< @brief clear device        */
00110         int     (*if_read)FB_ARGS((struct FBIO_ *ifp, int x, int y, unsigned char *pp, int count));             /**< @brief read pixels         */
00111         int     (*if_write)FB_ARGS((struct FBIO_ *ifp, int x, int y, const unsigned char *pp, int count));      /**< @brief write pixels                */
00112         int     (*if_rmap)FB_ARGS((struct FBIO_ *ifp, ColorMap *cmap));         /**< @brief read colormap       */
00113         int     (*if_wmap)FB_ARGS((struct FBIO_ *ifp, const ColorMap *cmap));           /**< @brief write colormap      */
00114         int     (*if_view)FB_ARGS((struct FBIO_ *ifp, int xcent, int ycent, int xzoom, int yzoom));             /**< @brief set view            */
00115         int     (*if_getview)FB_ARGS((struct FBIO_ *ifp, int *xcent, int *ycent, int *xzoom, int *yzoom));      /**< @brief get view            */
00116         int     (*if_setcursor)FB_ARGS((struct FBIO_ *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo)); /**< @brief define cursor       */
00117         int     (*if_cursor)FB_ARGS((struct FBIO_ *ifp, int mode, int x, int y));               /**< @brief set cursor          */
00118         int     (*if_getcursor)FB_ARGS((struct FBIO_ *ifp, int *mode, int *x, int *y)); /**< @brief get cursor          */
00119         int     (*if_readrect)FB_ARGS((struct FBIO_ *ifp, int xmin, int ymin, int width, int height, unsigned char *pp));       /**< @brief read rectangle      */
00120         int     (*if_writerect)FB_ARGS((struct FBIO_ *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp));        /**< @brief write rectangle     */
00121         int     (*if_bwreadrect)FB_ARGS((struct FBIO_ *ifp, int xmin, int ymin, int width, int height, unsigned char *pp));     /**< @brief read monochrome rectangle   */
00122         int     (*if_bwwriterect)FB_ARGS((struct FBIO_ *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp));      /**< @brief write rectangle     */
00123         int     (*if_poll)FB_ARGS((struct FBIO_ *ifp));         /**< @brief handle events       */
00124         int     (*if_flush)FB_ARGS((struct FBIO_ *ifp));        /**< @brief flush output        */
00125         int     (*if_free)FB_ARGS((struct FBIO_ *ifp));         /**< @brief free resources      */
00126         int     (*if_help)FB_ARGS((struct FBIO_ *ifp));         /**< @brief print useful info   */
00127         char    *if_type;               /**< @brief what "open" calls it        */
00128         int     if_max_width;           /**< @brief max device width    */
00129         int     if_max_height;          /**< @brief max device height   */
00130         /* Dynamic information: per device INSTANCE. */
00131         char    *if_name;       /**< @brief what the user called it */
00132         int     if_width;       /**< @brief current values */
00133         int     if_height;
00134         int     if_selfd;       /**< @brief select(fd) for input events if >= 0 */
00135         /* Internal information: needed by the library. */
00136         int     if_fd;          /**< @brief internal file descriptor */
00137         int     if_xzoom;       /**< @brief zoom factors */
00138         int     if_yzoom;
00139         int     if_xcenter;     /**< @brief pan position */
00140         int     if_ycenter;
00141         int     if_cursmode;    /**< @brief cursor on/off */
00142         int     if_xcurs;       /**< @brief cursor position */
00143         int     if_ycurs;
00144         unsigned char *if_pbase;/**< @brief Address of malloc()ed page buffer.  */
00145         unsigned char *if_pcurp;/**< @brief Current pointer into page buffer.   */
00146         unsigned char *if_pendp;/**< @brief End of page buffer.                 */
00147         int     if_pno;         /**< @brief Current "page" in memory.           */
00148         int     if_pdirty;      /**< @brief Page modified flag.                 */
00149         long    if_pixcur;      /**< @brief Current pixel number in framebuffer. */
00150         long    if_ppixels;     /**< @brief Sizeof page buffer (pixels).                */
00151         int     if_debug;       /**< @brief Buffered IO debug flag.             */
00152         /* State variables for individual interface modules */
00153         union   {
00154                 char    *p;
00155                 long    l;
00156         } u1, u2, u3, u4, u5, u6;
00157 } FBIO;
00158 
00159 /* declare all the possible interfaces */
00160 #ifdef IF_REMOTE
00161   FB_EXPORT extern FBIO remote_interface;       /* not in list[] */
00162 #endif
00163 
00164 #ifdef IF_ADAGE
00165   FB_EXPORT extern FBIO adage_interface;
00166 #endif
00167 
00168 #ifdef IF_SUN
00169   FB_EXPORT extern FBIO sun_interface;
00170 #endif
00171 
00172 #if defined(IF_SGI)
00173   FB_EXPORT extern FBIO sgi_interface;
00174 #endif
00175 
00176 #ifdef IF_OGL
00177   FB_EXPORT extern FBIO ogl_interface;
00178 #endif
00179 
00180 #ifdef IF_WGL
00181   FB_EXPORT extern FBIO wgl_interface;
00182 #endif
00183 
00184 #ifdef IF_RAT
00185   FB_EXPORT extern FBIO rat_interface;
00186 #endif
00187 
00188 #ifdef IF_UG
00189   FB_EXPORT extern FBIO ug_interface;
00190 #endif
00191 
00192 #ifdef IF_X
00193   FB_EXPORT extern FBIO X24_interface;
00194   FB_EXPORT extern FBIO X_interface;
00195 #endif
00196 
00197 #ifdef IF_PTTY
00198   FB_EXPORT extern FBIO ptty_interface;
00199 #endif
00200 
00201 #ifdef IF_AB
00202   FB_EXPORT extern FBIO abekas_interface;
00203 #endif
00204 
00205 #ifdef IF_TS
00206   FB_EXPORT extern FBIO ts_interface;
00207 #endif
00208 
00209 #ifdef IF_TK
00210   FB_EXPORT extern FBIO tk_interface;
00211 #endif
00212 
00213 
00214 /* Always included */
00215 FB_EXPORT extern FBIO debug_interface, disk_interface, stk_interface;
00216 FB_EXPORT extern FBIO memory_interface, null_interface;
00217 
00218 #endif  /* __FBIO_H__ */
00219 /*@}*/
00220 /*
00221  * Local Variables:
00222  * mode: C
00223  * tab-width: 8
00224  * c-basic-offset: 4
00225  * indent-tabs-mode: t
00226  * End:
00227  * ex: shiftwidth=4 tabstop=8
00228  */
00229 

Generated on Mon Sep 18 01:24:40 2006 for BRL-CAD by  doxygen 1.4.6