mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-16 22:08:28 +01:00
Hide away some more Renderer functions
This commit is contained in:
parent
820f44a716
commit
a9b84e5f26
@ -56,26 +56,19 @@ int main(int argc, char *argv[])
|
||||
rendererSettings.decorations_enable = true;
|
||||
rendererSettings.blackDecorations = true;
|
||||
ren->ApplySettings(rendererSettings);
|
||||
|
||||
int frame = 15;
|
||||
while(frame)
|
||||
{
|
||||
frame--;
|
||||
ren->render_parts();
|
||||
ren->render_fire();
|
||||
ren->clearScreen();
|
||||
}
|
||||
ren->ClearAccumulation();
|
||||
ren->Clear();
|
||||
ren->ApproximateAccumulation();
|
||||
ren->RenderSimulation();
|
||||
}
|
||||
else
|
||||
{
|
||||
ren->clearScreen();
|
||||
ren->Clear();
|
||||
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->BlendText({ x+8, y+8 }, "Save file invalid", 0xC0C0F0_rgb .WithAlpha(255));
|
||||
}
|
||||
|
||||
ren->RenderSimulation();
|
||||
|
||||
if (auto data = VideoBuffer(ren->GetVideo()).ToPNG())
|
||||
Platform::WriteFile(*data, outputFilename);
|
||||
}
|
||||
|
@ -11,6 +11,11 @@
|
||||
#include "simulation/orbitalparts.h"
|
||||
#include <cmath>
|
||||
|
||||
void Renderer::RenderBackground()
|
||||
{
|
||||
draw_air();
|
||||
}
|
||||
|
||||
void Renderer::RenderSimulation()
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (auto p : RES.OriginRect())
|
||||
|
@ -46,20 +46,6 @@ class Renderer : private RendererSettings, public RasterDrawMethods<Renderer>
|
||||
unsigned char fire_b[YCELLS][XCELLS];
|
||||
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 DrawWalls();
|
||||
void DrawSigns();
|
||||
@ -72,12 +58,21 @@ public:
|
||||
void draw_grav();
|
||||
void draw_other();
|
||||
|
||||
void ClearAccumulation();
|
||||
void clearScreen();
|
||||
|
||||
static std::unique_ptr<VideoBuffer> WallIcon(int wallID, Vec2<int> size);
|
||||
|
||||
public:
|
||||
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
|
||||
{
|
||||
@ -87,6 +82,8 @@ public:
|
||||
bool operator <(const GradientStop &other) const;
|
||||
};
|
||||
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) \
|
||||
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)
|
||||
{
|
||||
|
@ -2130,8 +2130,8 @@ void GameView::SetSaveButtonTooltips()
|
||||
void GameView::RenderSimulation(const RenderableSimulation &sim, bool handleEvents)
|
||||
{
|
||||
ren->sim = ∼
|
||||
ren->clearScreen();
|
||||
ren->draw_air();
|
||||
ren->Clear();
|
||||
ren->RenderBackground();
|
||||
if (handleEvents)
|
||||
{
|
||||
c->BeforeSimDraw();
|
||||
|
@ -32,20 +32,11 @@ std::unique_ptr<VideoBuffer> SaveRenderer::Render(const GameSave *save, bool dec
|
||||
|
||||
sim->Load(save, true, { 0, 0 });
|
||||
ren->ClearAccumulation();
|
||||
ren->clearScreen();
|
||||
|
||||
ren->Clear();
|
||||
if (fire)
|
||||
{
|
||||
int frame = 15;
|
||||
while(frame)
|
||||
{
|
||||
frame--;
|
||||
ren->render_parts();
|
||||
ren->render_fire();
|
||||
ren->clearScreen();
|
||||
}
|
||||
ren->ApproximateAccumulation();
|
||||
}
|
||||
|
||||
ren->RenderSimulation();
|
||||
|
||||
auto tempThumb = std::make_unique<VideoBuffer>(save->blockSize * CELL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user