Unnamed: 0
int64
0
0
repo_id
stringlengths
5
186
file_path
stringlengths
15
223
content
stringlengths
1
32.8M
βŒ€
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-36-shapes-lines-bezier/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-68-textures-textured-curve/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-68-textures-textured-curve/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [textures] example - Draw a texture along a segmented curve //* //* Example originally created with raylib 4.5, last time updated with raylib 4.5 //* //* Example contributed by Jeffery Myers and reviewed by Ramon Santamaria (@raysan5) //* //* 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) 2022-2023 Jeffery Myers and Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const std = @import("std"); // std.math.pow() const c = @cImport( { @cInclude("raylib.h"); @cInclude("raymath.h"); @cInclude("rlgl.h"); }); var tex_road = c.Texture{ .id = 0, .width = 0, .height = 0, .mipmaps = 0, .format = 0 }; var show_curve = false; var curve_width: f32 = 50.0; var curve_segments: u32 = 24; var curve_start_pos = c.Vector2{ .x = 80.0, .y = 100.0 }; var curve_start_pos_tangent = c.Vector2{ .x = 100.0, .y = 300.0 }; var curve_end_pos = c.Vector2{ .x = 700.0, .y = 350.0 }; var curve_end_pos_tangent = c.Vector2{ .x = 600.0, .y = 100.0 }; var curve_selected_point: ?*c.Vector2 = null; pub fn main() void { const screen_width = 800; const screen_height = 450; c.SetConfigFlags(c.FLAG_VSYNC_HINT | c.FLAG_MSAA_4X_HINT); c.InitWindow(screen_width, screen_height, "raylib [textures] examples - textured curve"); defer c.CloseWindow(); // Close window and OpenGL context // Load the road texture tex_road = c.LoadTexture("resources/road.png"); defer c.UnloadTexture(tex_road); c.SetTextureFilter(tex_road, c.TEXTURE_FILTER_BILINEAR); c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- UpdateCurve(); UpdateOptions(); //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); DrawTexturedCurve(); DrawCurve(); c.DrawText("Drag points to move curve, press SPACE to show/hide base curve", 10, 10, 10, c.DARKGRAY); c.DrawText(c.TextFormat("Curve width: %2.0f (Use + and - to adjust)", curve_width), 10, 30, 10, c.DARKGRAY); c.DrawText(c.TextFormat("Curve segments: %u (Use LEFT and RIGHT to adjust)", curve_segments), 10, 50, 10, c.DARKGRAY); //--------------------------------------------------------------------------------- } } fn DrawCurve() void { if (show_curve) { if (c.RAYLIB_VERSION_MAJOR >= 5) // - Raylib v5.0 works { c.DrawSplineSegmentBezierCubic(curve_start_pos, curve_start_pos_tangent, curve_end_pos, curve_end_pos_tangent, 2.0, c.BLUE); } else // - Raylib v4.5 is supported, older version may work, but no promises c.DrawLineBezierCubic(curve_start_pos, curve_end_pos, curve_start_pos_tangent, curve_end_pos_tangent, 2.0, c.BLUE); } // Draw the various control points and highlight where the mouse is c.DrawLineV(curve_start_pos, curve_start_pos_tangent, c.SKYBLUE); c.DrawLineV(curve_end_pos, curve_end_pos_tangent, c.PURPLE); const mouse = c.GetMousePosition(); // Vector2 if (c.CheckCollisionPointCircle(mouse, curve_start_pos, 6)) c.DrawCircleV(curve_start_pos, 7, c.YELLOW); c.DrawCircleV(curve_start_pos, 5, c.RED); if (c.CheckCollisionPointCircle(mouse, curve_start_pos_tangent, 6)) c.DrawCircleV(curve_start_pos_tangent, 7, c.YELLOW); c.DrawCircleV(curve_start_pos_tangent, 5, c.MAROON); if (c.CheckCollisionPointCircle(mouse, curve_end_pos, 6)) c.DrawCircleV(curve_end_pos, 7, c.YELLOW); c.DrawCircleV(curve_end_pos, 5, c.GREEN); if (c.CheckCollisionPointCircle(mouse, curve_end_pos_tangent, 6)) c.DrawCircleV(curve_end_pos_tangent, 7, c.YELLOW); c.DrawCircleV(curve_end_pos_tangent, 5, c.DARKGREEN); } fn DrawTexturedCurve() void { const step = 1.0 / @as(f32, @floatFromInt(curve_segments)); var previous = curve_start_pos; var previous_tangent = c.Vector2{ .x = 0.0, .y = 0.0 }; var previous_v: f32 = 0.0; // We can't compute a tangent for the first point, so we need to reuse the tangent from the first segment var tangent_set = false; var current = c.Vector2{ .x = 0.0, .y = 0.0 }; var t: f32 = 0.0; for (1..curve_segments + 1) |i| { // Segment the curve t = step * @as(f32, @floatFromInt(i)); const one_minus_t = 1.0 - t; const a = std.math.pow(f32, one_minus_t, 3.0); const b = 3.0 * std.math.pow(f32, one_minus_t, 2.0) * t; const cc = 3.0 * one_minus_t * std.math.pow(f32, t, 2.0); const d = std.math.pow(f32, t, 3.0); // Compute the endpoint for this segment current.y = a*curve_start_pos.y + b*curve_start_pos_tangent.y + cc*curve_end_pos_tangent.y + d*curve_end_pos.y; current.x = a*curve_start_pos.x + b*curve_start_pos_tangent.x + cc*curve_end_pos_tangent.x + d*curve_end_pos.x; // Vector from previous to current const delta = c.Vector2{ .x = current.x - previous.x, .y = current.y - previous.y }; // The right hand normal to the delta vector const normal = c.Vector2Normalize(.{ .x = -delta.y, .y = delta.x }); // Vector2 // The v texture coordinate of the segment (add up the length of all the segments so far) const v = previous_v + c.Vector2Length(delta); // Make sure the start point has a normal if (!tangent_set) { previous_tangent = normal; tangent_set = true; } // Extend out the normals from the previous and current points to get the quad for this segment const prev_pos_normal = c.Vector2Add(previous, c.Vector2Scale(previous_tangent, curve_width)); // Vector2 const prev_neg_normal = c.Vector2Add(previous, c.Vector2Scale(previous_tangent, -curve_width)); // Vector2 const current_pos_normal = c.Vector2Add(current, c.Vector2Scale(normal, curve_width)); // Vector2 const current_neg_normal = c.Vector2Add(current, c.Vector2Scale(normal, -curve_width)); // Vector2 // Draw the segment as a quad c.rlSetTexture(tex_road.id); { c.rlBegin(c.RL_QUADS); defer c.rlEnd(); c.rlColor4ub(255,255,255,255); c.rlNormal3f(0.0, 0.0, 1.0); c.rlTexCoord2f(0, previous_v); c.rlVertex2f(prev_neg_normal.x, prev_neg_normal.y); c.rlTexCoord2f(1, previous_v); c.rlVertex2f(prev_pos_normal.x, prev_pos_normal.y); c.rlTexCoord2f(1, v); c.rlVertex2f(current_pos_normal.x, current_pos_normal.y); c.rlTexCoord2f(0, v); c.rlVertex2f(current_neg_normal.x, current_neg_normal.y); } // The current step is the start of the next step previous = current; previous_tangent = normal; previous_v = v; } } fn UpdateCurve() void { // If the mouse is not down, we are not editing the curve so clear the selection if (!c.IsMouseButtonDown(c.MOUSE_LEFT_BUTTON)) { curve_selected_point = null; return; } // If a point was selected, move it if (curve_selected_point) |pt_ptr| { pt_ptr.* = c.Vector2Add(pt_ptr.*, c.GetMouseDelta()); return; } // The mouse is down, and nothing was selected, so see if anything was picked const mouse_pos = c.GetMousePosition(); // Vector2 if (c.CheckCollisionPointCircle(mouse_pos, curve_start_pos, 6)) { curve_selected_point = &curve_start_pos; } else { if (c.CheckCollisionPointCircle(mouse_pos, curve_start_pos_tangent, 6)) { curve_selected_point = &curve_start_pos_tangent; } else { if (c.CheckCollisionPointCircle(mouse_pos, curve_end_pos, 6)) { curve_selected_point = &curve_end_pos; } else { if (c.CheckCollisionPointCircle(mouse_pos, curve_end_pos_tangent, 6)) curve_selected_point = &curve_end_pos_tangent; } } } } fn UpdateOptions() void { if (c.IsKeyPressed(c.KEY_SPACE)) show_curve = !show_curve; // Update with if (c.IsKeyPressed(c.KEY_EQUAL)) curve_width += 2.0; if (c.IsKeyPressed(c.KEY_MINUS)) curve_width -= 2.0; if (curve_width < 2.0) curve_width = 2.0; // Update segments if (c.IsKeyPressed(c.KEY_LEFT)) curve_segments -= 2; if (c.IsKeyPressed(c.KEY_RIGHT)) curve_segments += 2; if (curve_segments < 2) curve_segments = 2; }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-68-textures-textured-curve/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-68-textures-textured-curve/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-68-textures-textured-curve/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-11-core-3d-camera-mode/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-11-core-3d-camera-mode/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [core] example - Initialize 3d camera mode //* //* 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-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [core] example - 3d camera mode"); defer c.CloseWindow(); // Close window and OpenGL context // Define the camera to look into our 3d world const camera = c.Camera3D { .position = .{ .x = 0.0, .y = 10.0, .z = 10.0 }, // Camera position .target = .{ .x = 0.0, .y = 0.0, .z = 0.0 }, // Camera looking at point .up = .{ .x = 0.0, .y = 1.0, .z = 0.0 }, // Camera up vector (rotation towards target) .fovy = 45.0, // Camera field-of-view Y .projection = c.CAMERA_PERSPECTIVE // Camera mode type }; const cube_pos = c.Vector3{ .x = 0.0, .y = 0.0, .z = 0.0 }; c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); { c.BeginMode3D(camera); defer c.EndMode3D(); c.DrawCube(cube_pos, 2.0, 2.0, 2.0, c.RED); c.DrawCubeWires(cube_pos, 2.0, 2.0, 2.0, c.MAROON); c.DrawGrid(10, 1.0); } c.DrawText("Welcome to the third dimension!", 10, 40, 20, c.DARKGRAY); c.DrawFPS(10, 10); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-11-core-3d-camera-mode/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-11-core-3d-camera-mode/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-11-core-3d-camera-mode/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-87a-models-mesh-generation-(MemAlloc-calloc)/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-87a-models-mesh-generation-(MemAlloc-calloc)/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib example - procedural mesh generation //* //* Example originally created with raylib 1.8, last time updated with raylib 4.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) 2017-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ // This version's GenMeshCustom() uses raylib's MemAlloc() function to allocate RAM. // MemAlloc(), in turn, uses RL_CALLOC(n,sz) macro, which is defined as calloc(n,sz) // See version 87b for the version that uses native Zig allocators. const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; const num_models = 9; c.InitWindow(screen_width, screen_height, "raylib [models] example - mesh-generation"); defer c.CloseWindow(); // Close window and OpenGL context const checked = c.GenImageChecked(2, 2, 1, 1, c.RED, c.GREEN); // c.Image const texture = c.LoadTextureFromImage(checked); // c.Texture2D defer c.UnloadTexture(texture); // Unload texture c.UnloadImage(checked); var models = [num_models]c.Model // Can't be const, since we update their textures below { c.LoadModelFromMesh(c.GenMeshPlane(2, 2, 5, 5)), c.LoadModelFromMesh(c.GenMeshCube(2.0, 1.0, 2.0)), c.LoadModelFromMesh(c.GenMeshSphere(2, 32, 32)), c.LoadModelFromMesh(c.GenMeshHemiSphere(2, 16, 16)), c.LoadModelFromMesh(c.GenMeshCylinder(1, 2, 16)), c.LoadModelFromMesh(c.GenMeshTorus(0.25, 4.0, 16, 32)), c.LoadModelFromMesh(c.GenMeshKnot(1.0, 2.0, 16, 128)), c.LoadModelFromMesh(c.GenMeshPoly(5, 2.0)), c.LoadModelFromMesh(GenMeshCustom()) }; // Unload model data (from GPU VRAM) defer for (0..num_models) |i| c.UnloadModel(models[i]); // Generated meshes could be exported as .obj files //c.ExportMesh(models[0].meshes[0], "plane.obj"); //c.ExportMesh(models[1].meshes[0], "cube.obj"); //c.ExportMesh(models[2].meshes[0], "sphere.obj"); //c.ExportMesh(models[3].meshes[0], "hemisphere.obj"); //c.ExportMesh(models[4].meshes[0], "cylinder.obj"); //c.ExportMesh(models[5].meshes[0], "torus.obj"); //c.ExportMesh(models[6].meshes[0], "knot.obj"); //c.ExportMesh(models[7].meshes[0], "poly.obj"); //c.ExportMesh(models[8].meshes[0], "custom.obj"); // Set checked texture as default diffuse component for all models material for (0..num_models) |i| models[i].materials[0].maps[c.MATERIAL_MAP_DIFFUSE].texture = texture; // Define the camera to look into our 3d world var camera = c.Camera3D { .position = .{ .x = 5.0, .y = 5.0, .z = 5.0 }, // Camera position .target = .{ .x = 0.0, .y = 0.0, .z = 0.0 }, // Camera looking at point .up = .{ .x = 0.0, .y = 1.0, .z = 0.0 }, // Camera up vector (rotation towards target) .fovy = 45.0, // Camera field-of-view Y .projection = c.CAMERA_PERSPECTIVE // Camera mode type }; // Model drawing position const position = c.Vector3{ .x = 0.0, .y = 0.0, .z = 0.0 }; var current_model: usize = 0; c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- c.UpdateCamera(&camera, c.CAMERA_ORBITAL); if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_LEFT)) current_model = (current_model + 1) % num_models; // Cycle between the models if (c.IsKeyPressed(c.KEY_RIGHT)) { current_model += 1; if (current_model >= num_models) current_model = 0; } else if (c.IsKeyPressed(c.KEY_LEFT)) { if (current_model <= 1) { current_model = num_models - 1; } else current_model -= 1; } //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); { c.BeginMode3D(camera); defer c.EndMode3D(); c.DrawModel(models[current_model], position, 1.0, c.WHITE); c.DrawGrid(10, 1.0); } c.DrawRectangle(30, 400, 310, 30, c.Fade(c.SKYBLUE, 0.5)); c.DrawRectangleLines(30, 400, 310, 30, c.Fade(c.DARKBLUE, 0.5)); c.DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, c.BLUE); switch (current_model) { 0 => c.DrawText("PLANE", 680, 10, 20, c.DARKBLUE), 1 => c.DrawText("CUBE", 680, 10, 20, c.DARKBLUE), 2 => c.DrawText("SPHERE", 680, 10, 20, c.DARKBLUE), 3 => c.DrawText("HEMISPHERE", 640, 10, 20, c.DARKBLUE), 4 => c.DrawText("CYLINDER", 680, 10, 20, c.DARKBLUE), 5 => c.DrawText("TORUS", 680, 10, 20, c.DARKBLUE), 6 => c.DrawText("KNOT", 680, 10, 20, c.DARKBLUE), 7 => c.DrawText("POLY", 680, 10, 20, c.DARKBLUE), 8 => c.DrawText("Custom (triangle)", 580, 10, 20, c.DARKBLUE), else => {} } //--------------------------------------------------------------------------------- } } // Generate a simple triangle mesh from code // Warning: uses raylib's MemAlloc() function to allocate RAM. // 1) we assume allocations are always successful; // 2) we assume allocated RAM is f32-aligned (4 bytes). // All the allocated RAM is freed in deferred calls to raylib's UnloadModel() in the main // function ( https://github.com/raysan5/raylib/blob/7d68aa686974347cefe0ef481c835e3d60bdc4b9/src/rmodels.c#L1123 ) // UnloadModel() calls UnloadMesh() in a loop for all the meshes of the model, then uses raylib's RL_FREE macro // to free the materials in a similar fashion. Then it uses RL_FREE to free the array of mesh pointers, the array // of material pointers, etc. fn GenMeshCustom() c.Mesh { var mesh = c.Mesh { .vertexCount = 3, .triangleCount = 1, // @ptrCast -> [*c]f32, @alignCast -> @alignOf(f32) .vertices = @ptrCast(@alignCast(c.MemAlloc(3 * 3 * @sizeOf(f32)).?)), // 3 vertices, 3 coordinates each (x, y, z) // @ptrCast -> [*c]f32, @alignCast -> @alignOf(f32) .texcoords = @ptrCast(@alignCast(c.MemAlloc(3 * 2 * @sizeOf(f32)).?)), // 3 vertices, 2 coordinates each (x, y) .texcoords2 = null, // @ptrCast -> [*c]f32, @alignCast -> @alignOf(f32) .normals = @ptrCast(@alignCast(c.MemAlloc(3 * 3 * @sizeOf(f32)).?)), // 3 vertices, 3 coordinates each (x, y, z) .tangents = null, .colors = null, .indices = null, .animVertices = null, .animNormals = null, .boneIds = null, .boneWeights = null, .vaoId = 0, // UploadMesh() uses RL_CALLOC() macro to allocate MAX_MESH_VERTEX_BUFFERS unsigned ints, // and saves the pointer to them in .vboId .vboId = null }; // Vertex at (0, 0, 0) mesh.vertices[0] = 0.0; mesh.vertices[1] = 0.0; mesh.vertices[2] = 0.0; mesh.normals[0] = 0.0; mesh.normals[1] = 1.0; mesh.normals[2] = 0.0; mesh.texcoords[0] = 0.0; mesh.texcoords[1] = 0.0; // Vertex at (1, 0, 2) mesh.vertices[3] = 1.0; mesh.vertices[4] = 0.0; mesh.vertices[5] = 2.0; mesh.normals[3] = 0.0; mesh.normals[4] = 1.0; mesh.normals[5] = 0.0; mesh.texcoords[2] = 0.5; mesh.texcoords[3] = 1.0; // Vertex at (2, 0, 0) mesh.vertices[6] = 2.0; mesh.vertices[7] = 0.0; mesh.vertices[8] = 0.0; mesh.normals[6] = 0.0; mesh.normals[7] = 1.0; mesh.normals[8] = 0.0; mesh.texcoords[4] = 1.0; mesh.texcoords[5] = 0.0; // Upload mesh data from CPU (RAM) to GPU (VRAM) memory c.UploadMesh(&mesh, false); return mesh; }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-87a-models-mesh-generation-(MemAlloc-calloc)/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-87a-models-mesh-generation-(MemAlloc-calloc)/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-87a-models-mesh-generation-(MemAlloc-calloc)/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-15-core-world-screen/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-15-core-world-screen/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [core] example - World to screen //* //* Example originally created with raylib 1.3, last time updated with raylib 1.4 //* //* 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) 2015-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [core] example - core world screen"); defer c.CloseWindow(); // Close window and OpenGL context // Define the camera to look into our 3d world var camera = c.Camera3D { .position = .{ .x = 10.0, .y = 10.0, .z = 10.0 }, // Camera position .target = .{ .x = 0.0, .y = 0.0, .z = 0.0 }, // Camera looking at point .up = .{ .x = 0.0, .y = 1.0, .z = 0.0 }, // Camera up vector (rotation towards target) .fovy = 45.0, // Camera field-of-view Y .projection = c.CAMERA_PERSPECTIVE // Camera mode type }; const cube_pos = c.Vector3{ .x = 0.0, .y = 0.0, .z = 0.0 }; var cube_scr_pos = c.Vector2{ .x = 0.0, .y = 0.0 }; c.DisableCursor(); // Limit cursor to relative movement inside the window c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- c.UpdateCamera(&camera, c.CAMERA_THIRD_PERSON); // Calculate cube screen space position (with a little offset to be in top) cube_scr_pos = c.GetWorldToScreen(.{.x = cube_pos.x, .y = cube_pos.y + 2.5, .z = cube_pos.z}, camera); //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); { c.BeginMode3D(camera); defer c.EndMode3D(); c.DrawCube(cube_pos, 2.0, 2.0, 2.0, c.RED); c.DrawCubeWires(cube_pos, 2.0, 2.0, 2.0, c.MAROON); c.DrawGrid(10, 1.0); } c.DrawText("Enemy: 100 / 100", @as(c_int, @intFromFloat(cube_scr_pos.x)) - @divTrunc(c.MeasureText("Enemy: 100/100", 20), 2), @intFromFloat(cube_scr_pos.y), 20, c.BLACK); // -- The following code causes Zig compiler (0.11.0-dev.3859+88284c124) to segfault //c.DrawText(c.TextFormat("Cube position in screen space coordinates: [%i, %i]", // @intFromFloat(cube_scr_pos.x), @intFromFloat(cube_scr_pos.y)), // 10, 10, 20, c.LIME); // -- But this does not c.DrawText(c.TextFormat("Cube position in screen space coordinates: [%i, %i]", @as(c_int, @intFromFloat(cube_scr_pos.x)), @as(c_int, @intFromFloat(cube_scr_pos.y))), 10, 10, 20, c.LIME); c.DrawText("Text 2d should be always on top of the cube", 10, 40, 20, c.GRAY); c.DrawFPS(screen_width - 100, 10); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-15-core-world-screen/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-15-core-world-screen/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-15-core-world-screen/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-49-textures-image-generation/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-49-textures-image-generation/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [textures] example - Procedural images generation //* //* Example originally created with raylib 1.8, last time updated with raylib 1.8 //* //* 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) 2O17-2023 Wilhem Barbier (@nounoursheureux) and Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; const num_textures = 6; // Currently we have 7 generation algorithms c.InitWindow(screen_width, screen_height, "raylib [textures] example - procedural images generation"); defer c.CloseWindow(); // Close window and OpenGL context const vertical_gradient = if (c.RAYLIB_VERSION_MAJOR >= 5) // - Raylib v5.0 works c.GenImageGradientLinear(screen_width, screen_height, 0, c.RED, c.BLUE) // c.Image else // - Raylib v4.5 is supported, older version may work, but no promises c.GenImageGradientV(screen_width, screen_height, c.RED, c.BLUE); // c.Image const horizontal_gradient = if (c.RAYLIB_VERSION_MAJOR >= 5) // - Raylib v5.0 works c.GenImageGradientLinear(screen_width, screen_height, 0, c.RED, c.BLUE) // c.Image else // - Raylib v4.5 is supported, older version may work, but no promises c.GenImageGradientH(screen_width, screen_height, c.RED, c.BLUE); // c.Image const radial_gradient = c.GenImageGradientRadial(screen_width, screen_height, 0.0, c.WHITE, c.BLACK); const checked = c.GenImageChecked(screen_width, screen_height, 32, 32, c.RED, c.BLUE); const white_noise = c.GenImageWhiteNoise(screen_width, screen_height, 0.5); const cellular = c.GenImageCellular(screen_width, screen_height, 32); const textures = [num_textures]c.Texture2D { c.LoadTextureFromImage(vertical_gradient), c.LoadTextureFromImage(horizontal_gradient), c.LoadTextureFromImage(radial_gradient), c.LoadTextureFromImage(checked), c.LoadTextureFromImage(white_noise), c.LoadTextureFromImage(cellular) }; // Unload textures data (GPU VRAM) defer for (textures) |texture| c.UnloadTexture(texture); // Unload image data (CPU RAM) c.UnloadImage(vertical_gradient); c.UnloadImage(horizontal_gradient); c.UnloadImage(radial_gradient); c.UnloadImage(checked); c.UnloadImage(white_noise); c.UnloadImage(cellular); var current_texture: u32 = 0; c.SetTargetFPS(60); // Set our game to run at 60 frames-per-second while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_LEFT) or c.IsKeyPressed(c.KEY_RIGHT)) current_texture = (current_texture + 1) % num_textures; // Cycle between the textures //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawTexture(textures[current_texture], 0, 0, c.WHITE); c.DrawRectangle(30, 400, 325, 30, c.Fade(c.SKYBLUE, 0.5)); c.DrawRectangleLines(30, 400, 325, 30, c.Fade(c.WHITE, 0.5)); c.DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, c.WHITE); switch (current_texture) { 0 => c.DrawText("VERTICAL GRADIENT", 560, 10, 20, c.RAYWHITE), 1 => c.DrawText("HORIZONTAL GRADIENT", 540, 10, 20, c.RAYWHITE), 2 => c.DrawText("RADIAL GRADIENT", 580, 10, 20, c.LIGHTGRAY), 3 => c.DrawText("CHECKED", 680, 10, 20, c.RAYWHITE), 4 => c.DrawText("WHITE NOISE", 640, 10, 20, c.RED), 5 => c.DrawText("CELLULAR", 670, 10, 20, c.RAYWHITE), else => {} } //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-49-textures-image-generation/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-49-textures-image-generation/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-49-textures-image-generation/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-46-textures-logo-raylib/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-46-textures-logo-raylib/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* 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-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [textures] example - texture loading and drawing"); defer c.CloseWindow(); // Close window and OpenGL context // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) const texture = c.LoadTexture("resources/raylib_logo.png"); // c.Texture2D defer c.UnloadTexture(texture); // c.SetTargetFPS(60); -- Don't need this since we're displaying a static image while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawTexture(texture, screen_width/2 - @divTrunc(texture.width, 2), screen_height/2 - @divTrunc(texture.height, 2), c.WHITE); c.DrawText("this IS a texture!", 360, 370, 10, c.GRAY); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-46-textures-logo-raylib/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-46-textures-logo-raylib/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-46-textures-logo-raylib/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-50-textures-image-loading/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-50-textures-image-loading/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [textures] example - Image loading and texture creation //* //* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) //* //* Example originally created with raylib 1.3, last time updated with raylib 1.3 //* //* 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) 2015-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [textures] example - image loading"); defer c.CloseWindow(); // Close window and OpenGL context // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) const image = c.LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM) - c.Image const texture = c.LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) - c.Texture2D defer c.UnloadTexture(texture); // Texture unloading c.UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM // Do we really need this? We're displaying a static image.. Oh well. c.SetTargetFPS(60); // Set our game to run at 60 frames-per-second while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawTexture(texture, screen_width/2 - @divTrunc(texture.width, 2), screen_height/2 - @divTrunc(texture.height, 2), c.WHITE); c.DrawText("this IS a texture loaded from an image!", 300, 370, 10, c.GRAY); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-50-textures-image-loading/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-50-textures-image-loading/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-50-textures-image-loading/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-35-shapes-rectangle-scaling/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-35-shapes-rectangle-scaling/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [shapes] example - rectangle scaling by mouse //* //* Example originally created with raylib 2.5, last time updated with raylib 2.5 //* //* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) //* //* 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) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; const mouse_scale_mark_size = 12; c.InitWindow(screen_width, screen_height, "raylib [shapes] example - rectangle scaling mouse"); defer c.CloseWindow(); // Close window and OpenGL context var rec = c.Rectangle{ .x = 100.0, .y = 100.0, .width = 200.0, .height = 80.0 }; var mouse_pos = c.Vector2{ .x = 0.0, .y = 0.0 }; var mouse_scale_ready = false; var mouse_scale_mode = false; c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- mouse_pos = c.GetMousePosition(); if (c.CheckCollisionPointRec(mouse_pos, .{ .x = rec.x + rec.width - mouse_scale_mark_size, .y = rec.y + rec.height - mouse_scale_mark_size, .width = mouse_scale_mark_size, .height = mouse_scale_mark_size })) { mouse_scale_ready = true; if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_LEFT)) mouse_scale_mode = true; } else mouse_scale_ready = false; if (mouse_scale_mode) { mouse_scale_ready = true; rec.width = mouse_pos.x - rec.x; rec.height = mouse_pos.y - rec.y; // Check minimum rec size if (rec.width < mouse_scale_mark_size) rec.width = mouse_scale_mark_size; if (rec.height < mouse_scale_mark_size) rec.height = mouse_scale_mark_size; // Check maximum rec size if (rec.width > (@as(f32, @floatFromInt(c.GetScreenWidth())) - rec.x)) rec.width = @as(f32, @floatFromInt(c.GetScreenWidth())) - rec.x; if (rec.height > (@as(f32, @floatFromInt(c.GetScreenHeight())) - rec.y)) rec.height = @as(f32, @floatFromInt(c.GetScreenHeight())) - rec.y; if (c.IsMouseButtonReleased(c.MOUSE_BUTTON_LEFT)) mouse_scale_mode = false; } //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, c.GRAY); c.DrawRectangleRec(rec, c.Fade(c.GREEN, 0.5)); if (mouse_scale_ready) { c.DrawRectangleLinesEx(rec, 1, c.RED); c.DrawTriangle(.{ .x = rec.x + rec.width - mouse_scale_mark_size, .y = rec.y + rec.height }, .{ .x = rec.x + rec.width, .y = rec.y + rec.height }, .{ .x = rec.x + rec.width, .y = rec.y + rec.height - mouse_scale_mark_size }, c.RED); } //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-35-shapes-rectangle-scaling/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-35-shapes-rectangle-scaling/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-35-shapes-rectangle-scaling/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-70-text-font-spritefont/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-70-text-font-spritefont/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [text] example - Sprite font loading //* //* NOTE: Sprite fonts should be generated following this conventions: //* //* - Characters must be ordered starting with character 32 (Space) //* - Every character must be contained within the same Rectangle height //* - Every character and every line must be separated by the same distance (margin/padding) //* - Rectangles must be defined by a MAGENTA color background //* //* Following those constraints, a font can be provided just by an image, //* this is quite handy to avoid additional font descriptor files (like BMFonts use). //* //* 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-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const std = @import("std"); const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [text] example - sprite font loading"); defer c.CloseWindow(); // Close window and OpenGL context const msg1: [*:0]const u8 = "THIS IS A custom SPRITE FONT..."; const msg2: [*:0]const u8 = "...and this is ANOTHER CUSTOM font..."; const msg3: [*:0]const u8 = "...and a THIRD one! GREAT! :D"; // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) const font1 = c.LoadFont("resources/custom_mecha.png"); // Font loading const font2 = c.LoadFont("resources/custom_alagard.png"); // Font loading const font3 = c.LoadFont("resources/custom_jupiter_crash.png"); // Font loading defer { c.UnloadFont(font1); c.UnloadFont(font2); c.UnloadFont(font3); } const font_pos1 = c.Vector2{ .x = screen_width / 2.0 - c.MeasureTextEx(font1, msg1, @floatFromInt(font1.baseSize), -3).x / 2.0, .y = screen_height / 2.0 - @as(f32, @floatFromInt(font1.baseSize)) / 2.0 - 80.0 }; const font_pos2 = c.Vector2{ .x = screen_width / 2.0 - c.MeasureTextEx(font2, msg2, @floatFromInt(font2.baseSize), -2.0).x / 2.0, .y = screen_height / 2.0 - @as(f32, @floatFromInt(font2.baseSize)) / 2.0 - 10.0 }; const font_pos3 = c.Vector2{ .x = screen_width/2.0 - c.MeasureTextEx(font3, msg3, @floatFromInt(font3.baseSize), 2.0).x / 2.0, .y = screen_height/2.0 - @as(f32, @floatFromInt(font3.baseSize)) / 2.0 + 50.0 }; c.SetTargetFPS(60); while (!c.WindowShouldClose()) { // Update //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawTextEx(font1, msg1, font_pos1, @floatFromInt(font1.baseSize), -3, c.WHITE); c.DrawTextEx(font2, msg2, font_pos2, @floatFromInt(font2.baseSize), -2, c.WHITE); c.DrawTextEx(font3, msg3, font_pos3, @floatFromInt(font3.baseSize), 2, c.WHITE); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-70-text-font-spritefont/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-70-text-font-spritefont/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-70-text-font-spritefont/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-86-models-geometric-shapes/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-86-models-geometric-shapes/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...) //* //* Example originally created with raylib 1.0, last time updated with raylib 3.5 //* //* 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-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [models] example - geometric shapes"); defer c.CloseWindow(); // Close window and OpenGL context // Define the camera to look into our 3d world const camera = c.Camera3D { .position = .{ .x = 0.0, .y = 10.0, .z = 10.0 }, // Camera position .target = .{ .x = 0.0, .y = 0.0, .z = 0.0 }, // Camera looking at point .up = .{ .x = 0.0, .y = 1.0, .z = 0.0 }, // Camera up vector (rotation towards target) .fovy = 45.0, // Camera field-of-view Y .projection = c.CAMERA_PERSPECTIVE // Camera mode type }; c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); { c.BeginMode3D(camera); defer c.EndMode3D(); c.DrawCube(.{.x = -4.0, .y = 0.0, .z = 2.0}, 2.0, 5.0, 2.0, c.RED); c.DrawCubeWires(.{.x = -4.0, .y = 0.0, .z = 2.0}, 2.0, 5.0, 2.0, c.GOLD); c.DrawCubeWires(.{.x = -4.0, .y = 0.0, .z = -2.0}, 3.0, 6.0, 2.0, c.MAROON); c.DrawSphere(.{.x = -1.0, .y = 0.0, .z = -2.0}, 1.0, c.GREEN); c.DrawSphereWires(.{.x = 1.0, .y = 0.0, .z = 2.0}, 2.0, 16, 16, c.LIME); c.DrawCylinder(.{.x = 4.0, .y = 0.0, .z = -2.0}, 1.0, 2.0, 3.0, 4, c.SKYBLUE); c.DrawCylinderWires(.{.x = 4.0, .y = 0.0, .z = -2.0}, 1.0, 2.0, 3.0, 4, c.DARKBLUE); c.DrawCylinderWires(.{.x = 4.5, .y = -1.0, .z = 2.0}, 1.0, 1.0, 2.0, 6, c.BROWN); c.DrawCylinder(.{.x = 1.0, .y = 0.0, .z = -4.0}, 0.0, 1.5, 3.0, 8, c.GOLD); c.DrawCylinderWires(.{.x = 1.0, .y = 0.0, .z = -4.0}, 0.0, 1.5, 3.0, 8, c.PINK); c.DrawCapsule (.{.x = -3.0, .y = 1.5, .z = -4.0}, .{.x = -4.0, .y = -1.0, .z = -4.0}, 1.2, 8, 8, c.VIOLET); c.DrawCapsuleWires(.{.x = -3.0, .y = 1.5, .z = -4.0}, .{.x = -4.0, .y = -1.0, .z = -4.0}, 1.2, 8, 8, c.PURPLE); c.DrawGrid(10, 1.0); // Draw a grid } c.DrawFPS(10, 10); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-86-models-geometric-shapes/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-86-models-geometric-shapes/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-86-models-geometric-shapes/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-19-core-window-should-close/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-19-core-window-should-close/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [core] example - Window should close //* //* Example originally created with raylib 4.2, last time updated with raylib 4.2 //* //* 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) 2013-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [core] example - window should close"); defer c.CloseWindow(); // Close window and OpenGL context c.SetExitKey(c.KEY_NULL); // Disable KEY_ESCAPE to close window, X-button still works var exit_window_requested = false; // Flag to request window to exit var exit_window = false; // Flag to set window to exit c.SetTargetFPS(60); // Set our game to run at 60 frames-per-second while (!exit_window) { // Update //---------------------------------------------------------------------------------- // Detect if X-button or KEY_ESCAPE have been pressed to close window if (c.WindowShouldClose() or c.IsKeyPressed(c.KEY_ESCAPE)) exit_window_requested = true; if (exit_window_requested) { // A request for close window has been issued, we can save data before closing // or just show a message asking for confirmation if (c.IsKeyPressed(c.KEY_Y)) { exit_window = true; } else if (c.IsKeyPressed(c.KEY_N)) exit_window_requested = false; } //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); if (exit_window_requested) { c.DrawRectangle(0, 100, screen_width, 200, c.BLACK); c.DrawText("Are you sure you want to exit program? [Y/N]", 40, 180, 30, c.WHITE); } else c.DrawText("Try to close the window to get confirmation message!", 120, 200, 20, c.LIGHTGRAY); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-19-core-window-should-close/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-19-core-window-should-close/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-19-core-window-should-close/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-42-shapes-draw-ring/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-42-shapes-draw-ring/main.zig
// This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [shapes] example - draw ring (with gui options) //* //* Example originally created with raylib 2.5, last time updated with raylib 2.5 //* //* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) //* //* 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) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) //* //********************************************************************************************/ // Download raygui.h from https://github.com/raysan5/raygui/tree/master/src and copy it to this project's folder. // Build with `zig build-exe main.zig -idirafter ./ -lc -lraylib` // WARNING: if you're using old (pre- https://github.com/raysan5/raygui/commit/78ad65365ebae6433f60cf03a09e76b43c46cfa2) // version of raygui.h AND unless this bug in Zig transtale - https://github.com/ziglang/zig/issues/15408 - has been fixed, // you're going to see errors similar to this: // /home/archie/.cache/zig/o/c95bc39f271b884ec25d6b2251a68075/cimport.zig:7631:27: error: incompatible types: 'c_int' and 'f32' // value += (GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange); // ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // /home/archie/.cache/zig/o/c95bc39f271b884ec25d6b2251a68075/cimport.zig:7631:21: note: type 'c_int' here // value += (GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange); // ^~~~~ // /home/archie/.cache/zig/o/c95bc39f271b884ec25d6b2251a68075/cimport.zig:7631:87: note: type 'f32' here // value += (GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Zig incorrectly skips type coercion when translating certain C code in raygui.h. // As a workaround, edit raygui.h you have downloaded to this example's folder: // Find the body of the function that causes Zig translate-c to stumble (currently it's `static int GuiScrollBar`, on line 4442), // then within it, find the lines that are causing the issue (currently lines 4516, 4517): // // if (isVertical) value += (GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange); // else value += (GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange); // below them, two more lines (currently lines 4553, 4554): // // if (isVertical) value += (GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange); // else value += (GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange); // Add explicit type cast `(int)` to the value added to `value` variable in each of the 4 lines like this: // // if (isVertical) value += (int)(GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange); // else value += (int)(GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange); // This should fix the issue. // Alternatively, edit the lines in cimport.zig mentioned in the error message, manually adding necessary type coercion: // value += @intFromFloat((GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange)); // // Also correct the lines below it: // value += (GetMouseDelta().x / (scrollbar.width - slider.width)) * @floatFromInt(valueRange); // Add similar type coercion: // value += @intFromFloat((GetMouseDelta().x / (scrollbar.width - slider.width)) * @floatFromInt(valueRange)); // // Apply the same modification to each line where it is needed. // // Save cimport.zig and build the project again, it should compile without errors. // You may need to do this again, if cimport.zig is regenerated by Zig :( const c = @cImport( { @cInclude("stddef.h"); // NULL @cInclude("raylib.h"); //@cDefine("RAYGUI_IMPLEMENTATION", {}); - Moved to raygui_impl.c // Here we only need raygui declarations, not actual function bodies. @cInclude("raygui.h"); // Required for GUI controls }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [shapes] example - draw ring"); defer c.CloseWindow(); // Close window and OpenGL context const center = c.Vector2{ .x = @as(f32, @floatFromInt(c.GetScreenWidth() - 300)) / 2.0, .y = @as(f32, @floatFromInt(c.GetScreenHeight())) / 2.0 }; var inner_radius: f32 = 80.0; var outer_radius: f32 = 190.0; var start_angle: f32 = 0.0; var end_angle: f32 = 360.0; var segments: f32 = 0.0; var draw_ring = true; var draw_ring_lines = false; var draw_circle_lines = false; c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- // NOTE: All variables update happens inside GUI control functions //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawLine(500, 0, 500, c.GetScreenHeight(), c.Fade(c.LIGHTGRAY, 0.6)); c.DrawRectangle(500, 0, c.GetScreenWidth() - 500, c.GetScreenHeight(), c.Fade(c.LIGHTGRAY, 0.3)); if (draw_ring) c.DrawRing(center, inner_radius, outer_radius, start_angle, end_angle, @intFromFloat(segments), c.Fade(c.MAROON, 0.3)); if (draw_ring_lines) c.DrawRingLines(center, inner_radius, outer_radius, start_angle, end_angle, @intFromFloat(segments), c.Fade(c.BLACK, 0.4)); if (draw_circle_lines) c.DrawCircleSectorLines(center, outer_radius, start_angle, end_angle, @intFromFloat(segments), c.Fade(c.BLACK, 0.4)); // Draw GUI controls //------------------------------------------------------------------------------ _ = c.GuiSliderBar(.{ .x = 600, .y = 40, .width = 120, .height = 20 }, "StartAngle", null, &start_angle, -450, 450); _ = c.GuiSliderBar(.{ .x = 600.0, .y = 70.0, .width = 120.0, .height = 20.0 }, "EndAngle", null, &end_angle, -450, 450); _ = c.GuiSliderBar(.{ .x = 600.0, .y = 140.0, .width = 120.0, .height = 20.0 }, "InnerRadius", null, &inner_radius, 0, 100); _ = c.GuiSliderBar(.{ .x = 600.0, .y = 170.0 , .width = 120.0, .height = 20.0 }, "OuterRadius", null, &outer_radius, 0, 200); _ = c.GuiSliderBar(.{ .x = 600.0, .y = 240.0, .width = 120.0, .height = 20.0 }, "Segments", null, &segments, 0, 100); _ = c.GuiCheckBox(.{ .x = 600, .y = 320, .width = 20, .height = 20 }, "Draw Ring", &draw_ring); _ = c.GuiCheckBox(.{ .x = 600, .y = 350, .width = 20, .height = 20 }, "Draw RingLines", &draw_ring_lines); _ = c.GuiCheckBox(.{ .x = 600, .y = 380, .width = 20, .height = 20 }, "Draw CircleLines", &draw_circle_lines); //------------------------------------------------------------------------------ const min_segments: i32 = @intFromFloat(@ceil((end_angle - start_angle) / 90.0)); // @ptrCast -> [*c]const u8: https://github.com/ziglang/zig/issues/16234 // -- This code causes Zig compiler (0.11.0-dev.3859+88284c124) to segfault, see // -- https://github.com/ziglang/zig/issues/16197 //c.DrawText(c.TextFormat("MODE: %s", if (@as(i32, @intFromFloat(segments)) >= min_segments) "MANUAL" // else "AUTO"), // 600, 270, 10, if (@as(i32, @intFromFloat(segments)) >= min_segments) c.MAROON else c.DARKGRAY); const text = if (@as(i32, @intFromFloat(segments)) >= min_segments) "MODE: MANUAL" else "MODE: AUTO"; c.DrawText(text, 600, 270, 10, if (@as(i32, @intFromFloat(segments)) >= min_segments) c.MAROON else c.DARKGRAY); c.DrawFPS(10, 10); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-42-shapes-draw-ring/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig raygui_impl.c ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig raygui_impl.c ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-42-shapes-draw-ring/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig raygui_impl.c %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-42-shapes-draw-ring/raygui_impl.c
// Since raygui is a single-header C library, // we've got to have this "implementation" file, // which is just an adapter used to facilitate C-to-Zig // translation #define RAYGUI_IMPLEMENTATION // UGLY WORKAROUND: // Declaration and implementation of `TextToFloat` were copied from raygui.h due to reasons below. // I'm not sure why `raygui.h` does this now, but `TextToFloat` is defined ONLY if // `RAYGUI_STANDALONE` constant is defined. // At the same time, `TextToFloat` is called from `GuiValueBoxFloat`, which means it can't be compiled. // So, in order to build our project, we must provide a copy of `TextToFloat`, since we do not // want to define `RAYGUI_STANDALONE` (it breaks things for us). static float TextToFloat(const char *text); // Get float value from text #include "raygui.h" // Get float value from text // NOTE: This function replaces atof() [stdlib.h] // WARNING: Only '.' character is understood as decimal point static float TextToFloat(const char *text) { float value = 0.0f; float sign = 1.0f; if ((text[0] == '+') || (text[0] == '-')) { if (text[0] == '-') sign = -1.0f; text++; } int i = 0; for (; ((text[i] >= '0') && (text[i] <= '9')); i++) value = value*10.0f + (float)(text[i] - '0'); if (text[i++] != '.') value *= sign; else { float divisor = 10.0f; for (; ((text[i] >= '0') && (text[i] <= '9')); i++) { value += ((float)(text[i] - '0'))/divisor; divisor = divisor*10.0f; } } return value; }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-42-shapes-draw-ring/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-69-text-raylib-fonts/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-69-text-raylib-fonts/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [text] example - raylib fonts loading //* //* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!) //* To view details and credits for those fonts, check raylib license file //* //* Example originally created with raylib 1.7, last time updated with raylib 3.7 //* //* 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) 2017-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; const max_fonts = 8; c.InitWindow(screen_width, screen_height, "raylib [text] example - raylib fonts"); defer c.CloseWindow(); // Close window and OpenGL context // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) const fonts = [max_fonts]c.Font { c.LoadFont("resources/fonts/alagard.png"), c.LoadFont("resources/fonts/pixelplay.png"), c.LoadFont("resources/fonts/mecha.png"), c.LoadFont("resources/fonts/setback.png"), c.LoadFont("resources/fonts/romulus.png"), c.LoadFont("resources/fonts/pixantiqua.png"), c.LoadFont("resources/fonts/alpha_beta.png"), c.LoadFont("resources/fonts/jupiter_crash.png") }; defer { for (fonts) |font| c.UnloadFont(font); } const messages = [max_fonts][*:0]const u8 { "ALAGARD FONT designed by Hewett Tsoi", "PIXELPLAY FONT designed by Aleksander Shevchuk", "MECHA FONT designed by Captain Falcon", "SETBACK FONT designed by Brian Kent (AEnigma)", "ROMULUS FONT designed by Hewett Tsoi", "PIXANTIQUA FONT designed by Gerhard Grossmann", "ALPHA_BETA FONT designed by Brian Kent (AEnigma)", "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" }; const spacings = [max_fonts]u32{ 2, 4, 8, 4, 3, 4, 4, 1 }; //var positions = [max_fonts]c.Vector2{ .{}, .{}, .{}, .{}, .{}, .{}, .{}, .{} }; // initialize with default values - doesn't work with Zig 0.11 var positions: [max_fonts]c.Vector2 = undefined; for (&positions, fonts, messages, spacings, 0..) |*pos, font, msg, spacing, i| { pos.x = @as(f32, @floatFromInt(screen_width)) / 2.0 - c.MeasureTextEx(font, msg, @as(f32, @floatFromInt(font.baseSize)) * 2.0, @floatFromInt(spacing)).x / 2.0; pos.y = 60.0 + @as(f32, @floatFromInt(font.baseSize)) + 45.0 * @as(f32, @floatFromInt(i)); } // Small Y position corrections positions[3].y += 8.0; positions[4].y += 2.0; positions[7].y -= 8.0; const colors = [max_fonts]c.Color{ c.MAROON, c.ORANGE, c.DARKGREEN, c.DARKBLUE, c.DARKPURPLE, c.LIME, c.GOLD, c.RED }; c.SetTargetFPS(60); while (!c.WindowShouldClose()) { // Update //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawText("free fonts included with raylib", 250, 20, 20, c.DARKGRAY); c.DrawLine(220, 50, 590, 50, c.DARKGRAY); for (positions, fonts, messages, spacings, colors) |pos, font, msg, spacing, color| c.DrawTextEx(font, msg, pos, @as(f32, @floatFromInt(font.baseSize)) * 2.0, @floatFromInt(spacing), color); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-69-text-raylib-fonts/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-69-text-raylib-fonts/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-69-text-raylib-fonts/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-53-textures-to-image/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-53-textures-to-image/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [textures] example - Retrieve image data from texture: LoadImageFromTexture() //* //* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) //* //* Example originally created with raylib 1.3, last time updated with raylib 4.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) 2015-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [textures] example - texture to image"); defer c.CloseWindow(); // Close window and OpenGL context // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) var image = c.LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM) - c.Image var texture = c.LoadTextureFromImage(image); // Image converted to texture, GPU memory (RAM -> VRAM) - c.Texture2D c.UnloadImage(image); // Unload image data from CPU memory (RAM) image = c.LoadImageFromTexture(texture); // Load image from GPU texture (VRAM -> RAM) c.UnloadTexture(texture); // Unload texture from GPU memory (VRAM) texture = c.LoadTextureFromImage(image); // Recreate texture from retrieved image data (RAM -> VRAM) c.UnloadImage(image); // Unload retrieved image data from CPU memory (RAM) defer c.UnloadTexture(texture); // Texture unloading // Do we really need this? We're displaying a static image.. Oh well. c.SetTargetFPS(60); // Set our game to run at 60 frames-per-second while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawTexture(texture, screen_width/2 - @divTrunc(texture.width, 2), screen_height/2 - @divTrunc(texture.height, 2), c.WHITE); c.DrawText("this IS a texture loaded from an image!", 300, 370, 10, c.GRAY); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-53-textures-to-image/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-53-textures-to-image/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-53-textures-to-image/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-76-text-writing-anim/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-76-text-writing-anim/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [text] example - Input Box //* //* Example originally created with raylib 1.7, last time updated with raylib 3.5 //* //* 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) 2017-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [text] example - text writing anim"); defer c.CloseWindow(); // Close window and OpenGL context const message: [*:0]const u8 = "This sample illustrates a text writing\nanimation effect! Check it out! ;)"; var frames_counter: usize = 0; c.SetTargetFPS(60); // Set our game to run at 10 frames-per-second while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- if (c.IsKeyDown(c.KEY_SPACE)) { frames_counter += 8; } else frames_counter += 1; if (c.IsKeyPressed(c.KEY_ENTER)) frames_counter = 0; //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); // @intCast -> c_int c.DrawText(c.TextSubtext(message, 0, @intCast(frames_counter / 10)), 210, 160, 20, c.MAROON); c.DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, c.LIGHTGRAY); c.DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, c.LIGHTGRAY); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-76-text-writing-anim/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-76-text-writing-anim/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-76-text-writing-anim/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-44-shapes-draw-rectangle_rounded/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-44-shapes-draw-rectangle_rounded/main.zig
// This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [shapes] example - draw rectangle rounded (with gui options) //* //* Example originally created with raylib 2.5, last time updated with raylib 2.5 //* //* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) //* //* 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) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) //* //********************************************************************************************/ // Download raygui.h from https://github.com/raysan5/raygui/tree/master/src and copy it to this project's folder. // Build with `zig build-exe main.zig -idirafter ./ -lc -lraylib` // WARNING: unless this bug in Zig transtale - https://github.com/ziglang/zig/issues/15408 - has been fixed, // you're going to see errors similar to this: // /home/archie/.cache/zig/o/c95bc39f271b884ec25d6b2251a68075/cimport.zig:7631:27: error: incompatible types: 'c_int' and 'f32' // value += (GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange); // ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // /home/archie/.cache/zig/o/c95bc39f271b884ec25d6b2251a68075/cimport.zig:7631:21: note: type 'c_int' here // value += (GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange); // ^~~~~ // /home/archie/.cache/zig/o/c95bc39f271b884ec25d6b2251a68075/cimport.zig:7631:87: note: type 'f32' here // value += (GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Zig incorrectly skips type coercion when translating certain C code in raygui.h. // As a workaround, edit raygui.h you have downloaded to this example's folder: // Find the body of the function that causes Zig translate-c to stumble (currently it's `static int GuiScrollBar`, on line 4442), // then within it, find the lines that are causing the issue (currently lines 4516, 4517): // // if (isVertical) value += (GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange); // else value += (GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange); // below them, two more lines (currently lines 4553, 4554): // // if (isVertical) value += (GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange); // else value += (GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange); // Add explicit type cast `(int)` to the value added to `value` variable in each of the 4 lines like this: // // if (isVertical) value += (int)(GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange); // else value += (int)(GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange); // This should fix the issue. // Alternatively, edit the lines in cimport.zig mentioned in the error message, manually adding necessary type coercion: // value += @intFromFloat((GetMouseDelta().y / (scrollbar.height - slider.height)) * @floatFromInt(valueRange)); // // Also correct the lines below it: // value += (GetMouseDelta().x / (scrollbar.width - slider.width)) * @floatFromInt(valueRange); // Add similar type coercion: // value += @intFromFloat((GetMouseDelta().x / (scrollbar.width - slider.width)) * @floatFromInt(valueRange)); // // Apply the same modification to each line where it is needed. // // Save cimport.zig and build the project again, it should compile without errors. // You may need to do this again, if cimport.zig is regenerated by Zig :( const c = @cImport( { @cInclude("raylib.h"); //@cDefine("RAYGUI_IMPLEMENTATION", {}); - Moved to raygui_impl.c // Here we only need raygui declarations, not actual function bodies. @cInclude("raygui.h"); // Required for GUI controls }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [shapes] example - draw rectangle rounded"); defer c.CloseWindow(); // Close window and OpenGL context var roundness: f32 = 0.2; var width: f32 = 200.0; var height: f32 = 100.0; var segments: f32 = 0.0; var line_thick: f32 = 1.0; var draw_rect = false; var draw_rounded_rect = true; var draw_rounded_lines = false; c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- const rec = c.Rectangle{ .x = @as(f32, @floatFromInt(c.GetScreenWidth() - @as(c_int, @intFromFloat(width)) - 250)) / 2.0, .y = @as(f32, @floatFromInt(c.GetScreenHeight() - @as(c_int, @intFromFloat(height)))) / 2.0, .width = width, .height = height }; //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawLine(560, 0, 560, c.GetScreenHeight(), c.Fade(c.LIGHTGRAY, 0.6)); c.DrawRectangle(560, 0, c.GetScreenWidth() - 500, c.GetScreenHeight(), c.Fade(c.LIGHTGRAY, 0.3)); if (draw_rect) c.DrawRectangleRec(rec, c.Fade(c.GOLD, 0.6)); if (draw_rounded_rect) c.DrawRectangleRounded(rec, roundness, @intFromFloat(segments), c.Fade(c.MAROON, 0.2)); if (draw_rounded_lines) c.DrawRectangleRoundedLines(rec, roundness, @intFromFloat(segments), line_thick, c.Fade(c.MAROON, 0.4)); // Draw GUI controls //------------------------------------------------------------------------------ _ = c.GuiSliderBar(.{ .x = 640.0, .y = 40.0, .width = 105.0, .height = 20.0 }, "Width", null, &width, 0.0, @as(f32, @floatFromInt(c.GetScreenWidth())) - 300.0); _ = c.GuiSliderBar(.{ .x = 640.0, .y = 70.0, .width = 105.0, .height = 20.0 }, "Height", null, &height, 0.0, @as(f32, @floatFromInt(c.GetScreenHeight())) - 50.0); _ = c.GuiSliderBar(.{ .x = 640.0, .y = 140.0, .width = 105.0, .height = 20.0 }, "Roundness", null, &roundness, 0.0, 1.0); _ = c.GuiSliderBar(.{ .x = 640.0, .y = 170.0, .width = 105.0, .height = 20.0 }, "Thickness", null, &line_thick, 0.0, 20.0); _ = c.GuiSliderBar(.{ .x = 640.0, .y = 240.0, .width = 105.0, .height = 20.0 }, "Segments", null, &segments, 0.0, 60.0); _ = c.GuiCheckBox(.{ .x = 640.0, .y = 320.0, .width = 20.0, .height = 20.0 }, "DrawRoundedRect", &draw_rounded_rect); _ = c.GuiCheckBox(.{ .x = 640.0, .y = 350.0, .width = 20.0, .height = 20.0 }, "DrawRoundedLines", &draw_rounded_lines); _ = c.GuiCheckBox(.{ .x = 640.0, .y = 380.0, .width = 20.0, .height = 20.0 }, "DrawRect", &draw_rect); //------------------------------------------------------------------------------ // @ptrCast -> [*c]const u8: https://github.com/ziglang/zig/issues/16234 // -- This code causes Zig compiler (0.11.0-dev.3859+88284c124) to segfault, see // -- https://github.com/ziglang/zig/issues/16197 //c.DrawText(c.TextFormat("MODE: %s", @ptrCast(if (segments >= 4) "MANUAL" else "AUTO")), 640, 280, 10, // if (segments >= 4) c.MAROON else c.DARKGRAY); // -- This does not const text = if (segments >= 4) "MODE: MANUAL" else "MODE: AUTO"; c.DrawText(text, 640, 280, 10, if (segments >= 4) c.MAROON else c.DARKGRAY); c.DrawFPS(10, 10); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-44-shapes-draw-rectangle_rounded/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig raygui_impl.c ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig raygui_impl.c ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-44-shapes-draw-rectangle_rounded/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig raygui_impl.c %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-44-shapes-draw-rectangle_rounded/raygui_impl.c
// Since raygui is a single-header C library, // we've got to have this "implementation" file, // which is just an adapter used to facilitate C-to-Zig // translation #define RAYGUI_IMPLEMENTATION // UGLY WORKAROUND: // Declaration and implementation of `TextToFloat` were copied from raygui.h due to reasons below. // I'm not sure why `raygui.h` does this now, but `TextToFloat` is defined ONLY if // `RAYGUI_STANDALONE` constant is defined. // At the same time, `TextToFloat` is called from `GuiValueBoxFloat`, which means it can't be compiled. // So, in order to build our project, we must provide a copy of `TextToFloat`, since we do not // want to define `RAYGUI_STANDALONE` (it breaks things for us). static float TextToFloat(const char *text); // Get float value from text #include "raygui.h" // Get float value from text // NOTE: This function replaces atof() [stdlib.h] // WARNING: Only '.' character is understood as decimal point static float TextToFloat(const char *text) { float value = 0.0f; float sign = 1.0f; if ((text[0] == '+') || (text[0] == '-')) { if (text[0] == '-') sign = -1.0f; text++; } int i = 0; for (; ((text[i] >= '0') && (text[i] <= '9')); i++) value = value*10.0f + (float)(text[i] - '0'); if (text[i++] != '.') value *= sign; else { float divisor = 10.0f; for (; ((text[i] >= '0') && (text[i] <= '9')); i++) { value += ((float)(text[i] - '0'))/divisor; divisor = divisor*10.0f; } } return value; }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-44-shapes-draw-rectangle_rounded/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-03-core-mouse-input/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-03-core-mouse-input/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [core] example - Mouse input //* //* Example originally created with raylib 1.0, last time updated with raylib 4.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-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [core] example - mouse input"); defer c.CloseWindow(); // Close window and OpenGL context c.SetTargetFPS(60); var ball_pos = c.Vector2{ .x = @as(f32, screen_width) / 2.0, .y = @as(f32, screen_height) / 2.0, }; var ball_color: c.Color = c.DARKBLUE; while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- ball_pos = c.GetMousePosition(); if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_LEFT)) { ball_color = c.MAROON; } else if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_MIDDLE)) { ball_color = c.LIME; } else if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_RIGHT)) { ball_color = c.DARKBLUE; } else if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_SIDE)) { ball_color = c.PURPLE; } else if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_EXTRA)) { ball_color = c.YELLOW; } else if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_FORWARD)) { ball_color = c.ORANGE; } else if (c.IsMouseButtonPressed(c.MOUSE_BUTTON_BACK)) { ball_color = c.BEIGE; } //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawText("move the ball mouse, click to change color", 10, 10, 20, c.DARKGRAY); c.DrawCircleV(ball_pos, 50, ball_color); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-03-core-mouse-input/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-03-core-mouse-input/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-03-core-mouse-input/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-83-models-box-collisions/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-83-models-box-collisions/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [models] example - Detect basic 3d collisions (box vs sphere vs box) //* //* Example originally created with raylib 1.3, last time updated with raylib 3.5 //* //* 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) 2015-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [models] example - box collisions"); defer c.CloseWindow(); // Close window and OpenGL context // Define the camera to look into our 3d world const camera = c.Camera3D { .position = .{ .x = 0.0, .y = 10.0, .z = 10.0 }, // Camera position .target = .{ .x = 0.0, .y = 0.0, .z = 0.0 }, // Camera looking at point .up = .{ .x = 0.0, .y = 1.0, .z = 0.0 }, // Camera up vector (rotation towards target) .fovy = 45.0, // Camera field-of-view Y .projection = c.CAMERA_PERSPECTIVE // Camera mode type }; var player_pos = c.Vector3{ .x = 0.0, .y = 1.0, .z = 2.0 }; const player_size = c.Vector3{ .x = 1.0, .y = 2.0, .z = 1.0 }; var player_clr = c.GREEN; // c.Color const enemy_box_pos = c.Vector3{ .x = -4.0, .y = 1.0, .z = 0.0 }; const enemy_box_size = c.Vector3{ .x = 2.0, .y = 2.0, .z = 2.0 }; const enemy_sphere_pos = c.Vector3{ .x = 4.0, .y = 0.0, .z = 0.0 }; const enemy_sphere_size = 1.5; var collision = false; c.SetTargetFPS(60); while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- // Move player if (c.IsKeyDown(c.KEY_RIGHT)) { player_pos.x += 0.2; } else { if (c.IsKeyDown(c.KEY_LEFT)) { player_pos.x -= 0.2; } else { if (c.IsKeyDown(c.KEY_DOWN)) { player_pos.z += 0.2; } else { if (c.IsKeyDown(c.KEY_UP)) player_pos.z -= 0.2; } } } collision = false; // Check collisions player vs enemy-box if (c.CheckCollisionBoxes( .{ .min = .{ .x = player_pos.x - player_size.x/2.0, .y = player_pos.y - player_size.y/2.0, .z = player_pos.z - player_size.z/2.0 }, .max = .{ .x = player_pos.x + player_size.x/2.0, .y = player_pos.y + player_size.y/2.0, .z = player_pos.z + player_size.z/2.0 }}, .{ .min = .{ .x = enemy_box_pos.x - enemy_box_size.x/2.0, .y = enemy_box_pos.y - enemy_box_size.y/2.0, .z = enemy_box_pos.z - enemy_box_size.z/2.0 }, .max = .{ .x = enemy_box_pos.x + enemy_box_size.x/2.0, .y = enemy_box_pos.y + enemy_box_size.y/2.0, .z = enemy_box_pos.z + enemy_box_size.z/2.0 }})) collision = true; // Check collisions player vs enemy-sphere if (c.CheckCollisionBoxSphere( .{ .min = .{ .x = player_pos.x - player_size.x/2.0, .y = player_pos.y - player_size.y/2.0, .z = player_pos.z - player_size.z/2.0 }, .max = .{ .x = player_pos.x + player_size.x/2.0, .y = player_pos.y + player_size.y/2.0, .z = player_pos.z + player_size.z/2.0 }}, enemy_sphere_pos, enemy_sphere_size)) collision = true; if (collision) { player_clr = c.RED; } else player_clr = c.GREEN; //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); { c.BeginMode3D(camera); defer c.EndMode3D(); // Draw enemy-box c.DrawCube(enemy_box_pos, enemy_box_size.x, enemy_box_size.y, enemy_box_size.z, c.GRAY); c.DrawCubeWires(enemy_box_pos, enemy_box_size.x, enemy_box_size.y, enemy_box_size.z, c.DARKGRAY); // Draw enemy-sphere c.DrawSphere(enemy_sphere_pos, enemy_sphere_size, c.GRAY); c.DrawSphereWires(enemy_sphere_pos, enemy_sphere_size, 16, 16, c.DARKGRAY); // Draw player c.DrawCubeV(player_pos, player_size, player_clr); c.DrawGrid(10, 1.0); // Draw a grid } c.DrawText("Move player with cursors to collide", 220, 40, 20, c.GRAY); c.DrawFPS(10, 10); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-83-models-box-collisions/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-83-models-box-collisions/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-83-models-box-collisions/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-02-core-keyboard-input/clean.sh
rm ./main rm ./main.o
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-02-core-keyboard-input/main.zig
// build with `zig build-exe main.zig -lc -lraylib` // This is a Zig version of a raylib example from // https://github.com/raysan5/raylib/ // It is distributed under the same license as the original - unmodified zlib/libpng license // Header from the original source code follows below: ///******************************************************************************************* //* //* raylib [core] example - Keyboard input //* //* 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-2023 Ramon Santamaria (@raysan5) //* //********************************************************************************************/ const c = @cImport( { @cInclude("raylib.h"); }); pub fn main() void { const screen_width = 800; const screen_height = 450; c.InitWindow(screen_width, screen_height, "raylib [core] example - keyboard input"); defer c.CloseWindow(); // Close window and OpenGL context c.SetTargetFPS(60); var ball_pos = c.Vector2{ .x = @as(f32, screen_width) / 2.0, .y = @as(f32, screen_height) / 2.0, }; while (!c.WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- if (c.IsKeyDown(c.KEY_RIGHT)) ball_pos.x += 2.0; if (c.IsKeyDown(c.KEY_LEFT)) ball_pos.x -= 2.0; if (c.IsKeyDown(c.KEY_UP)) ball_pos.y -= 2.0; if (c.IsKeyDown(c.KEY_DOWN)) ball_pos.y += 2.0; //---------------------------------------------------------------------------------- // Draw //--------------------------------------------------------------------------------- c.BeginDrawing(); defer c.EndDrawing(); c.ClearBackground(c.RAYWHITE); c.DrawText("move the ball with arrow keys", 10, 10, 20, c.DARKGRAY); c.DrawCircleV(ball_pos, 50, c.MAROON); //--------------------------------------------------------------------------------- } }
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-02-core-keyboard-input/build.sh
#!/bin/sh tmp_raylib_include_path='' tmp_raylib_external_include_path='' tmp_raylib_lib_path='' tmp_raylib_zig_build_mode='' # No command line arguments => use local variables if [ $# -eq 0 ]; then echo echo 'Using locally defined build variables and paths' # Set the paths here if you invoke this build.sh manually tmp_raylib_path='~/ray' tmp_raylib_include_path="${tmp_raylib_path}/zig-out/include" tmp_raylib_external_include_path="${tmp_raylib_path}/src/external" tmp_raylib_lib_path="${tmp_raylib_path}/zig-out/lib" # One of: # -O Debug # -O ReleaseFast # -O ReleaseSafe # -O ReleaseSmall tmp_raylib_zig_build_mode='-O ReleaseSmall' else # Using variables set in ../build_example.sh tmp_raylib_include_path=$RAYLIB_INCLUDE_PATH tmp_raylib_external_include_path=$RAYLIB_EXTERNAL_INCLUDE_PATH tmp_raylib_lib_path=$RAYLIB_LIB_PATH tmp_raylib_zig_build_mode=$RAYLIB_ZIG_BUILD_MODE fi tmp_raylib_include_arg='' if [ -n "$tmp_raylib_include_path" ]; then # Not empty tmp_raylib_include_arg="-idirafter ${tmp_raylib_include_path}" fi if [ -n "$tmp_raylib_external_include_path" ]; then # Not empty tmp_raylib_include_arg="${tmp_raylib_include_arg} -idirafter ${tmp_raylib_external_include_path}" fi #echo 'tmp_raylib_include_arg = ' #echo "$tmp_raylib_include_arg" tmp_raylib_lib_arg='' if [ -n "$tmp_raylib_lib_path" ]; then # Not empty tmp_raylib_lib_arg="-L${tmp_raylib_lib_path} -lc -lraylib" else tmp_raylib_lib_arg='-lc -lraylib' fi #echo 'tmp_raylib_lib_arg = ' #echo "$tmp_raylib_lib_arg" echo "zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}" zig build-exe main.zig ${tmp_raylib_zig_build_mode} ${tmp_raylib_include_arg} -idirafter ./ ${tmp_raylib_lib_arg}
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-02-core-keyboard-input/build.bat
@echo off REM First parameter not set = build.bat launched manually if "%~1"=="" ( echo. echo Using locally defined build variables and paths setlocal enableDelayedExpansion REM These values are used if you invoke this build.bat file manualy. REM If you use build_example.bat in the root folder, values set in that file are used. SET RAYLIB_PATH=D:\libs\raylib-4.5.0 SET RAYLIB_INCLUDE_PATH=!RAYLIB_PATH!\zig-out\include SET RAYLIB_EXTERNAL_INCLUDE_PATH=!RAYLIB_PATH!\src\external SET RAYLIB_LIB_PATH=!RAYLIB_PATH!\zig-out\lib REM One of: REM -O Debug REM -O ReleaseFast REM -O ReleaseSafe REM -O ReleaseSmall SET RAYLIB_ZIG_BUILD_MODE=-O ReleaseSmall ) REM echo RAYLIB_PATH: %RAYLIB_PATH% REM echo RAYLIB_INCLUDE_PATH: %RAYLIB_INCLUDE_PATH% REM echo RAYLIB_EXTERNAL_INCLUDE_PATH: %RAYLIB_EXTERNAL_INCLUDE_PATH% REM echo RAYLIB_LIB_PATH: %RAYLIB_LIB_PATH% REM echo RAYLIB_ZIG_BUILD_MODE: %RAYLIB_ZIG_BUILD_MODE% @echo on zig build-exe main.zig %RAYLIB_ZIG_BUILD_MODE% -idirafter .\ -idirafter %RAYLIB_INCLUDE_PATH% -idirafter %RAYLIB_EXTERNAL_INCLUDE_PATH% -L%RAYLIB_LIB_PATH% -lraylib -lopengl32 -lgdi32 -lwinmm -lc @echo off REM End local variables scope if not called from the main script if "%~1"=="" ( endlocal & ( SET RAYLIB_PATH=%RAYLIB_PATH% SET RAYLIB_INCLUDE_PATH=%RAYLIB_INCLUDE_PATH% SET RAYLIB_EXTERNAL_INCLUDE_PATH=%RAYLIB_EXTERNAL_INCLUDE_PATH% SET RAYLIB_LIB_PATH=%RAYLIB_LIB_PATH% SET RAYLIB_ZIG_BUILD_MODE=%RAYLIB_ZIG_BUILD_MODE% ) )
0
repos/raylib-zig-examples
repos/raylib-zig-examples/zig-raylib-02-core-keyboard-input/clean.bat
del main.exe del main.exe.obj del main.pdb
0
repos
repos/linuxwave/cliff.toml
# configuration for https://github.com/orhun/git-cliff [changelog] # changelog header header = """ # Changelog 🐧🎡\n All notable changes to this project will be documented in this file.\n """ # template for the changelog body # https://tera.netlify.app/docs/#introduction body = """ {% if version %}\ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} {% else %}\ ## [unreleased] {% endif %}\ {% for group, commits in commits | group_by(attribute="group") %} ### {{ group | striptags | trim | upper_first }} {% for commit in commits | filter(attribute="scope") | sort(attribute="scope") %} - *({{commit.scope}})*{% if commit.breaking %} [**breaking**]{% endif %} \ {{ commit.message | upper_first }} {%- endfor -%} {% raw %}\n{% endraw %}\ {%- for commit in commits %} {%- if commit.scope -%} {% else -%} - *(uncategorized)*{% if commit.breaking %} [**breaking**]{% endif %} \ {{ commit.message | upper_first }} {% endif -%} {% endfor -%} {% endfor %}\n """ # remove the leading and trailing whitespace from the template trim = true # changelog footer footer = """ <!-- generated by git-cliff --> """ [git] # parse the commits based on https://www.conventionalcommits.org conventional_commits = true # filter out the commits that are not conventional filter_unconventional = true # process each line of a commit as an individual commit split_commits = false # regex for preprocessing the commit messages commit_preprocessors = [ { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/linuxwave/issues/${2}))" }, ] # regex for parsing and grouping commits commit_parsers = [ { message = "^feat", group = "<!-- 0 -->🎡 Features" }, { message = "^fix", group = "<!-- 1 -->πŸ› Bug Fixes" }, { message = "^doc", group = "<!-- 3 -->πŸ“š Documentation" }, { message = "^perf", group = "<!-- 4 -->⚑ Performance" }, { message = "^refactor", group = "<!-- 2 -->🚜 Refactor" }, { message = "^style", group = "<!-- 5 -->🎨 Styling" }, { message = "^test", group = "<!-- 6 -->πŸ§ͺ Testing" }, { message = "^chore\\(release\\): prepare for", skip = true }, { message = "^chore\\(pr\\)", skip = true }, { message = "^chore\\(pull\\)", skip = true }, { message = "^chore", group = "<!-- 7 -->βš™οΈ Miscellaneous Tasks" }, { body = ".*security", group = "<!-- 8 -->πŸ›‘οΈ Security" }, ] # protect breaking changes from being skipped due to matching a skipping commit_parser protect_breaking_commits = false # filter out the commits that are not matched by commit parsers filter_commits = false # glob pattern for matching git tags tag_pattern = "v[0-9]*" # regex for skipping tags skip_tags = "v0.1.0-rc.1" # regex for ignoring tags ignore_tags = "" # sort the tags topologically topo_order = false # sort the commits inside sections by oldest/newest order sort_commits = "newest"
0
repos
repos/linuxwave/CHANGELOG.md
# Changelog 🐧🎡 All notable changes to this project will be documented in this file. ## [0.1.5] - 2023-07-21 ### πŸ“š Documentation - *(readme)* Add Spotify link - *(readme)* Update table of contents ### βš™οΈ Miscellaneous Tasks - *(deps)* Bump actions/upload-pages-artifact from 1 to 2 ## [0.1.4] - 2023-06-29 ### 🚜 Refactor - *(build)* Use Builder's fmt function to avoid using allocator - *(build)* Use built-in allocator ### πŸ“š Documentation - *(readme)* Add installation instruction for Void Linux - *(readme)* Simplify the Docker command ## [0.1.3] - 2023-04-19 ### 🎡 Features - *(cd)* Publish the signed source code which includes submodules ### πŸ“š Documentation - *(readme)* Add stdout playback example ### βš™οΈ Miscellaneous Tasks - *(ci)* Use Zig 0.10.1 for CI/CD ## [0.1.2] - 2023-04-17 ### πŸ› Bug Fixes - *(docker)* Scan the correct docker image ### πŸ“š Documentation - *(preset)* Add the "spooky_manor" preset ### βš™οΈ Miscellaneous Tasks - *(deps)* Bump actions/configure-pages from 1 to 3 - *(deps)* Bump actions/deploy-pages from 1 to 2 ## [0.1.1] - 2023-04-17 ### πŸ“š Documentation - *(readme)* Add submodule update step for building from source - *(readme)* Add installation instructions for Arch Linux ## [0.1.0] - 2023-04-17 ### 🎡 Features - *(docs)* Add a man page ### 🚜 Refactor - *(ci)* Remove unnecessary node options ### πŸ“š Documentation - *(readme)* Add demo link - *(readme)* Add motivation section - *(website)* Add demo link to website ### 🎨 Styling - *(readme)* Set the alignment to center for demo link - *(readme)* Center the demo text ## [0.1.0-rc.4] - 2023-04-15 ### 🎡 Features - *(website)* Add a landing page ### 🚜 Refactor - *(ci)* Remove unnecessary OS from build matrixes - *(lib)* Extract reusable modules as packages ### πŸ“š Documentation - *(lib)* Support auto-generation of documentation with a build flag - *(readme)* Mention the API documentation - *(readme)* Add documentation build badge ### 🎨 Styling - *(readme)* Use HTML for the badges - *(readme)* Fix centering the badges - *(readme)* Center the badges ### βš™οΈ Miscellaneous Tasks - *(ci)* Fix the grammar for the build job - *(pages)* Rename deploy step - *(pages)* Add workflow for deploying documentation ## [0.1.0-rc.3] - 2023-04-15 ### πŸ› Bug Fixes - *(cd)* Use windows specific commands ### βš™οΈ Miscellaneous Tasks - *(changelog)* Remove author names from changelog ## [0.1.0-rc.2] - 2023-04-15 ### 🎡 Features - *(cd)* Add different build targets <!-- generated by git-cliff -->