Ejemplo n.º 1
0
bool InitApp() 
{
	// create GLUT menu:
	int menu = glutCreateMenu(ProcessMenu);
	glutAddMenuEntry("Reset Camera", MENU_RESET);
	glutAddMenuEntry("euler integration", MENU_EULER);
	glutAddMenuEntry("verlet integration", MENU_VERLET);
	glutAddMenuEntry("Exit", MENU_EXIT);
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	glEnable(GL_DEPTH_TEST);
	
	g_meshDisplayList = glGenLists(1);

	glNewList(g_meshDisplayList,GL_COMPILE);
		glutSolidSphere(0.15f, 8, 8);
	glEndList();

	srand(time(NULL));

	if (utLoadAndBuildShader("data\\light.vert", "data\\light.frag", &g_shaderLight) == false)
		return false;

	g_camera.m_zoom = 10.0f;

	InitSimulation();

	return true;
}
Ejemplo n.º 2
0
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	// Set desired system states and initialize HGE

	hge->System_SetState(HGE_LOGFILE, "hge_tut08.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 08 - The Big Calm");
	hge->System_SetState(HGE_USESOUND, false);
	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_SCREENWIDTH, SCREEN_WIDTH);
	hge->System_SetState(HGE_SCREENHEIGHT, SCREEN_HEIGHT);
	hge->System_SetState(HGE_SCREENBPP, 32);

	if(hge->System_Initiate())
	{
		fnt=new hgeFont("font2.fnt");
		
		if(!InitSimulation())
		{
			// If one of the data files is not found, display an error message and shutdown
			MessageBox(NULL, "Can't load resources. See log for details.", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		hge->System_Start();

		DoneSimulation();
		delete fnt;
	}

	hge->System_Shutdown();
	hge->Release();
	return 0;
}
Ejemplo n.º 3
0
void KeyboardCB(unsigned char key, int x, int y)
{
	switch (key) {
		case 'q':
		case 27:
			exit(0); 
		case 'f': // take a snapshot in ppm format
			g_frameSaver.DumpPPM(g_width,g_height) ;
			break;
		case 't':
			resetTime() ;
			break ;
		case 'r':
			resetArcball() ;
			Reset() ;
			g_zoom = 1 ;
			glutPostRedisplay() ;
			break ;
		case 'a': // toggle animation state
			if( g_state == STATE_ANIMATE )
			{
				g_state = STATE_IDLE ;
			}
			else
			{
				resetTime() ;
				g_state = STATE_ANIMATE ;
			}
			break ;
		case 's': // togle simulation state
			if( g_state == STATE_SIMULATE )
			{
				g_state = STATE_IDLE ;
			}
			else
			{
				resetTime() ;
				InitSimulation() ;
				g_state = STATE_SIMULATE ;
			}
			break ;
		case 'p': // togle playback
			if( g_state == STATE_PLAYBACK )
			{
				g_state = STATE_IDLE ;
			}
			else
			{
				g_state = STATE_PLAYBACK ;
			}
			break ;
		case '0':
			//reset your object
			break ;
		case 'm': // toggle frame dumping
			if( g_frameDumping == 1 )
			{
				animTcl::OutputMessage("Frame Frame Dumping disabled.\n") ;
				g_frameDumping = 0 ;
			}
			else
			{
				animTcl::OutputMessage("Frame Frame Dumping enabled.\n") ;
				g_frameDumping = 1  ;
			}
			g_frameSaver.Toggle(g_width);
			break ;
		case 'h':
		case '?':
			instructions();
			break;
	}

	myKey(key, x, y) ;

	glutPostRedisplay() ;

}