1
0
forked from 0ad/0ad

Removes cinema path recording from atlas added in 2c71c22045 and not removed with ffmpeg in [[SVN:9520]], 4c395f4bf2 and 47b26e56d3.

Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D4411
This was SVN commit r26147.
This commit is contained in:
Vladislav Belov 2021-12-31 10:35:56 +00:00
parent c9ba9299a3
commit 202e248c93
2 changed files with 3 additions and 87 deletions

View File

@ -22,26 +22,23 @@
#include "../GameLoop.h"
#include "../View.h"
#include "graphics/CinemaManager.h"
#include "graphics/GameView.h"
#include "gui/GUIManager.h"
#include "gui/CGUI.h"
#include "lib/external_libraries/libsdl.h"
#include "lib/ogl.h"
#include "lib/sysdep/cpu.h"
#include "maths/MathUtil.h"
#include "ps/Game.h"
#include "ps/Util.h"
#include "ps/GameSetup/Config.h"
#include "ps/GameSetup/GameSetup.h"
#include "renderer/Renderer.h"
#include "scriptinterface/ScriptInterface.h"
#include "simulation2/Simulation2.h"
#include "simulation2/components/ICmpSoundManager.h"
extern void (*Atlas_GLSwapBuffers)(void* context);
namespace AtlasMessage {
namespace AtlasMessage
{
MESSAGEHANDLER(MessageTrace)
{
@ -56,69 +53,6 @@ MESSAGEHANDLER(Screenshot)
WriteScreenshot(L".png");
}
QUERYHANDLER(CinemaRecord)
{
const int w = msg->width, h = msg->height;
{
g_Renderer.Resize(w, h);
SViewPort vp = { 0, 0, w, h };
g_Game->GetView()->SetViewport(vp);
}
unsigned char* img = new unsigned char [w*h*3];
unsigned char* temp = new unsigned char[w*3];
int num_frames = msg->framerate * msg->duration;
AtlasView::GetView_Game()->SaveState(L"cinema_record");
// Set it to update the simulation at normal speed
AtlasView::GetView_Game()->SetSpeedMultiplier(1.f);
for (int frame = 0; frame < num_frames; ++frame)
{
AtlasView::GetView_Game()->Update(1.f / msg->framerate);
Render();
Atlas_GLSwapBuffers((void*)g_AtlasGameLoop->glCanvas);
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, img);
// Swap the rows around, else the image will be upside down
//* // TODO: BGR24 output doesn't need flipping, YUV420 and RGBA32 do
for (int y = 0; y < h/2; ++y)
{
memcpy(temp, &img[y*w*3], w*3);
memcpy(&img[y*w*3], &img[(h-1-y)*w*3], w*3);
memcpy(&img[(h-1-y)*w*3], temp, w*3);
}
//*/
// Call the user-supplied function with this data, so they can
// store it as a video
sCinemaRecordCB cbdata = { img };
msg->cb.Call(cbdata);
}
// Pause the game once we've finished
AtlasView::GetView_Game()->SetSpeedMultiplier(0.f);
AtlasView::GetView_Game()->RestoreState(L"cinema_record");
// TODO: delete the saved state now that we don't need it any more
delete[] img;
delete[] temp;
// Restore viewport
{
g_Renderer.Resize(g_xres, g_yres);
SViewPort vp = { 0, 0, g_xres, g_yres };
g_Game->GetView()->SetViewport(vp);
}
}
QUERYHANDLER(Ping)
{
UNUSED2(msg);
@ -217,4 +151,4 @@ MESSAGEHANDLER(GuiCharEvent)
in_dispatch_event(&ev);
}
}
} // namespace AtlasMessage

View File

@ -276,24 +276,6 @@ MESSAGE(Screenshot,
((int, tiles)) // For big screenshots: the final image will be (640*tiles)x(480*tiles)
);
#ifndef MESSAGES_SKIP_STRUCTS
struct sCinemaRecordCB
{
unsigned char* buffer;
};
SHAREABLE_STRUCT(sCinemaRecordCB);
#endif
QUERY(CinemaRecord,
((std::wstring, path))
((int, framerate))
((float, duration))
((int, width))
((int, height))
((Callback<sCinemaRecordCB>, cb))
,
);
//////////////////////////////////////////////////////////////////////////
MESSAGE(Brush,