int App::Run() { InitApp(); MSG msg; ZeroMemory(&msg, sizeof(MSG)); while (true) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else { v_Update(); v_Render(); } } v_Shutdown(); return (int)msg.wParam; }
void FilterCheckpointCellModel::v_Initialise(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time) { ASSERTL0(m_cell.get(), "Cell model has not been set by EquationSystem " "class. Use SetCellModel on this filter to achieve this."); m_index = 0; m_outputIndex = 0; v_Update(pFields, 0.0); }
void FilterEnergyBase::v_Initialise( const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time) { m_index = -1; MultiRegions::ExpListSharedPtr areaField; ASSERTL0(pFields[0]->GetExpType() != MultiRegions::e3DH2D, "Homogeneous 2D expansion not supported" "for energy filter"); if (pFields[0]->GetExpType() == MultiRegions::e3DH1D) { m_homogeneous = true; } // Calculate area/volume of domain. if (m_homogeneous) { m_planes = pFields[0]->GetZIDs(); areaField = pFields[0]->GetPlane(0); } else { areaField = pFields[0]; } Array<OneD, NekDouble> inarray(areaField->GetNpoints(), 1.0); m_area = areaField->Integral(inarray); if (m_homogeneous) { m_area *= m_homogeneousLength; } // Output values at initial time. v_Update(pFields, time); }
bool GameMode::update() { return v_Update(); }
void Application::Run(std::shared_ptr<Application> the_app) { app = the_app; std::cout << "Starting GLFW context" << std::endl; if (!glfwInit()) { std::cerr << "Failed to initialize GLFW" << std::endl; return; } v_InitInfo(); //Add this to use the debug output glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, true); GLFWwindow *window = glfwCreateWindow(windowInfo.Width, windowInfo.Height, windowInfo.title.c_str(), nullptr, nullptr); glfwSetWindowPos(window, windowInfo.posX, windowInfo.posY); glfwMakeContextCurrent(window); glfwSetCursorPosCallback(window, glfw_mouse); // - Directly redirect GLFW mouse position events to AntTweakBar glfwSetScrollCallback(window, glfw_scroll); // - Directly redirect GLFW mouse wheel events to AntTweakBar glfwSetKeyCallback(window, glfw_key); // - Directly redirect GLFW key events to AntTweakBar //glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); // GLFW Options //glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); if (window == NULL) { std::cerr << "Failed to create GLFW window" << std::endl; glfwTerminate(); return; } glewExperimental = GL_TRUE; //Check the GLSL and OpenGL status if (glewInit() != GLEW_OK) { std::cerr << "Failed to initialize GLEW" << std::endl; return; } const GLubyte *renderer = glGetString(GL_RENDERER); const GLubyte *vendor = glGetString(GL_VENDOR); const GLubyte *version = glGetString(GL_VERSION); const GLubyte *glslVersion = glGetString(GL_SHADING_LANGUAGE_VERSION); m_GLRenderer = (const char *)renderer; m_GLVersion = (const char *)version; m_GLSLVersion = (const char *)glslVersion; GLint major, minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); std::cout << "GL Vendor :" << vendor << std::endl; std::cout << "GL Renderer : " << renderer << std::endl; std::cout << "GL Version (std::string) : " << version << std::endl; std::cout << "GL Version (integer) : " << major << "." << minor << std::endl; std::cout << "GLSL Version : " << glslVersion << std::endl; std::cout << "--------------------------------------------------------------------------------" << std::endl; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major); //opengl 4.3 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // Create a GLFWwindow object that we can use for GLFW's functions v_Init(); while (!glfwWindowShouldClose(window)) { int sw, sh; glfwGetWindowSize(window, &sw, &sh); glViewport(0, 0, sw, sh); glfwPollEvents(); v_Movement(window); v_Update(); //Render for the object v_Render(); glfwSwapBuffers(window); } v_Shutdown(); glfwTerminate(); }
void FilterAeroForces::v_Initialise( const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time) { // Parse the boundary regions into a list. std::string::size_type FirstInd = m_BoundaryString.find_first_of('[') + 1; std::string::size_type LastInd = m_BoundaryString.find_last_of(']') - 1; ASSERTL0(FirstInd <= LastInd, (std::string("Error reading boundary region definition:") + m_BoundaryString).c_str()); std::string IndString = m_BoundaryString.substr(FirstInd, LastInd - FirstInd + 1); bool parseGood = ParseUtils::GenerateSeqVector(IndString.c_str(), m_boundaryRegionsIdList); ASSERTL0(parseGood && !m_boundaryRegionsIdList.empty(), (std::string("Unable to read boundary regions index " "range for FilterAeroForces: ") + IndString).c_str()); // determine what boundary regions need to be considered int cnt; unsigned int numBoundaryRegions = pFields[0]->GetBndConditions().num_elements(); m_boundaryRegionIsInList.insert(m_boundaryRegionIsInList.end(), numBoundaryRegions, 0); SpatialDomains::BoundaryConditions bcs(m_session, pFields[0]->GetGraph()); const SpatialDomains::BoundaryRegionCollection &bregions = bcs.GetBoundaryRegions(); SpatialDomains::BoundaryRegionCollection::const_iterator it; for (cnt = 0, it = bregions.begin(); it != bregions.end(); ++it, cnt++) { if ( std::find(m_boundaryRegionsIdList.begin(), m_boundaryRegionsIdList.end(), it->first) != m_boundaryRegionsIdList.end() ) { m_boundaryRegionIsInList[cnt] = 1; } } LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm(); if (vComm->GetRank() == 0) { // Open output stream m_outputStream.open(m_outputFile.c_str()); m_outputStream << "#"; m_outputStream.width(7); m_outputStream << "Time"; m_outputStream.width(25); m_outputStream << "Fx (press)"; m_outputStream.width(25); m_outputStream << "Fx (visc)"; m_outputStream.width(25); m_outputStream << "Fx (tot)"; m_outputStream.width(25); m_outputStream << "Fy (press)"; m_outputStream.width(25); m_outputStream << "Fy (visc)"; m_outputStream.width(25); m_outputStream << "Fy (tot)"; m_outputStream.width(25); m_outputStream << "Fz (press)"; m_outputStream.width(25); m_outputStream << "Fz (visc)"; m_outputStream.width(25); m_outputStream << "Fz (tot)"; m_outputStream << endl; } v_Update(pFields, time); }