server now receives images and create final video. server now handles clients disconnect

This commit is contained in:
2025-02-25 22:33:18 +01:00
parent 29f00cf9b2
commit 5ba33c4f69
11 changed files with 320 additions and 72 deletions

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/22 16:34:53 by tomoron #+# #+# */
/* Updated: 2025/02/25 00:52:27 by tomoron ### ########.fr */
/* Updated: 2025/02/25 19:16:53 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -97,7 +97,7 @@ void Renderer::update(std::vector<GLuint> &textures, ShaderProgram &denoisingPr
_curSamples++;
if(_headless)
showRenderInfo(0);
showRenderInfo(0, 0);
if((_testMode && _curSamples < _testSamples) || (!_testMode && _curSamples < _samples))
return;
@ -165,13 +165,13 @@ void Renderer::initRender(Clusterizer *clust)
throw std::runtime_error("render path is 0 seconds long, aborting");
_curPathIndex = 0;
_frameCount = 0;
_destPathIndex = _path.size() - 1;
_renderStartTime = glfwGetTime();
if(clust && clust->isServer())
createClusterJobs(*clust);
else
{
_frameCount = 0;
_curSamples = 0;
_testMode = 0;
_scene->getCamera()->setPosition(_path[0].pos);
@ -183,15 +183,29 @@ void Renderer::initRender(Clusterizer *clust)
void Renderer::addImageToRender(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram)
{
if(!_ffmpegVideo)
return;
_ffmpegVideo->addImageToVideo(*_scene, textures, denoisingProgram);
}
void Renderer::endRender(void)
void Renderer::addImageToRender(std::vector<uint8_t> &buf)
{
if(!_ffmpegVideo)
return;
_ffmpegVideo->addImageToVideo(buf);
_frameCount++;
}
void Renderer::endRender(Clusterizer *clust)
{
_destPathIndex = 0;
if(_headless)
_shouldClose = 1;
delete _ffmpegVideo;
if(_ffmpegVideo)
delete _ffmpegVideo;
if(clust && clust->isServer())
clust->abortJobs();
}
bool Renderer::shouldClose(void) const

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/20 15:54:35 by tomoron #+# #+# */
/* Updated: 2025/02/24 17:42:35 by tomoron ### ########.fr */
/* Updated: 2025/02/25 19:17:19 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -185,7 +185,7 @@ void Renderer::imguiRenderSettings(Clusterizer &clust)
_renderSettings = 0;
}
void Renderer::showRenderInfo(int isImgui)
void Renderer::showRenderInfo(int isImgui, Clusterizer *clust)
{
std::ostringstream oss;
long int totalFrames;
@ -250,7 +250,7 @@ void Renderer::showRenderInfo(int isImgui)
if(ImGui::Button("stop"))
{
_destPathIndex = 0;
endRender();
endRender(clust);
}
}
else
@ -312,7 +312,7 @@ void Renderer::renderImgui(Clusterizer &clust)
if (ImGui::CollapsingHeader("Renderer"))
{
if(rendering() || clust.hasJobs())
showRenderInfo(1);
showRenderInfo(1, &clust);
else if(_renderSettings)
imguiRenderSettings(clust);
else

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/20 16:01:59 by tomoron #+# #+# */
/* Updated: 2025/02/23 22:13:32 by tomoron ### ########.fr */
/* Updated: 2025/02/25 19:15:33 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -168,6 +168,6 @@ void Renderer::makeMovement(float time)
{
_destPathIndex = 0;
if(!_testMode)
endRender();
endRender(0);
}
}