1 /***********************************************************************/ 2 /* Open Visualization Data Explorer */ 3 /* (C) Copyright IBM Corp. 1989,1999 */ 4 /* ALL RIGHTS RESERVED */ 5 /* This code licensed under the */ 6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ 7 /***********************************************************************/ 8 9 #include <dxconfig.h> 10 11 12 #ifndef hwPortSB_h 13 #define hwPortSB_h 14 /*---------------------------------------------------------------------------*\ 15 $Source: /src/master/dx/src/exec/hwrender/starbase/hwPortSB.h,v $ 16 Author: Mark Hood 17 18 Data structures used by starbase implementation of tdm renderer. 19 20 \*---------------------------------------------------------------------------*/ 21 22 #include <X11/Xutil.h> 23 24 #define NOBUFFER 0 25 #define BCKBUFFER 1 26 #define FRNTBUFFER 2 27 #define BOTHBUFFERS 3 28 #define MAX_CLIP_PLANES 6 29 30 typedef struct tdmImageSBS { /* 3 banks to make 24 planes*/ 31 unsigned char *saveBufRed ; /* Bank 0 - Red - 8 planes */ 32 unsigned char *saveBufGreen ; /* Bank 1 - Green - 8 planes */ 33 unsigned char *saveBufBlue ; /* Bank 2 - Blue - 8 planes */ 34 } tdmImageSBT, *tdmImageSBP ; 35 36 typedef struct tdmClipPlaneSBS { 37 Point pt; 38 Vector normal; 39 } tdmClipPlaneSBT,*tdmClipPlane; 40 typedef struct tdmSBctxS 41 { 42 int fildes ; /* file descriptor used for all SB calls */ 43 int lightState ; 44 int ambient_id ; 45 int win_height ; /* DX notion of window height */ 46 int vp_left, vp_right, /* Current Viewport dimensions */ 47 vp_bottom, vp_top ; 48 int buffer_config_mode ; /* BCKBUFFER, FRNTBUFFER */ 49 int buffer_state ; /* Even number is Buffer 0 (lower half) 50 Odd number is Buffer 1 (upper half) */ 51 int hidden_surface ; /* Hidden surface removal flag -> TRUE(1) */ 52 int planes ; /* Number of HW Image planes */ 53 int color_map ; /* Color DXMap --FULL, NORMAL, or MONOTONIC */ 54 Display *dpy_sb ; /* X display connection to window */ 55 int screen_sb ; /* X screen used */ 56 Window xwindow_id ; /* Same as XWINID, _wdata->xid in hwWindow.h */ 57 int xwin_width, xwin_height ; /* window width and height in pixels */ 58 int xmaxscreen, ymaxscreen ; 59 void *gnobeBuffer ; /* handle to HW globe/gnomon image buffer */ 60 int singleBuffer ; /* single buffer mode -> TRUE(1) */ 61 hwTranslationP translation ; /* translation for _dxf_dither */ 62 float clipPlanes[6 * 6]; /* model clip planes (6 planes * 6 coords) */ 63 int clipPlaneCnt ; /* number of active clip planes */ 64 } tdmSBctxT, *tdmSBctx ; 65 66 #define DEFCONTEXT(ctx) \ 67 register tdmSBctx _portContext = (tdmSBctx)ctx 68 69 #define FILDES (((tdmSBctx)_portContext)->fildes) 70 #define LIGHTSTATE (((tdmSBctx)_portContext)->lightState) 71 #define AMBIENT_ID (((tdmSBctx)_portContext)->ambient_id) 72 #define VP_LEFT (((tdmSBctx)_portContext)->vp_left) 73 #define VP_RIGHT (((tdmSBctx)_portContext)->vp_right) 74 #define VP_BOTTOM (((tdmSBctx)_portContext)->vp_bottom) 75 #define VP_TOP (((tdmSBctx)_portContext)->vp_top) 76 #define BUFFER_CONFIG_MODE (((tdmSBctx)_portContext)->buffer_config_mode) 77 #define BUFFER_STATE (((tdmSBctx)_portContext)->buffer_state) 78 #define WIN_HEIGHT (((tdmSBctx)_portContext)->win_height) 79 #define HIDDEN_SURFACE (((tdmSBctx)_portContext)->hidden_surface) 80 #define COLOR_MAP (((tdmSBctx)_portContext)->color_map) 81 #define PLANES (((tdmSBctx)_portContext)->planes) 82 #define DPY_SB (((tdmSBctx)_portContext)->dpy_sb) 83 #define SCREEN_SB (((tdmSBctx)_portContext)->screen_sb) 84 #define XWINDOW_ID (((tdmSBctx)_portContext)->xwindow_id) 85 #define XWIN_WIDTH (((tdmSBctx)_portContext)->xwin_width) 86 #define XWIN_HEIGHT (((tdmSBctx)_portContext)->xwin_height) 87 #define XMAXSCREEN (((tdmSBctx)_portContext)->xmaxscreen) 88 #define YMAXSCREEN (((tdmSBctx)_portContext)->ymaxscreen) 89 #define GNOBE_BUF (((tdmSBctx)_portContext)->gnobeBuffer) 90 #define SINGLE_BUF (((tdmSBctx)_portContext)->singleBuffer) 91 #define SBTRANSLATION (((tdmSBctx)_portContext)->translation) 92 #define SBCLIPPLANES (((tdmSBctx)_portContext)->clipPlanes) 93 #define SBCLIPPLANECNT (((tdmSBctx)_portContext)->clipPlaneCnt) 94 95 #define CLAMP(c) (c > 1.0 ? 1.0 : (c < 0.0 ? 0.0 : c)) 96 #define SET_COLOR(f, i) (color_map? SET_CMAP_COLOR(f,i): SET_CDIR_COLOR(f,i)) 97 #define SET_CDIR_COLOR(f,i) (f(FILDES, \ 98 CLAMP(fcolors[i].r), \ 99 CLAMP(fcolors[i].g), \ 100 CLAMP(fcolors[i].b))) 101 #define SET_CMAP_COLOR(f,i) (f(FILDES, \ 102 CLAMP(color_map[((char *)fcolors)[i]].r), \ 103 CLAMP(color_map[((char *)fcolors)[i]].g), \ 104 CLAMP(color_map[((char *)fcolors)[i]].b))) 105 106 #define IS_2D(array,type,rank,shape) \ 107 (DXGetArrayInfo (array, NULL, &type, NULL, &rank, NULL) && \ 108 rank == 1 && type == TYPE_FLOAT && \ 109 DXGetArrayInfo (array, NULL, NULL, NULL, NULL, &shape) && \ 110 shape == 2) 111 112 #endif /* hwPortSB_h */ 113