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 tdmWindow_h 13 #define tdmWindow_h 14 /* 15 * 16 * $Header: /src/master/dx/src/exec/hwrender/hwWindow.h,v 1.6 2003/07/30 22:39:07 davidt Exp $ 17 */ 18 19 #include "hwStereo.h" 20 21 /* 22 ^L 23 *=================================================================== 24 * Defines 25 *=================================================================== 26 */ 27 28 #ifndef FALSE 29 #define FALSE 0 30 #endif 31 32 #ifndef TRUE 33 #define TRUE 1 34 #endif 35 36 37 38 #ifndef UP 39 #define UP 0 40 #define DOWN 1 41 #endif 42 43 /* 44 ^L 45 *=================================================================== 46 * Structure Definitions and Typedefs 47 *=================================================================== 48 */ 49 50 /* 51 * window information 52 */ 53 54 typedef struct WinS { 55 #if defined(DX_NATIVE_WINDOWS) 56 HWND wigWindow ; /* parent window owned by UI process */ 57 HWND xid ; /* X handle to graphics window */ 58 HANDLE busy; 59 HANDLE lock; 60 int canRender; 61 DWORD windowThread; 62 HRGN lrgn; /* left clipping region */ 63 HRGN rrgn; /* right clipping region */ 64 int useGLStereo; /* whether or not we're using GL stereo */ 65 #else 66 Display *dpy ; /* X display connection to window */ 67 Window wigWindow ; /* parent window owned by UI process */ 68 Window msgWindow ; /* window which receives UI messages */ 69 Window toplevel ; /* top level UI shell */ 70 Window xid ; /* X handle to graphics window */ 71 Window lxid ; /* X handle to graphics window for left stereo image */ 72 Window rxid ; /* X handle to graphics window for right stereo image */ 73 Colormap xColormap ; /* X colormap for graphics window */ 74 #endif 75 int visibility ; /* visibility state of X window */ 76 tdmPortHandleP phP ; /* graphics API context */ 77 void *curcam ; /* current camera object */ 78 void *curobj ; /* current object to render */ 79 int x, y ; /* window position */ 80 int w, h ; /* window width and height in pixels */ 81 int depth ; /* window depth */ 82 int vpw, vph ; /* viewport width/height in pixels */ 83 int correctSize ; /* UI and HW agree on window size? */ 84 int bufferMode ; /* double or single buffer mode? */ 85 void *buf ; /* handle to SW image buffer */ 86 int bufCurrent ; /* SW image current? */ 87 int buffSize ; /* size of SW image */ 88 void *saveBuf ; /* handle to HW image buffer */ 89 int saveBufValid ; /* HW image current? */ 90 int saveBufSize ; /* size of HW image */ 91 tdmInteractorWin interactorData ; /* handle to interactor common data */ 92 void *matrixStack ; /* SW matrix stack shadow */ 93 int mapped ; /* graphics window mapped? */ 94 int camtag ; /* tag of last camera used */ 95 int objtag ; /* tag of last object rendered */ 96 int gl_window ; /* GL window exist? */ 97 /* #X */ int uitype; 98 char *where; /* original where parameter */ 99 int link; /* whether its a '#X window */ 100 char *originalWhere; 101 long pad[12] ; /* under construction */ 102 103 int saveBufObjectTag; 104 int saveBufCameraTag; 105 106 int stereoSystemMode; 107 int stereoCameraMode; 108 float currentFrom[3]; 109 float currentTo[3]; 110 float currentUp[3]; 111 float currentWidth; 112 float currentFov; 113 void *stereoCameraData; 114 WindowInfo leftWindowInfo; 115 WindowInfo rightWindowInfo; 116 117 } WinT ; 118 119 120 /* 121 * Renderer state. References to `child' are historical. 122 */ 123 124 typedef struct tdmChildGlobalS { 125 #if defined(DX_NATIVE_WINDOWS) 126 dxObject owner; 127 #endif 128 tdmHWDescP adapter ; /* hardware description */ 129 WinT win ; /* window description */ 130 char *cacheId ; /* renderer state handle in cache */ 131 132 int executeOnChange ; /* Execute Once / Execute On Change */ 133 int displayGlobe ; /* display or don't display globe */ 134 135 dxObject gather; 136 int gatherTag; 137 138 tdmInteractor Globe ; /* handles to direct interactors */ 139 tdmInteractor Roamer ; 140 tdmInteractor Cursor3D ; 141 tdmInteractor Zoomer ; 142 tdmInteractor ViewRotate ; 143 tdmInteractor GnomonRotate ; 144 tdmInteractor CrntInteractor ; 145 tdmInteractor Navigator ; 146 tdmInteractor PanZoom ; 147 tdmInteractor CursorGroup ; 148 tdmInteractor RoamGroup ; 149 tdmInteractor RotateGroup ; 150 tdmInteractor ViewTwirl ; 151 tdmInteractor GnomonTwirl ; 152 tdmInteractor Pick ; 153 tdmInteractor User; 154 155 HashTable meshHash; 156 HashTable textureHash; 157 SortList sortList; 158 159 long pad[11] ; /* under construction */ 160 } tdmChildGlobalT ; 161 162 /* 163 * The following macros are used to access global data from the port 164 * implementations. As the number of tdm ports grow, it is very 165 * important for maintainability to use these macros instead of accessing 166 * the data structure directly from the port level; otherwise we'll have 167 * to update several groups of files in parallel if the data structure 168 * ever changes. 169 * 170 * Every port layer routine which needs access only to the data in the 171 * WinT data structure should declare its first parameter as "void *" and 172 * use the DEFWINDATA macro as the first statement in the body of the 173 * function. 174 * 175 * A port layer routine which needs access to the entire _dxdChildGlobals 176 * data structure should declare its first parameter as "void *" and use 177 * the DEFGLOBALDATA macro as the first statement in the body of the 178 * function. 179 * 180 * See hwPortGL.c for examples. 181 */ 182 183 #define DEFWINDATA(W) register WinT* _wdata = (WinT*) W 184 185 #define DPY (_wdata->dpy) 186 #define XWINID (_wdata->xid) 187 #define CAN_RENDER (_wdata->canRender) 188 #define PARENT_WINDOW (_wdata->wigWindow) 189 #define PORT_HANDLE (_wdata->phP) 190 #define CLRMAP (_wdata->xColormap) 191 #define CAMERA (_wdata->curcam) 192 #define OBJECT (_wdata->curobj) 193 #define PIXW (_wdata->w) 194 #define PIXH (_wdata->h) 195 #define SW_BUF (_wdata->buf) 196 #define SAVE_BUF (_wdata->saveBuf) 197 #define SAVE_BUF_SIZE (_wdata->saveBufSize) 198 #define SAVE_BUF_VALID (_wdata->saveBufValid) 199 #define BUFFER_MODE (_wdata->bufferMode) 200 #define INTERACTOR_DATA (_wdata->interactorData) 201 #define MATRIX_STACK (_wdata->matrixStack) 202 #define GL_WINDOW (_wdata->gl_window) 203 #define SAVEBUFOBJECTTAG (_wdata->saveBufObjectTag) 204 #define SAVEBUFCAMERATAG (_wdata->saveBufObjectTag) 205 206 207 /* #X follows */ 208 #define UI_TYPE (_wdata->uitype) 209 210 #define DXD_DXUI 1 211 #define DXD_EXTERNALUI 2 212 #define DXD_NOUI 3 213 #define DXUI (UI_TYPE == DXD_DXUI) 214 #define EXTERNALUI (UI_TYPE == DXD_EXTERNALUI) 215 #define NOUI (UI_TYPE == DXD_NOUI) 216 /* #X end */ 217 218 #define WHERE (_wdata->where) 219 #define LINK (_wdata->link) 220 #define ORIGINALWHERE (_wdata->originalWhere) 221 222 #define STEREOSYSTEMMODE (_wdata->stereoSystemMode) 223 #define STEREOCAMERAMODE (_wdata->stereoCameraMode) 224 #define STEREOCAMERADATA (_wdata->stereoCameraData) 225 226 #if defined(DX_NATIVE_WINDOWS) 227 #define LEFTWINDOW (_wdata->lrgn) 228 #define RIGHTWINDOW (_wdata->rrgn) 229 #define USEGLSTEREO (_wdata->useGLStereo) 230 #else 231 #define LEFTWINDOW (_wdata->lxid) 232 #define RIGHTWINDOW (_wdata->rxid) 233 #endif 234 #define CURRENT_UP (_wdata->currentUp) 235 #define CURRENT_FROM (_wdata->currentFrom) 236 #define CURRENT_TO (_wdata->currentTo) 237 #define CURRENT_FOV (_wdata->currentFov) 238 #define CURRENT_WIDTH (_wdata->currentWidth) 239 #define LEFTWINDOWINFO (_wdata->leftWindowInfo) 240 #define RIGHTWINDOWINFO (_wdata->rightWindowInfo) 241 242 /* added by TJM */ 243 #define TOPLEVEL (_wdata->toplevel) 244 #define PIXX (_wdata->x) 245 #define PIXY (_wdata->y) 246 #define PIXDEPTH (_wdata->depth) 247 #define MAPPED (_wdata->mapped) 248 #define VISIBILITY (_wdata->visibility) 249 #define CORRECT_SIZE (_wdata->correctSize) 250 #define OBJECT_TAG (_wdata->objtag) 251 #define CAMERA_TAG (_wdata->camtag) 252 #define MSG_WINDOW (_wdata->msgWindow) 253 #define SW_BUF_CURRENT (_wdata->bufCurrent) 254 #define SW_BUF_SIZE (_wdata->buffSize) 255 #define VIEWPORT_W (_wdata->vpw) 256 #define VIEWPORT_H (_wdata->vph) 257 #define LWIN ((WinP)_wdata) /* Use only to pass win to functions */ 258 259 260 #define DEFGLOBALDATA(G) \ 261 register tdmChildGlobalT* _gdata = (tdmChildGlobalT*) G ; \ 262 DEFWINDATA(&(((tdmChildGlobalT*) G)->win)) 263 264 #define GATHER (_gdata->gather) 265 #define GATHER_TAG (_gdata->gatherTag) 266 #define SORTLIST (_gdata->sortList) 267 #define MESHHASH (_gdata->meshHash) 268 #define TEXTUREHASH (_gdata->textureHash) 269 270 271 void _dxfSetCurrentView(WinP, float *, float *, float *, float, float); 272 273 #if defined(DX_NATIVE_WINDOWS) 274 275 #define BASE (_wdata->busy); 276 #define WINDOWTHREAD (_wdata->windowThread) 277 #define LOCK (_wdata->lock) 278 279 typedef struct _OGLWindow 280 { 281 HGLRC hRC; 282 void *globals; 283 PAINTSTRUCT ps; 284 int repaint; 285 long lastX, lastY; 286 int stroke; 287 int quit; 288 int buttonState; 289 } OGLWindow; 290 291 292 #ifdef _WIN32 293 #define GetOGLWPtr(hwnd) (OGLWindow *)GetWindowLong((hwnd),0) 294 #define SetOGLWPtr(hwnd,ptr) SetWindowLong((hwnd),0,(LONG)(ptr)) 295 #else 296 #define GetOGLWPtr(hwnd) (OGLWindow *)GetWindowLong((hwnd),0) 297 #define SetOGLWPtr(hwnd,ptr) SetWindowLong((hwnd),0,(WORD)(ptr)) 298 #endif 299 300 #endif 301 302 303 /* 304 *=================================================================== 305 * END OF FILE 306 * $Source: /src/master/dx/src/exec/hwrender/hwWindow.h,v $ 307 *=================================================================== 308 */ 309 #endif /* tdmWindow_h */ 310