diff --git a/CMakeLists.txt b/CMakeLists.txt index 69d43c7..7b96e61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,6 @@ add_executable(app shared/src/canvas/BackGround.cpp shared/src/canvas/BackGroundColors.cpp shared/src/canvas/Canvas.cpp - shared/src/canvas/Circle.cpp shared/src/canvas/Tree.cpp shared/src/values/Dna.cpp shared/src/values/DnaManager.cpp @@ -56,7 +55,6 @@ add_executable(view shared/src/canvas/BackGround.cpp shared/src/canvas/BackGroundColors.cpp shared/src/canvas/Canvas.cpp - shared/src/canvas/Circle.cpp shared/src/canvas/Tree.cpp shared/src/values/Dna.cpp shared/src/values/DnaManager.cpp diff --git a/Readme.md b/Readme.md index 4715362..f23ba6d 100644 --- a/Readme.md +++ b/Readme.md @@ -23,11 +23,4 @@ ## Include order - Std - local ( form inc dir ) - - external raylib - - -## Generate shader .h files -``` -xxd -i shaders/sun_100.fs > shared/inc/canvas/sunShader.hpp -xxd -i shaders/sun_330.fs >> shared/inc/canvas/sunShader.hpp -``` \ No newline at end of file + - external raylib \ No newline at end of file diff --git a/shaders/sun_100.fs b/shaders/sun_100.fs deleted file mode 100644 index 91ae54c..0000000 --- a/shaders/sun_100.fs +++ /dev/null @@ -1,32 +0,0 @@ -#version 300 es - -precision mediump float; - -in vec2 fragTexCoord; -in vec4 fragColor; -out vec4 finalColor; - -uniform vec3 color; -vec2 offset = vec2(1.0, 1.0); - -float start_transparency = 0.40f; -float sun_radius = 0.6f; -float sun_end = 1.0f; - -void main() -{ - offset.x -= fragTexCoord.x * 2.0; - offset.y -= fragTexCoord.y * 2.0; - float radius = length(offset); - - if(radius < sun_radius){ - finalColor = vec4(color, 1.0); - }else if(radius < sun_end){ - float gradient = radius; - gradient -= sun_radius; - gradient = gradient / 0.4f * start_transparency; - finalColor = vec4(color, start_transparency - gradient); - }else{ - finalColor = vec4(color, 0.0); - } -} diff --git a/shaders/sun_330.fs b/shaders/sun_330.fs deleted file mode 100644 index 3afc15a..0000000 --- a/shaders/sun_330.fs +++ /dev/null @@ -1,29 +0,0 @@ -#version 330 - -in vec2 fragTexCoord; -in vec4 fragColor; -out vec4 finalColor; - -uniform vec3 color; -vec2 offset = vec2(1.0, 1.0); - -float start_transparency = 0.40f; -float sun_radius = 0.6f; -float sun_end = 1.0f; - -void main() -{ - offset.x -= fragTexCoord.x * 2; - offset.y -= fragTexCoord.y * 2; - float radius = length(offset); - if(radius < sun_radius){ - finalColor = vec4(color, 1.0f); - }else if(radius < sun_end){ - float gradient = radius; - gradient -= sun_radius; - gradient = gradient / 0.4f * start_transparency; - finalColor = vec4(color, start_transparency - gradient); - }else{ - finalColor = vec4(color, 0.0f); - } -} diff --git a/shared/inc/canvas/Circle.hpp b/shared/inc/canvas/Circle.hpp deleted file mode 100644 index bb42716..0000000 --- a/shared/inc/canvas/Circle.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#include - -class Circle -{ -public: - static void init(); - static void deinit(); - static void setColor(Color color); - static void draw(float x, float y, float size); - - Circle() = delete; - -private: - static const int sizeTexute = 250; - static RenderTexture2D target; - static Shader shader; - - static float c[3]; - static int colorLoc; -}; diff --git a/shared/inc/canvas/sunShader.hpp b/shared/inc/canvas/sunShader.hpp deleted file mode 100644 index 785c9f6..0000000 --- a/shared/inc/canvas/sunShader.hpp +++ /dev/null @@ -1,123 +0,0 @@ -unsigned char shaders_sun_100_fs[] = { - 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x30, 0x30, - 0x20, 0x65, 0x73, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x20, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x66, - 0x6c, 0x6f, 0x61, 0x74, 0x3b, 0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, - 0x63, 0x32, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, - 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, - 0x20, 0x66, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, - 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e, - 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e, - 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f, - 0x66, 0x66, 0x73, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, - 0x28, 0x31, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, - 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, - 0x79, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x34, 0x30, 0x66, 0x3b, 0x0a, 0x66, - 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, - 0x69, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x36, 0x66, 0x3b, 0x0a, - 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, - 0x64, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76, - 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, - 0x78, 0x20, 0x2d, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, - 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x2e, - 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, - 0x74, 0x2e, 0x79, 0x20, 0x2d, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, - 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x79, 0x20, 0x2a, 0x20, - 0x32, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, - 0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3d, 0x20, - 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28, 0x6f, 0x66, 0x66, 0x73, 0x65, - 0x74, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x28, - 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73, 0x75, 0x6e, - 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x7b, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, - 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, - 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, - 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73, - 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29, 0x7b, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x67, - 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x72, 0x61, - 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2d, - 0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, - 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72, - 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x67, 0x72, 0x61, - 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f, 0x20, 0x30, 0x2e, 0x34, 0x66, - 0x20, 0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x3b, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, - 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, - 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73, 0x74, 0x61, 0x72, - 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, - 0x63, 0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, - 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, - 0x65, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, - 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, - 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, - 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, - 0x7d, 0x0a -}; -unsigned int shaders_sun_100_fs_len = 710; -unsigned char shaders_sun_330_fs[] = { - 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30, - 0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x66, 0x72, - 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, - 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x72, 0x61, 0x67, - 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, - 0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, - 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, - 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, - 0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, - 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x30, 0x2c, - 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x0a, 0x66, 0x6c, 0x6f, 0x61, - 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x3d, 0x20, 0x30, - 0x2e, 0x34, 0x30, 0x66, 0x3b, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, - 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3d, - 0x20, 0x30, 0x2e, 0x36, 0x66, 0x3b, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, - 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x31, - 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, - 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x78, 0x20, 0x2d, 0x3d, 0x20, - 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, - 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x79, 0x20, 0x2d, 0x3d, 0x20, - 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, - 0x2e, 0x79, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, - 0x20, 0x3d, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28, 0x6f, 0x66, - 0x66, 0x73, 0x65, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, - 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73, - 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x7b, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, - 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, - 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31, 0x2e, 0x30, - 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, - 0x65, 0x20, 0x69, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, - 0x3c, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29, 0x7b, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, - 0x74, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, - 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, - 0x74, 0x20, 0x2d, 0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, - 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, - 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f, 0x20, 0x30, - 0x2e, 0x34, 0x66, 0x20, 0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, - 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, - 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, - 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73, - 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, - 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64, - 0x69, 0x65, 0x6e, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, - 0x65, 0x6c, 0x73, 0x65, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, - 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, - 0x72, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a -}; -unsigned int shaders_sun_330_fs_len = 678; diff --git a/shared/src/canvas/BackGround.cpp b/shared/src/canvas/BackGround.cpp index 30a1f5f..4743398 100644 --- a/shared/src/canvas/BackGround.cpp +++ b/shared/src/canvas/BackGround.cpp @@ -2,7 +2,6 @@ #include "canvas/BackGround.hpp" #include "canvas/BackGroundColors.hpp" -#include "canvas/Circle.hpp" #include "canvas/stb_perlin.h" #include @@ -44,6 +43,9 @@ Color ColorAdd(Color c1, Color c2) void BackGround::init(int canvasSize) { this->canvasSize = canvasSize; + // resitev da ne postane tekstura okoli sonca transparentna in da se ne vidi nasledna slika + // https://github.com/raysan5/raylib/issues/3820 + rlSetBlendFactorsSeparate(RL_SRC_ALPHA, RL_ONE_MINUS_SRC_ALPHA, RL_ONE, RL_ONE, RL_FUNC_ADD, RL_MAX); } void BackGround::deinit() @@ -117,26 +119,45 @@ void BackGround::drawStars() void BackGround::drawSun() { - int r = ((m_dna->moonY / 255.0f * (maxSizeOfMoon - minSizeOfMoon)) + minSizeOfMoon) * canvasSize; + int radius = ((m_dna->moonY / 255.0f * (maxSizeOfMoon - minSizeOfMoon)) + minSizeOfMoon) * canvasSize; int xpos = Lerp(canvasSize * moonXOffset, canvasSize - canvasSize * moonXOffset, m_dna->moonX / 255.0f); int ypos = Lerp(canvasSize * moonXOffset, maxYPosOfMoon * canvasSize, m_dna->moonY / 255.0f); + Color color = {0}; if (getColorSet() == 3) { - Circle::setColor(BackGroundColors::moonColor); - r = (((m_dna->moonSize / 255.0f) * (maxSizeOfMoon - minSizeOfMoon)) + minSizeOfMoon) * canvasSize; + color = BackGroundColors::moonColor; + radius = (((m_dna->moonSize / 255.0f) * (maxSizeOfMoon - minSizeOfMoon)) + minSizeOfMoon) * canvasSize; } else { - Color color = {0}; color.r = 255; color.g = std::lerp(200, 50, m_dna->moonY / 255.0f); color.b = std::lerp(50, 0, m_dna->moonY / 255.0f); - color.a = 255; - - Circle::setColor(color); } - Circle::draw(xpos, ypos, r); + + BeginBlendMode(RL_BLEND_CUSTOM_SEPARATE); + + constexpr float numOfCircles = 15.0f; + constexpr float sunMin = 1.7f; + + float amount = 0.0f; + color.a = 15; + for (size_t i = 0; i < numOfCircles; i++) + { + + float r = Lerp(radius, radius / sunMin, amount); + DrawCircle(xpos, ypos, r, color); + amount += 1.0f / numOfCircles; + } + + + EndBlendMode(); + + color.a = 255; + DrawCircle(xpos, ypos, radius / sunMin, color); + + } void BackGround::drawMounten(size_t mountenSegments, int min, int max, Color color, float scale) diff --git a/shared/src/canvas/Canvas.cpp b/shared/src/canvas/Canvas.cpp index 3f3a180..ab9eee0 100644 --- a/shared/src/canvas/Canvas.cpp +++ b/shared/src/canvas/Canvas.cpp @@ -1,11 +1,9 @@ #include "canvas/Canvas.hpp" -#include "canvas/Circle.hpp" void Canvas::init(int size) { backGround.init(size); tree.init(size); - Circle::init(); } void Canvas::newGen(RenderTexture2D &target, Dna *dna) @@ -30,5 +28,4 @@ bool Canvas::tick(RenderTexture2D &target) void Canvas::deinit() { backGround.deinit(); - Circle::deinit(); } diff --git a/shared/src/canvas/Circle.cpp b/shared/src/canvas/Circle.cpp deleted file mode 100644 index 1245827..0000000 --- a/shared/src/canvas/Circle.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "canvas/Circle.hpp" -#include "canvas/sunShader.hpp" - -#include -#include - -RenderTexture2D Circle::target; -Shader Circle::shader; -float Circle::c[3]; -int Circle::colorLoc; - -void Circle::init() -{ -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) - shader = LoadShaderFromMemory(nullptr, sun_shader_100); -#else - shader = LoadShaderFromMemory(nullptr, (const char *)shaders_sun_330_fs); -#endif - target = LoadRenderTexture(sizeTexute, sizeTexute); - - c[0] = 1.0f; - c[1] = 1.0f; - c[2] = 1.0f; - colorLoc = GetShaderLocation(shader, "color"); - SetShaderValue(shader, colorLoc, c, SHADER_UNIFORM_VEC3); - - // resitev da ne postane tekstura okoli sonca transparentna in da se ne vidi nasledna slika - // https://github.com/raysan5/raylib/issues/3820 - rlSetBlendFactorsSeparate(RL_SRC_ALPHA, RL_ONE_MINUS_SRC_ALPHA, RL_ONE, RL_ONE, RL_FUNC_ADD, RL_MAX); -} - -void Circle::deinit() -{ - UnloadShader(shader); - UnloadRenderTexture(target); -} - -void Circle::setColor(Color color) -{ - c[0] = color.r / 255.0f; - c[1] = color.g / 255.0f; - c[2] = color.b / 255.0f; - SetShaderValue(shader, colorLoc, c, SHADER_UNIFORM_VEC3); -} - -void Circle::draw(float x, float y, float size) -{ - Rectangle dest = {x - size, y - size, size * 2, size * 2}; - Rectangle source = {0, 0, (float)target.texture.width, (float)-target.texture.height}; - Vector2 origin = {0.0f, 0.0f}; - - // zgorni komentar da se mesanje barv oklopi pravilno - BeginBlendMode(RL_BLEND_CUSTOM_SEPARATE); - BeginShaderMode(shader); - DrawTexturePro(target.texture, source, dest, origin, 0.0f, WHITE); - EndShaderMode(); - EndBlendMode(); -} \ No newline at end of file