mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-11 19:04:05 +02:00
Hide away some more Renderer functions
This commit is contained in:
@@ -56,26 +56,19 @@ int main(int argc, char *argv[])
|
|||||||
rendererSettings.decorations_enable = true;
|
rendererSettings.decorations_enable = true;
|
||||||
rendererSettings.blackDecorations = true;
|
rendererSettings.blackDecorations = true;
|
||||||
ren->ApplySettings(rendererSettings);
|
ren->ApplySettings(rendererSettings);
|
||||||
|
ren->ClearAccumulation();
|
||||||
int frame = 15;
|
ren->Clear();
|
||||||
while(frame)
|
ren->ApproximateAccumulation();
|
||||||
{
|
ren->RenderSimulation();
|
||||||
frame--;
|
|
||||||
ren->render_parts();
|
|
||||||
ren->render_fire();
|
|
||||||
ren->clearScreen();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ren->clearScreen();
|
ren->Clear();
|
||||||
int w = Graphics::TextSize("Save file invalid").X + 15, x = (XRES-w)/2, y = (YRES-24)/2;
|
int w = Graphics::TextSize("Save file invalid").X + 15, x = (XRES-w)/2, y = (YRES-24)/2;
|
||||||
ren->DrawRect(RectSized(Vec2{ x, y }, Vec2{ w, 24 }), 0xC0C0C0_rgb);
|
ren->DrawRect(RectSized(Vec2{ x, y }, Vec2{ w, 24 }), 0xC0C0C0_rgb);
|
||||||
ren->BlendText({ x+8, y+8 }, "Save file invalid", 0xC0C0F0_rgb .WithAlpha(255));
|
ren->BlendText({ x+8, y+8 }, "Save file invalid", 0xC0C0F0_rgb .WithAlpha(255));
|
||||||
}
|
}
|
||||||
|
|
||||||
ren->RenderSimulation();
|
|
||||||
|
|
||||||
if (auto data = VideoBuffer(ren->GetVideo()).ToPNG())
|
if (auto data = VideoBuffer(ren->GetVideo()).ToPNG())
|
||||||
Platform::WriteFile(*data, outputFilename);
|
Platform::WriteFile(*data, outputFilename);
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,11 @@
|
|||||||
#include "simulation/orbitalparts.h"
|
#include "simulation/orbitalparts.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
void Renderer::RenderBackground()
|
||||||
|
{
|
||||||
|
draw_air();
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::RenderSimulation()
|
void Renderer::RenderSimulation()
|
||||||
{
|
{
|
||||||
draw_grav();
|
draw_grav();
|
||||||
@@ -37,6 +42,16 @@ void Renderer::RenderSimulation()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::ApproximateAccumulation()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 15; ++i)
|
||||||
|
{
|
||||||
|
render_parts();
|
||||||
|
render_fire();
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::render_gravlensing(const RendererFrame &source)
|
void Renderer::render_gravlensing(const RendererFrame &source)
|
||||||
{
|
{
|
||||||
for (auto p : RES.OriginRect())
|
for (auto p : RES.OriginRect())
|
||||||
|
@@ -46,20 +46,6 @@ class Renderer : private RendererSettings, public RasterDrawMethods<Renderer>
|
|||||||
unsigned char fire_b[YCELLS][XCELLS];
|
unsigned char fire_b[YCELLS][XCELLS];
|
||||||
unsigned int fire_alpha[CELL*3][CELL*3];
|
unsigned int fire_alpha[CELL*3][CELL*3];
|
||||||
|
|
||||||
public:
|
|
||||||
const RendererFrame &GetVideo() const
|
|
||||||
{
|
|
||||||
return video;
|
|
||||||
}
|
|
||||||
|
|
||||||
const RenderableSimulation *sim = nullptr;
|
|
||||||
|
|
||||||
void ApplySettings(const RendererSettings &newSettings);
|
|
||||||
|
|
||||||
static const std::vector<RenderPreset> renderModePresets;
|
|
||||||
|
|
||||||
void RenderSimulation();
|
|
||||||
|
|
||||||
void DrawBlob(Vec2<int> pos, RGB<uint8_t> colour);
|
void DrawBlob(Vec2<int> pos, RGB<uint8_t> colour);
|
||||||
void DrawWalls();
|
void DrawWalls();
|
||||||
void DrawSigns();
|
void DrawSigns();
|
||||||
@@ -72,12 +58,21 @@ public:
|
|||||||
void draw_grav();
|
void draw_grav();
|
||||||
void draw_other();
|
void draw_other();
|
||||||
|
|
||||||
void ClearAccumulation();
|
public:
|
||||||
void clearScreen();
|
|
||||||
|
|
||||||
static std::unique_ptr<VideoBuffer> WallIcon(int wallID, Vec2<int> size);
|
|
||||||
|
|
||||||
Renderer();
|
Renderer();
|
||||||
|
void ApplySettings(const RendererSettings &newSettings);
|
||||||
|
void RenderSimulation();
|
||||||
|
void RenderBackground();
|
||||||
|
void ApproximateAccumulation();
|
||||||
|
void ClearAccumulation();
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
const RendererFrame &GetVideo() const
|
||||||
|
{
|
||||||
|
return video;
|
||||||
|
}
|
||||||
|
|
||||||
|
const RenderableSimulation *sim = nullptr;
|
||||||
|
|
||||||
struct GradientStop
|
struct GradientStop
|
||||||
{
|
{
|
||||||
@@ -87,6 +82,8 @@ public:
|
|||||||
bool operator <(const GradientStop &other) const;
|
bool operator <(const GradientStop &other) const;
|
||||||
};
|
};
|
||||||
static std::vector<RGB<uint8_t>> Gradient(std::vector<GradientStop> stops, int resolution);
|
static std::vector<RGB<uint8_t>> Gradient(std::vector<GradientStop> stops, int resolution);
|
||||||
|
static std::unique_ptr<VideoBuffer> WallIcon(int wallID, Vec2<int> size);
|
||||||
|
static const std::vector<RenderPreset> renderModePresets;
|
||||||
|
|
||||||
#define RENDERER_TABLE(name) \
|
#define RENDERER_TABLE(name) \
|
||||||
static std::vector<RGB<uint8_t>> name; \
|
static std::vector<RGB<uint8_t>> name; \
|
||||||
|
@@ -74,7 +74,7 @@ const std::vector<RenderPreset> Renderer::renderModePresets = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void Renderer::clearScreen()
|
void Renderer::Clear()
|
||||||
{
|
{
|
||||||
if(displayMode & DISPLAY_PERS)
|
if(displayMode & DISPLAY_PERS)
|
||||||
{
|
{
|
||||||
|
@@ -2130,8 +2130,8 @@ void GameView::SetSaveButtonTooltips()
|
|||||||
void GameView::RenderSimulation(const RenderableSimulation &sim, bool handleEvents)
|
void GameView::RenderSimulation(const RenderableSimulation &sim, bool handleEvents)
|
||||||
{
|
{
|
||||||
ren->sim = ∼
|
ren->sim = ∼
|
||||||
ren->clearScreen();
|
ren->Clear();
|
||||||
ren->draw_air();
|
ren->RenderBackground();
|
||||||
if (handleEvents)
|
if (handleEvents)
|
||||||
{
|
{
|
||||||
c->BeforeSimDraw();
|
c->BeforeSimDraw();
|
||||||
|
@@ -32,20 +32,11 @@ std::unique_ptr<VideoBuffer> SaveRenderer::Render(const GameSave *save, bool dec
|
|||||||
|
|
||||||
sim->Load(save, true, { 0, 0 });
|
sim->Load(save, true, { 0, 0 });
|
||||||
ren->ClearAccumulation();
|
ren->ClearAccumulation();
|
||||||
ren->clearScreen();
|
ren->Clear();
|
||||||
|
|
||||||
if (fire)
|
if (fire)
|
||||||
{
|
{
|
||||||
int frame = 15;
|
ren->ApproximateAccumulation();
|
||||||
while(frame)
|
|
||||||
{
|
|
||||||
frame--;
|
|
||||||
ren->render_parts();
|
|
||||||
ren->render_fire();
|
|
||||||
ren->clearScreen();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ren->RenderSimulation();
|
ren->RenderSimulation();
|
||||||
|
|
||||||
auto tempThumb = std::make_unique<VideoBuffer>(save->blockSize * CELL);
|
auto tempThumb = std::make_unique<VideoBuffer>(save->blockSize * CELL);
|
||||||
|
Reference in New Issue
Block a user