Back to index

radiance  4R0+20100331
rhd_odraw.h
Go to the documentation of this file.
00001 /* RCSid $Id: rhd_odraw.h,v 3.13 2005/01/07 20:33:02 greg Exp $ */
00002 /*
00003  * Header for OpenGL cone drawing routines with depth buffer checks.
00004  *
00005  * Include after "standard.h"
00006  */
00007 #ifndef _RAD_RHD_ODRAW_H_
00008 #define _RAD_RHD_ODRAW_H_
00009 
00010 #include "color.h"
00011 #include "tonemap.h"
00012 #include "rhdriver.h"
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 extern struct ODview {
00019        int    sfirst, snext;       /* first sample and first in next view */
00020        short  hhi, vhi;     /* screen image resolution */
00021        short  hlow, vlow;   /* block resolution */
00022        int    n2redraw;     /* approx. number of samples needing redraw */
00023        struct ODblock {
00024               short  nsamp;        /* number of samples in block */
00025               short  nused;        /* number actually allocated */
00026               int    first;        /* first sample in this block */
00027               int    free;         /* index for block free list */
00028               float  pthresh;      /* proximity threshold */
00029        }      *bmap;        /* low resolution image map */
00030        int32  *emap;        /* low resolution edge presence map */
00031        int32  *pmap;        /* high resolution presence map */
00032        GLfloat       *dmap;        /* high resolution depth map */
00033 } *odView;           /* our view list */
00034 
00035 extern int    odNViews;     /* number of views in our list */
00036 
00037 extern TMstruct      *tmGlobal;    /* global tone-mapping structure */
00038 
00039 extern struct ODsamp {
00040        union ODfunion {
00041               float  prox;                /* viewpoint proximity */
00042               int32  next;                /* next in free list */
00043               
00044        } *f;                       /* free list next or proximity */
00045        short         (*ip)[2];     /* image position array */
00046        TMbright      *brt;         /* encoded brightness array */
00047        BYTE          (*chr)[3];    /* encoded chrominance array */
00048        BYTE          (*rgb)[3];    /* tone-mapped color array */
00049        int32         *redraw;      /* redraw flags */
00050        int           nsamp;        /* total number of samples */
00051        char          *base;        /* base of allocated memory */
00052 } odS;               /* sample values */
00053 
00054 #ifndef FL4OP
00055 #define FL4OP(f,i,op)       ((f)[(i)>>5] op (1L<<((i)&0x1f)))
00056 #define CHK4(f,i)    FL4OP(f,i,&)
00057 #define SET4(f,i)    FL4OP(f,i,|=)
00058 #define CLR4(f,i)    FL4OP(f,i,&=~)
00059 #define TGL4(f,i)    FL4OP(f,i,^=)
00060 #define FL4NELS(n)   (((n)+0x1f)>>5)
00061 #define CLR4ALL(f,n) memset((char *)(f),'\0',FL4NELS(n)*sizeof(int32))
00062 #endif
00063 
00064 #define OMAXDEPTH    32000                /* maximum depth value */
00065 
00066 #define nextfree(i)  f[i].next            /* free pointers */
00067 #define closeness(i) f[i].prox            /* viewpoint proximity */
00068 #define ENDFREE             (-1)                 /* free list terminator */
00069 
00070 #define odClean()    odInit(odS.nsamp)    /* clear samples */
00071 #define odDone()     odInit(0)            /* free samples */
00072 
00073 
00074 /*****************************************************************************
00075  * Interface routines:
00076 
00077 
00078 int
00079 odInit(nsamps)                     : allocate and initialize memory
00080 int    nsamps;                     : number of samples to make available
00081 
00082 If nsamps is zero, then this becomes a deallocation routine.  If nsamps
00083 is the same as last time, then this merely clears all data.  The dev_auxview()
00084 function may be called to determine the current view(s).  The odAlloc()
00085 function returns the number of samples actually allocated.
00086 
00087 
00088 void
00089 odSample(c, d, p)           : register new sample value
00090 COLR   c;                   : pixel color (RGBE)
00091 FVECT  d;                   : ray direction vector
00092 FVECT  p;                   : world intersection point
00093 
00094 If p is NULL, then the point is at infinity.
00095 
00096 
00097 void
00098 odDepthMap(vn, dm)          : set depth map for the given view
00099 int    vn;                  : view number
00100 GLfloat       *dm;                 : depth map
00101 
00102 Assign the depth map associated with view number vn.  The map has
00103 been preallocated, and won't be freed until it is no longer needed
00104 (after an odAlloc() call).  All depth values are the projected
00105 distance along the view direction from the view origin.  If dm
00106 is NULL, then there is no depth map associated with this view.
00107 
00108 
00109 void
00110 odRedraw(vn, x0, y0, x1, y1)       : region needs to be redrawn
00111 int    vn;                  : view number
00112 int    x0, y0, x1, y1;             : rectangle to redraw
00113 
00114 This call indicates that the given rectangular region in view vn
00115 needs to be redrawn in the next call to odUpdate().
00116 
00117 
00118 void
00119 odRedrawAll()               : everything needs to be redrawn
00120 
00121 Redraw everything in all views on the next call to odUpdate().
00122 Unless odRemap() is called, no new tone mapping will be done.
00123 
00124 
00125 void
00126 odUpdate(vn)                : update the current view
00127 int    vn;                  : view number
00128 
00129 Draw all new and undrawn sample values since last call for this view.
00130 
00131 
00132 void
00133 odRemap(newhist)            : recompute tone mapping
00134 int    newhist;             : flag whether to clear history
00135 
00136 Recompute the tone mapping for all the samples in all the views
00137 and redraw them on the next call(s) to odUpdate().  If newhist
00138 is non-zero, then clear the previous sample history.
00139 
00140  **********************************************************************/
00141 
00142        /* rhd_geom.c */
00143 void gmNewGeom( char *file);
00144 extern void gmEndGeom(void);
00145 extern int gmDrawGeom(void);
00146 extern void gmDrawPortals(int r, int g, int b, int a);
00147 extern void gmDepthLimit( double dl[2], FVECT vorg, FVECT vdir);
00148 extern void gmNewPortal(char *pflist);
00149 extern int gmEndPortal(void);
00150        /* rhd_odraw.c */
00151 extern int odInit(int n);
00152 extern void odSample(COLR c, FVECT d, FVECT p);
00153 extern void odRemap(int newhist);
00154 extern void odRedrawAll(void);
00155 extern void odRedraw(int vn, int hmin, int vmin, int hmax, int vmax);
00156 extern void odDepthMap(int vn, GLfloat *dm);
00157 extern void odUpdate(int vn);
00158 
00159 
00160 #ifdef __cplusplus
00161 }
00162 #endif
00163 #endif /* _RAD_RHD_ODRAW_H_ */
00164