static void mswindows_init_device (struct device *d, Lisp_Object UNUSED (props)) { HDC hdc; WNDCLASSEXW wc; call0 (Qmake_device_early_mswindows_entry_point); DEVICE_CLASS (d) = Qcolor; DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; init_baud_rate (d); init_one_device (d); #ifdef NEW_GC d->device_data = XMSWINDOWS_DEVICE (ALLOC_NORMAL_LISP_OBJECT (mswindows_device)); #else /* not NEW_GC */ d->device_data = xnew_and_zero (struct mswindows_device); #endif /* not NEW_GC */ hdc = CreateCompatibleDC (NULL); assert (hdc != NULL); DEVICE_MSWINDOWS_HCDC (d) = hdc; DEVICE_MSWINDOWS_FONTLIST (d) = mswindows_enumerate_fonts (hdc); DEVICE_MSWINDOWS_UPDATE_TICK (d) = GetTickCount (); /* Register the main window class */ wc.cbSize = sizeof (wc); wc.style = CS_OWNDC; /* One DC per window */ wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc; wc.cbClsExtra = 0; wc.cbWndExtra = MSWINDOWS_WINDOW_EXTRA_BYTES; /* This must match whatever is passed to CreateWIndowEx, NULL is ok for this. */ wc.hInstance = NULL; wc.hIcon = qxeLoadIcon (qxeGetModuleHandle (NULL), XETEXT (XEMACS_CLASS)); wc.hCursor = qxeLoadCursor (NULL, IDC_ARROW); /* Background brush is only used during sizing, when XEmacs cannot take over */ wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1); wc.lpszMenuName = NULL; wc.lpszClassName = (XELPTSTR) XETEXT (XEMACS_CLASS); wc.hIconSm = (HICON) qxeLoadImage (qxeGetModuleHandle (NULL), XETEXT (XEMACS_CLASS), IMAGE_ICON, 16, 16, 0); qxeRegisterClassEx (&wc); #ifdef HAVE_WIDGETS xzero (wc); /* Register the main window class */ wc.cbSize = sizeof (wc); wc.lpfnWndProc = (WNDPROC) mswindows_control_wnd_proc; wc.lpszClassName = (XELPTSTR) XETEXT (XEMACS_CONTROL_CLASS); wc.hInstance = NULL; qxeRegisterClassEx (&wc); #endif #if defined (HAVE_TOOLBARS) || defined (HAVE_WIDGETS) InitCommonControls (); #endif }
/* Pixel distance lookup ganked from ofxKinect and * http://openkinect.org/wiki/Imaging_Information */ int kinect_init() { int i; const FP_TYPE k1 = 0.1236; const FP_TYPE k2 = 2842.5; const FP_TYPE k3 = 1.1863; const FP_TYPE k4 = 0.0370; /* Populate depthDistance[i], in meters. */ for (i = 1; i < 2047; i++) { depthDistance[i] = k1 * FP_TAN((i/k2) + k3) - k4; /* Colors; Red for bits 0-4, green for bits 5-8, blue for 9-11 */ /* if (!(i&0x7F)) { printf("At distance %d (%f), meters is %f\n", i, i/k2, depthDistance[i]); } */ /* Psychedelic: depthColors[i] = ((i & 0xF) << 20) // Red | ((i & 0xF0) << 8) // Green | ((i & 0xF00) >> 3) // Blue ; */ /* Blue shades: */ /* depthColors[i] = 0xFF // blue | (0x010100 * ((2048-i)>>2)); */ /* if (!(i&0x7F)) { printf("At height %d, color is %.6X\n", i, depthColors[i]); } */ } for (i = 0; i < CUBE_HEIGHT; i++) { cubeColor[i] = 0xFF // blue | ((0x0101 * ((256 * (CUBE_HEIGHT - i)) / CUBE_HEIGHT)) << 8); // printf("Z_COLOR(%d) = %.6X\n", i, cubeColor[i]); } depthDistance[2047] = 0.0; /* Since depth is weirdly curved. */ FP_TYPE angle; for (i = 0; i < SENSOR_WIDTH; i++) { angle = (HANGLE * (i / SENSOR_WIDTH_D)) - (HANGLE/2); horizDepthMultiplier[i] = 1.0 / FP_COS(DEG2RAD(angle)); /* if (!(i&63)) { printf("HorizDepthMultiplier[%d] = %f\n", i, horizDepthMultiplier[i]); } */ } for (i = 0; i < SENSOR_HEIGHT; i++) { angle = (VANGLE * (i / SENSOR_HEIGHT_D)) - (VANGLE/2); vertDepthMultiplier[i] = 1.0 / FP_COS(DEG2RAD(angle)); /* if (!(i&63)) { printf("VertDepthMultiplier[%d] = %f\n", i, vertDepthMultiplier[i]); } */ } /* Init the devices. */ for (numDevices = 0; deviceDefinitions[numDevices].device >= 0; numDevices++); /* Create the devices. */ devices = malloc(numDevices * sizeof(KDevice)); for (i = 0; i < numDevices; i++) { init_one_device(&devices[i], deviceDefinitions[i].device, deviceDefinitions[i].baseX, deviceDefinitions[i].baseY, deviceDefinitions[i].baseZ, deviceDefinitions[i].hangle, deviceDefinitions[i].vangle); } return 1; }