当前位置: 首页>>代码示例>>C++>>正文


C++ HandleEvents函数代码示例

本文整理汇总了C++中HandleEvents函数的典型用法代码示例。如果您正苦于以下问题:C++ HandleEvents函数的具体用法?C++ HandleEvents怎么用?C++ HandleEvents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HandleEvents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetTime

void PlatformDesktop::SingleLoop() 
{
	if( mEventRecorder )
		mEventRecorder->StartOfFrame( GetTime() );

	HandleEvents();

	poro_assert( GetApplication() );
	poro_assert( mGraphics );

	types::Double32 dt = mOneFrameShouldLast;
	if( mFixedTimeStep == false )
	{
		static types::Double32 last_time_update_called = 0;
		dt = (types::Double32)( GetUpTime() - last_time_update_called );
		last_time_update_called = GetUpTime();
	}

	GetApplication()->Update( (types::Float32)(dt) );

	mGraphics->BeginRendering();
	GetApplication()->Draw(mGraphics);
	mGraphics->EndRendering();

	if( mEventRecorder )
		mEventRecorder->EndOfFrame( GetTime() );
}
开发者ID:gummikana,项目名称:qr_test,代码行数:27,代码来源:platform_desktop.cpp

示例2: CaptureUserInput

void * CaptureUserInput(void * arg) {
	int i;
	
	GetMyDeviceType();
	ReadDeviceKeyDB();
	
	printf("sizeof(struct input_event) = %d\n", sizeof(struct input_event));
	maxEventPlusOne = -1;
			
	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {		
		if (nKeyEntries[i] == 0) {
			inputEvents[i] = -1;
		} else {
			inputEvents[i] = OpenInputDevice(i);
			if (inputEvents[i] > maxEventPlusOne) maxEventPlusOne = inputEvents[i];
		}
	}
	maxEventPlusOne++;	
	
	while (1) {
		if (!HandleEvents()) break;
	}

	printf("Thread CaptureUserInput() exit.\n");

	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {
		CloseInputDevice(i);
	}
	
	return 0;
}
开发者ID:ynyntracyzhou,项目名称:RobustDataCollector,代码行数:31,代码来源:user_input.c

示例3: Initialise

void GameStateManager::Run(void)
{
	Initialise();

	while (m_running)
	{
		// If a new state is set to begin, set it now
		if (m_preparedState)
			InitialisePreparedState();

		// Update static key states
		KeyTools::UpdateStates();
		// State's key press responses
		m_currentState->OnKeys(SDL_GetKeyboardState(nullptr));
		// Update State
		m_currentState->OnUpdate(delta);
		// Render State
		m_currentState->OnRender();
		
		HandleEvents();
		delta = RegulateFrameRate();
	}

	delete this;
}
开发者ID:JordanBell,项目名称:LastGame,代码行数:25,代码来源:GameStateManager.cpp

示例4: while

 void Game::Run()
 {
     const float TargetFps = 60.0f;
     const float DelayTime = 1000.0f / TargetFps;
     
     gameState = RUNNING;
     
     while(gameState == RUNNING)
     {
         frameStart = SDL_GetTicks();
         
         HandleEvents();
         Update();
         Render();
         
         
         frameCount += 1;
         frameTime = SDL_GetTicks() - frameStart;
         
         if(frameStart < DelayTime)
         {
             SDL_Delay((int)(DelayTime - frameTime));
         }
         
     }
     
     Clean();
 }
开发者ID:beersbr,项目名称:ludum_dare_28,代码行数:28,代码来源:Game.cpp

示例5: InitWindow

void Displayer::RenderLoop()
{
	InitWindow();
		
	while (win->IsOpened() && !closed)
	{
		HandleEvents();
			
		// Don't draw if disabled/minimised
		if (!Displayer::drawingEnabled)
			continue;

		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, win->GetWidth(), win->GetHeight(), 0, -1, 1);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		glClearColor(0, 0, 0, 1);
		glClear(GL_COLOR_BUFFER_BIT);

		// Draw panels
		controlPanel->Draw(*win, defaultFont);
		DrawWorldPanel();
			
		// Display and sleep
		win->Display();
		sf::Sleep(1.0f / refreshRate);
	}
}
开发者ID:Seltzer,项目名称:Algovis---Algorithm-Visualisation,代码行数:31,代码来源:display.cpp

示例6: SDL_GetTicks

void GameEngine::Start()
{
  int ticksPerFrame = (int)(1000.0 / FPS_TARGET + 0.5);
  Uint32 nextSecond = SDL_GetTicks() + 1000;
  int frames = 0;

  Mix_Chunk *track = NULL;
  int channel = 0; 

  _isRunning = true;
  while (_isRunning)
  {
    _frameTimer.Mark();

    HandleEvents();
    Update();
    Draw();

    // If there is no music playing
    if(Mix_Playing(channel) == 0)
      // Play music
      channel = Music(track);

    if (_frameTimer.GetTicks() < ticksPerFrame)
      SDL_Delay(ticksPerFrame - _frameTimer.GetTicks());
    if (SDL_GetTicks() >= nextSecond)
    {
      nextSecond += 1000;
      _currentFps = frames;
      frames = 0;
    }
    ++frames;
  }
}
开发者ID:larsemil,项目名称:project-destination,代码行数:34,代码来源:GameEngine.cpp

示例7: NewGameWindow

Word NewGameWindow(Word NewVidSize)
{
	XSizeHints sizehints;
		
	if (NewVidSize == VidSize)
		return VidSize;
	
	if (NewVidSize < 4) {
		w = VidXs[NewVidSize];
		h = VidYs[NewVidSize];
		v = VidVs[NewVidSize];
	} else {
		fprintf(stderr, "Invalid Vid size: %d\n", NewVidSize);
		exit(EXIT_FAILURE);
	}

	sizehints.min_width =  w;
	sizehints.min_height = h;
	sizehints.flags = PMinSize;
	XSetWMNormalHints(dpy, win, &sizehints);
	XResizeWindow(dpy, win, w, h);
	
	SetAPalette(rBlackPal);
	ClearTheScreen(BLACK);
	BlastScreen();
	
	VidSize = NewVidSize;
	
	XSync(dpy, False);
	glXWaitGL();
	glXWaitX();
	HandleEvents();
	
	return VidSize;
}
开发者ID:PocketInsanity,项目名称:wolf3d,代码行数:35,代码来源:vi_glx.c

示例8: HandleWindowEvents

void GameEngine::Run()
{
    HandleWindowEvents();
    HandleEvents();
    Update();
    Draw();
}
开发者ID:lukezimmerer,项目名称:Arkanoid,代码行数:7,代码来源:gameEngine.cpp

示例9: main

int
main( int argc, char **argv )
{
    /* Save our program name - for error messages */
	set_DeadPipe_handler(DeadPipe);
    InitMyApp (CLASS_IDENT, argc, argv, NULL, NULL, 0 );
	LinkAfterStepConfig();

    set_signal_handler( SIGSEGV );

    ConnectX( ASDefaultScr, 0 );
    ConnectAfterStep (WINDOW_CONFIG_MASK |
                      WINDOW_NAME_MASK |
                      M_END_WINDOWLIST, 0);
    Config = CreateIdentConfig ();

    /* Request a list of all windows, while we load our config */
    SendInfo ("Send_WindowList", 0);

    LoadBaseConfig ( GetBaseOptions);
	LoadColorScheme();
	LoadConfig ("ident", GetOptions);
    CheckConfigSanity();
	ReloadASDatabase();
	ReloadCategories(True);

	if (MyArgs.src_window == 0)
		MyArgs.src_window = get_target_window();

	/* And at long last our main loop : */
    HandleEvents();
	return 0 ;
}
开发者ID:Remmy,项目名称:afterstep,代码行数:33,代码来源:Ident.c

示例10: Initialize

void Application::Run() {
    Initialize();

    double tickCounter = 0;
    int frames = 0;
    clock_t t1 = clock();
    clock_t t2;

    while(!HandleEvents()) {
        Update();
        BeginDraw();
        Draw();
        EndDraw();

        frames++;
        t2 = clock();
        clock_t diff = t2 - t1;

        //Guarantee a maximum fps rate
        double sleepInteval = (double)CLOCKS_PER_SEC / fps - diff;
        if(sleepInteval > 0) {
            usleep(1000000 * sleepInteval / CLOCKS_PER_SEC);
            tickCounter += sleepInteval;
        }

        //Display FPS rate
        tickCounter += diff;
        if(tickCounter > CLOCKS_PER_SEC) {
            _frameRate = frames;
            tickCounter = 0;
            frames = 0;
        }
        t1 = clock();
    }
}
开发者ID:vitillo,项目名称:zeroengine,代码行数:35,代码来源:Application.cpp

示例11: Sys_SendKeyEvents

void Sys_SendKeyEvents (void) {
  // XEvent event; // bk001204 - unused

  if (!screen)
    return;
  HandleEvents();
}
开发者ID:martinez-zea,项目名称:localconflict,代码行数:7,代码来源:sdl_glimp.c

示例12: HandleCollision

void Map::Update()
{
	for (std::vector<Entity*>::iterator it = entities.begin(); it != entities.end();)
	{
		if ((*it)->active)
			++it;
		else {
			delete *it;
			it = entities.erase(it);
		}
	}

	HandleCollision();
	HandleEvents();

	Entity* entity;
	for (std::vector<Entity*>::iterator it = entities.begin(); it != entities.end(); ++it)
	{
		entity = (*it);
		if (entity->OnScreen == false)
			continue;
		if (entity->GetLight() > 0 && ((int) entity->shape->GetCenterX() != (int) (entity->prevPos.x + entity->GetSize().x / 2.0) || (int) entity->shape->GetCenterY() != (int) (entity->prevPos.y + entity->GetSize().y / 2.0)))
			lightDirty = true;
	}
	skyManager->Update();
}
开发者ID:SharkDX,项目名称:PenguinBasket,代码行数:26,代码来源:Map.cpp

示例13: main

int main(int argc, char* argv[])
{
	SDL_Init(SDL_INIT_EVERYTHING);
	atexit(SDL_Quit);

	debugLogFile = fopen("stderr.txt", "wb");
	{
		char buffer[128];
		const time_t raw(time(NULL));
		const struct tm* local(localtime(&raw));
		strftime(buffer, sizeof(buffer)-1, "%c\n", local);
		LOG("%s", buffer);
	}

	if (!Initialise()) { exit(EXIT_FAILURE); }

	unsigned int lastUpdate = 0;
	while (!quit)
	{
		HandleEvents();

		unsigned int now = SDL_GetTicks();
		unsigned int elapsedMS = now - lastUpdate;
		lastUpdate = now;
		UpdateGame(elapsedMS);

		RenderFrame();

		Device::SwapBuffers();
	}

	return 0;
}
开发者ID:geoff-wode,项目名称:strumpfaffen,代码行数:33,代码来源:main.cpp

示例14: while

void Game::Run(){
	while (running)	{

		
		//trap mouse curser in window
		HWND hwnd;
		hwnd = FindWindow(0,LPCWSTR("Pew"));
		RECT r;
		//top left coords
		r.left = window.getPosition().x;
		r.top = window.getPosition().y;
		//bottom right coords
		r.right = window.getPosition().x + window.getSize().x;
		r.bottom = window.getPosition().y + window.getSize().y;

		//clip mouse to window
		GetWindowRect(hwnd, &r);
		ClipCursor(&r);
		
		//do the game stuff
		Update();
		HandleEvents();
		Render();
		Quit();		
	}
}
开发者ID:nebula2,项目名称:Pew,代码行数:26,代码来源:Game.cpp

示例15: main

int main(int argc, char *argv[])
{
  initialize();
  
  srand(time(NULL));
    
  SDL_Surface *screen;
  screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_SWSURFACE);
  
  if ( screen == NULL )
    {
      fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError());
      exit(1);
    }
  
  //Main game loop
  while(1)
    {
      //Check for end game conditions
      if (!player.alive)
	{ RenderFinal(screen, FALSE); }
      else if (g_monsters == NULL)
	{ RenderFinal(screen, TRUE); }
	
      UpdateState();

      RenderState(screen);
      
      HandleEvents();
      
      usleep(50000);
    }
}
开发者ID:astine,项目名称:Gingerwar,代码行数:33,代码来源:helloworld.c


注:本文中的HandleEvents函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。