Example #1
0
int
main(int argc, char *argv[])
{
	int winmax,sw1,sw2,i;
	
    glutInitWindowSize(640,480);
    glutInitWindowPosition(40,40);
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);

    glutCreateWindow("FreeGLUT Sub Windows");

    glutReshapeFunc(resize);
    glutDisplayFunc(display);
    glutKeyboardFunc(key);
    glutSpecialFunc(special);
    glutEntryFunc(entry);

    glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ) ;

    glClearColor(1,1,1,1);

	mainwin = glutGetWindow();
	winmax=mainwin;
	
	sw1=glutCreateSubWindow(mainwin,4,240,314,236);
    glutReshapeFunc(resize);
    glutDisplayFunc(display);
    glutKeyboardFunc(key);
    glutSpecialFunc(special);
    glutEntryFunc(entry);
    glClearColor(0.7f,0.7f,0.7f,1);
	winmax = sw1 > winmax ? sw1 : winmax;

	sw2=glutCreateSubWindow(mainwin,322,240,314,236);
    glutReshapeFunc(resize);
    glutDisplayFunc(display);
    glutKeyboardFunc(key);
    glutSpecialFunc(special);
    glutEntryFunc(entry);
    glClearColor(0.7f,0.7f,0.7f,1);
	winmax = sw2 > winmax ? sw2 : winmax;

	strings = malloc(sizeof(char *)*(winmax+1));
	for (i=0;i<winmax+1;i++) {
		strings[i] = malloc(sizeof(char)*MAXSTR+1);
		strings[i][0]=0;
	}

    glutMainLoop();

#ifdef _MSC_VER
    /* DUMP MEMORY LEAK INFORMATION */
    _CrtDumpMemoryLeaks () ;
#endif

    return EXIT_SUCCESS;
}
Example #2
0
int
main(int argc, char **argv)
{
  qobj = gluNewQuadric();
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  win1 = glutCreateWindow("sphere");
  glutEntryFunc(enter_leave);
  init();
  glutDisplayFunc(display_win1);
  glutCreateMenu(it);
  glutAddMenuEntry("toggle draw mode", 1);
  glutAddMenuEntry("exit", 2);
  glutAddMenuEntry("new menu entry", 3);
  glutAddMenuEntry("motion", 4);
  glutAttachMenu(GLUT_LEFT_BUTTON);
  glutCreateMenu(it);
  glutAddMenuEntry("yes", 1);
  glutAddMenuEntry("no", 2);
  glutAttachMenu(GLUT_RIGHT_BUTTON);
  win2 = glutCreateWindow("second window");
  glutEntryFunc(enter_leave);
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(special);
  glutMouseFunc(mouse);
#if 0
  glutMotionFunc(motion);
#endif
  glutVisibilityFunc(visible);
  init();
  light_diffuse[1] = 1;
  light_diffuse[2] = 1;
  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
  glutDisplayFunc(display);
  submenu1 = glutCreateMenu(it);
  glutAddMenuEntry("submenu a", 666);
  glutAddMenuEntry("submenu b", 777);
  submenu2 = glutCreateMenu(it);
  glutAddMenuEntry("submenu 1", 25);
  glutAddMenuEntry("submenu 2", 26);
  glutAddSubMenu("submenuXXX", submenu1);
  glutCreateMenu(it);
  glutAddSubMenu("submenu", submenu2);
  glutAddMenuEntry("stop motion", 5);
  glutAddMenuEntry("delayed stop motion", 6);
  glutAddSubMenu("submenu", submenu2);
  glutAttachMenu(GLUT_LEFT_BUTTON);
  glutMenuStateFunc(menustate);
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
Example #3
0
bool initGL(int *argc, char **argv )
{
	controls.initCtrls();
	// Create GL context
    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);

    glutInitWindowSize(window_width, window_height);
    iGLUTWindowHandle = glutCreateWindow("CuMagicField");
//-----------------------------------------------------------
    glutKeyboardFunc(keyboard);
    glutReshapeFunc(reshape);
	glutMouseWheelFunc(mouseWheel);
	glutEntryFunc(processMouseEntry);
//-----------------------------------------------------------
	iGLUTCtrlHandle = glutCreateSubWindow(iGLUTWindowHandle, sim_width+9, 9, CTRL_WIDTH, sim_height);
	bool res = SetupViewGL(CTRL_WIDTH, sim_height);
	
	glutDisplayFunc(displayCtrls);
	glutMouseFunc(clickCtrl);
	//glutMotionFunc(motionCtrl);
	//glutMouseWheelFunc(mouseWheelCtrl);
	glutPassiveMotionFunc(motionCtrl);
	glutPostRedisplay();

	if(!res)
		return false;

	iGLUTFieldHandle = glutCreateSubWindow(iGLUTWindowHandle, 9, 9, sim_width, sim_height);
	res = SetupViewGL(sim_width, sim_height);

    return res;
}
Example #4
0
void WindowsManager::setSubWindow(bool enable)
{
	m_subWindow = enable;

	if(m_subWindow)
	{
		glutDestroyWindow(m_window2);
		//m_dt.init2();
		reshape1(m_width, m_height);

		setFullScreen(m_fullScreen);
	}
	else
	{
		glutDestroyWindow(m_window2);
		m_window2 = glutCreateWindow("Dual Touch 2"); 
		
		//m_dt.init2();
		glutReshapeFunc(m_reshape2); 
		glutDisplayFunc(m_display2); 
		glutKeyboardFunc(m_keyboard2);
		glutKeyboardUpFunc(m_keyboardUp2);
		glutMouseFunc(m_mouse2);
		glutMotionFunc(m_motion2);
		glutEntryFunc(m_entry2);

		setFullScreen(m_fullScreen);
	}
}
Example #5
0
/// Adds a new view. Function has to be called just from the inside of view thread with a locked sync_view.
int add_view_in_thread(void* view_pars_ptr)
{
  error_if(need_safe_call(), "Calling add_view_in_thread from other thread.");
  ViewParams& view_params = *((ViewParams*)view_pars_ptr);

  //create GLUT window
  glutInitWindowPosition(view_params.x, view_params.y);
  glutInitWindowSize(view_params.width, view_params.height);
  int view_id = glutCreateWindow(view_params.title);
  glutSetWindowData(view_params.view);

  //initialize GLEW
  GLenum err = glewInit();
  error_if(err != GLEW_OK, "GLEW error: %s", glewGetErrorString(err));
  glew_initialized = true;

  //register callbacks
  glutDisplayFunc(on_display_stub);
  glutReshapeFunc(on_reshape_stub);
  glutMotionFunc(on_mouse_move_stub);
  glutPassiveMotionFunc(on_mouse_move_stub);
  glutMouseFunc(on_mouse_click_stub);
  glutKeyboardFunc(on_key_down_stub);
  glutSpecialFunc(on_special_key_stub);
  glutEntryFunc(on_entry_stub);
  glutCloseFunc(on_close_stub);

  //add to structures
  view_instances[view_id] = view_params.view;

  //call handlers
  view_params.view->on_create(view_id);

  return view_id;
}
Example #6
0
//------------------------------------------------------------
void ofAppGlutWindow::initializeWindow(){


    //----------------------
    // setup the callbacks

    glutMouseFunc(mouse_cb);
    glutMotionFunc(motion_cb);
    glutPassiveMotionFunc(passive_motion_cb);
    glutIdleFunc(idle_cb);
    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard_cb);
    glutKeyboardUpFunc(keyboard_up_cb);
    glutSpecialFunc(special_key_cb);
    glutSpecialUpFunc(special_key_up_cb);

    glutReshapeFunc(resize_cb);
	glutEntryFunc(entry_cb);

#ifdef TARGET_OSX
//	glutDragEventFunc(dragEvent);
#endif

    nFramesSinceWindowResized = 0;

    #ifdef TARGET_WIN32
        //----------------------
        // this is specific to windows (respond properly to close / destroy)
        fixCloseWindowOnWin32();
    #endif

}
Example #7
0
/*  Main Loop
 *  Open window with initial window size, title bar, 
 *  RGBA display mode, and handle input events.
 */
int
main(int argc, char **argv)
{
  int submenu;

  glutInit(&argc, argv);
  glutInitWindowSize(W, H);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glutCreateWindow(argv[0]);
  myinit();
  glutReshapeFunc(myReshape);
  glutDisplayFunc(display);
  submenu = glutCreateMenu(polygon_mode);
  glutAddMenuEntry("Filled", 1);
  glutAddMenuEntry("Outline", 2);
  glutCreateMenu(main_menu);
  glutAddMenuEntry("Quit", 666);
  glutAddSubMenu("Polygon mode", submenu);
  glutAttachMenu(GLUT_RIGHT_BUTTON);
  glutPassiveMotionFunc(passive);
  glutEntryFunc(entry);
  glutMenuStatusFunc(mstatus);
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
Example #8
0
int main(int argc, char ** argv)
{

	// Initialize GLUT
	glutInit(&argc, argv);

	//glutInitDisplayString("rgba alpha double samples>=4");
	glutInitWindowSize(XRES, YRES);
	glutCreateWindow("mpchristmas");


	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutKeyboardFunc(keydown);
	glutMouseFunc(processMouse);
	glutSpecialFunc(specialKeydown);
	glutMotionFunc(processMouseActiveMotion);
	glutPassiveMotionFunc(processMousePassiveMotion);
	glutEntryFunc(processMouseEntry);
	glutIdleFunc(idle);



	initGL();



	g_server.init();

	glutMainLoop();

	g_server.shutdown();
	return 0;
}
Example #9
0
static void registerCallbacks ()
{
  glutIdleFunc(gst_glut_IdleFunc);
  glutKeyboardFunc(gst_glut_KeyboardFunc);
  glutSpecialFunc(gst_glut_SpecialFunc);
  glutReshapeFunc(gst_glut_ReshapeFunc);
  glutVisibilityFunc(gst_glut_VisibilityFunc);
  glutDisplayFunc(gst_glut_DisplayFunc); 
  glutMouseFunc(gst_glut_MouseFunc);
  glutMotionFunc(gst_glut_MotionFunc);
  glutPassiveMotionFunc(gst_glut_PassiveMotionFunc);
  glutEntryFunc(gst_glut_EntryFunc);
  glutKeyboardUpFunc(gst_glut_KeyboardUpFunc);
  glutSpecialUpFunc(gst_glut_SpecialUpFunc);
  glutMenuStateFunc(gst_glut_MenuStateFunc);
  glutMenuStatusFunc(gst_glut_MenuStatusFunc);
  glutOverlayDisplayFunc(gst_glut_OverlayDisplayFunc);
  glutWindowStatusFunc(gst_glut_WindowStatusFunc);
  glutSpaceballMotionFunc(gst_glut_SpaceballMotionFunc);
  glutSpaceballRotateFunc(gst_glut_SpaceballRotateFunc);
  glutSpaceballButtonFunc(gst_glut_SpaceballButtonFunc);
  glutButtonBoxFunc(gst_glut_ButtonBoxFunc);
  glutDialsFunc(gst_glut_DialsFunc);
  glutTabletMotionFunc(gst_glut_TabletMotionFunc);
  glutTabletButtonFunc(gst_glut_TabletButtonFunc);
  glutWMCloseFunc(gst_glut_WMCloseFunc);

#if 0
  glutJoystickFunc(gst_glut_JoystickFunc);
  glutMouseWheelFunc(gst_glut_MouseWheelFunc);
  glutCloseFunc(gst_glut_CloseFunc);
  glutMenuDestroyFunc(gst_glut_MenuDestroyFunc);
#endif
}
//-----------------------------------------------------------------------------
// createWindow() -- create the main window
//-----------------------------------------------------------------------------
int GlutDisplay::createWindow()
{
   winId = -1;

#ifdef __FREEGLUT_EXT_H__     /* freeglut only */
      glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
#endif

   unsigned int wmode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
   if (getClearDepth() >= 0.0f) { wmode = wmode | GLUT_DEPTH; }
   if (accumBuff) { wmode = wmode | GLUT_ACCUM; }
   if (stencilBuff) { wmode = wmode | GLUT_STENCIL; }
   glutInitDisplayMode( wmode );

   GLint  vpX(0), vpY(0);                   // our initial viewport position
   GLsizei vpWidth(0), vpHeight(0);    // our initial viewport size
   getViewport(&vpX, &vpY, &vpWidth, &vpHeight);
   glutInitWindowPosition(vpX, vpY);
   glutInitWindowSize(vpWidth, vpHeight);
   winId = glutCreateWindow(getName());
   if (winId > 0) {
      if (isMessageEnabled(MSG_INFO)) {
         std::cout << "GlutDisplay::createWindow() name = " << getName() << ", winId = " << winId << std::endl;
      }

      // Configure the new window
      if (fullScreenFlg) glutFullScreen();
      glutDisplayFunc(drawFuncCB);
      glutReshapeFunc(reshapeItCB);
      glutIdleFunc(idleCB);
      glutPassiveMotionFunc(passiveMotionFuncCB);
      glutMotionFunc(motionFuncCB);
      glutKeyboardFunc(keyboardFuncCB);
      glutSpecialFunc(specialFuncCB);
      glutMouseFunc(mouseFuncCB);
      glutEntryFunc(entryFuncCB);
      registerGlutDisplay(winId, this);
      glutSetWindow(winId);
      configure();
      loadTextures();

      // Create sub windows (if any)
      if (subDisplays() != nullptr) {
         Basic::List::Item* item = subDisplays()->getFirstItem();
         while (item != nullptr) {
            Basic::Pair* pair = dynamic_cast<Basic::Pair*>(item->getValue());
            if (pair != nullptr) {
               GlutDisplay* dobj = dynamic_cast<GlutDisplay*>( pair->object() );
               if (dobj != nullptr) dobj->createSubWindow(winId);
            }
            item = item->getNext();
         }
      }

      // Select this window
      select();
   }

   return winId;
}
// initalise glut 
void
initGlut(int argc, char *argv[])
{
    /* initialising the window */
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
    
    // Print available keyboard and mouse options.
    printf("\n\tKeyboard Options :\n"
           "\t  'i'  double the number of iterations\n"
           "\t  'I'  halve the number of iterations\n"
           "\t  'b'  benchmark the current frame (when -t is enabled)\n"
           "\t  'c'  print the current center position\n"
           "\t  'p'  toggle panning\n" 
           "\n\tMouse Options :\n"
           "\t  Move mouse to pan image\n"
           "\t  Left click to zoom in\n"
           "\t  Right click to zoom out\n\n");

    printf("width %d, height %d\n", width, height);
    glutInitWindowSize(width, height);
    mouseX = width / 2;
    mouseY = height / 2;
    glutInitWindowPosition(0,0);
    glutCreateWindow("Mandelbrot Fractal Generator");

    // the various glut callbacks 
    glutDisplayFunc(displayFunc);
    glutIdleFunc(idleFunc);
    glutKeyboardFunc(keyboardFunc);
    glutMouseFunc(mouseFunc);
    glutMotionFunc(motionFunc);
    glutPassiveMotionFunc(passiveMotionFunc);
    glutEntryFunc(mouseEntry);
}
Example #12
0
JNIEXPORT void JNICALL Java_go_graphics_nativegl_NativeAreaWindow_openWindow_1native(
		JNIEnv *env, jobject obj) {
	if (windowEnv != NULL ) {
		return;
	}

	int zero = 0;
	char* title_native = "TODO: title";

	glutInit(&zero, NULL );
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowSize(640, 480);
	glutCreateWindow(title_native);
	glutReshapeFunc(resizeGlWindow);
	glutDisplayFunc(drawGlWindow);
	glutMouseFunc(mouseCallback);
	glutMotionFunc(mouseMotionCallback);
	glutPassiveMotionFunc(mouseMotionCallback);
	glutEntryFunc(mouseEntryCallback);
	glutKeyboardFunc(keyboardCallbackDown);
	glutSpecialFunc(keyboardSpecialCallbackDown);
	glutKeyboardUpFunc(keyboardCallbackUp);
	glutSpecialUpFunc(keyboardSpecialCallbackUp);

	glewInit();
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	windowEnv = env;
	windowObject = obj;

	glutMainLoop();
}
Example #13
0
void
time5(int value)
{
  if (value != 5) {
    printf("FAIL: time5 expected 5\n");
    exit(1);
  }
  glutEntryFunc(entry);
  printf("In the black window, leave it, then enter it\n");
}
Example #14
0
int main( int argc, char *argv[] )
{
    // Signal handler
	signal(SIGINT, signalHandler);
    
    try
    {
		// initialize sound
		Sound::initialize();

		// Initialize GLUT
        glutInit( &argc, argv );
        glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH );
        glutInitWindowSize( 1024, 768 );
        glutInitWindowPosition( -1, -1 );
        
        // Create GLUT Window
        int windowID = glutCreateWindow( "Tank Game" );    
		
        // Bind handlers
        glutDisplayFunc( __displayFunc );
        glutReshapeFunc( __reshapeFunc );
        glutKeyboardFunc( __keyboardFunc );
		glutKeyboardUpFunc( __keyboardUpFunc );
        glutSpecialFunc( __specialFunc );
		glutSpecialUpFunc( __specialUpFunc );
        glutMouseFunc( __mouseFunc );
        glutMotionFunc( __motionFunc );
        glutPassiveMotionFunc( __passiveMotionFunc );
        glutEntryFunc( __entryFunc );
        glutVisibilityFunc( __visibilityFunc );
        glutTimerFunc( 1, __timerFunc, 1 );
//        glutIdleFunc( __idleFunc );
        
        // Show window and start event loop
		scene = new Scene();
        scene->initialize();
        glutMainLoop();
    }
    catch ( const Exception &e )
    {
        std::cerr << "Exception : " << e.what() << std::endl;
        return 1;
    }
    catch ( ... )
    {
        std::cerr << "Exception : Unknown exception" << std::endl;
        return 1;
    }

    delete scene;

    return 0;
};
Example #15
0
 static void init(void) {
   glutReshapeFunc(reshape);
   glutEntryFunc(entry);
   glutMouseFunc(mouse);
   glutMotionFunc(motion);
   glutPassiveMotionFunc(motion);
   glutKeyboardFunc(keyDown);
   glutKeyboardUpFunc(keyUp);
   glutSpecialUpFunc(specialKeyUp);
   glutSpecialFunc(specialKeyDown);
 }
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutEntryFunc
 * Signature: (Lscala/Function1;)V
 */
JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutEntryFunc
  (JNIEnv * jenv, jobject jobj, jobject arg1) {

  if(jvm == NULL) {
    (*jenv)->GetJavaVM(jenv, &jvm);
  }

  // fixme remove old obj if exists

  glutEntryFunc_obj = (*jenv)->NewGlobalRef(jenv, arg1);
  return glutEntryFunc(glutEntryFuncCallback);

}
Example #17
0
/* GLUT child thread function.
 * The argument of the function is ignored.
 * The function takes the allocated values for 'glut_window_properties' and
 * 'glut_window_title' from the thread creator, uses them, and then frees them. */
static void *glut_thread_func(void *arg)
{
	struct glut_window_properties_t *properties = glut_window_properties;
	char *title = glut_window_title;

	/* Detach thread. Parent does not need to 'pthread_join' the child to
	 * release its resources. */
	pthread_detach(pthread_self());

	/* Configure host window properties */
	glutInitWindowPosition(properties->x, properties->y);
	glutInitWindowSize(properties->width, properties->height);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

	/* Create window */
	glutCreateWindow(title);

	/* Host window callbacks */
	glutIdleFunc(glut_idle_func);
	glutDisplayFunc(glut_display_func);
	glutOverlayDisplayFunc(glut_overlay_display_func);
	glutReshapeFunc(glut_reshape_func);
	glutKeyboardFunc(glut_keyboard_func);
	glutMouseFunc(glut_mouse_func);
	glutMotionFunc(glut_motion_func);
	glutPassiveMotionFunc(glut_passive_motion_func);
	glutVisibilityFunc(glut_visibility_func);
	glutEntryFunc(glut_entry_func);
	glutSpecialFunc(glut_special_func);
	glutSpaceballRotateFunc(glut_spaceball_rotate_func);
	glutSpaceballButtonFunc(glut_spaceball_button_func);
	glutButtonBoxFunc(glut_button_box_func);
	glutDialsFunc(glut_dials_func);
	glutTabletMotionFunc(glut_tablet_motion_func);
	glutTabletButtonFunc(glut_tablet_button_func);

	/* Resize guest frame buffer */
	glut_frame_buffer_resize(properties->width, properties->height);

	/* Free input arguments */
	free(properties);
	free(title);
	glut_window_properties = NULL;
	glut_window_title = NULL;

	/* Host GLUT main loop */
	glutMainLoop();

	/* Function never returns */
	return NULL;
}
Example #18
0
//GlutInstace Class Constructor(Default and 5 argument version)
Glut2D::Glut2D(const std::string& windowCaption,const int windowWidth,const int windowHeight,void(*timer)(Glut2D&),
    const unsigned int timerTime,void(*display)(Glut2D&)):camera(),_windowID(-1),_windowWidth(windowWidth),_windowHeight(windowHeight),
    _active(false),_timer(timer),_timerTime(timerTime),_display(display),_dt(0.0),_ot(0.0),_mouseX(0),_mouseY(0)
{
    //Check Timer Function
    if(!_timer)
    {
        throw std::runtime_error("Glut2D - Invalid timer function!!!");
    }

    //Check Display Function
    if(!_display)
    {
        throw std::runtime_error("Glut2D - Invalid display function!!!");
    }

    //Add to Static Vector
    _instance.push_back(this);

    //Set Window Size and Create Window
    glutInitWindowSize(_windowWidth,_windowHeight);
    _windowID=glutCreateWindow(windowCaption.c_str());

    //Input Functions
    glutKeyboardFunc(keyboardDown);
	glutKeyboardUpFunc(keyboardUp);
	glutSpecialFunc(specialDown);
	glutSpecialUpFunc(specialUp);
	glutMouseFunc(mouse);
	glutEntryFunc(mouseEntry);
	glutMotionFunc(motion);
	glutPassiveMotionFunc(motion);

	glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);

    //Window Functions
	glutReshapeFunc(Glut2D::reshape);
	glutWindowStatusFunc(Glut2D::windowStatus);

	//Timer Function
	glutTimerFunc(_timerTime,Glut2D::timer,0);

	//Display Function
	glutDisplayFunc(Glut2D::display);

	//Enable Color Key Transparency
    glEnable(GL_ALPHA_TEST);
        glAlphaFunc(GL_GREATER,0.0);
    glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
}
GLUTwrapper::GLUTwrapper ( EventHandlerBase *h )
{
  if (handler)
    {
      std::cerr << "Only one instance of the GLUTwrapper class allowed!" << std::endl;
      std::exit(1);
    }

  int a = h->getArgc();
  glutInit(&a,h->getArgv());
  glutInitContextVersion (3, 3);
  glutInitContextFlags (GLUT_CORE_PROFILE | GLUT_DEBUG);

  glutInitWindowSize(h->getWindowWidth(),h->getWindowHeight());
  glutInitWindowPosition(10,10);
  glutInitDisplayMode(h->getWindowMode());
  windowID = glutCreateWindow("A window");

  glewExperimental=GL_TRUE;
  GLenum err=glewInit();
  if(err!=GLEW_OK)
  {
    //Problem: glewInit failed, something is seriously wrong.
    cout<<"glewInit failed, aborting."<<endl;
    exit(1);
  }
  //if (glewIsSupported("GL_VERSION_3_1"))
  //  cout << "Ready for OpenGL 3.1" << endl;
  //else
  //  {
  //    cerr << "OpenGL 3.1 not supported" << endl;
  //    exit(1);
  //  }

  handler = h;

  glutMouseFunc(mouseButton);
  glutMotionFunc(activeMotion);
  glutPassiveMotionFunc(passiveMotion);
  glutIdleFunc(idleFunction);
  glutDisplayFunc(draw);
  glutVisibilityFunc(visibilityFunction);
  glutSpecialFunc(specialFunction);
  glutEntryFunc(entryFunction);
  glutKeyboardFunc(keyPressed);
  glutReshapeFunc(resize);

  h->initializeGL();
}
Example #20
0
void GlutInit()
{
	glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF) ;

	glutKeyboardFunc(KeyboardDown);
	glutKeyboardUpFunc(KeyboardUp);
	glutSpecialFunc(SpecialDown);
	glutSpecialUpFunc(SpecialUp);
	glutMouseFunc(MouseButton);
	glutMotionFunc(MouseMotion);
	glutPassiveMotionFunc(MouseMotion);
	glutDisplayFunc(Display);
	glutIdleFunc(Display);
	glutReshapeFunc(Reshape);
	glutEntryFunc(MouseEntry);
	//glutVisibilityFunc(visible);
}
void 
OpenSteer::initializeGraphics (int argc, char **argv)
{
    // initialize GLUT state based on command line arguments
    glutInit (&argc, argv);  

    // display modes: RGB+Z and double buffered
    GLint mode = GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE;
    glutInitDisplayMode (mode);

    // create and initialize our window with GLUT tools
    // (center window on screen with size equal to "ws" times screen size)
    const int sw = glutGet (GLUT_SCREEN_WIDTH);
    const int sh = glutGet (GLUT_SCREEN_HEIGHT);
    const float ws = 0.8f; // window_size / screen_size
    const int ww = (int) (sw * ws);
    const int wh = (int) (sh * ws);
    glutInitWindowPosition ((int) (sw * (1-ws)/2), (int) (sh * (1-ws)/2));
    glutInitWindowSize (ww, wh);
    windowID = glutCreateWindow (appVersionName.c_str());
    reshapeFunc (ww, wh);
    initGL ();

    // register our display function, make it the idle handler too
    glutDisplayFunc (&displayFunc);  
    glutIdleFunc (&displayFunc);

    // register handler for window reshaping
    glutReshapeFunc (&reshapeFunc);

    // register handler for keyboard events
    glutKeyboardFunc (&keyboardFunc);
    glutSpecialFunc (&specialFunc);

    // register handler for mouse button events
    glutMouseFunc (&mouseButtonFunc);

    // register handler to track mouse motion when any button down
    glutMotionFunc (mouseMotionFunc);

    // register handler to track mouse motion when no buttons down
    glutPassiveMotionFunc (mousePassiveMotionFunc);

    // register handler for when mouse enters or exists the window
    glutEntryFunc (mouseEnterExitWindowFunc);
}
Example #22
0
void
entry(int state)
{
  printf("entry: %s\n", state == GLUT_LEFT ? "left" : "entered");
  switch (estate) {
  case 0:
    if (state == GLUT_LEFT)
      estate++;
    break;
  case 1:
    if (state == GLUT_ENTERED)
      estate++;
    glutTimerFunc(1000, time6, 6);
    glutEntryFunc(NULL);
    break;
  }
}
Example #23
0
void registerWindowCallback::callback() {
    freeglutManager->windows[window->id] = window;
    glutSetWindow(window->id);
    
    glutDisplayFunc(freeglutManager_glutDisplayFunc);
    glutReshapeFunc(freeglutManager_glutReshapeFunc);
    glutKeyboardFunc(freeglutManager_glutKeyboardFunc);
    glutMouseFunc(freeglutManager_glutMouseFunc);
    glutMotionFunc(freeglutManager_glutMotionFunc);
    glutPassiveMotionFunc(freeglutManager_glutPassiveMotionFunc);
    glutVisibilityFunc(freeglutManager_glutVisibilityFunc);
    glutEntryFunc(freeglutManager_glutEntryFunc);
    glutSpecialFunc(freeglutManager_glutSpecialFunc);
    glutTimerFunc(2000, freeglutManager_RenderTimer, window->id);
    
    glutShowWindow();
    waiting = false;
}
Example #24
0
void WindowsManager::createWindows(int argc, char** argv)
{
	glutInit(&argc, argv); 
	glutInitDisplayMode(GLUT_MULTISAMPLE | GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );

	if(m_subWindow)
		glutInitWindowSize(IntialSize*2,IntialSize); 
	else
		glutInitWindowSize(IntialSize,IntialSize); 

	m_window1 = glutCreateWindow("Haptic launch"); 
	glutPositionWindow(IntialPosition,IntialPosition); 

	m_dt.init1();

	glutReshapeFunc(m_reshape1); 
	glutDisplayFunc(m_display1); 
	glutKeyboardFunc(m_keyboard1);
	glutKeyboardUpFunc(m_keyboardUp1);
	glutMouseFunc(m_mouse1);
	glutMotionFunc(m_motion1);
	glutEntryFunc(m_entry1);

	/*glutInitWindowSize(IntialSize,IntialSize); 
	m_window2 = glutCreateWindow("Dual Touch 2"); 
	glutPositionWindow(IntialPosition+IntialSize+IntialMargin,IntialPosition); 

	m_dt.init2();

	glutReshapeFunc(m_reshape2); 
	glutDisplayFunc(m_display2); 
	glutKeyboardFunc(m_keyboard2);
	glutKeyboardUpFunc(m_keyboardUp2);
	glutMouseFunc(m_mouse2);
	glutMotionFunc(m_motion2);
	glutEntryFunc(m_entry2);*/

	//setFullScreen(m_fullScreen);

	//glutTimerFunc(0,m_idle2,0);
	glutIdleFunc(m_idle);
	glutMainLoop(); 
	
}
void
InitGraphics( )
{
	glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
	glutInitWindowPosition( 0, 0 );
	glutInitWindowSize( INIT_WINDOW_SIZE, INIT_WINDOW_SIZE );

	MainWindow = glutCreateWindow( WINDOWTITLE );
	glutSetWindowTitle( WINDOWTITLE );
	glClearColor( BACKCOLOR[0], BACKCOLOR[1], BACKCOLOR[2], BACKCOLOR[3] );


	// setup the callback routines:

	glutSetWindow( MainWindow );
	glutDisplayFunc( Display );
	glutReshapeFunc( Resize );
	glutKeyboardFunc( Keyboard );
	glutMouseFunc( MouseButton );
	glutMotionFunc( MouseMotion );
	glutPassiveMotionFunc( NULL );
	glutVisibilityFunc( Visibility );
	glutEntryFunc( NULL );
	glutSpecialFunc( NULL );
	glutSpaceballMotionFunc( NULL );
	glutSpaceballRotateFunc( NULL );
	glutSpaceballButtonFunc( NULL );
	glutButtonBoxFunc( NULL );
	glutDialsFunc( NULL );
	glutTabletMotionFunc( NULL );
	glutTabletButtonFunc( NULL );
	glutMenuStateFunc( NULL );
	glutTimerFunc( 0, NULL, 0 );

#ifdef WIN32
	GLenum err = glewInit();
	if( err != GLEW_OK )
	{
		fprintf( stderr, "glewInit Error\n" );
	}
#endif
}
Example #26
0
void main(int argc, char* argv[]){
	/****************************************/
	/*   Initialize GLUT and create window  */
	/****************************************/

	glutInit(&argc, argv);

	//  Set the window x and y coordinates such that the 
	//  window becomes centered
	window.centerOnScreen();

	//  Connect to the windowing system + create a window
	//  with the specified dimensions and position
	//  + set the display mode + specify the window title.
	glutInitWindowSize(window.window_width, window.window_height);
	glutInitWindowPosition(window.window_x, window.window_y);

	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	main_window = glutCreateWindow("Bind Mesh");
	
	init();

	glutDisplayFunc(onDisplay);
	glutReshapeFunc(onReshape);
	glutKeyboardFunc(onKeyboard);
	glutMouseFunc(onMouse);
	glutMotionFunc(onMotion);
	glutEntryFunc(onEntry);

	scene = Scene(800, 600);
	scene.createModel("wasp.skel", "wasp.skin");
	//scene.createSkel("tube.skel");

	window = Window(800, 600, scene);
	window.main_window = main_window;

	//  Setup all GLUI stuff
	setupGLUI();

	glutMainLoop();
}
GLUTwrapper::GLUTwrapper ( EventHandlerBase *h )
{
  if (handler)
    {
      std::cerr << "Only one instance of the GLUTwrapper class allowed!" << std::endl;
      std::exit(1);
    }

  int a = h->getArgc();
  glutInit(&a,h->getArgv());
  
  glutInitWindowSize(h->getWindowWidth(),h->getWindowHeight());
  glutInitWindowPosition(10,10);
  glutInitDisplayMode(h->getWindowMode());
  windowID = glutCreateWindow("A window");

  // initialize glew and check for OpenGL 4.0 support
  glewInit();
  if (glewIsSupported("GL_VERSION_4_0"))
    cout << "Ready for OpenGL 4.0" << endl;
  else 
    {
      cerr << "OpenGL 4.0 not supported" << endl;
      exit(1);
    }

  handler = h;

  glutMouseFunc(mouseButton);
  glutMotionFunc(activeMotion);
  glutPassiveMotionFunc(passiveMotion);
  glutIdleFunc(idleFunction);
  glutDisplayFunc(draw);
  glutVisibilityFunc(visibilityFunction);
  glutSpecialFunc(specialFunction);
  glutEntryFunc(entryFunction);
  glutKeyboardFunc(keyPressed);
  glutReshapeFunc(resize);

  h->initializeGL();
}
Example #28
0
int main(int argc, char **argv)
{
   /* Initialize GLUT */
   glutInit(&argc, argv);
   glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH );
   glutInitWindowSize(window_width, window_height);
   glutCreateWindow("MazeViewer");
   glutInitWindowPosition(100,50);

   /* Set all the GLUT callback functions */
   glutDisplayFunc(display);      /* in GLUTCallbacks.cpp */
   //glutIdleFunc(redisplay);     /* use an idle function to compute frame rate */
   glutIdleFunc(NULL);            /* turn off idle function when debugging */
   glutReshapeFunc(reshape);      /* in GLUTCallbacks.cpp */
   glutKeyboardFunc(keyboard);    /* in GLUTCallbacks.cpp */
   glutEntryFunc(mouseEntry);     /* in GLUTMouseCallbacks.cpp */  /* doesn't work */
   glutMotionFunc(mouseMotion);   /* in GLUTMouseCallbacks.cpp */
   glutPassiveMotionFunc(mouseMotion);

   /* set the eye's initial location */
   eye_pos[0] = 0.0;
   eye_pos[1] = 0.0;
   eye_pos[2] = 5.0;

   /* initialize the eye's parameters */
   eye_theta = 180.0;
   eye_phi = 90.0;
   eye_fov = 45.0;

   /* Create the Scene object that we shall render */
   MazeParser mp;
   scene = mp.loadScene((char*)"maze.txt");

   initializeTexturesOpenGL(scene); /* in SceneRenderOpenGL.cpp */

   glutMainLoop();                  /* Enter GLUT's main loop */

   return 1;
}
Example #29
0
int
gluiHorizontalSlider(int parent, int x, int y, int width, int height,
		     float percent, void (*update)(float))
{
    GLUIslider* slider = (GLUIslider*)malloc(sizeof(GLUIslider));
    slider->next = _gluiSliders;
    _gluiSliders = slider;

    slider->type = GLUI_HORIZONTAL;
    slider->parent = parent;
    slider->window = glutCreateSubWindow(parent, x, y, width, height);
    slider->win_x = x;
    slider->win_y = y;
    slider->win_w = width;
    slider->win_h = height;
    slider->update = update;
    slider->lit = GL_FALSE;

/*     glutSetCursor(GLUT_CURSOR_LEFT_RIGHT); */
    glutDisplayFunc(_gluiDisplay);
    glutEntryFunc(_gluiEntry);
    glutMouseFunc(_gluiMouse);
    glutMotionFunc(_gluiMotion);
    glutPassiveMotionFunc(_gluiPassive);

    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);

    slider->length = width;
    if (width < 0) {
	glutSetWindow(parent);
	slider->length = glutGet(GLUT_WINDOW_WIDTH) + width - slider->win_x;
    }

    slider->knob = _gluiKnobPosition(slider, percent);
    _gluiConstrainKnob(slider);

    return slider->window;
}
Example #30
0
//*************************************************************************
//  Program Main method.
//*************************************************************************
int main (int argc, char **argv)
{
    //  Connect to the windowing system + create a window
    //  with the specified dimensions and position
    //  + set the display mode + specify the window title.
    glutInit(&argc, argv);
    glutInitWindowSize (window_width, window_height);
    glutInitWindowPosition (window_x, window_y);
    glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE);
    main_window = glutCreateWindow (window_title);
    
    //  Set the window x and y coordinates such that the 
    //  window becomes centered
    centerOnScreen ();
    
    //  View in full screen if the full_screen flag is on
    if (full_screen)
        glutFullScreen ();

    //  Set OpenGL context initial state.
    init();
    
    // Set the GLUT callback functions
    glutDisplayFunc (display);
    glutReshapeFunc  (reshape);
    glutMouseFunc (mouse);
    glutMotionFunc (motion);
    glutPassiveMotionFunc (pmotion);
    glutKeyboardFunc (keyboard);
    glutSpecialFunc (special);
    glutEntryFunc (entry);

    //  Setup all GLUI stuff
    setupGLUI ();

    //  Start GLUT event processing loop
    glutMainLoop();
    return 0;
}