From 9b778b6645480b24a93e64fd656c2cfa0acd079e Mon Sep 17 00:00:00 2001 From: John Kisor Date: Tue, 13 Feb 2024 22:35:40 -0500 Subject: [PATCH] Build example --- build.sh | 2 + examples/textures_logo_raylib.c | 70 ++++++++++++++++++++++++++++++++ resources/raylib_logo.png | Bin 0 -> 3672 bytes wasm/textures_logo_raylib.wasm | Bin 0 -> 1463 bytes 4 files changed, 72 insertions(+) create mode 100644 examples/textures_logo_raylib.c create mode 100644 resources/raylib_logo.png create mode 100755 wasm/textures_logo_raylib.wasm diff --git a/build.sh b/build.sh index 60ccd66..589e615 100755 --- a/build.sh +++ b/build.sh @@ -10,6 +10,7 @@ clang -I./include/ -o build/core_input_keys ./examples/core_input_keys.c -L./lib clang -I./include/ -o build/shapes_colors_palette ./examples/shapes_colors_palette.c -L./lib/ -lraylib -lm clang -I./include/ -o build/game ./game.c -L./lib/ -lraylib -lm clang -I./include/ -o ./build/core_input_mouse_wheel ./examples/core_input_mouse_wheel.c -L./lib/ -lraylib -lm +clang -I./include/ -o ./build/textures_logo_raylib ./examples/textures_logo_raylib.c -L./lib/ -lraylib -lm clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/core_basic_window.wasm ./examples/core_basic_window.c -DPLATFORM_WEB clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/core_basic_screen_manager.wasm ./examples/core_basic_screen_manager.c -DPLATFORM_WEB @@ -17,3 +18,4 @@ clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/shapes_colors_palette.wasm ./examples/shapes_colors_palette.c -DPLATFORM_WEB clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/game.wasm game.c -DPLATFORM_WEB clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/core_input_mouse_wheel.wasm ./examples/core_input_mouse_wheel.c -DPLATFORM_WEB +clang --target=wasm32 -I./include --no-standard-libraries -Wl,--export-table -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=main -o wasm/textures_logo_raylib.wasm ./examples/textures_logo_raylib.c -DPLATFORM_WEB diff --git a/examples/textures_logo_raylib.c b/examples/textures_logo_raylib.c new file mode 100644 index 0000000..f0b401c --- /dev/null +++ b/examples/textures_logo_raylib.c @@ -0,0 +1,70 @@ +/******************************************************************************************* +* +* raylib [textures] example - Texture loading and drawing +* +* Example originally created with raylib 1.0, last time updated with raylib 1.0 +* +* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software +* +* Copyright (c) 2014-2024 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +void raylib_js_set_entry(void (*entry)(void)); + +const int screenWidth = 800; +const int screenHeight = 450; +Texture2D texture = {0}; + +void GameFrame() { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); + + DrawText("this IS a texture!", 360, 370, 10, GRAY); + + EndDrawing(); +} + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + + InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + texture = LoadTexture("resources/raylib_logo.png"); // Texture loading + //--------------------------------------------------------------------------------------- + +#ifdef PLATFORM_WEB + raylib_js_set_entry(GameFrame); +#else + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + GameFrame(); + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- +#endif + return 0; +} diff --git a/resources/raylib_logo.png b/resources/raylib_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..15bbaa2f42d01ac30fb672d31ab00701e6c32895 GIT binary patch literal 3672 zcmaJ^dt6gj5>5yh!$V#Qib$%+vM#j*6%e{cVrD)J71c4ABD6W9E z)&<%?7OgXz3hsNEDM(osU&d(Ta3e5OgCA55D+^n9JLqKsK3TT`6eXZZrx;oJDy zU$ewpu)*`4#INebjo+Cj7YD1kY>tO)%)a=9%7WiJ{X9#0E^nf!wP9t9(`w8Pq9nY3 zD$h=35tI8RSZzA;n%5R(LoH&xbfX>&i5kz9%PQ<7vg}H-%g{DKy8EL*y6;Szj?7{v3aQ5DemCQwO|25#Oq1%Z4u&*4H+Xoy<8c{cPVQrkEK-zvie<^6*e>DS zVPBnr`2ALp&)4e=eMb6;jbrz|DI~j8^ybR>GQy1?9*iU7i0w(VXoM4KY>|SkZZd<% zb-gCtor7uz^f~a7l56&GOPN^zs>bN&H?ZMXD^-D$36KOt>%mRjkMbca^Di5-tpy=hCsI7BfL zjlol{y#C3MbsmO?^od^3;o}&X<+uCsNv@cMsKL#09?2>0;Nc041;mmcIZpU_x*|i1 zWXjWHI{;M>_q`EIWvGrjkWvJC{9<&`@SItbUmw5jJ`fPBc6fwu2~Or*MoVl(4IXs{ zBhfmS9-fkj%>RW?J2%wSJ|^8@j#5Zc z2(b>8D=QXv*g*@T#FiSSQ#9e*+Q&0KfO2!W*EoJPlsYIR<>oV8t=|huPOq>+JW+_0 zX7L;zb0KOJZE;unp(3yjLEvxHX&G9JBHmf&tiGZKBc+8NNj5uZqsW!p&Za#JxT>u= zTi{$=s+y-%#WC^%H1Q`h^ziB0(RSU#p#ad@j)zPQa_A(B=$4DDx zTjZMJ(+`FZ_&q4eBHX}|>qR*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RB8{ zp3^=#-q?vGr@SI=hd0s7v6(X**2pO2^qo8fF&OMvD%35S)3@yw!CZ`lLOU~9fXYl) z?qC4=23l%f;S=5+sl)Ao%+dG2FfX05m%)0MtUS9Nvs635r8$*BEh1lUY}G$sEteg6 zp8LbHQ8eYc%F^~7&K6_oKg+zRW=9gL~}fxv!)38QQ;okNWYV zhxpY~bl0fsFbz*XXQZuKJ_V=PZbN2o z#gDo(5O&V%Hq5%A?d^32u{Es&-fW0p8jbN?k_BD+=KfUk#D#;q>Fq(Z4Kl(Giz*{` zYt(tt1#Q27Hd;7=qoet2Tg)I0m%-^`ryzS^sft!JD9O(`# z?n;Z8IHxkQ8ChPxUMz;&(U|6lbS1wR_b0fC*h^ySDH4s-%ad F{U1buITru` literal 0 HcmV?d00001 diff --git a/wasm/textures_logo_raylib.wasm b/wasm/textures_logo_raylib.wasm new file mode 100755 index 0000000000000000000000000000000000000000..9e1f92a73005f8be53e197287ee73915e0148994 GIT binary patch literal 1463 zcmZuxOLOBy5bha0EK5$TIGdL@o9)?Tcb%7GCzKP!X%-f0tGEHhfua<}7D0+FrDU1i zTyR*Pd!vfea^lE;;6m{e_y^qfz=5KQDvAsA$O&WtRcZ81_owceo}Lea;eY`E+p-P; z4%rwE^)WqgXs8c;wPNH70vjI^U}OH2Sz4HUP`MW#N69N$@Gwe_0hFowaz6~RdqMZ) zI7>%K516t#it}dpC?91ZaAmPBEug8XeLv|v7sq~(METoM(n}wLUW9l(4SJU$3}ug+%*!18f@ ziEDTbXHUeON<2^T=RIgCyg+!tgSNtpgcm*7Rd|W;k_USfwT|@$|GkKMU7}bf&vGno z;0?Uq;ehq^iZqe*khgYO4Rtc`gVog@W zZGyLBaR=A1igS3!eO&DRF%x&mbJv50B-|j}@L*lxb;9c&Y^W7)5Z>@$Q~szD*5xx^ zm%q|$*HzAj*d+gEhp$ciVoTa$n+T#wOtB-^M2iTmShR5qcd&`u*mgfw3vfRvmOhC#K?)}Lr%A(__Mdsbli*z6s=+KMSh^Z@^@N>bpxu7)2BOgZaHBV4%1QA4Tn1y*R-D=r_EE+iOC$_$tQX+d>6wnvGC^fUR z7vupPlurqbx?whC6@pZ)Vc6R~I%Ac$jz&p7!froEj%V60G+WKqc6(G9+s*c02aRZL literal 0 HcmV?d00001