Esempio n. 1
0
int main(int argc, char *argv[])
{
	memset(&_esContext, 0, sizeof(ESContext));

	_esContext.height = 600;
	_esContext.width = 800;

	if (esMain(&_esContext) != GL_TRUE)
	{
		return 1;
	}

	WinLoop(&_esContext);

	if (_esContext.shutdownFunc != NULL)
	{
		_esContext.shutdownFunc(&_esContext);
	}

	if (_esContext.userData != NULL)
	{
		free(_esContext.userData);
	}

	return 0;
}
Esempio n. 2
0
///
//  main()
//
//      Main entrypoint for application
//
int main ( int argc, char *argv[] )
{
   ESContext esContext;

   memset ( &esContext, 0, sizeof ( ESContext ) );

   if ( esMain ( &esContext ) != GL_TRUE )
   {
      return 1;
   }

   WinLoop ( &esContext );

   if ( esContext.shutdownFunc != NULL )
   {
      esContext.shutdownFunc ( &esContext );
   }

   if ( esContext.userData != NULL )
   {
      free ( esContext.userData );
   }

   return 0;
}
Esempio n. 3
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	AAContext aaContext;
	UserData userData;
	aaInitContext(&aaContext);
	aaContext.userData = &userData;
	aaCreateWindow(&aaContext, L"A Rotating Sphere!", 1000, 1000);
	GLenum glewinit = glewInit();
	Init(&aaContext);
	Sphere sphere;
	userData.sphere = &sphere;
	GenSphere(200, 5.0, &sphere);
	userData.eye[0] = 0.0f;
	userData.eye[1] = 0.0f;
	userData.eye[2] = -8.0f;
	aaRegisterKeyFunc(&aaContext, KeyFunc);
	aaRegisterDrawFunc(&aaContext, Draw);
	WPARAM result = WinLoop(&aaContext);
	Cleanup(&aaContext);
	return result;
}
Esempio n. 4
0
//  esMainLoop()
//
//    Start the main loop for the OpenGL ES application
void ESUTIL_API esMainLoop(ESContext *esContext)
{
	WinLoop(esContext);
}
Esempio n. 5
0
/** Game event loop. */
void EventLoop() {

   struct timeval last, current;
   unsigned long elapsedTime;
   int repeat;
   XEvent event;

   SetFirstLevel();

   XSelectInput(display, mainWindow, KeyPressMask | KeyReleaseMask
      | ButtonPressMask | ButtonReleaseMask | ExposureMask);

   shouldExit = 0;

   DoStartDelay();

   gettimeofday(&last, NULL);

   while(!shouldExit) {

      if(didWin) {
         WinLoop();
         NextLevel();
         moveRight = 0;
         moveLeft = 0;
         gettimeofday(&last, NULL);
      }
      if(didLose) {
         Redraw();
         DoStartDelay();
         break;
      }

      while(XPending(display) > 0) {
         XNextEvent(display, &event);
         switch(event.type) {
         case Expose:
            HandleExposeEvent(&event.xexpose);
            break;
         case KeyPress:
            HandleKeyPressEvent(&event.xkey);
            break;
         case KeyRelease:
            HandleKeyReleaseEvent(&event.xkey);
            break;
         case ButtonPress:
            HandleButtonPressEvent();
            break;
         default:
            break;
         }
      }

      if(isPaused) {
         gettimeofday(&last, NULL);
         continue;
      }

      gettimeofday(&current, NULL);
      elapsedTime = (current.tv_sec - last.tv_sec) * 1000000;
      elapsedTime += current.tv_usec - last.tv_usec;

      if(elapsedTime >= SPEED) {
         last = current;

         EraseBall();
         repeat = (int)(((float)elapsedTime / SPEED) + 0.5);
         do {
            if(moveRight && !moveLeft) {
               MoveBallRight();
            } else if(moveLeft && !moveRight) {
               MoveBallLeft();
            }
            MoveBall();
            --repeat;
         } while(repeat);
         DrawBall();

         Redraw();

         if(didDie) {
            didDie = 0;
            DoStartDelay();
            gettimeofday(&last, NULL);
         }

      }

   }
}