Ejemplo n.º 1
1
int main( int argc, char *argv[] )
{
   glutInit( &argc, argv );
   glutInitWindowPosition( 200, 200 );
   glutInitWindowSize( 800, 500 );
   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
   glutCreateWindow("World of Awesome");
   glutReshapeFunc( ReshapeGL );
   glutDisplayFunc( Draw );
   glutKeyboardFunc( keyboard );
   glutMouseFunc( mouse );
   glutMotionFunc( mouseMove );
   glutPassiveMotionFunc( passiveMove );
   glutTimerFunc(TIMER_DELAY, tock, 0);

   g_width = g_height = 200;

#ifdef _WIN32 
   GLenum err = glewInit();
   if (GLEW_OK != err)
   {
      std::cerr << "Error initializing glew! " << glewGetErrorString(err) << std::endl;
      return 1;
   }
#endif
#ifdef __APPLE__
   glutSetCursor(GLUT_CURSOR_NONE); 
#endif

   backShade = glm::vec3(0.2,0.5,0.9);

   Initialize();
   
   //test the openGL version
   getGLversion();
   //install the shader
   if (!InstallShader(textFileRead((char *)"shaders/vert.glsl"), textFileRead((char *)"shaders/frag.glsl")))   {
      printf("Error installing shader!\n");
      return 0;
   }

   InitGeom();


   g_shadeType = PHONG;

   g_pitch = 0;
   g_yaw = M_PI / 2;
   float tx = cos(g_pitch)*cos(g_yaw);
   float ty = sin(g_pitch);
   float tz = cos(g_pitch)*cos(M_PI/2 - g_yaw);
   eye = glm::vec3(0, 2.5, 0);
   target = eye + glm::vec3(tx, ty, tz);
   sunDir = normalize(vec3(-0.2, -1.0, 0.0));


   sunShade = glm::vec3(1.0, 1.0, 0.9);

   glutMainLoop();
   return 0;
}
Ejemplo n.º 2
0
void StageOutro::init()
{
	glutSetCursor(GLUT_CURSOR_NONE);
}
Ejemplo n.º 3
0
//------------------------------------------------------------
void ofAppGlutWindow::showCursor(){
	glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
}
Ejemplo n.º 4
0
//------------------------------------------------------------
void ofAppGlutWindow::hideCursor(){
	glutSetCursor(GLUT_CURSOR_NONE);
}
void ImGui_ImplGlut_NewFrame()
{
    if (!g_FontTexture)
    {
        ImGui_ImplGlut_CreateDeviceObjects();
    }

    ImGuiIO& io = ImGui::GetIO();

    // Setup display size (every frame to accommodate for window resizing)
    int w, h;
    int display_w, display_h;

    //TODO: what is the difference in freeglut?
    //glfwGetWindowSize(g_Window, &w, &h);
    //glfwGetFramebufferSize(g_Window, &display_w, &display_h);
    w = glutGet(GLUT_WINDOW_WIDTH);
    h = glutGet(GLUT_WINDOW_HEIGHT);
    display_w = glutGet(GLUT_WINDOW_WIDTH);
    display_h = glutGet(GLUT_WINDOW_HEIGHT);

    io.DisplaySize = ImVec2((float)w, (float)h);
    io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);

    // Setup time step (TODO: replace glut timer with something better (but portable)?)
    static int last_time = 0;
    int time = glutGet(GLUT_ELAPSED_TIME);
    int elapsed = time - last_time;
    last_time = time;
    io.DeltaTime = 0.001f*elapsed;

    // Setup inputs
    // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())

   //TODO we can't poll in freeglut, so we can't do this. Double clicks at low framerate are broken because of this.
    /*
    if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
    {
        double mouse_x, mouse_y;
        glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
        io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);   // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
    }
    else
    {
        io.MousePos = ImVec2(-1,-1);
    }

    for (int i = 0; i < 3; i++)
    {
        io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0;    // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
        g_MousePressed[i] = false;
    }
*/

    io.MouseWheel = g_MouseWheel;
    g_MouseWheel = 0.0f;

    // Hide OS mouse cursor if ImGui is drawing it
    glutSetCursor(io.MouseDrawCursor ? GLUT_CURSOR_NONE : GLUT_CURSOR_INHERIT);

    // Start the frame
    ImGui::NewFrame();
}
Ejemplo n.º 6
0
void Viewport::setGrabbed(bool value) {
    grabbed = value ? true : false;
    if (grabbed)    glutSetCursor(GLUT_CURSOR_NONE);        // 禁用光标
    else            glutSetCursor(GLUT_CURSOR_INHERIT);     // 启用光标
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
// Initialize GLUT & OpenSG and start the cluster server
int main(int argc,char **argv)
{
#ifdef WIN32
	OSG::preloadSharedObject("OSGFileIO");
    OSG::preloadSharedObject("OSGImageFileIO");
	OSG::preloadSharedObject("OSGEffectGroups");
#endif
	ChangeList::setReadWriteDefault();
    osgInit(argc, argv);
	
	std::string name("ClusterServer");
    std::string connectionType("StreamSock");
    std::string address("127.0.0.1");
	bool fullscreen = true;
	bool always_on_top = false;
	bool stereo = false;
	WindowGeometry geometry = {0,0,500,500};

	if (!parseCmdLineArgs(argc, argv, name, connectionType, address, geometry, fullscreen, always_on_top, stereo))
		return 0;

	printConfiguration(name, address, connectionType, stereo, fullscreen, always_on_top);

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | (stereo ? GLUT_STEREO : 0));
	glutInitWindowPosition(geometry.x, geometry.y);
	glutInitWindowSize(geometry.w, geometry.h);
    int winid = glutCreateWindow(name.c_str());
    if(fullscreen) 
	{
        glutFullScreen();
    }
	if (always_on_top)
	{
		setAlwaysOnTop(name);
	}
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutReshapeFunc(reshape);
    glutSetCursor(GLUT_CURSOR_NONE);

    ract = RenderAction::create();

    window     = GLUTWindow::create();
	OSGCompat::setGlutId(window, winid);
    window->init();

	bool failed = false;
	do
	{
		try 
		{
			delete server;
			server = new ClusterServer(window, name, connectionType, address);
			server->start();
			failed = false;
		}
		catch (OSG_STDEXCEPTION_NAMESPACE::exception& e)
		{
			SLOG << "ERROR: " << e.what() << endLog;
			SLOG << "Attempting to restart ClusterServer..." << endLog;
			failed = true;
		}
	} while (failed);

    glutMainLoop();

    return 0;
}
Ejemplo n.º 9
0
// Initialize GLUT & OpenSG and start the cluster server
int main(int argc,char **argv)
{
    int             winid;
    char           *name          ="ClusterServer";
    char           *connectionType="StreamSock";
    bool            fullscreen     =true;
    std::string     address        ="";
    char           *opt;

    // initialize Glut
    glutInit(&argc, argv);
    glutInitDisplayMode( GLUT_RGB | 
                         GLUT_DEPTH | 
                         GLUT_DOUBLE);

    // evaluate params
    for(int a=1 ; a<argc ; ++a)
    {
        if(argv[a][0] == '-')
        {
            switch(argv[a][1])
            {
                case 'm': connectionType="Multicast";
                          break;
                case 'p': connectionType="SockPipeline";
                          break;
                case 'w': fullscreen=false;
                          break;
                case 'a': address = argv[a][2] ? argv[a]+2 : argv[++a];
                          if(address == argv[argc])
                          { 
                              SLOG << "address missing" << endLog;
                              return 0;
                          }
                          std::cout << address << endLog;
                          break;
                default:  std::cout << argv[0] 
                                    << "-m "
                                    << "-p "
                                    << "-w "
                                    << "-a address "
                                    << endLog;
                          return 0;
            }
        }
        else
        {
            name=argv[a];
        }
    }
    try
    {
        ChangeList::setReadWriteDefault();

        // init OpenSG
        osgInit(argc, argv);

        winid = glutCreateWindow(name);
        if(fullscreen)
            glutFullScreen();
        glutDisplayFunc(display);
        glutIdleFunc(update);
        glutReshapeFunc(reshape);
        glutSetCursor(GLUT_CURSOR_NONE);

        glEnable( GL_LIGHTING );
        glEnable( GL_LIGHT0 );
        glEnable( GL_NORMALIZE );

        // create the render action
        ract=RenderAction::create();

        // setup the OpenSG Glut window
        window     = GLUTWindow::create();
        window->setId(winid);
        window->init();

        // create the cluster server
        server     = new ClusterServer(window,name,connectionType,address);
        // start the server
        server->start();

        // enter glut main loop
        glutMainLoop();
    }
    catch(OSG_STDEXCEPTION_NAMESPACE::exception &e)
    {
        SLOG << e.what() << endLog;
        delete server;
        osgExit(); 
    }
    return 0;
}
Ejemplo n.º 10
0
//----------------------------------------------------------------//
void _AKUHideCursor () {
	glutSetCursor( GLUT_CURSOR_NONE ) ;
}
Ejemplo n.º 11
0
//----------------------------------------------------------------//
void _AKUShowCursor () {
	glutSetCursor( GLUT_CURSOR_INHERIT ) ;
}