36 #if defined(__APPLE__) 37 #include <GLUT/glut.h> 105 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
108 glEnable(GL_TEXTURE_2D);
111 glTexImage2D(GL_TEXTURE_2D, 0, 3, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE,
depth_front);
113 glBegin(GL_TRIANGLE_FAN);
114 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
115 glTexCoord2f(0, 0); glVertex3f(0,0,0);
116 glTexCoord2f(1, 0); glVertex3f(640,0,0);
117 glTexCoord2f(1, 1); glVertex3f(640,480,0);
118 glTexCoord2f(0, 1); glVertex3f(0,480,0);
143 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
146 glEnable(GL_TEXTURE_2D);
150 glTexImage2D(GL_TEXTURE_2D, 0, 3, frame_mode.
width, frame_mode.
height, 0, GL_RGB, GL_UNSIGNED_BYTE,
rgb_front);
152 glTexImage2D(GL_TEXTURE_2D, 0, 1, frame_mode.
width, frame_mode.
height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
rgb_front);
154 glBegin(GL_TRIANGLE_FAN);
155 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
156 glTexCoord2f(0, 0); glVertex3f(0,0,0);
157 glTexCoord2f(1, 0); glVertex3f(frame_mode.
width,0,0);
158 glTexCoord2f(1, 1); glVertex3f(frame_mode.
width,frame_mode.
height,0);
159 glTexCoord2f(0, 1); glVertex3f(0,frame_mode.
height,0);
229 glViewport(0,0,Width,Height);
230 glMatrixMode(GL_PROJECTION);
232 glOrtho (0, Width, Height, 0, -1.0f, 1.0f);
233 glMatrixMode(GL_MODELVIEW);
238 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
240 glDepthFunc(GL_LESS);
241 glDisable(GL_DEPTH_TEST);
243 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
244 glShadeModel(GL_SMOOTH);
247 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
248 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
251 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
252 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
258 printf(
"GL thread\n");
262 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
263 glutInitWindowSize(640, 480);
264 glutInitWindowPosition(0, 0);
273 glutInitWindowPosition(640,0);
298 for (i=0; i<640*480; i++) {
300 int lb = pval & 0xff;
373 while (!
die && status >= 0) {
394 printf(
"Something went terribly wrong. Aborting.\n");
398 printf(
"\nshutting down streams...\n");
406 printf(
"-- done!\n");
410 int main(
int argc,
char **argv)
417 printf(
"Kinect camera test\n");
420 for (i=0; i<2048; i++) {
430 printf(
"freenect_init() failed\n");
438 printf (
"Number of devices found: %d\n", nr_devices);
440 int user_device_number = 0;
442 user_device_number = atoi(argv[1]);
444 if (nr_devices < 1) {
450 printf(
"Could not open device\n");
457 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_mutex_t video_mutex
int freenect_num_devices(freenect_context *ctx)
void InitGL(int Width, int Height)
void * gl_threadfunc(void *arg)
void keyPressed(unsigned char key, int x, int y)
int freenect_start_depth(freenect_device *dev)
int freenect_set_led(freenect_device *dev, freenect_led_options option)
int freenect_set_video_buffer(freenect_device *dev, void *buf)
int freenect_shutdown(freenect_context *ctx)
pthread_mutex_t depth_mutex
freenect_resolution current_resolution
void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp)
void ReSizeGLScene(int Width, int Height)
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)
freenect_video_format current_format
freenect_frame_mode freenect_find_depth_mode(freenect_resolution res, freenect_depth_format fmt)
pthread_cond_t gl_frame_cond
pthread_t freenect_thread
int freenect_close_device(freenect_device *dev)
int freenect_set_depth_mode(freenect_device *dev, const freenect_frame_mode mode)
freenect_frame_mode freenect_get_current_video_mode(freenect_device *dev)
int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index)
void * freenect_threadfunc(void *arg)
int main(int argc, char **argv)
int freenect_stop_depth(freenect_device *dev)
void video_cb(freenect_device *dev, void *rgb, uint32_t timestamp)
freenect_resolution requested_resolution
freenect_video_format requested_format
int freenect_process_events(freenect_context *ctx)
int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx)