// virtual void LLQueuedThread::run() { // call checPause() immediately so we don't try to do anything before the class is fully constructed checkPause(); startThread(); mStarted = TRUE; while (1) { // this will block on the condition until runCondition() returns true, the thread is unpaused, or the thread leaves the RUNNING state. checkPause(); if (isQuitting()) { endThread(); break; } mIdleThread = FALSE; threadedUpdate(); int res = processNextRequest(); if (res == 0) { mIdleThread = TRUE; ms_sleep(1); } //LLThread::yield(); // thread should yield after each request } LL_INFOS() << "LLQueuedThread " << mName << " EXITING." << LL_ENDL; }
//----------------------------------------------------------------------------// bool CEGuiD3D9BaseApplication::execute_impl(CEGuiSample* sampleApp) { sampleApp->initialiseSample(); // // This is basically a modified Win32 message pump // bool idle; HRESULT coop; while (Win32AppHelper::doWin32Events(idle)) { if (idle) { CEGUI::System& guiSystem = CEGUI::System::getSingleton(); // do time based updates DWORD thisTime = GetTickCount(); const float elapsed = static_cast<float>(thisTime - d_lastFrameTime) / 1000.0f; d_lastFrameTime = thisTime; // handle D3D lost device stuff coop = pimpl->d_3DDevice->TestCooperativeLevel(); if (coop == D3DERR_DEVICELOST) { Sleep(500); continue; } else if (coop == D3DERR_DEVICENOTRESET) { if (!resetDirect3D()) { continue; } } Win32AppHelper::doDirectInputEvents(pimpl->d_directInput); // draw display if (FAILED(pimpl->d_3DDevice->BeginScene())) continue; renderSingleFrame(elapsed); } // check if the application is quitting, and break the loop next time // around if so. if (isQuitting()) PostQuitMessage(0); } return true; }
/*virtual*/ void run(void) { while(!isQuitting() && LLPluginProcessParent::getUseReadThread()) { LLPluginProcessParent::poll(0.1f); checkPause(); } // Final poll to clean up the pollset, etc. LLPluginProcessParent::poll(0.0f); }
//----------------------------------------------------------------------------// bool CEGuiGLFWSharedBase::execute_impl(CEGuiSample* sampleApp) { sampleApp->initialiseSample(); // Input callbacks of glfw for CEGUI glfwSetKeyCallback(glfwKeyCallback); glfwSetCharCallback(glfwCharCallback); glfwSetMouseButtonCallback(glfwMouseButtonCallback); glfwSetMouseWheelCallback(glfwMouseWheelCallback); glfwSetMousePosCallback(glfwMousePosCallback); //Window callbacks glfwSetWindowSizeCallback(glfwWindowResizeCallback); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // set starting time d_frameTime = glfwGetTime(); while (!isQuitting() && !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED)) { if (d_windowSized) { d_windowSized = false; CEGUI::System::getSingleton(). notifyDisplaySizeChanged( CEGUI::Sizef(static_cast<float>(d_newWindowWidth), static_cast<float>(d_newWindowHeight))); } drawFrame(); } glfwTerminate(); return true; }
bool LLApp::isExiting() { return isQuitting() || isError(); }
//----------------------------------------------------------------------------// bool CEGuiD3D10BaseApplication::execute(CEGuiSample* sampleApp) { sampleApp->initialiseSample(); float clear_colour[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; // // This is basically a modified Win32 message pump // bool idle; while (Win32AppHelper::doWin32Events(idle)) { if (idle) { CEGUI::System& guiSystem = CEGUI::System::getSingleton(); // do time based updates DWORD thisTime = GetTickCount(); float elapsed = static_cast<float>(thisTime - d_lastFrameTime); d_lastFrameTime = thisTime; // inject the time pulse guiSystem.injectTimePulse(elapsed / 1000.0f); updateFPS(); char fpsbuff[16]; sprintf(fpsbuff, "FPS: %d", d_FPS); Win32AppHelper::doDirectInputEvents(pimpl->d_directInput); // get render target view // this is a bit wasteful, but done like this for now since the // resize code can change the view from under us. ID3D10RenderTargetView* rtview; pimpl->d_device->OMGetRenderTargets(1, &rtview, 0); // clear display pimpl->d_device->ClearRenderTargetView(rtview, clear_colour); // main CEGUI rendering call guiSystem.renderGUI(); // render FPS: CEGUI::Font* fnt = guiSystem.getDefaultFont(); if (fnt) { guiSystem.getRenderer()->setQueueingEnabled(false); fnt->drawText(fpsbuff, CEGUI::Vector3(0, 0, 0), guiSystem.getRenderer()->getRect()); } pimpl->d_swapChain->Present(0, 0); rtview->Release(); } // check if the application is quitting, and break the loop next time // around if so. if (isQuitting()) PostQuitMessage(0); } return true; }
int gameLoop( GLFWwindow window, sfgeEntity *player, sfgeEntityList *dynamics, sfgeEntityList *statics ) { double lastTime, currentTime, elapsedTime; sfgeRenderBuffers *buffer; sfgeDrawable *ds; sfgeLight *light; sfgeEntityList *e; buffer = sfgeGetProducerBuffer(); lastTime = glfwGetTime(); while( buffer ) { /* Step 1: Set up the clock */ currentTime = glfwGetTime(); elapsedTime = currentTime - lastTime; lastTime = currentTime; /* Step 2: Handle input */ /*glfwPollEvents();*/ if( isQuitting(window) ) { sfgeSignalExit(); } handleMouseLook(window, player->rot); handleKeyboard(window, player->vel, player->rot); /* Step 3: Let dynamic entities update velocity */ updateDynamicEntities(dynamics); /* Step 4: Collision detection */ /* TODO */ /* Step 5: Update positions */ player->pos[0] += player->vel[0] * elapsedTime; player->pos[1] += player->vel[1] * elapsedTime; player->pos[2] += player->vel[2] * elapsedTime; /* TODO: Update dynamic entiies */ /* Step 6: Populate drawable buffer */ /* Camera (ie. the player) is always the first entry */ sfgeResetDrawables(buffer); sfgeResetLights(buffer); ds = sfgeNextDrawable(buffer); ds->pos[0] = player->pos[0]; ds->pos[1] = player->pos[1]; ds->pos[2] = player->pos[2]; ds->rot[0] = player->rot[0]; ds->rot[1] = player->rot[1]; ds->rot[2] = player->rot[2]; ds->set = NULL; /* Dynamic entities */ for( e = dynamics; e; e = e->next ) { ds = sfgeNextDrawable(buffer); ds->pos[0] = e->entity.pos[0]; ds->pos[1] = e->entity.pos[1]; ds->pos[2] = e->entity.pos[2]; ds->rot[0] = e->entity.rot[0]; ds->rot[1] = e->entity.rot[1]; ds->rot[2] = e->entity.rot[2]; ds->set = e->entity.set; } /* Static entities */ for( e = statics; e; e = e->next ) { ds = sfgeNextDrawable(buffer); ds->pos[0] = e->entity.pos[0]; ds->pos[1] = e->entity.pos[1]; ds->pos[2] = e->entity.pos[2]; ds->rot[0] = e->entity.rot[0]; ds->rot[1] = e->entity.rot[1]; ds->rot[2] = e->entity.rot[2]; ds->set = e->entity.set; } /* TODO: Lights */ /* Simple point light on the player */ light = sfgeNextLight(buffer); light->type = pointL; light->light.point.color[0] = 1.0f; light->light.point.color[1] = 1.0f; light->light.point.color[2] = 0.5f; light->light.point.pos[0] = player->pos[0]; light->light.point.pos[1] = player->pos[1]; light->light.point.pos[2] = player->pos[2]; light->light.point.r_end = 200.0f; light->light.point.r_start = 100.0f; /* Step 7: Swap buffers */ buffer = sfgeSwapBuffers(buffer); } return 0; }