void ReymentaServerApp::update() { if (mFirstLaunch) { CI_LOG_V("update begin"); CI_LOG_V(getElapsedFrames()); } mParameterBag->iFps = getAverageFps(); mParameterBag->sFps = toString(floor(mParameterBag->iFps)); getWindow()->setTitle("(" + mParameterBag->sFps + " fps) Server"); if (mParameterBag->iGreyScale) { mParameterBag->controlValues[1] = mParameterBag->controlValues[2] = mParameterBag->controlValues[3]; mParameterBag->controlValues[5] = mParameterBag->controlValues[6] = mParameterBag->controlValues[7]; } mParameterBag->iChannelTime[0] = getElapsedSeconds(); mParameterBag->iChannelTime[1] = getElapsedSeconds() - 1; mParameterBag->iChannelTime[3] = getElapsedSeconds() - 2; mParameterBag->iChannelTime[4] = getElapsedSeconds() - 3; // if (mParameterBag->mUseTimeWithTempo) { mParameterBag->iGlobalTime = mParameterBag->iTempoTime*mParameterBag->iTimeFactor; } else { mParameterBag->iGlobalTime = getElapsedSeconds(); } mParameterBag->iGlobalTime *= mParameterBag->iSpeedMultiplier; if (ui::GetDrawData() != NULL) { if (mBatchass->isRemoteClientActive()) { // Count int cmd_count = 0; int vtx_count = 0; for (int n = 0; n < ui::GetDrawData()->CmdListsCount; n++) { const ImDrawList * cmd_list = ui::GetDrawData()->CmdLists[n]; const ImDrawVert * vtx_src = cmd_list->VtxBuffer.begin(); cmd_count += cmd_list->CmdBuffer.size(); vtx_count += cmd_list->VtxBuffer.size(); } // Send static int sendframe = 0; if (sendframe++ >= 240) // every 2 frames, @TWEAK { sendframe = 0; if (cmd_count > 0 || vtx_count > 0) { mBatchass->preparePacketFrame(cmd_count, vtx_count); // Add all drawcmds Cmd cmd; for (int n = 0; n < ui::GetDrawData()->CmdListsCount; n++) { const ImDrawList* cmd_list = ui::GetDrawData()->CmdLists[n]; const ImDrawCmd* pcmd_end = cmd_list->CmdBuffer.end(); for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != pcmd_end; pcmd++) { cmd.Set(*pcmd); mBatchass->Write(cmd); } } // Add all vtx Vtx vtx; for (int n = 0; n < ui::GetDrawData()->CmdListsCount; n++) { const ImDrawList* cmd_list = ui::GetDrawData()->CmdLists[n]; const ImDrawVert* vtx_src = cmd_list->VtxBuffer.begin(); int vtx_remaining = cmd_list->VtxBuffer.size(); while (vtx_remaining-- > 0) { vtx.Set(*vtx_src++); mBatchass->Write(vtx); } } // Send mBatchass->SendPacket(); } } } ImGuiIO& io = ImGui::GetIO(); // Setup resolution (every frame to accommodate for window resizing) int w, h; int display_w, display_h; // Setup time step static double time = 0.0f; const double current_time = getElapsedSeconds(); io.DeltaTime = (float)(current_time - time); time = current_time; } // @RemoteImgui begin /*ImGui::RemoteUpdate(); ImGui::RemoteInput input; if (ImGui::RemoteGetInput(input)) { ImGuiIO& io = ImGui::GetIO(); for (int i = 0; i < 256; i++) io.KeysDown[i] = input.KeysDown[i]; io.KeyCtrl = input.KeyCtrl; io.KeyShift = input.KeyShift; io.MousePos = input.MousePos; io.MouseDown[0] = (input.MouseButtons & 1); io.MouseDown[1] = (input.MouseButtons & 2) != 0; io.MouseWheel = (float)input.MouseWheel; } else*/ // @RemoteImgui end { // Setup inputs // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents()) //double mouse_x, mouse_y; //glfwGetCursorPos(window, &mouse_x, &mouse_y); //mouse_x *= (float)display_w / w; // Convert mouse coordinates to pixels //mouse_y *= (float)display_h / h; //io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.) //io.MouseDown[0] = mousePressed[0] || glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. //io.MouseDown[1] = mousePressed[1] || glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) != 0; } mBatchass->update(); mProg->uniform("iGlobalTime", static_cast<float>(getElapsedSeconds())); //mProg->uniform("iMouse", mMouseCoord); //mProg->uniform("iChannel0", 0); if (mFirstLaunch) { CI_LOG_V("update end"); } }