From 1da356d8a64c45c99871aca156ee9fdd3e10ec15 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Wed, 27 Sep 2023 08:03:04 -0400 Subject: Simplification of the Theme system with a more OO model --- themes/src/summer/SummerTheme.cpp | 14 +++++++++++++- themes/src/summer/SummerTheme.h | 10 ++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'themes/src/summer') diff --git a/themes/src/summer/SummerTheme.cpp b/themes/src/summer/SummerTheme.cpp index 6106c89..522b44c 100644 --- a/themes/src/summer/SummerTheme.cpp +++ b/themes/src/summer/SummerTheme.cpp @@ -6,6 +6,17 @@ #include "../shaders/sun_vert.h" #include +SummerTheme::SummerTheme(Renderer2d* renderer, WebglContext* context) + : renderer{renderer} +{ + load(renderer, context); +} + +SummerTheme::~SummerTheme() +{ + unload(); +} + void SummerTheme::load(Renderer2d* renderer, WebglContext* context) { renderer->load(context, shader_sun_vert, shader_sun_frag); renderer->clearColor = Vector4(0, 181, 286, 255.f).toNormalizedColor(); @@ -18,7 +29,8 @@ void SummerTheme::update(f32 dtSeconds) { sun.update(dtSeconds); } -void SummerTheme::render(Renderer2d* renderer) { +void SummerTheme::render() { + renderer->render(); sun.render(renderer); } diff --git a/themes/src/summer/SummerTheme.h b/themes/src/summer/SummerTheme.h index dad4ac9..030f20a 100644 --- a/themes/src/summer/SummerTheme.h +++ b/themes/src/summer/SummerTheme.h @@ -1,6 +1,7 @@ #pragma once #include "../types.h" #include "../Renderer2d.h" +#include "../theme.h" #include struct Sun { @@ -14,10 +15,15 @@ struct Sun { void unload(); }; -struct SummerTheme { +class SummerTheme : public Theme { +public: + SummerTheme(Renderer2d*, WebglContext*); + ~SummerTheme(); Sun sun; void load(Renderer2d*, WebglContext*); void update(f32 dtSeconds); - void render(Renderer2d* renderer); + void render(); void unload(); +private: + Renderer2d* renderer; }; -- cgit v1.2.1