• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ HandleEvents函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CaptureUserInput

void * CaptureUserInput(void * arg) { 
	int i;
	
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() ", "pre_getMyDeviceType");
	GetMyDeviceType();
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() ", "pre_ReadDeviceKeyDB");
	ReadDeviceKeyDB();
	
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() ", "post_ReadDeviceKeyDB");
	printf("sizeof(struct input_event) = %d\n", sizeof(struct input_event));
	maxEventPlusOne = -1;
			
	char aLine[256];
	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {		
		sprintf(aLine, "i = %d", i);
		if (nKeyEntries[i] == 0) {
			inputEvents[i] = -1;
		} else {
			inputEvents[i] = OpenInputDevice(i);
			if (inputEvents[i] > maxEventPlusOne) {
				maxEventPlusOne = inputEvents[i];
				sprintf(aLine, "NOT_EXPECTED: i = %d, inputEvents[i] (%d) > maxEventPlusOne = %d", 
					i, inputEvents[i], maxEventPlusOne);
				#ifdef TEST_INPUT
				WriteUserInputLog("libpcap: b CaptureUserInput() nKeyEntries[i] != 0 ", aLine);
				#endif
			} 
		}
	}
	maxEventPlusOne++;	
	
	while (1) {
		if  (!HandleEvents()) { 
		    #ifdef TEST_INPUT
		    WriteUserInputLog("libpcap: After HandleEvents returns 0 in CaptureUserInput() ", 
					"setting exitFlag = 3 and breaking from loop");
		    #endif
		    exitFlag = 3; 
		    break; 
		}
		if (exitFlag == 4) { 
		    #ifdef TEST_INPUT
		    WriteUserInputLog("libpcap: After HandleEvents exitFlag is 4 ", 
					"setting exitFlag = 3 and breaking from loop");
		    #endif
		    exitFlag = 3; 
		    break; 
		}
	}
	printf("Thread CaptureUserInput() exit.\n");
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() exit", "EXIT");
	printf("sizeof(struct input_event) = %d\n", sizeof(struct input_event));
	
	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {
		CloseInputDevice(i);
	}
	CloseUserInputLog();
	return 0;
}
开发者ID:904498910,项目名称:ARO,代码行数:59,代码来源:user_input.c


示例17: FrameStart

void BaseScene::RunFrame() {
	FrameStart();
	HandleEvents();
	Update();
	Render(screen);
	SDL_Flip(screen);
	FrameEnd();
}
开发者ID:Ratstail91,项目名称:Gene-Bot,代码行数:8,代码来源:base_scene.cpp


示例18: lock

// internal routines, run by the posting thread
void LinuxaioQueue::PostRequests() {
    RequestPtr req;
    io_event* events = new io_event[max_events_];

    for ( ; ; ) // as long as thread is running
    {
        // might block until next request or message comes in
        size_t num_currently_waiting_requests = num_waiting_requests_.wait();

        // terminate if termination has been requested
        if (post_thread_state_() == TERMINATING && num_currently_waiting_requests == 0)
            break;

        std::unique_lock<std::mutex> lock(waiting_mtx_);
        if (!waiting_requests_.empty())
        {
            req = waiting_requests_.front();
            waiting_requests_.pop_front();
            lock.unlock();

            // might block because too many requests are posted
            num_free_events_.wait();

            // polymorphic_downcast
            while (!dynamic_cast<LinuxaioRequest*>(req.get())->post())
            {
                // post failed, so first handle events to make queues (more)
                // empty, then try again.

                // wait for at least one event to complete, no time limit
                long num_events = syscall(SYS_io_getevents, context_, 1, max_events_, events, nullptr);
                if (num_events < 0) {
                    THRILL_THROW_ERRNO(IoError, "linuxaio_queue::post_requests"
                                       " io_getevents() nr_events=" << num_events);
                }

                HandleEvents(events, num_events, false);
            }

            // request is finally posted

            {
                std::unique_lock<std::mutex> lock(posted_mtx_);
                posted_requests_.push_back(req);
                num_posted_requests_.signal();
            }
        }
        else
        {
            lock.unlock();

            // num_waiting_requests-- was premature, compensate for that
            num_waiting_requests_.signal();
        }
    }

    delete[] events;
}
开发者ID:manpen,项目名称:thrill,代码行数:59,代码来源:linuxaio_queue.cpp


示例19: while

    int CSDL_ApplicationBase::Main(int argc, char *argv[]) {
        while(m_bIsRunning) {
            m_pKeystate = ::SDL_GetKeyState(NULL);
            m_Modstate = ::SDL_GetModState();
            HandleEvents();
        }

        return EXIT_SUCCESS;
    }
开发者ID:puring0815,项目名称:OpenKore,代码行数:9,代码来源:csdl.cpp


示例20: while

void Game::RunGameLoop()
{
	while (window->isOpen())
	{
		HandleEvents();
		Update();
		Draw();
	}
}
开发者ID:Pandamonium-san,项目名称:Boids,代码行数:9,代码来源:Game.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HandleException函数代码示例发布时间:2022-05-30
下一篇:
C++ HandleEvent函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap