コード例 #1
0
void rglGlutRecreateWindow()
{
  int oldmain = main_window;
  
  glutInitWindowSize( screen_width, screen_height );
  main_window = glutCreateWindow( "z64gl" );
  glutDisplayFunc( myGlutDisplay );
  glutReshapeFunc( myGlutReshape );  

  glui->set_main_gfx_window( main_window );
  /* We register the idle callback with GLUI, *not* with GLUT */
  GLUI_Master.set_glutIdleFunc( myGlutIdle );
  //glutTimerFunc(1, myGlutTimer, 0);

  glutSetWindow(main_window);  
  
  glutDestroyWindow(oldmain);
}
コード例 #2
0
ファイル: freeglut.cpp プロジェクト: srjek/dcpu16
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;
}
コード例 #3
0
ファイル: proj3.cpp プロジェクト: guwu/cs553
void
Visibility ( int state )
{
	if( DebugOn != 0 )
		fprintf( stderr, "Visibility: %d\n", state );

	if( state == GLUT_VISIBLE )
	{
		glutSetWindow( MainWindow );
		glutPostRedisplay( );
	}
	else
	{
		// could optimize by keeping track of the fact
		// that the window is not visible and avoid
		// animating or redrawing it ...
	}
}
コード例 #4
0
/* There can be only one idle() callback function. In an
   animation, this idle() function must update not only the
   main window but also all derived subwindows */
void idle (void)
{
    glutSetWindow (winIdMain);
    glutPostRedisplay ();
    glutSetWindow (winIdSub);
    glutPostRedisplay ();
};
void drawString (char *s)
{
    unsigned int i;
    for (i = 0; i < strlen (s); i++)
        glutBitmapCharacter (GLUT_BITMAP_HELVETICA_10, s[i]);
};
void drawStringBig (char *s)
{
    unsigned int i;
    for (i = 0; i < strlen (s); i++)
        glutBitmapCharacter (GLUT_BITMAP_HELVETICA_12, s[i]);
};
static char label[100];                            /* Storage for current string   */
void subMenuDisplay()
{
    /* Clear subwindow */
    glutSetWindow (winIdSub);
    glClearColor(0.7f, 0.7f, 0.7f, 1.0f);
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    /* Write State Variables */
    glColor3f (1.0F, 1.0F, 1.0F);
    sprintf (label, "Number Of Particle LIQUID_PARTICLE + ELASTIC_PARTICLE + BOUNDARY_PARTICLE = %d + %d + %d", fluid_simulation->get_numOfLiquidP(),fluid_simulation->get_numOfElasticP(),fluid_simulation->get_numOfBoundaryP());
    glRasterPos2f (0.01F, 0.65F);
    drawStringBig (label);
    glColor3f (1.0F, 1.0F, 1.0F);
    sprintf (label, "FPS = %.2f ", fps);
    glRasterPos2f (0.01F, 0.20F);
    drawStringBig (label);

    glutSwapBuffers ();
};
コード例 #5
0
ファイル: PCAPlot.cpp プロジェクト: hillst/RCAPlot
void
MouseMotion( int x, int y )
{
	if( DebugOn != 0 )
		fprintf( stderr, "MouseMotion: %d, %d\n", x, y );


	int dx = x - Xmouse;		// change in mouse coords
	int dy = y - Ymouse;

	if( ( ActiveButton & LEFT ) != 0 )
	{
		switch( LeftButton )
		{
			case ROTATE:
				Xrot += ( ANGFACT*dy );
				Yrot += ( ANGFACT*dx );
				break;

			case SCALE:
				Scale += SCLFACT * (float) ( dx - dy );
				if( Scale < MINSCALE )
					Scale = MINSCALE;
				break;
		}
	}


	if( ( ActiveButton & MIDDLE ) != 0 )
	{
		Scale += SCLFACT * (float) ( dx - dy );

		// keep object from turning inside-out or disappearing:

		if( Scale < MINSCALE )
			Scale = MINSCALE;
	}

	Xmouse = x;			// new current position
	Ymouse = y;

	glutSetWindow( MainWindow );
	glutPostRedisplay( );
}
コード例 #6
0
void render()
{ 
  glutSetWindow(1);
  //Clear color buffer
  glClear( GL_COLOR_BUFFER_BIT );

  //Reset modelview matrix
  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
  

  glLineWidth(1.0) ; 


  //dibujamos el SOL
  glLineWidth(1.0) ;
  glColor3f( 0.77f, 0.12f, 0.12f );
  DrawDisk(0, 0, 10, 50);

  float r2=1;

  glColor3f( 0.3f, 0.12f, 0.6f );
  DrawDisk(Tierra.q(0), Tierra.q(1), r2, 50);


 
  if( trazo ){
    glColor4f( 0.1f, 0.8f, 0.1f, 0.1f );
    glLineWidth(2.0) ;
    glBegin(GL_LINES);    
    for(int i=1; i<trazounox.size();i++){
      glVertex2f(trazounox[i-1], trazounoy[i-1]);//output vertex           
      glVertex2f(trazounox[i], trazounoy[i]);//output vertex           
    };
    glEnd();
    
  };


  
  //Update screen 1
  glutSwapBuffers();
  
};
コード例 #7
0
ファイル: visu.cpp プロジェクト: BlueBrain/FlowVR
// Body of the main loop :
void IdleFunc()
{
  timeval time;
  static double timePreviousIt = -1.0;
  double timeCurrentIt = 0.0;

  // Blocks until new data is available on the input port.
  // Note that the synchronisation message on predefined output port "endIt" is sent just after the wait complete.
  // It is better to notify the compute nodes before the rendering task in order them to start as soon as possible a new calculation
  // and thus maximizing coupling.
  if (!pFlowVRModule->wait())
  {
    // Clean up and exit :
    if (tPrimeNumbers)
      delete [] tPrimeNumbers;
    if (pKeysPressed)
      delete [] pKeysPressed;
    CleanFlowVR();
    exit(0);
  }
  else
    // Visu module enters into a new iteration :
    iterationCounterVisu++;

  // Read received data (only if port connected to some producer)
  if (pFlowVRModule->isPortConnected(pPortPrimesIn)) ReceivePrimeNumbers();
  if (pFlowVRModule->isPortConnected(pPortKeysIn)) ReceiveKeysPressed();

  // Compute time elapsed since previous iteration, in seconds :
  gettimeofday(&time, NULL);
  timeCurrentIt = ((double)time.tv_sec) + ((double)time.tv_usec)*0.000001;
  if (timePreviousIt >= 0.0)
    timeElapsedSincePrevIteration = timeCurrentIt - timePreviousIt;
  else
    timeElapsedSincePrevIteration = 0.0;
  timePreviousIt = timeCurrentIt;

  // Use keys pressed information to update display according to user interaction :
  ProcessKeysPressed();

  // Update display:
  glutSetWindow(win_id);
  glutPostRedisplay();
}
コード例 #8
0
void
input_generator2 (INPUT_DESC *input,
		int status __attribute__ ((unused)))
{
	if (input->win == 0)
	{
		init_visual_search_thin (input);
	}
	else
	{
		if (status == MOVE)
		{
			check_input_bounds (input, input->wxd, input->wxd);
			glutSetWindow (input->win);
			input_display ();
			update_input_filters();
		}
	}
}
コード例 #9
0
void
Quit( )
{
	Glui->close( );
	glutSetWindow( MainWindow );
	glFinish( );
	glutDestroyWindow( MainWindow );


	// 13. clean everything up:

	clReleaseKernel(        Kernel   );
	clReleaseProgram(       Program  );
	clReleaseCommandQueue(  CmdQueue );
	clReleaseMemObject(     dPobj  );
	clReleaseMemObject(     dCobj  );

	exit( 0 );
}
コード例 #10
0
void
Keyboard( unsigned char c, int x, int y )
{
	if( DebugOn != 0 )
		fprintf( stderr, "Keyboard: '%c' (0x%0x)\n", c, c );

	switch( c )
	{
		case 'o':
		case 'O':
			WhichProjection = ORTHO;
			break;

		case 'p':
		case 'P':
			WhichProjection = PERSP;
			break;

		case 'q':
		case 'Q':
		case ESCAPE:
			DoMainMenu( QUIT );	// will not return here
			break;				// happy compiler


		case 'f':
		case 'F':
			Frozen = !Frozen;
			if (Frozen)
				glutIdleFunc(NULL);
			else
				glutIdleFunc(Animate);
			break;

		default:
			fprintf( stderr, "Don't know what to do with keyboard hit: '%c' (0x%0x)\n", c, c );
	}

	// force a call to Display( ):

	glutSetWindow( MainWindow );
	glutPostRedisplay( );
}
コード例 #11
0
ファイル: debug.c プロジェクト: BIC-MNI/bicgl
static  void  test_glut_windows( void )
{
    int  i, window_ids[8];

    window_ids[0] = test_glut_window( 0, 0, 0 );
    window_ids[1] = test_glut_window( 0, 0, 1 );
    window_ids[2] = test_glut_window( 0, 1, 0 );
    window_ids[3] = test_glut_window( 0, 1, 1 );
    window_ids[4] = test_glut_window( 1, 0, 0 );
    window_ids[5] = test_glut_window( 1, 0, 1 );
    window_ids[6] = test_glut_window( 1, 1, 0 );
    window_ids[7] = test_glut_window( 1, 1, 1 );

    for( i = 0;  i < 8;  ++i )
    {
        glutSetWindow( window_ids[i] );
        glutDisplayFunc( display_function );
    }
}
コード例 #12
0
ファイル: draw.c プロジェクト: MirkoFerrati/sdls
 void Reset( void )
 {
     ActiveButton = 0;
     AxesOn = false;
     LeftButton = ROTATE;
     Scale  = 1.0;
     Scale2 = 0.0;           /* because add 1. to it in Display()    */
     WhichProjection = ORTHO;
     Xrot = Yrot = 0.;
     TransXYZ[0] = TransXYZ[1] = TransXYZ[2] = 0.;
     WhichShape = YSHAPE;
     WhichMethod = SDLS;
     RotAxesOn = false;
     JointLimitsOn = false;
     RestPositionOn = false;
     UseJacobianTargets = false;
     EigenVectorsOn = false;
     
     RotMatrix[0][1] = RotMatrix[0][2] = RotMatrix[0][3] = 0.;
     RotMatrix[1][0]                   = RotMatrix[1][2] = RotMatrix[1][3] = 0.;
     RotMatrix[2][0] = RotMatrix[2][1]                   = RotMatrix[2][3] = 0.;
     RotMatrix[3][0] = RotMatrix[3][1] = RotMatrix[3][3]                   = 0.;
     RotMatrix[0][0] = RotMatrix[1][1] = RotMatrix[2][2] = RotMatrix[3][3] = 1.;
     
     treeY.Init();
     treeY.Compute();
     jacobY->Reset();
     
     treeDoubleY.Init();
     treeDoubleY.Compute();  
     jacobDoubleY->Reset();
     
     treeDoubleYDLS.Init();
     treeDoubleYDLS.Compute();
     jacobDoubleYDLS->Reset();
     
     treeDoubleYSDLS.Init();
     treeDoubleYSDLS.Compute();
     jacobDoubleYSDLS->Reset();
     
     glutSetWindow( GrWindow );
     glutPostRedisplay();
 }
コード例 #13
0
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
}
コード例 #14
0
void MultiCursorAppCpp::initGL(int argc, char* argv[])
{
	glutInit(&argc, argv);

	WinIDs = new int[TKinect2Display.size()];
	for (size_t i = 0; i < TKinect2Display.size(); ++i)
	{
		glutInitWindowPosition(i*20, 0);
		//glutInitWindowPosition(windowOffsetX[i], 0);
		glutInitWindowSize(VEC_WIN_WIDTH[i], VEC_WIN_HEIGHT[i]);

		glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
		char winName[8];
		_itoa((int)i, winName, 10);
		WinIDs[i] = glutCreateWindow(winName);

		//// Register callback functions
		//glutReshapeFunc(sreshape);
		glutDisplayFunc(sdisplay);
		glutIdleFunc(sidle);
		glutKeyboardFunc(skeyboard);
		glutMouseFunc(smouse);

		glClearColor(1.0, 1.0, 1.0, 1.0);

		/* Camera setup */
		glViewport(0, 0, kinectBasics.widthDepth, kinectBasics.heightDepth);
		glLoadIdentity();

		if (i == 0){
			/* GLのウィンドウをフルスクリーンに */
			//GLのデバイスコンテキストハンドル取得
			glutSetWindow(WinIDs[i]);
			HDC glDc = wglGetCurrentDC();
			//ウィンドウハンドル取得
			HWND hWnd = WindowFromDC(glDc);
			//ウィンドウの属性と位置変更
			SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
			SetWindowPos(hWnd, HWND_TOP, windowOffsetX[i], 0, VEC_WIN_WIDTH[i], VEC_WIN_HEIGHT[i], SWP_SHOWWINDOW);
		}
	}
}
コード例 #15
0
int
main( int argc, char *argv[ ] )
{
	// turn on the glut package:
	// (do this before checking argc and argv since it might
	// pull some command line arguments out)

	glutInit( &argc, argv );


	// setup all the graphics stuff:

	InitGraphics( );


	// create the display structures that will not change:

	InitLists( );


	// init all the global variables used by Display( ):
	// this will also post a redisplay

	Reset( );


	// setup all the user interface stuff:

	InitMenus( );


	// draw the scene once and wait for some interaction:
	// (this will never return)

	glutSetWindow( MainWindow );
	glutMainLoop( );


	// this is here to make the compiler happy:

	return 0;
}
コード例 #16
0
/// Removes a new view. Function has to be called just from the inside of view thread with a locked sync_view.
int remove_view_in_thread(void* remove_params_ptr)
{
  debug_assert(!need_safe_call(), "E remove_view_in_thread called from other thread.");
  RemoveParams& params = *(RemoveParams*)remove_params_ptr;
  std::map<int, View*>::iterator found_view = view_instances.find(params.view_id);
  //debug_assert(found_view != view_instances.end(), "E removing of a view that is not registered");
  if (found_view == view_instances.end()) {
    debug_log("W removing of a view that is not registered\n");
    return -1;
  }

  //destroy window if requested (it will not be requested when remove is called as a reaction to on_close)
  if (params.destroy_glut_window)
  {
    //remove window from GLUT
    glutSetWindow(params.view_id);
    glutSetWindowData(NULL); //prevent stubs from being executed if there is still some message waiting for the window

    //call on-close event
    found_view->second->on_close();

    //finish removal of window from GLUT
    glutDestroyWindow(params.view_id);
  }

  //remove from structures
  view_instances.erase(found_view);

  //thread cleanup
  if (view_instances.size() == 0)
  {
    view_thread->should_quit = true;
    view_thread = NULL;

    //signal all events
    view_sync.signal_close();
    view_sync.signal_keypress();
    view_sync.signal_drawing_finished();
  }

  return 0;
}
コード例 #17
0
ファイル: main.cpp プロジェクト: Shakebones/VFX
static void Idle()
{
	GetUserOperations(d0, v0);
	if (!bPause)
	{
		if (frame_counter != stopFrame)
		{
			KeepSource();
			//Advance();
			IVOCKAdvance();
			frame_counter++;
		}
		else
		{
			Reset();
		}
	}
	glutSetWindow(ID);
	glutPostRedisplay();
}
コード例 #18
0
ファイル: gui.cpp プロジェクト: nilthehuman/Retra
    void GUI::initialize( int* argc, char* argv[] )
    {
        glutInitWindowPosition( 200, 100 );
        glutInitWindowSize( camera->getGridwidth(), camera->getGridheight() );
        glutInit( argc, argv );
        glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
        windowId = glutCreateWindow( "Retra" );
        glutSetWindow( windowId );

        glutDisplayFunc( &redisplay );
        glutKeyboardFunc( &handleKeyPress );
        glutKeyboardUpFunc( &handleKeyRelease );
        glutSpecialFunc( &handleArrowKeyPress );
        glutSpecialUpFunc( &handleArrowKeyRelease );
        glutReshapeFunc( &undoReshape );

        glClearColor( 0, 0, 0, 1 );
        glClear( GL_COLOR_BUFFER_BIT );
        glutSwapBuffers();
    }
コード例 #19
0
ファイル: percolationgl.c プロジェクト: gwax/www-gwax
void renderSub2(void)	/*sub window for rms distance as a function of steps taken*/
{
	char buffer[255];

	glutSetWindow(subWindow2);	/*switch to sub window 2*/
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	/*draw stuff here*/
	glLoadIdentity();
	glColor3f(1.0,0.0,0.0);		/*display info about p sub c*/
	renderBitmapString(-1.75,1.9,-5,GLUT_BITMAP_HELVETICA_12,"p sub c is being estimated");
	renderBitmapString(-1.75,1.66,-5,GLUT_BITMAP_HELVETICA_12,"as the lowest occupation");
	renderBitmapString(-1.75,1.42,-5,GLUT_BITMAP_HELVETICA_12,"probability that results in");
	renderBitmapString(-1.75,1.18,-5,GLUT_BITMAP_HELVETICA_12,"a 50% chance of spanning");

	sprintf(buffer, "p sub c ~= %f", pc);
	renderBitmapString(-1.75,0.70,-5,GLUT_BITMAP_HELVETICA_12,buffer);
	
	glutSwapBuffers();	/*do the double buffer thing*/
}
コード例 #20
0
void
draw_output(char *output_name, char *input_name)
{
	OUTPUT_DESC *output;

	if ((g_label >= 0) && (g_label <= 9))
	{
		output = get_output_by_name(output_name);

		set_neurons(output->neuron_layer->neuron_vector, 0, output->ww * output->wh, 0);
		// user_set_neurons(output->neuron_layer->neuron_vector, output, g_label, NUM_COLORS - 1);
		fill_in_all_neurons_output_with_label(output->neuron_layer->neuron_vector, output, g_label);
		update_output_image(output);

#ifndef	NO_INTERFACE
		glutSetWindow(output->win);
		glutPostWindowRedisplay(output->win);
#endif
	}
}
コード例 #21
0
ファイル: penguin.cpp プロジェクト: mscho88/CSC418H1S
// Callback idle function for animating the scene
void animate()
{
	// Only update if enough time has passed
	// (This locks the display to a certain frame rate rather
	//  than updating as fast as possible. The effect is that
	//  the animation should run at about the same rate
	//  whether being run on a fast machine or slow machine)
	if( frameRateTimer->elapsed() > SEC_PER_FRAME )
	{
		// Tell glut window to update itself. This will cause the display()
		// callback to be called, which renders the object (once you've written
		// the callback).
		glutSetWindow(windowID);
		glutPostRedisplay();

		// Restart the frame rate timer
		// for the next frame
		frameRateTimer->reset();
	}
}
コード例 #22
0
///////////////////////////////////////////////////////////////////////////////
/// FFD routine for GLUT idle callback
///
///\param para Pointer to FFD parameters
///\param var Pointer to all variables
///\param BINDEX Pointer to bounary index
///
///\return No return needed
///////////////////////////////////////////////////////////////////////////////
void ffd_idle_func(PARA_DATA *para, REAL **var, int **BINDEX) {
  // Get the display in XY plane
  get_xy_UI(para, var, (int)para->geom->kmax/2);

  vel_step(para, var, BINDEX);
  den_step(para, var, BINDEX);
  temp_step(para, var, BINDEX);

  if(para->outp->cal_mean == 1)
    average_time(para, var);

  // Update the visualization results after a few tiem steps 
  // to save the time for visualization
  if(para->mytime->step_current%para->outp->tstep_display==0) {
    glutSetWindow(para->outp->win_id);
    glutPostRedisplay( );
  } 
  
  timing(para);
} // End of ffd_idle_func()
コード例 #23
0
// init the window: create the context  
void GLUTWindow::init(GLInitFunctor oFunc)
{
#if defined(WIN32)
    Inherited::setHdc  (wglGetCurrentDC     ());
    Inherited::setHglrc(wglGetCurrentContext());
    Inherited::setHwnd (WindowFromDC(Inherited::getHdc()));
#elif defined(__APPLE__)
    //Inherited::setContext(cocoaWrapperCurrentContext());
    Inherited::setContext(carbonWrapperCurrentContext());
#else
    glutSetWindow(getGlutId());

    Inherited::setDisplay(glXGetCurrentDisplay ());
    Inherited::setContext(glXGetCurrentContext ());
    Inherited::setWindow (glXGetCurrentDrawable());
#endif
    this->doDeactivate();

    Window::init(oFunc);
}
コード例 #24
0
ファイル: reflect.c プロジェクト: MttDs/new-rexeno-tindpe
static void
Idle(void)
{
   double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
   struct window *w;
   for (w = FirstWindow; w; w = w->next) {
      if (w->anim) {
         double dt;
         if (w->t0 < 0.0)
            w->t0 = t;
         dt = t - w->t0;
         w->t0 = t;
         w->spin += 60.0 * dt;
         w->yrot += 90.0 * dt;
         assert(w->id);
         glutSetWindow(w->id);
         glutPostRedisplay();
      }
   }
}
コード例 #25
0
void idleFun ( void )
{
	struct timeval tt1, tt2;
	static int it = 0;
	static struct timeval tt3, tt4;
	tt3=tt4;
	gettimeofday(&tt4, NULL);

	gettimeofday(&tt1, NULL);
	animate();
	gettimeofday(&tt2, NULL);
	int milliSeconds = (tt2.tv_sec - tt1.tv_sec) * 1000 + (tt2.tv_usec - tt1.tv_usec)/1000;
	cout<<"Iteration "<<it<<" : "<<milliSeconds<<"ms"<<endl;
	int milliSeconds2 = (tt4.tv_sec - tt3.tv_sec) * 1000 + (tt4.tv_usec - tt3.tv_usec)/1000;
	cout<<"Actual   "<<it<<" : "<<milliSeconds2<<"ms"<<endl<<endl;

	it++;
	glutSetWindow ( winId );
	glutPostRedisplay ( );
}
コード例 #26
0
void main(int argc, char **argv)
{
    glutInit( &argc, argv );
    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
    glutInitWindowSize(500, 500);
    glutInitWindowPosition(100, 100);

    int windowHandle = glutCreateWindow("Comp390 TME 2 pt 1");
    glutSetWindow(windowHandle);

    glutDisplayFunc( display );
    glutReshapeFunc( reshape );

    initialize();

    // init Menus
    createPopupMenus();

    glutMainLoop();
}
コード例 #27
0
ファイル: Camera.c プロジェクト: AM1244/Blog
//-------------------------------------------------------------------------
// Redisplays all subwindows
//-------------------------------------------------------------------------
void redisplayAll ()
{
    glutSetWindow (subwindow_1);
    glutPostRedisplay ();
    glutSetWindow (subwindow_2);
    glutPostRedisplay ();
    glutSetWindow (subwindow_3);
    glutPostRedisplay ();
    glutSetWindow (subwindow_4);
    glutPostRedisplay ();
    glutSetWindow (subwindow_5);
    glutPostRedisplay ();
    glutSetWindow (subwindow_6);
    glutPostRedisplay ();
}
コード例 #28
0
static void IdleFunc()
{
	// Get user input
	GetFromUI(DeltaDensityFieldRed,
			  DeltaDensityFieldGreen,
			  DeltaDensityFieldBlue,
			  DeltaTemperatureField,
			  AccelerationField);

	// Add gravity and temperature forces to velocity field.
	// Assumes the ambient temperature is zero.
	for (int i = 0; i < TotalGridCells; ++i)
	{
		double tot_den = (*DensityFieldRed)[i]
			+ (*DensityFieldGreen)[i]
			+ (*DensityFieldBlue)[i];
		double T = (*TemperatureField)[i];
		(*AccelerationField)[i] += Vec2(0, -(alpha * tot_den) + (beta * T));
	}

	// Advance sim
	VelocityField->TimeStep(*AccelerationField, *VelocityField);
	DensityFieldRed->TimeStep(*DeltaDensityFieldRed, *VelocityField);
	DensityFieldGreen->TimeStep(*DeltaDensityFieldGreen, *VelocityField);
	DensityFieldBlue->TimeStep(*DeltaDensityFieldBlue, *VelocityField);
	TemperatureField->TimeStep(*DeltaTemperatureField, *VelocityField);

	glutSetWindow(WinId);
	glutPostRedisplay();

	// Calculate fps
	int cur_time = glutGet(GLUT_ELAPSED_TIME);
	if (cur_time - PrevFpsTakenTime > 1000)
	{
		float fps = (1000.0f * FpsFrameNumber) / static_cast<float>(cur_time - PrevFpsTakenTime);
		sprintf(FpsString, "FPS: %4.2f", fps);
		PrevFpsTakenTime = cur_time;
		FpsFrameNumber = 0;
	}
	FpsFrameNumber++;
}
コード例 #29
0
/*
 * void animate();
 *
 * This acts as the idle function, whenever the system is idle, animte() is
 * called.  The end of animate() forces display() to refresh
 */
void animate() {
	int j;
	
	while((double) clock() == current){} // waits for next time step
	current = (double) clock();

	for(j = 0; j < all_spheres.size(); j++) {
		
		// DECAY
		double decay = (rand() % 101)/100.;

		if( all_spheres[j].radius>0.0) {
			if( decay <= DECAY_PROB && all_spheres[j].active) {
				all_spheres[j].radius -= 0.00045;
			}
		}else{
			all_spheres.erase(all_spheres.begin()+j);
			balls--;
			break;
		}
		// END DECAY

		if(all_spheres[j].path == 0) { //linear paths
			// advance position on vector
			all_spheres[j] = move_on_vector(all_spheres[j]);
		
		}else if(all_spheres[j].path == 1) { // bezier curves for path	
			
			if( all_spheres[j].interval < 1.0) {
				// advance position on curve
				move_on_curve(&all_spheres[j]);
			} else { 
				// generate a new curve
				generate_curve(&all_spheres[j]);		
			}
		}	
	}
	// set window and call display to refresh screen
	glutSetWindow(window);
	glutPostRedisplay();
}
コード例 #30
0
ファイル: main.cpp プロジェクト: chunkyan/DirectX
void main(int argc, char** argv)
{
    W = 800; H = 800;

    int windowHandle = glutCreateWindow("Program 2");
    glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
	glEnable(GLUT_RGBA);
    glutSetWindow(windowHandle);
    glutPositionWindow ( 100, 10 );
    glutReshapeWindow( W, H );
    initializeGraphics();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutIdleFunc(update);
    glutSpecialFunc( specialChar );
    glutKeyboardFunc( keyBoard );
	glutMouseFunc( mouseFunc );
	glutPassiveMotionFunc(idleMouse);
    glutMainLoop();
	cleanup();
}