diff options
Diffstat (limited to 'themes/src')
| -rw-r--r-- | themes/src/_shaders/sun.frag | 40 | ||||
| -rw-r--r-- | themes/src/_shaders/sun.vert | 27 | ||||
| -rw-r--r-- | themes/src/autumn/autumn_theme.cpp (renamed from themes/src/autumn/AutumnTheme.cpp) | 2 | ||||
| -rw-r--r-- | themes/src/autumn/autumn_theme.hpp (renamed from themes/src/autumn/AutumnTheme.hpp) | 6 | ||||
| -rw-r--r-- | themes/src/autumn/leaf_particle_render.cpp (renamed from themes/src/autumn/LeafParticleRender.cpp) | 6 | ||||
| -rw-r--r-- | themes/src/autumn/leaf_particle_render.h (renamed from themes/src/autumn/LeafParticleRender.h) | 2 | ||||
| -rw-r--r-- | themes/src/autumn/tree_shape.cpp (renamed from themes/src/autumn/TreeShape.cpp) | 2 | ||||
| -rw-r--r-- | themes/src/autumn/tree_shape.h (renamed from themes/src/autumn/TreeShape.h) | 2 | ||||
| -rw-r--r-- | themes/src/list.h | 2 | ||||
| -rw-r--r-- | themes/src/logger.cpp (renamed from themes/src/Logger.cpp) | 2 | ||||
| -rw-r--r-- | themes/src/logger.h (renamed from themes/src/Logger.h) | 0 | ||||
| -rw-r--r-- | themes/src/main.cpp | 21 | ||||
| -rw-r--r-- | themes/src/main_loop.cpp (renamed from themes/src/MainLoop.cpp) | 2 | ||||
| -rw-r--r-- | themes/src/main_loop.h (renamed from themes/src/MainLoop.h) | 2 | ||||
| -rw-r--r-- | themes/src/renderer_2d.cpp (renamed from themes/src/Renderer2d.cpp) | 6 | ||||
| -rw-r--r-- | themes/src/renderer_2d.h (renamed from themes/src/Renderer2d.h) | 4 | ||||
| -rw-r--r-- | themes/src/renderer_3d.cpp (renamed from themes/src/Renderer3d.cpp) | 8 | ||||
| -rw-r--r-- | themes/src/renderer_3d.h (renamed from themes/src/Renderer3d.h) | 0 | ||||
| -rw-r--r-- | themes/src/shader.cpp (renamed from themes/src/Shader.cpp) | 2 | ||||
| -rw-r--r-- | themes/src/shader.h (renamed from themes/src/Shader.h) | 0 | ||||
| -rw-r--r-- | themes/src/shaders/sun_frag.cpp | 40 | ||||
| -rw-r--r-- | themes/src/shaders/sun_vert.cpp | 27 | ||||
| -rw-r--r-- | themes/src/shapes_2d.cpp | 2 | ||||
| -rw-r--r-- | themes/src/shapes_2d.h | 2 | ||||
| -rw-r--r-- | themes/src/spring/grass_renderer.cpp (renamed from themes/src/spring/GrassRenderer.cpp) | 4 | ||||
| -rw-r--r-- | themes/src/spring/grass_renderer.hpp (renamed from themes/src/spring/GrassRenderer.hpp) | 2 | ||||
| -rw-r--r-- | themes/src/spring/spring_theme.cpp (renamed from themes/src/spring/SpringTheme.cpp) | 4 | ||||
| -rw-r--r-- | themes/src/spring/spring_theme.hpp (renamed from themes/src/spring/SpringTheme.hpp) | 2 | ||||
| -rw-r--r-- | themes/src/summer/summer_theme.cpp (renamed from themes/src/summer/SummerTheme.cpp) | 12 | ||||
| -rw-r--r-- | themes/src/summer/summer_theme.h (renamed from themes/src/summer/SummerTheme.h) | 4 | ||||
| -rw-r--r-- | themes/src/webgl_context.cpp (renamed from themes/src/WebglContext.cpp) | 2 | ||||
| -rw-r--r-- | themes/src/webgl_context.h (renamed from themes/src/WebglContext.h) | 0 | ||||
| -rw-r--r-- | themes/src/winter/snowflake.cpp (renamed from themes/src/winter/Snowflake.cpp) | 4 | ||||
| -rw-r--r-- | themes/src/winter/snowflake.h (renamed from themes/src/winter/Snowflake.h) | 2 | ||||
| -rw-r--r-- | themes/src/winter/windfield.cpp (renamed from themes/src/winter/Windfield.cpp) | 2 | ||||
| -rw-r--r-- | themes/src/winter/windfield.hpp (renamed from themes/src/winter/Windfield.hpp) | 0 | ||||
| -rw-r--r-- | themes/src/winter/winter_theme.cpp (renamed from themes/src/winter/WinterTheme.cpp) | 4 | ||||
| -rw-r--r-- | themes/src/winter/winter_theme.hpp (renamed from themes/src/winter/WinterTheme.hpp) | 4 |
38 files changed, 179 insertions, 74 deletions
diff --git a/themes/src/_shaders/sun.frag b/themes/src/_shaders/sun.frag index 8463e06..2170b39 100644 --- a/themes/src/_shaders/sun.frag +++ b/themes/src/_shaders/sun.frag @@ -1,5 +1,43 @@ varying lowp vec4 VertexColor; +varying lowp vec2 TexCoord; +uniform lowp float time; + +// Simple noise function for edge distortion +lowp float noise(lowp vec2 p) { + return sin(p.x * 10.0 + time) * cos(p.y * 10.0 + time * 0.5) * 0.5 + 0.5; +} void main() { - gl_FragColor = VertexColor; + // TexCoord is now normalized: center is (0,0), edges are at distance ~1 + lowp float dist = length(TexCoord); + + // Add animated noise to the edge + lowp float angle = atan(TexCoord.y, TexCoord.x); + lowp float wave = sin(angle * 8.0 + time * 2.0) * 0.05 + sin(angle * 4.0 - time * 1.5) * 0.03; + lowp float noiseValue = noise(TexCoord + time * 0.1) * 0.02; + + // Create soft edge using smoothstep - ensure fade reaches zero at the actual edge + lowp float innerEdge = 0.8; + lowp float outerEdge = 1.0; + lowp float alpha = 1.0 - smoothstep(innerEdge, outerEdge, dist); + + // Apply wave distortion to the edge + alpha *= 1.0 - smoothstep(0.85 + wave + noiseValue * 2.0, 1.0, dist); + + // Make edges more transparent but not too much + alpha = alpha * alpha; + + // Add slight glow effect at the edge + lowp float glow = smoothstep(0.5, 0.8, dist) * (1.0 - smoothstep(0.8, 1.0, dist)); + + // Create orange gradient from center + lowp vec3 orangeColor = vec3(1.0, 0.5, 0.1); + lowp float centerGradient = smoothstep(0.6, 0.0, dist); + lowp vec3 baseColor = mix(VertexColor.rgb, orangeColor, centerGradient * 0.6); + + // Mix in the glow with a brighter color + lowp vec3 glowColor = baseColor * 1.3; + lowp vec3 finalColor = mix(baseColor, glowColor, glow * 0.5); + + gl_FragColor = vec4(finalColor, VertexColor.a * alpha); } diff --git a/themes/src/_shaders/sun.vert b/themes/src/_shaders/sun.vert index 76150f0..5ed77d7 100644 --- a/themes/src/_shaders/sun.vert +++ b/themes/src/_shaders/sun.vert @@ -1,13 +1,22 @@ -attribute vec2 position; -attribute vec4 color; -attribute mat4 vMatrix; -uniform mat4 projection; -uniform mat4 model; +attribute vec2 position; +attribute vec4 color; +attribute mat4 vMatrix; +uniform mat4 projection; +uniform mat4 model; varying lowp vec4 VertexColor; +varying lowp vec2 TexCoord; -void main() { - vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1); - gl_Position = fragmentPosition; - VertexColor = color; +void main() { + vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1); + gl_Position = fragmentPosition; + VertexColor = color; + // Normalize the position - the center is at (0,0) and edge vertices are at distance 'radius' + // We want TexCoord to be in the range roughly [-1, 1] at the edges + lowp float maxDist = length(position); + if (maxDist > 0.1) { + TexCoord = position / maxDist; + } else { + TexCoord = vec2(0.0, 0.0); + } } diff --git a/themes/src/autumn/AutumnTheme.cpp b/themes/src/autumn/autumn_theme.cpp index 4b7a2e2..d88b265 100644 --- a/themes/src/autumn/AutumnTheme.cpp +++ b/themes/src/autumn/autumn_theme.cpp @@ -1,4 +1,4 @@ -#include "AutumnTheme.hpp" +#include "autumn_theme.hpp" #include "../shapes_2d.h" #include <memory> diff --git a/themes/src/autumn/AutumnTheme.hpp b/themes/src/autumn/autumn_theme.hpp index e3f5748..b61c0f3 100644 --- a/themes/src/autumn/AutumnTheme.hpp +++ b/themes/src/autumn/autumn_theme.hpp @@ -1,11 +1,11 @@ #ifndef AUTUMN_THEME_HPP #define AUTUMN_THEME_HPP -#include "TreeShape.h" -#include "LeafParticleRender.h" +#include "tree_shape.h" +#include "leaf_particle_render.h" #include "../types.h" #include "../theme.h" -#include "../Renderer2d.h" +#include "../renderer_2d.h" #include <memory> #include <vector> diff --git a/themes/src/autumn/LeafParticleRender.cpp b/themes/src/autumn/leaf_particle_render.cpp index fee3df2..569bb2d 100644 --- a/themes/src/autumn/LeafParticleRender.cpp +++ b/themes/src/autumn/leaf_particle_render.cpp @@ -1,7 +1,7 @@ -#include "LeafParticleRender.h" -#include "../Renderer2d.h" +#include "leaf_particle_render.h" +#include "../renderer_2d.h" #include "../mathlib.h" -#include "TreeShape.h" +#include "tree_shape.h" #include "../types.h" #include <math.h> diff --git a/themes/src/autumn/LeafParticleRender.h b/themes/src/autumn/leaf_particle_render.h index f6efe1f..1209e1b 100644 --- a/themes/src/autumn/LeafParticleRender.h +++ b/themes/src/autumn/leaf_particle_render.h @@ -1,4 +1,4 @@ -#include "../Renderer2d.h" +#include "../renderer_2d.h" #include "../mathlib.h" #include "../types.h" diff --git a/themes/src/autumn/TreeShape.cpp b/themes/src/autumn/tree_shape.cpp index 7c80929..622751b 100644 --- a/themes/src/autumn/TreeShape.cpp +++ b/themes/src/autumn/tree_shape.cpp @@ -1,4 +1,4 @@ -#include "TreeShape.h" +#include "tree_shape.h" #include "../mathlib.h" #include <cstdio> #include <cstdlib> diff --git a/themes/src/autumn/TreeShape.h b/themes/src/autumn/tree_shape.h index fc0d11e..0d18415 100644 --- a/themes/src/autumn/TreeShape.h +++ b/themes/src/autumn/tree_shape.h @@ -1,4 +1,4 @@ -#include "../Renderer2d.h" +#include "../renderer_2d.h" #include "../types.h" #include "../mathlib.h" diff --git a/themes/src/list.h b/themes/src/list.h index 25b236a..9b6a719 100644 --- a/themes/src/list.h +++ b/themes/src/list.h @@ -1,7 +1,7 @@ #pragma once #include <cstdlib> #include <cstring> -#include "Logger.h" +#include "logger.h" #define FOREACH(list) \ for (i32 idx = 0; idx < list.numElements; idx++) \ diff --git a/themes/src/Logger.cpp b/themes/src/logger.cpp index 1068d88..bead282 100644 --- a/themes/src/Logger.cpp +++ b/themes/src/logger.cpp @@ -1,4 +1,4 @@ -#include "Logger.h" +#include "logger.h" #include <chrono> #include <cstdarg> #include <cstdio> diff --git a/themes/src/Logger.h b/themes/src/logger.h index 7596b6f..7596b6f 100644 --- a/themes/src/Logger.h +++ b/themes/src/logger.h diff --git a/themes/src/main.cpp b/themes/src/main.cpp index 14227c9..60e6aed 100644 --- a/themes/src/main.cpp +++ b/themes/src/main.cpp @@ -1,13 +1,13 @@ -#include "WebglContext.h" -#include "MainLoop.h" -#include "Renderer2d.h" +#include "webgl_context.h" +#include "main_loop.h" +#include "renderer_2d.h" #include "mathlib.h" #include "theme.h" #include "types.h" -#include "summer/SummerTheme.h" -#include "autumn/AutumnTheme.hpp" -#include "spring/SpringTheme.hpp" -#include "winter/WinterTheme.hpp" +#include "summer/summer_theme.h" +#include "autumn/autumn_theme.hpp" +#include "spring/spring_theme.hpp" +#include "winter/winter_theme.hpp" #include <cstdio> #include <emscripten/fetch.h> @@ -67,14 +67,19 @@ void load(ThemeType theme) { } void update(f32 dtSeconds, void* userData) { + if (!active_theme) + return; active_theme->update(dtSeconds); active_theme->render(); } void unload() { delete active_theme; + active_theme = nullptr; type = ThemeType::Default; + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); if (mainLoop.isRunning) { mainLoop.stop(); } @@ -84,7 +89,7 @@ void unload() { EM_BOOL selectNone(int eventType, const EmscriptenMouseEvent* mouseEvent, void* userData) { printf("Default theme selected\n"); unload(); - return true; + return true; } EM_BOOL selectAutumn(int eventType, const EmscriptenMouseEvent* mouseEvent, void* userData) { diff --git a/themes/src/MainLoop.cpp b/themes/src/main_loop.cpp index 09aa643..e5397ca 100644 --- a/themes/src/MainLoop.cpp +++ b/themes/src/main_loop.cpp @@ -1,4 +1,4 @@ -#include "MainLoop.h" +#include "main_loop.h" #include <cstdio> #include <cstdlib> diff --git a/themes/src/MainLoop.h b/themes/src/main_loop.h index 2573bb8..07520a2 100644 --- a/themes/src/MainLoop.h +++ b/themes/src/main_loop.h @@ -26,4 +26,4 @@ struct MainLoop { void stop() { isRunning = false; } -};
\ No newline at end of file +}; diff --git a/themes/src/Renderer2d.cpp b/themes/src/renderer_2d.cpp index f1d78e3..7200669 100644 --- a/themes/src/Renderer2d.cpp +++ b/themes/src/renderer_2d.cpp @@ -1,6 +1,6 @@ -#include "Renderer2d.h" -#include "Shader.h" -#include "WebglContext.h" +#include "renderer_2d.h" +#include "shader.h" +#include "webgl_context.h" #include "mathlib.h" #include <cstdio> #include "shaders/renderer2d_vert.h" diff --git a/themes/src/Renderer2d.h b/themes/src/renderer_2d.h index 7432894..d572533 100644 --- a/themes/src/Renderer2d.h +++ b/themes/src/renderer_2d.h @@ -1,8 +1,8 @@ #pragma once -#include "WebglContext.h" +#include "webgl_context.h" #include "types.h" -#include "Shader.h" +#include "shader.h" #include "mathlib.h" struct WebglContext; diff --git a/themes/src/Renderer3d.cpp b/themes/src/renderer_3d.cpp index 00315de..cc79940 100644 --- a/themes/src/Renderer3d.cpp +++ b/themes/src/renderer_3d.cpp @@ -1,9 +1,9 @@ -#include "Renderer3d.h" -#include "Shader.h" +#include "renderer_3d.h" +#include "shader.h" #include "list.h" #include "mathlib.h" -#include "WebglContext.h" -#include "Logger.h" +#include "webgl_context.h" +#include "logger.h" #include <cstdio> // Note: In the 'transform' attribute, the transform.x is the scale, diff --git a/themes/src/Renderer3d.h b/themes/src/renderer_3d.h index 5b2c8c8..5b2c8c8 100644 --- a/themes/src/Renderer3d.h +++ b/themes/src/renderer_3d.h diff --git a/themes/src/Shader.cpp b/themes/src/shader.cpp index 5f2b00e..ed2cab5 100644 --- a/themes/src/Shader.cpp +++ b/themes/src/shader.cpp @@ -1,4 +1,4 @@ -#include "Shader.h" +#include "shader.h" #include <string> GLuint loadIndividualShader(GLenum shaderType, const GLchar* cCode) { diff --git a/themes/src/Shader.h b/themes/src/shader.h index bc81764..bc81764 100644 --- a/themes/src/Shader.h +++ b/themes/src/shader.h diff --git a/themes/src/shaders/sun_frag.cpp b/themes/src/shaders/sun_frag.cpp index d1ea160..696b3b9 100644 --- a/themes/src/shaders/sun_frag.cpp +++ b/themes/src/shaders/sun_frag.cpp @@ -1,8 +1,46 @@ #include "sun_frag.h" const char* shader_sun_frag = "varying lowp vec4 VertexColor; \n" +"varying lowp vec2 TexCoord; \n" +"uniform lowp float time; \n" +" \n" +"// Simple noise function for edge distortion \n" +"lowp float noise(lowp vec2 p) { \n" +" return sin(p.x * 10.0 + time) * cos(p.y * 10.0 + time * 0.5) * 0.5 + 0.5; \n" +"} \n" " \n" "void main() { \n" -" gl_FragColor = VertexColor; \n" +" // TexCoord is now normalized: center is (0,0), edges are at distance ~1 \n" +" lowp float dist = length(TexCoord); \n" +" \n" +" // Add animated noise to the edge \n" +" lowp float angle = atan(TexCoord.y, TexCoord.x); \n" +" lowp float wave = sin(angle * 8.0 + time * 2.0) * 0.05 + sin(angle * 4.0 - time * 1.5) * 0.03; \n" +" lowp float noiseValue = noise(TexCoord + time * 0.1) * 0.02; \n" +" \n" +" // Create soft edge using smoothstep - ensure fade reaches zero at the actual edge \n" +" lowp float innerEdge = 0.8; \n" +" lowp float outerEdge = 1.0; \n" +" lowp float alpha = 1.0 - smoothstep(innerEdge, outerEdge, dist); \n" +" \n" +" // Apply wave distortion to the edge \n" +" alpha *= 1.0 - smoothstep(0.85 + wave + noiseValue * 2.0, 1.0, dist); \n" +" \n" +" // Make edges more transparent but not too much \n" +" alpha = alpha * alpha; \n" +" \n" +" // Add slight glow effect at the edge \n" +" lowp float glow = smoothstep(0.5, 0.8, dist) * (1.0 - smoothstep(0.8, 1.0, dist)); \n" +" \n" +" // Create orange gradient from center \n" +" lowp vec3 orangeColor = vec3(1.0, 0.5, 0.1); \n" +" lowp float centerGradient = smoothstep(0.6, 0.0, dist); \n" +" lowp vec3 baseColor = mix(VertexColor.rgb, orangeColor, centerGradient * 0.6); \n" +" \n" +" // Mix in the glow with a brighter color \n" +" lowp vec3 glowColor = baseColor * 1.3; \n" +" lowp vec3 finalColor = mix(baseColor, glowColor, glow * 0.5); \n" +" \n" +" gl_FragColor = vec4(finalColor, VertexColor.a * alpha); \n" "} \n" " \n"; diff --git a/themes/src/shaders/sun_vert.cpp b/themes/src/shaders/sun_vert.cpp index ca617c0..bacf3a6 100644 --- a/themes/src/shaders/sun_vert.cpp +++ b/themes/src/shaders/sun_vert.cpp @@ -1,16 +1,25 @@ #include "sun_vert.h" const char* shader_sun_vert = " \n" -"attribute vec2 position; \n" -"attribute vec4 color; \n" -"attribute mat4 vMatrix; \n" -"uniform mat4 projection; \n" -"uniform mat4 model; \n" +"attribute vec2 position; \n" +"attribute vec4 color; \n" +"attribute mat4 vMatrix; \n" +"uniform mat4 projection; \n" +"uniform mat4 model; \n" "varying lowp vec4 VertexColor; \n" +"varying lowp vec2 TexCoord; \n" " \n" -"void main() { \n" -" vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1); \n" -" gl_Position = fragmentPosition; \n" -" VertexColor = color; \n" +"void main() { \n" +" vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1); \n" +" gl_Position = fragmentPosition; \n" +" VertexColor = color; \n" +" // Normalize the position - the center is at (0,0) and edge vertices are at distance 'radius' \n" +" // We want TexCoord to be in the range roughly [-1, 1] at the edges \n" +" lowp float maxDist = length(position); \n" +" if (maxDist > 0.1) { \n" +" TexCoord = position / maxDist; \n" +" } else { \n" +" TexCoord = vec2(0.0, 0.0); \n" +" } \n" "} \n" " \n"; diff --git a/themes/src/shapes_2d.cpp b/themes/src/shapes_2d.cpp index d5a29ed..e00c521 100644 --- a/themes/src/shapes_2d.cpp +++ b/themes/src/shapes_2d.cpp @@ -1,5 +1,5 @@ #include "shapes_2d.h" -#include "Renderer2d.h" +#include "renderer_2d.h" #include "mathlib.h" #include "list.h" diff --git a/themes/src/shapes_2d.h b/themes/src/shapes_2d.h index 8e08504..325d525 100644 --- a/themes/src/shapes_2d.h +++ b/themes/src/shapes_2d.h @@ -2,7 +2,7 @@ #define SHAPES_2D #include "mathlib.h" -#include "Renderer2d.h" +#include "renderer_2d.h" #include "types.h" class RectangularGradient diff --git a/themes/src/spring/GrassRenderer.cpp b/themes/src/spring/grass_renderer.cpp index b69d111..685f733 100644 --- a/themes/src/spring/GrassRenderer.cpp +++ b/themes/src/spring/grass_renderer.cpp @@ -1,5 +1,5 @@ -#include "GrassRenderer.hpp" -#include "Renderer3d.h" +#include "grass_renderer.hpp" +#include "../renderer_3d.h" void GrassRenderer::load(GrassRendererLoadData params, Renderer3d* renderer) { const f32 COLUMN_INCREMENT = GRASS_BLADES_PER_COL / params.area.x; diff --git a/themes/src/spring/GrassRenderer.hpp b/themes/src/spring/grass_renderer.hpp index 8c96724..88879f3 100644 --- a/themes/src/spring/GrassRenderer.hpp +++ b/themes/src/spring/grass_renderer.hpp @@ -1,7 +1,7 @@ #ifndef GRASS_RENDERER_HPP #define GRASS_RENDERER_HPP -#include "Renderer3d.h" +#include "../renderer_3d.h" #include "mathlib.h" #include "types.h" diff --git a/themes/src/spring/SpringTheme.cpp b/themes/src/spring/spring_theme.cpp index e39c138..8507194 100644 --- a/themes/src/spring/SpringTheme.cpp +++ b/themes/src/spring/spring_theme.cpp @@ -1,5 +1,5 @@ -#include "SpringTheme.hpp" -#include "../Renderer3d.h" +#include "spring_theme.hpp" +#include "../renderer_3d.h" #include "../shader_fetcher.hpp" #include <cstdio> #include <emscripten/fetch.h> diff --git a/themes/src/spring/SpringTheme.hpp b/themes/src/spring/spring_theme.hpp index 64f9cb5..6079958 100644 --- a/themes/src/spring/SpringTheme.hpp +++ b/themes/src/spring/spring_theme.hpp @@ -3,7 +3,7 @@ #include "../mathlib.h" #include "../types.h" -#include "../Renderer3d.h" +#include "../renderer_3d.h" #include "../theme.h" diff --git a/themes/src/summer/SummerTheme.cpp b/themes/src/summer/summer_theme.cpp index 1f76b56..6d2cfec 100644 --- a/themes/src/summer/SummerTheme.cpp +++ b/themes/src/summer/summer_theme.cpp @@ -1,5 +1,5 @@ -#include "SummerTheme.h" -#include "../Renderer2d.h" +#include "summer_theme.h" +#include "../renderer_2d.h" #include "../list.h" #include "../mathlib.h" #include "../shaders/sun_frag.h" @@ -59,19 +59,23 @@ void Sun::load(Renderer2d* renderer) { indices.add(second); indices.add(third); } - + mesh.load(&vertices.data[0], vertices.numElements, &indices.data[0], indices.numElements, renderer); mesh.model = Mat4x4().translateByVec2(Vector2(renderer->context->width / 2.f, renderer->context->height / 2.f)); + + timeUniform = getShaderUniform(renderer->shader, "time"); + vertices.deallocate(); indices.deallocate(); } void Sun::update(f32 dtSeconds) { - + elapsedTime += dtSeconds; } void Sun::render(Renderer2d* renderer) { setShaderMat4(renderer->uniforms.model, mesh.model); + glUniform1f(timeUniform, elapsedTime); glBindVertexArray(mesh.vao); glDrawElements(GL_TRIANGLES, mesh.numIndices, GL_UNSIGNED_INT, 0); glBindVertexArray(0); diff --git a/themes/src/summer/SummerTheme.h b/themes/src/summer/summer_theme.h index 2ce6b7f..eb404fd 100644 --- a/themes/src/summer/SummerTheme.h +++ b/themes/src/summer/summer_theme.h @@ -1,6 +1,6 @@ #pragma once #include "../types.h" -#include "../Renderer2d.h" +#include "../renderer_2d.h" #include "../theme.h" #include <vector> @@ -8,6 +8,8 @@ struct Sun { f32 radius = 20.f; i32 sectors = 180; Mesh2D mesh; + f32 elapsedTime = 0.f; + i32 timeUniform = -1; void load(Renderer2d* renderer); void update(f32 dtSeconds); diff --git a/themes/src/WebglContext.cpp b/themes/src/webgl_context.cpp index df49c2d..71b983e 100644 --- a/themes/src/WebglContext.cpp +++ b/themes/src/webgl_context.cpp @@ -1,4 +1,4 @@ -#include "WebglContext.h" +#include "webgl_context.h" #include <cstdio> diff --git a/themes/src/WebglContext.h b/themes/src/webgl_context.h index 1956092..1956092 100644 --- a/themes/src/WebglContext.h +++ b/themes/src/webgl_context.h diff --git a/themes/src/winter/Snowflake.cpp b/themes/src/winter/snowflake.cpp index 57f1a8f..4ce8f3a 100644 --- a/themes/src/winter/Snowflake.cpp +++ b/themes/src/winter/snowflake.cpp @@ -1,5 +1,5 @@ -#include "Snowflake.h" -#include "../Renderer2d.h" +#include "snowflake.h" +#include "../renderer_2d.h" #include "../mathlib.h" #include "../list.h" #include <cstdio> diff --git a/themes/src/winter/Snowflake.h b/themes/src/winter/snowflake.h index ad027f6..11a1438 100644 --- a/themes/src/winter/Snowflake.h +++ b/themes/src/winter/snowflake.h @@ -4,7 +4,7 @@ #include "../types.h" #include "../mathlib.h" #include "../list.h" -#include "Windfield.hpp" +#include "windfield.hpp" struct Renderer2d; struct Vertex2D; diff --git a/themes/src/winter/Windfield.cpp b/themes/src/winter/windfield.cpp index 88fb74b..f6c3be3 100644 --- a/themes/src/winter/Windfield.cpp +++ b/themes/src/winter/windfield.cpp @@ -1,4 +1,4 @@ -#include "Windfield.hpp" +#include "windfield.hpp" template <i32 Width, i32 Height, i32 CellDimension> diff --git a/themes/src/winter/Windfield.hpp b/themes/src/winter/windfield.hpp index 5bf0c38..5bf0c38 100644 --- a/themes/src/winter/Windfield.hpp +++ b/themes/src/winter/windfield.hpp diff --git a/themes/src/winter/WinterTheme.cpp b/themes/src/winter/winter_theme.cpp index 052670e..a628f18 100644 --- a/themes/src/winter/WinterTheme.cpp +++ b/themes/src/winter/winter_theme.cpp @@ -1,5 +1,5 @@ -#include "WinterTheme.hpp" -#include "../Renderer2d.h" +#include "winter_theme.hpp" +#include "../renderer_2d.h" WinterTheme::WinterTheme(WebglContext* context) { diff --git a/themes/src/winter/WinterTheme.hpp b/themes/src/winter/winter_theme.hpp index 5ba6d94..d1c3e05 100644 --- a/themes/src/winter/WinterTheme.hpp +++ b/themes/src/winter/winter_theme.hpp @@ -1,10 +1,10 @@ #ifndef WINTER_THEME_HPP #define WINTER_THEME_HPP -#include "Snowflake.h" +#include "snowflake.h" #include "../types.h" #include "../theme.h" -#include "../Renderer2d.h" +#include "../renderer_2d.h" struct WebglContext; |
