37 #if defined(__APPLE__) 38 #include <GLUT/glut.h> 113 glTexImage2D(GL_TEXTURE_2D, 0, 3, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE,
rgb_front);
115 glBegin(GL_TRIANGLE_FAN);
116 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
117 glTexCoord2f(0, 0); glVertex3f(0,0,0);
118 glTexCoord2f(1, 0); glVertex3f(640,0,0);
119 glTexCoord2f(1, 1); glVertex3f(640,480,0);
120 glTexCoord2f(0, 1); glVertex3f(0,480,0);
124 glTexImage2D(GL_TEXTURE_2D, 0, 4, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE,
depth_front);
126 glBegin(GL_TRIANGLE_FAN);
127 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
128 glTexCoord2f(0, 0); glVertex3f(0,0,0);
129 glTexCoord2f(1, 0); glVertex3f(640,0,0);
130 glTexCoord2f(1, 1); glVertex3f(640,480,0);
131 glTexCoord2f(0, 1); glVertex3f(0,480,0);
137 if (
frame % 30 == 0) {
138 int ms = glutGet(GLUT_ELAPSED_TIME);
146 if (key == 27 || key ==
'q') {
150 glutDestroyWindow(
window);
163 glViewport(0,0,Width,Height);
164 glMatrixMode(GL_PROJECTION);
166 glOrtho (0, 640, 480, 0, -1.0f, 1.0f);
167 glMatrixMode(GL_MODELVIEW);
173 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
175 glDepthFunc(GL_LESS);
176 glDepthMask(GL_FALSE);
177 glDisable(GL_DEPTH_TEST);
179 glDisable(GL_ALPHA_TEST);
180 glEnable(GL_TEXTURE_2D);
181 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
182 glShadeModel(GL_FLAT);
186 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
187 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
191 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
192 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
199 printf(
"GL thread\n");
202 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
203 glutInitWindowSize(640, 480);
204 glutInitWindowPosition(0, 0);
206 window = glutCreateWindow(
"libfreenect Registration viewer");
228 for (i=0; i<640*480; i++) {
230 int pval =
t_gamma[depth[i]] / 4;
231 int lb = pval & 0xff;
304 printf(
"'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format\n");
308 if (res < 0 && res != -10) {
309 printf(
"\nError %d received from libusb - aborting.\n",res);
313 printf(
"\nshutting down streams...\n");
321 printf(
"-- done!\n");
325 int main(
int argc,
char **argv)
335 printf(
"Kinect camera test\n");
338 for (i=0; i<10000; i++) {
348 printf(
"freenect_init() failed\n");
356 printf (
"Number of devices found: %d\n", nr_devices);
358 int user_device_number = 0;
360 user_device_number = atoi(argv[1]);
362 if (nr_devices < 1) {
368 printf(
"Could not open device\n");
375 printf(
"pthread_create failed\n");
void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb)
void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs)
int freenect_stop_video(freenect_device *dev)
pthread_cond_t gl_frame_cond
int freenect_num_devices(freenect_context *ctx)
int freenect_start_depth(freenect_device *dev)
int main(int argc, char **argv)
int freenect_set_video_buffer(freenect_device *dev, void *buf)
void * gl_threadfunc(void *arg)
int freenect_shutdown(freenect_context *ctx)
int freenect_set_video_mode(freenect_device *dev, const freenect_frame_mode mode)
void freenect_set_depth_callback(freenect_device *dev, freenect_depth_cb cb)
void freenect_set_log_level(freenect_context *ctx, freenect_loglevel level)
int freenect_start_video(freenect_device *dev)
freenect_frame_mode freenect_find_video_mode(freenect_resolution res, freenect_video_format fmt)
void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp)
freenect_frame_mode freenect_find_depth_mode(freenect_resolution res, freenect_depth_format fmt)
void keyPressed(unsigned char key, int x, int y)
void rgb_cb(freenect_device *dev, void *rgb, uint32_t timestamp)
int freenect_close_device(freenect_device *dev)
int freenect_set_depth_mode(freenect_device *dev, const freenect_frame_mode mode)
int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index)
void * freenect_threadfunc(void *arg)
void InitGL(int Width, int Height)
int freenect_stop_depth(freenect_device *dev)
int freenect_process_events(freenect_context *ctx)
pthread_mutex_t gl_backbuf_mutex
int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx)
void ReSizeGLScene(int Width, int Height)
pthread_t freenect_thread