From 069d82bf021389f1c852d9d175f9eb7e9b19e483 Mon Sep 17 00:00:00 2001 From: julesgrc0 Date: Sun, 18 Feb 2024 21:45:08 +0100 Subject: [PATCH] add shaders for android version --- CMakeLists.txt | 13 +++++++++ android/.idea/deploymentTargetDropDown.xml | 26 +++++++++++++++++- android/app/src/main/assets/resource.pack | Bin 2130 -> 2130 bytes assets/shaders/menu_blur.android.fs | 28 ++++++++++++++++++++ src/screen/menu.c | 17 ++++++------ tools/pack_assets.py | 29 +++++++++++++++++---- tools/resource.pack | Bin 2130 -> 2130 bytes 7 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 assets/shaders/menu_blur.android.fs diff --git a/CMakeLists.txt b/CMakeLists.txt index 841ee2a..11f315f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,19 @@ endif() option(BUILD_MINSIZE "Build a smaller executable" OFF) +if(ANDROID) +add_custom_target(pack_assets + COMMAND python ${CMAKE_SOURCE_DIR}/tools/pack_assets.py menu_blur.android.fs=menu_blur.fs + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) +else() +add_custom_target(pack_assets + COMMAND python ${CMAKE_SOURCE_DIR}/tools/pack_assets.py menu_blur.android.fs=none + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) +endif() + + add_subdirectory(lib/raylib) add_subdirectory(lib/zlib) diff --git a/android/.idea/deploymentTargetDropDown.xml b/android/.idea/deploymentTargetDropDown.xml index 0c0c338..900cc39 100644 --- a/android/.idea/deploymentTargetDropDown.xml +++ b/android/.idea/deploymentTargetDropDown.xml @@ -3,7 +3,31 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/assets/resource.pack b/android/app/src/main/assets/resource.pack index 189c64a46692f80a490d41cd078bb81c2a943e91..79bd4cc70055b011bf714ad55aad982482e3b6bf 100644 GIT binary patch literal 2130 zcmV-Y2(9;coW+(4R1;Sk$0sBq5E2MJFcGbTSWF~_AqgN*kyn8r^@TvISQ3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Hgzg8gdfh{)|f_Xx|x4?1_y}@rnLOcn$N{z~)6d9^wvB9+12wIGhU%dBC?&^Wf|2;0r--oim~9INWgvaU|Xu=roU5nTMxSHt?P_)u42-1&@u I1Nqqtwm!izX8-^I diff --git a/assets/shaders/menu_blur.android.fs b/assets/shaders/menu_blur.android.fs new file mode 100644 index 0000000..2b492af --- /dev/null +++ b/assets/shaders/menu_blur.android.fs @@ -0,0 +1,28 @@ +#version 100 + +precision mediump float; + +varying vec2 fragTexCoord; +varying vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +const float renderWidth = 640.0; +const float renderHeight = 360.0; + +vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308); +vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703); + +void main() +{ + vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x; + + tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; + tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; + + tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; + tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/src/screen/menu.c b/src/screen/menu.c index ad816ac..3eba8ea 100644 --- a/src/screen/menu.c +++ b/src/screen/menu.c @@ -58,10 +58,15 @@ void menu_screen(w_state *state) { (Vector2){0, title_text->font_size + 10}), (char *)TextFormat("made by @julesgrc0 - %s", WISPY_VERSION), 20, WHITE); - while (!WindowShouldClose() && is_active) { + double angle = 0.0; + while (!WindowShouldClose() && is_active) { - camera.target.x += sinf(GetTime() * 0.05) * 100.0f * GetFrameTime(); - camera.target.y += cosf(GetTime() * 0.05) * 100.0f * GetFrameTime(); + double speed = GetFrameTime() * 0.1; + angle += speed; + angle = fmod(angle, 360.0); + + camera.target.x += (sin(angle) * 1000.0) * speed; + camera.target.y += (cos(angle) * 1000.0) * speed; update_chunkview(view, grp, get_camera_view(&camera)); update_chunkview_lighting( @@ -85,16 +90,10 @@ void menu_screen(w_state *state) { BeginDrawing(); ClearBackground(BLACK); -#ifndef __ANDROID__ BeginShaderMode(blurShader); -#endif - DrawTexturePro(state->render.texture, state->src_rnd, state->dest_rnd, VEC_ZERO, 0.0f, WHITE); - -#ifndef __ANDROID__ EndShaderMode(); -#endif DrawRectangleLinesEx( (Rectangle){0, 0, ctx->render_size.x, ctx->render_size.y}, 5, diff --git a/tools/pack_assets.py b/tools/pack_assets.py index 17e7ad0..771d252 100644 --- a/tools/pack_assets.py +++ b/tools/pack_assets.py @@ -6,14 +6,28 @@ from io import TextIOWrapper -def write_to_pack(out_file: TextIOWrapper, folder_path: str) -> int: +def write_to_pack(out_file: TextIOWrapper, folder_path: str, redirect_files: dict[str, str]) -> int: total_size = 0 null = 0 + for root, _, files in os.walk(folder_path): for file in files: file_path = os.path.join(root, file) relative_path = os.path.relpath(file_path, folder_path) + if file in redirect_files.keys(): + if redirect_files[file] == "none": + print(f"[+] SKIP {file} (ignored)") + continue + + file_path = os.path.join(root, file) + relative_path = os.path.relpath(os.path.join(root, redirect_files[file]), folder_path) + + print(f"[+] REDIRECT {file} => {redirect_files[file]}") + elif file in redirect_files.values(): + print(f"[+] SKIP {file} (ignored)") + continue + file_size = os.path.getsize(file_path) total_size += file_size @@ -22,7 +36,7 @@ def write_to_pack(out_file: TextIOWrapper, folder_path: str) -> int: length=1, byteorder="little", signed=False)) # end of string out_file.write(file_size.to_bytes( length=4, byteorder="little", signed=False)) # sizeof(unsigned int) = 4 - print(f"[+] {file_path:100}{file_size} o") + print(f"[+] {file_path:100}{file_size} o{' ' * 10}({relative_path})") with open(file_path, "rb") as file: out_file.write(file.read()) @@ -31,20 +45,25 @@ def write_to_pack(out_file: TextIOWrapper, folder_path: str) -> int: def main(args: list[str]) -> int: + redirect_files = {} + for arg in args: + parts = arg.split("=") + if len(parts) == 2: + redirect_files[parts[0]] = parts[1] + base_dir = os.path.dirname(os.path.abspath(__file__)) - assets_dir = os.path.join(os.path.dirname(base_dir), "assets") out_tmp = os.path.join(base_dir, "resource.tmp") out_gz = os.path.join(base_dir, "resource.pack") print("[PACK]: Start packing...") - print(f"[-] {'filename':100}{'size (octet)'}\n") + print(f"[I] {'filename':100}size{' '*10}id\n") start_t = time.time() total_size = 0 with open(out_tmp, "wb+") as fp: - total_size = write_to_pack(fp, assets_dir) + total_size = write_to_pack(fp, assets_dir, redirect_files) fp.close() with open(out_tmp, 'rb') as fp_in: diff --git a/tools/resource.pack b/tools/resource.pack index 189c64a46692f80a490d41cd078bb81c2a943e91..79bd4cc70055b011bf714ad55aad982482e3b6bf 100644 GIT binary patch literal 2130 zcmV-Y2(9;coW+(4R1;Sk$0sBq5E2MJFcGbTSWF~_AqgN*kyn8r^@TvISQ3&+m>QCF z5(HFm2nrggL@g?UZ>p=J3qDp?mo>Z;1w>GM9cU9L?`Mq$bFB#5U`DF74zfDH@gMbfDgsrX;IC@Opr-rEiR z>}>J2-s!Iect_AKiVOvgU77R{|KN(kLl(1Rr82Sj=T?)+)QC;)r-<&wVzJXZKT3?a z7EJKX*Ec+UVN;F~fVf)}O6>mhskk2?`gmUWu~4x-`E?L)Gf0s&AR-G$R#6Sz1k#9J zo*9Fz>d+aCJquF$qAO0^CmDk^^RC&8kaJIpSt~osmfj%5JSd-G++0~*^0KF6zsssM z$J>|GJ}GsgW=y8I&1mWwm6C6!+-MDD)ClE5M*t#)J)%|*vX<3^`W~8D;&nLlIzR&I zmL9q}HLCV*{svk3fqk3Lo^M;%u_g6ZW7YMLLFW7^wT$9;PPX@i3C773&yRzajS49+ zLvFJMa-jt>t*FTvaHEA*kzf9ClZ#F^En9xGppEeX0t8@rS-rbXyYe;$Bs-k?U zhwLnc|IDozi9(8dYZ?t%EECDL_4+?{Mo>lJ;i{rjuU2!AUCq)^pQH8Zp>d}S^ye49 zoX$KM#xv1xpMTMjx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