Skip to content

Commit a5a2f12

Browse files
committed
Display current frame in progress bar
1 parent ec225df commit a5a2f12

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

PixelRay/Output/Progress/ProgressBar.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ public void Update(RenderProgress p)
1111
{
1212
int filled = (int)(p.Percent * _width);
1313

14-
Console.Write("\r[");
14+
if (p.Frame >= 0)
15+
{
16+
Console.Write($"\rFrame {p.Frame} ");
17+
Console.Write("[");
18+
}
19+
else
20+
Console.Write("\r[");
21+
1522
Console.Write(new string('#', filled));
1623
Console.Write(new string('-', _width - filled));
1724
Console.Write($"] {p.Percent:P1} ({p.Done}/{p.Total})");

PixelRay/Output/Progress/ProgressReporter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace PixelRay.Output.Progress;
33
/// <summary>
44
/// Handles rendering progress updates via a callback function
55
/// </summary>
6-
public class ProgressReporter(int total, Action<RenderProgress> callback)
6+
public class ProgressReporter(int frame, int total, Action<RenderProgress> callback)
77
{
88
private int _done;
99
private readonly int _total = total;
@@ -17,6 +17,7 @@ public void Increment(int step = 1)
1717
if (done % 500 == 0 || done == _total)
1818
{
1919
_callback(new RenderProgress(
20+
frame,
2021
done,
2122
_total,
2223
(double)done / _total

PixelRay/Output/Progress/RenderProgress.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace PixelRay.Output.Progress;
44
/// Data record for rendering progression updates
55
/// </summary>
66
public readonly record struct RenderProgress(
7+
int Frame,
78
int Done,
89
int Total,
910
double Percent

PixelRay/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ public static void Main(string[] args)
213213
{
214214
lua.Update(frame);
215215

216-
buffer = renderer.Render(scene, scene.Camera, settings.Threading, upScaleFactor, debug);
216+
buffer = renderer.Render(scene, scene.Camera, settings.Threading, upScaleFactor, debug, frame);
217217
ImageWriter.WritePNG($"{frameOutputDir}/frame-{frame}.png", buffer); // scripts will only produce png
218218
}
219219

220220
// produce a GIF from frames
221221
if (values["produceGif"] == "enabled")
222-
GifBuilder.Build(frameOutputDir, "output.gif");
222+
GifBuilder.Build(frameOutputDir, "outputGIF.gif");
223223

224224
return;
225225
}

PixelRay/Rendering/Renderer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,19 @@ public FrameBuffer Render(
4747
Camera camera,
4848
bool threading,
4949
int upScale = 1,
50-
DebugMode mode = DebugMode.None
50+
DebugMode mode = DebugMode.None,
51+
int frame = -1
5152
)
5253
{
5354
int scaledW = upScale * _width;
5455
int scaledH = upScale * _height;
5556
FrameBuffer buffer = new(scaledW, scaledH);
5657

5758
var consoleBar = new ProgressBar(30);
59+
60+
5861
var reporter = new ProgressReporter(
62+
frame,
5963
_width * _height,
6064
consoleBar.Update
6165
);

0 commit comments

Comments
 (0)