示例#1
0
static gint eventDelete(GtkWidget *widget, GdkEvent *event, gpointer data)
{
  closeSample(widget);

  /* indicate that closeapp  already destroyed the window */
  return TRUE;
}
示例#2
0
static void closeapp(GtkWidget *widget, gpointer data)
{
  GtkWidget *app = GTK_WIDGET(data);

  closeSample(app);
}
示例#3
0
int main(int argc, char* argv[])
{
    
    XnBool bChooseDevice = false;
	const char* csRecordingName = NULL;
    
	if (argc > 1)
	{
		if (strcmp(argv[1], "-devices") == 0)
		{
			bChooseDevice = TRUE;
		}
		else
		{
			csRecordingName = argv[1];
		}
	}
    
	if (csRecordingName != NULL)
	{
		// check if running from a different directory. If so, we need to change directory
		// to the real one, so that path to INI file will be OK (for log initialization, for example)
		if (0 != changeDirectory(argv[0]))
		{
			return(ERR_DEVICE);
		}
	}
    
	// Xiron Init
	XnStatus rc = XN_STATUS_OK;
	EnumerationErrors errors;
    
	if (csRecordingName != NULL)
	{
		xnLogInitFromXmlFile(SAMPLE_XML_PATH);
		rc = openDeviceFile(argv[1]);
	}
	else if (bChooseDevice)
	{
		rc = openDeviceFromXmlWithChoice(SAMPLE_XML_PATH, errors);
	}
	else
	{
		rc = openDeviceFromXml(SAMPLE_XML_PATH, errors);
	}
    
	if (rc == XN_STATUS_NO_NODE_PRESENT)
	{
		XnChar strError[1024];
		errors.ToString(strError, 1024);
		printf("%s\n", strError);
		closeSample(ERR_DEVICE);
		return (rc);
	}
	else if (rc != XN_STATUS_OK)
	{
		printf("Open failed: %s\n", xnGetStatusString(rc));
		closeSample(ERR_DEVICE);
	}
    
	captureInit();
	statisticsInit();
    
	//reshaper.zNear = 1;
	//reshaper.zFar = 100;
	//glut_add_interactor(&reshaper);
    
	//cb.mouse_function = MouseCallback;
	//cb.motion_function = MotionCallback;
	//cb.passive_motion_function = MotionCallback;
	//cb.keyboard_function = KeyboardCallback;
	//cb.reshape_function = ReshapeCallback;
	//glut_add_interactor(&cb);
    
    glutInit(&argc, argv);
	glutInitDisplayString("stencil double rgb");
	glutInitWindowSize(WIN_SIZE_X, WIN_SIZE_Y);
	glutCreateWindow("OpenNI Viewer");
	//glutFullScreen();
	glutSetCursor(GLUT_CURSOR_NONE);
    
    glutMouseFunc(MouseCallback);
    glutMotionFunc(MotionCallback);
    
    init_opengl();
    
    glutIdleFunc(IdleCallback);
	glutDisplayFunc(drawFunctionMain);
    glutPassiveMotionFunc(MotionCallback);
    
	//createKeyboardMap();
	//createMenu();

    atexit(onExit);
    
    //Use built in hand tracker class to handle all hand movements and gestures
    HandTracker mainHandTracker(g_Context);
    m_HandTracker = &mainHandTracker;
    
    drawInit(m_HandTracker);
    
    //mainHandTracker.Init();
    //mainHandTracker.Run();
    xn::ImageGenerator test;
    g_Context.FindExistingNode(XN_NODE_TYPE_IMAGE, test);
    xn::DepthGenerator depth;
    g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, depth);
    
    depth.GetAlternativeViewPointCap().SetViewPoint(test);
    
    glutMainLoop();
    
	return 0;
}