summaryrefslogtreecommitdiff
path: root/themes/src/autumn
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew@matthewkosarek.xyz>2023-09-27 16:52:17 -0400
committerMatthew Kosarek <matthew@matthewkosarek.xyz>2023-09-27 16:52:17 -0400
commit9262b5c798e1921c759addb492b592f3ccf64980 (patch)
tree47c22d423f49678c8e50b365350777cc05ed17ac /themes/src/autumn
parent1da356d8a64c45c99871aca156ee9fdd3e10ec15 (diff)
Moving renderer construction out to the individual themes instead of main.cpp
Diffstat (limited to 'themes/src/autumn')
-rw-r--r--themes/src/autumn/AutumnTheme.cpp31
-rw-r--r--themes/src/autumn/AutumnTheme.hpp8
2 files changed, 19 insertions, 20 deletions
diff --git a/themes/src/autumn/AutumnTheme.cpp b/themes/src/autumn/AutumnTheme.cpp
index c6431a1..4b7a2e2 100644
--- a/themes/src/autumn/AutumnTheme.cpp
+++ b/themes/src/autumn/AutumnTheme.cpp
@@ -1,5 +1,4 @@
#include "AutumnTheme.hpp"
-#include "../Renderer2d.h"
#include "../shapes_2d.h"
#include <memory>
@@ -8,10 +7,10 @@ namespace
const int NUM_HILLS = 3;
}
-AutumnTheme::AutumnTheme(Renderer2d* renderer)
- : renderer{renderer}
+AutumnTheme::AutumnTheme(WebglContext* context)
{
- load(renderer);
+ renderer.load(context);
+ load();
}
AutumnTheme::~AutumnTheme()
@@ -19,21 +18,21 @@ AutumnTheme::~AutumnTheme()
unload();
}
-void AutumnTheme::load(Renderer2d* renderer) {
- renderer->clearColor = Vector4(252, 210, 153, 255).toNormalizedColor();
- auto lr = tree.load(renderer);
- leafParticles.load(renderer, &lr);
+void AutumnTheme::load() {
+ renderer.clearColor = Vector4(252, 210, 153, 255).toNormalizedColor();
+ auto lr = tree.load(&renderer);
+ leafParticles.load(&renderer, &lr);
background = new RectangularGradient(
- *renderer,
+ renderer,
Vector4{135, 206, 235, 255}.toNormalizedColor(),
Vector4(252, 210, 153, 255).toNormalizedColor(),
- renderer->get_width(),
- renderer->get_height(),
+ renderer.get_width(),
+ renderer.get_height(),
{0, 0});
background_hill = new Circleish(
- *renderer,
+ renderer,
1000,
Vector4(137, 129, 33, 255).toNormalizedColor(),
100,
@@ -42,7 +41,7 @@ void AutumnTheme::load(Renderer2d* renderer) {
background_hill->mesh.model = background_hill->mesh.model.translateByVec2({1200, -700});
tree_hill = new Circleish(
- *renderer,
+ renderer,
500,
Vector4{ 76, 75, 22, 255 }.toNormalizedColor(),
100,
@@ -57,12 +56,12 @@ void AutumnTheme::update(f32 dtSeconds) {
}
void AutumnTheme::render() {
- renderer->render();
+ renderer.render();
background->render();
background_hill->render();
- tree.render(renderer);
+ tree.render(&renderer);
tree_hill->render();
- leafParticles.render(renderer);
+ leafParticles.render(&renderer);
}
void AutumnTheme::unload() {
diff --git a/themes/src/autumn/AutumnTheme.hpp b/themes/src/autumn/AutumnTheme.hpp
index 41df04c..e3f5748 100644
--- a/themes/src/autumn/AutumnTheme.hpp
+++ b/themes/src/autumn/AutumnTheme.hpp
@@ -5,16 +5,16 @@
#include "LeafParticleRender.h"
#include "../types.h"
#include "../theme.h"
+#include "../Renderer2d.h"
#include <memory>
#include <vector>
-struct Renderer2d;
class RectangularGradient;
class Circleish;
class AutumnTheme : public Theme {
public:
- AutumnTheme(Renderer2d* renderer);
+ AutumnTheme(WebglContext*);
~AutumnTheme();
TreeShape tree;
LeafParticleRender leafParticles;
@@ -22,12 +22,12 @@ public:
Circleish* tree_hill;
Circleish* background_hill;
- void load(Renderer2d* renderer);
+ void load();
void update(f32 dtSeconds);
void render();
void unload();
private:
- Renderer2d* renderer;
+ Renderer2d renderer;
};
#endif