### Install and Run daspkg Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/daspkg/daspkg-example/README.md Installs all dependencies defined in .das_package and then runs the main daslang program. This is the primary setup for the example. ```bash daslang ../../../utils/daspkg/main.das -- --root . install ``` ```bash daslang main.das ``` -------------------------------- ### Install Path Tracer Example Files Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/pathTracer/CMakeLists.txt Installs the necessary DaScript files for the path tracer example to the designated installation directory. ```cmake install(FILES ${PROJECT_SOURCE_DIR}/examples/pathTracer/path_tracer.das ${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer.das ${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_pathtracer_opengl_basic.das ${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_opengl.das ${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_opengl_hdr.das ${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_profile.das DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/pathTracer) ``` -------------------------------- ### Install and Run PyBullet Examples Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/phys/bullet-3/README.md Install PyBullet using pip and run example environments for reinforcement learning and deep mimic. ```bash pip3 install pybullet --upgrade --user python3 -m pybullet_envs.examples.enjoy_TF_AntBulletEnv_v0_2017may python3 -m pybullet_envs.examples.enjoy_TF_HumanoidFlagrunHarderBulletEnv_v1_2017jul python3 -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt ``` -------------------------------- ### Run Build Toolkit Setup Script Source: https://github.com/gaijinentertainment/dagorengine/blob/main/README.md Execute the `make_devtools.py` script to download, install, and configure the build toolkit. Provide the desired path for the toolkit as an argument. The script will create the folder if it does not exist. Run as administrator if prompted for installation permissions. ```python python3 make_devtools.py X:\develop\devtools ``` -------------------------------- ### Install dasImgui Package Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/graphics/README.md Installs the dasImgui package and builds C++ shared modules. This is a setup step before running the graphics examples. ```bash cd examples/graphics daslang.exe ../../utils/daspkg/main.das -- install ``` -------------------------------- ### Install Node Editor Package Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/README.md Installs the dasImguiNodeEditor and dasImgui packages and runs the basic node editor example. Navigate to the examples/node-editor directory before running. ```das cd examples/node-editor daslang.exe ../../utils/daspkg/main.das -- install daslang.exe -project_root . imgui_node_editor_basic.das ``` -------------------------------- ### Run the daspkg Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/daspkg/daspkg-build-example/README.md Executes the main dascript file after the packages have been installed and built. This demonstrates the integrated functionality. ```bash daslang main.das ``` -------------------------------- ### Run Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_c_12_ecs.md Execute the compiled integration_c_12 binary to see the ECS example in action. ```none bin/Release/integration_c_12 ``` -------------------------------- ### Build Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_c_08_serialization.md Builds the C integration example using CMake. ```none cmake --build build --config Release --target integration_c_08 ``` -------------------------------- ### Platform-Dependent Build Directory Setup Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/openssl-3.x/CHANGES.md This example demonstrates how to set up a platform-dependent build directory outside the OpenSSL source tree. It uses symbolic links to reference source files. ```bash # Place yourself outside of the OpenSSL source tree. In # this example, the environment variable OPENSSL_SOURCE # is assumed to contain the absolute OpenSSL source directory. mkdir -p objtree/"`uname -s`-`uname -r`-`uname -m`" cd objtree/"`uname -s`-`uname -r`-`uname -m`" (cd $OPENSSL_SOURCE; find . -type f) | while read F; mkdir -p `dirname $F` ln -s $OPENSSL_SOURCE/$F $F done ``` -------------------------------- ### Full hello/main.das script for daslang-live Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/utils/daslang_live.md This is the complete dascript code for the 'hello' example. It includes setup for live reloading with GLFW and OpenGL, defines a live command to change background color via JSON, and implements lifecycle functions (init, update, shutdown) and a fallback main function for standalone execution. ```das options gen2 require live/glfw_live require opengl/opengl_boost require live/live_commands require live/live_api require daslib/json require daslib/json_boost require live_host // --- State --- var bg_r = 0.2f var bg_g = 0.3f var bg_b = 0.5f var frame_count : int = 0 // --- Live commands --- [live_command] def set_color(input : JsonValue?) : JsonValue? { if (input != null && input.value is _object) { let tab & = unsafe(input.value as _object) var rv = tab?["r"] ?? null if (rv != null && rv.value is _number) { bg_r = float(rv.value as _number) } var gv = tab?["g"] ?? null if (gv != null && gv.value is _number) { bg_g = float(gv.value as _number) } var bv = tab?["b"] ?? null if (bv != null && bv.value is _number) { bg_b = float(bv.value as _number) } } return JV("{\"r\": {bg_r}, \"g\": {bg_g}, \"b\": {bg_b}}") } // --- Lifecycle --- [export] def init() { live_create_window("Hello daslive", 640, 480) print("hello: init (is_reload={is_reload()})\n") if (!is_reload()) { frame_count = 0 } } [export] def update() { if (!live_begin_frame()) { return } frame_count++ if (frame_count % 300 == 0) { print("hello: frame {frame_count}, dt={get_dt()}, uptime={get_uptime()}\n") } var w, h : int live_get_framebuffer_size(w, h) glViewport(0, 0, w, h) glClearColor(bg_r, bg_g, bg_b, 1.0) glClear(GL_COLOR_BUFFER_BIT) live_end_frame() } [export] def shutdown() { print("hello: shutdown (frames={frame_count})\n") live_destroy_window() } // Dual-mode: also works with regular daslang.exe [export] def main() { init() while (!exit_requested()) { update() } shutdown() } ``` -------------------------------- ### Build Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_c_12_ecs.md Use CMake to build the integration_c_12 target for the ECS example. ```none cmake --build build --config Release --target integration_c_12 ``` -------------------------------- ### Run Tutorial Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/dasAudio_03_sound_control.md Command to execute the dasAudio sound control tutorial script. ```none daslang.exe tutorials/dasAudio/03_sound_control.das ``` -------------------------------- ### Running the tutorial example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/48_apply.md Command to execute the complete tutorial source file using the daslang compiler. ```none daslang.exe tutorials/language/48_apply.das ``` -------------------------------- ### Run Streaming Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/dasAudio_06_streaming.md Command to execute the streaming audio tutorial from the project root. ```none daslang.exe tutorials/dasAudio/06_streaming.das ``` -------------------------------- ### Run Tutorial Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/dasAudio_02_playing_files.md Command to execute the tutorial script using the daslang interpreter. ```none daslang.exe tutorials/dasAudio/02_playing_files.das ``` -------------------------------- ### Create and Install a Debug Agent Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/quirrel/quirrel/doc/source/reference/tutorials/45_debug_agents.md Define a class extending `DapiDebugAgent`, write a setup function to install it, and fork a new context to run the setup. ```das class CounterAgent : DapiDebugAgent { count : int = 0 } def install_counter(ctx : Context) { install_new_debug_agent(new CounterAgent(), "counter") } def demo_create_agent() { print(" has 'counter' = {has_debug_agent_context("counter")} ") fork_debug_agent_context(@@install_counter) print(" has 'counter' = {has_debug_agent_context( ``` ```das }")} ``` -------------------------------- ### Error Code Example with Prefixes Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/openssl-3.x/CHANGES.md Illustrates how module names can be prefixed with OSSL_ or OPENSSL_ for error code calls. ```c OSSL_FOOerr(OSSL_FOO_F_SOMETHING, OSSL_FOO_R_WHATEVER); ``` -------------------------------- ### Build and Run Example Project on OS X Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/nanosvg/README.md Steps to build the example project using make and run the executable on OS X. ```bash $ premake4 gmake $ cd build/ $ make $ ./example ``` -------------------------------- ### String Slicing Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/07_strings.md Demonstrates extracting substrings using `slice` with start and end indices, or just a start index to get the remainder of the string. ```das let phrase = "Hello, World!" print("{slice(phrase, 0, 5)}\n") // Hello print("{slice(phrase, 7)}\n") // World! ``` -------------------------------- ### DES Key Schedule and Encryption Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/openssl-3.x/CHANGES.md Illustrates the correct way to pass a pointer to a des_key_schedule for DES functions, ensuring proper key schedule management and encryption. ```c des_key_schedule ks; des_set_key_checked(..., &ks); des_ncbc_encrypt(..., &ks, ...); ``` -------------------------------- ### Build and Run Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_cpp_07_callbacks.md Instructions for building and running the C++ integration example. Ensure you have CMake configured correctly for your project. ```none cmake --build build --config Release --target integration_cpp_07 bin\Release\integration_cpp_07.exe ``` -------------------------------- ### Install ImGui Graphics Package Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/README.md Installs the dasImgui package and runs the Fourier series visualization example. Navigate to the examples/graphics directory before running. ```das cd examples/graphics daslang.exe ../../utils/daspkg/main.das -- install daslang.exe -project_root . furier_opengl_imgui_example.das ``` -------------------------------- ### Run hello example with daslang-live Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/utils/daslang_live.md Execute the 'hello' example using the daslang-live executable. This will open a GLFW window that can be updated by editing and saving the 'main.das' file. ```none bin/Release/daslang-live.exe examples/daslive/hello/main.das ``` -------------------------------- ### daspkg.lock File Structure Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/utils/daspkg.md Example of the daspkg.lock file format, which tracks installed packages, their sources, and versions. It distinguishes between explicitly installed and transitive dependencies. ```json { "sdk_version": "", "packages": [ { "name": "mymodule", "source": "github.com/user/mymodule", "version": "1.0", "tag": "v1.0", "branch": "", "root": true, "local": false, "global": false } ] } ``` -------------------------------- ### Using the 'get' Function with a Block Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/language/tables.md Example of using the built-in `get` function to safely retrieve a value from a table. The result is processed within a block if the key is found. ```das let tab <- { "one"=>1, "two"=>2 } let found = get(tab,"one") $(val) { assert(val==1) } assert(found) ``` -------------------------------- ### Set File Permissions for Random Seed File Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/openssl-3.x/CHANGES.md In RAND_write_file, use mode 0600 for creating files to ensure proper permissions are set from the start, rather than relying on chmod later. ```c RAND_write_file, use mode 0600 for creating files; don't just chmod when it may be too late. ``` -------------------------------- ### Run dasHV Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials.md Execute a dasHV (HTTP/WebSocket) tutorial from the project root using the daslang.exe compiler. ```none daslang.exe tutorials/dasHV/01_http_requests.das ``` -------------------------------- ### Build the C Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_c_01_hello_world.md Use CMake to build the C integration tutorial. Ensure you are in the project root for correct path resolution. ```none cmake --build build --config Release --target integration_c_01 ``` -------------------------------- ### Handle Error Mouse Down Event Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/gameLibs/webui/plugins/grapheditor/graphEditor.html Triggers a query to get the compiler log if an error message is present and starts with 'error:'. ```javascript function onErrorMouseDown(event) { if (lastErrorString && lastErrorString.indexOf("error:") == 0) query("command&" + clientId + "&get\_compiler\_log", null); } ``` -------------------------------- ### Complete daScript Program Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/language/program_structure.md Illustrates a full daScript program incorporating options, module requirements, struct and enum definitions, global variables, functions with annotations, and cleanup logic. This example demonstrates particle simulation setup and update. ```das options gen2 require math require daslib/strings_boost struct Particle { pos : float3 vel : float3 life : float } enum State { alive dead } let GRAVITY = float3(0.0, -9.8, 0.0) var particles : array def update_particle(var p : Particle; dt : float) : State { p.vel += GRAVITY * dt p.pos += p.vel * dt p.life -= dt if (p.life > 0.0) { return State.alive } return State.dead } [init] def setup { for (i in range(100)) { particles |> push(Particle(pos=float3(0), vel=float3(0, 10.0, 0), life=5.0)) } } [export] def main { let dt = 0.016 for (p in particles) { update_particle(p, dt) } print("particles: {length(particles)}\n") } [finalize] def cleanup { unsafe { delete particles } } ``` -------------------------------- ### Install Packages from Different Sources Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/quirrel/quirrel/doc/source/reference/utils/daspkg.md Demonstrates installing packages using git URLs, index names, and local paths. ```bash daspkg install github.com/user/repo daspkg install github.com/user/repo@v1.0 daspkg install das-claude daspkg install ./path/to/mymodule ``` -------------------------------- ### Running the Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/macros/01_call_macro.md Command to execute the daScript tutorial file. This shows how to compile and run the example code. ```none daslang.exe tutorials/macros/01_call_macro.das ``` -------------------------------- ### Catch2 Test Case with Sections Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/catch2/docs/tutorial.md Demonstrates how to use sections within a Catch2 TEST_CASE for shared setup and teardown. Each section is executed from the start of the TEST_CASE. ```cpp TEST_CASE( "vectors can be sized and resized", "[vector]" ) { // This setup will be done 4 times in total, once for each section std::vector v( 5 ); REQUIRE( v.size() == 5 ); REQUIRE( v.capacity() >= 5 ); SECTION( "resizing bigger changes size and capacity" ) { v.resize( 10 ); REQUIRE( v.size() == 10 ); REQUIRE( v.capacity() >= 10 ); } SECTION( "resizing smaller changes size but not capacity" ) { v.resize( 0 ); REQUIRE( v.size() == 0 ); REQUIRE( v.capacity() >= 5 ); } SECTION( "reserving bigger changes capacity but not size" ) { v.reserve( 10 ); REQUIRE( v.size() == 5 ); REQUIRE( v.capacity() >= 10 ); } SECTION( "reserving smaller does not change size or capacity" ) { v.reserve( 0 ); REQUIRE( v.size() == 5 ); REQUIRE( v.capacity() >= 5 ); } } ``` -------------------------------- ### Running the Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/macros/03_function_macro.md Command to execute the daScript tutorial file. ```none daslang.exe tutorials/macros/03_function_macro.das ``` -------------------------------- ### Get ASN1 Extensions from X509 Structures Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/openssl-3.x/CHANGES.md New functions to search, obtain, decode, and check the critical flag of ASN1 extensions within X509, CRL, and REVOKED structures. Simplifies extension handling. ```c X509V3_X509_get_d2i() ``` ```c X509V3_CRL_get_d2i() ``` ```c X509V3_REVOKED_get_d2i() ``` -------------------------------- ### Run FFT Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/README.md Computes the FFT of a sine wave signal and prints the frequency bins using the dasMinfft module. No additional setup is required. ```das daslang.exe examples/minfft/main.das ``` -------------------------------- ### Event-Driven Animation with Object Reference Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/gameLibs/daRg/_doc/animations.rst An example of triggering animations using an object reference as the trigger. The button's onClick event starts the 'pulse' animation. ```quirrrel let pulseAnim = {} // Object reference as trigger let animatedButton = { behavior = Behaviors.Button onClick = @() anim_start(pulseAnim) transform = true animations = const [ { prop=AnimProp.scale, from=[1,1], to=[1.2,1.2], duration=0.15, easing=OutCubic, trigger=pulseAnim, onExit=pulseAnim + "_back" } { prop=AnimProp.scale, from=[1.2,1.2], to=[1,1], duration=0.15, easing=OutCubic, trigger=pulseAnim + "_back" } ] } ``` -------------------------------- ### Get Previous UTF-8 Code Point (Unchecked) Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/assimp/contrib/utf8cpp/doc/utf8cpp.html Decrements the iterator to the start of the previous code point and returns its value. Use for performance when UTF-8 validity is assured. ```cpp char* twochars = "\xe6\x97\xa5\xd1\x88"; char* w = twochars + 3; int cp = unchecked::prior (w); assert (cp == 0x65e5); assert (w == twochars); ``` -------------------------------- ### Compile Example Project with Premake4 Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/nanosvg/README.md Commands to compile the NanoSVG demo project using premake4 for different operating systems. ```bash premake4 xcode4 ``` ```bash premake4 vs2010 ``` ```bash premake4 gmake ``` -------------------------------- ### Build C++ Integration with SDK Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_cpp_13_aot.md Configure and build C++ integration tutorials against the installed daScript SDK using CMake. This setup automatically handles AOT code generation. ```bash mkdir build_cpp && cd build_cpp cmake -DCMAKE_PREFIX_PATH=/path/to/daslang /path/to/daslang/tutorials/integration/cpp cmake --build . --config Release ``` ```powershell mkdir build_cpp; cd build_cpp cmake -DCMAKE_PREFIX_PATH=D:\daslang D:\daslang\tutorials\integration\cpp cmake --build . --config Release ``` -------------------------------- ### Run dasStbImage Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials.md Execute a dasStbImage (Image I/O) tutorial from the project root using the daslang.exe compiler. ```none daslang.exe tutorials/dasStbImage/01_loading_images.das ``` -------------------------------- ### ASN1 Embed Macro Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/openssl-3.x/CHANGES.md The ASN1_EMBED macro is used for fields that are part of the parent structure, reducing memory fragmentation. It requires the field to be declared directly, e.g., 'FOO x;' instead of 'FOO *x;'. ```c FOO x; ASN1_EMBED ``` -------------------------------- ### Build and Run Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_cpp_11_context_variables.md Provides the command-line instructions to build the C++ integration project and run the resulting executable. This is the final step to test the C++ and daslang interaction. ```none cmake --build build --config Release --target integration_cpp_11 bin\Release\integration_cpp_11.exe ``` -------------------------------- ### Build and Run Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_cpp_14_serialization.md Commands to build the C++ integration example using CMake and run the resulting executable. ```none cmake --build build --config Release --target integration_cpp_14 bin\Release\integration_cpp_14.exe ``` -------------------------------- ### Dynamic Array Pattern Matching Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/24_pattern_matching.md Match dynamic arrays by specifying initial elements and using `...` to ignore the rest of the array. This example matches arrays starting with specific elements. ```dascript match (da) { if (array(0, 0, ...)) { return "starts with 0,0" } if (array($v(x), $v(y), ...)) { return "starts with {x},{y}" } } ``` -------------------------------- ### Darg Production Shader Wrapper (.dshl) Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/tools/dargbox/shaders/source/readme.md Example of a `.dshl` wrapper file used for production builds. It includes necessary setup, includes the main HLSL file, and defines the compilation target. ```dshl include "darg_shader_inc.dshl" shader my_effect { DARG_PIXEL_SHADER_SETUP() hlsl(ps) { #include "my_effect.hlsl" float4 main_ps(VsOutput input) : SV_Target { return darg_ps(input.texcoord); } } compile("target_ps", "main_ps"); } ``` -------------------------------- ### Run Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_c_08_serialization.md Runs the compiled C integration executable. ```none bin/Release/integration_c_08 ``` -------------------------------- ### Build and run integration_cpp_02 Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_cpp_02_calling_functions.md Commands to build the C++ integration example and run the executable. ```none cmake --build build --config Release --target integration_cpp_02 bin\Release\integration_cpp_02.exe ``` -------------------------------- ### Include SPIR-V Headers in Bazel Project Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/metal/SPIRV-Headers/README.md Example include directives for C/C++ source files when using SPIR-V headers managed by Bazel. Ensure the include paths match the repository setup. ```c++ #include "spirv/unified1/GLSL.std.450.h" #include "spirv/unified1/OpenCL.std.h" #include "spirv/unified1/spirv.hpp" ``` -------------------------------- ### Get Next UTF-8 Code Point Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/3rdPartyLibs/assimp/contrib/utf8cpp/doc/utf8cpp.html Decodes the next UTF-8 code point from a sequence starting at the given iterator and advances the iterator. Throws utf8::not_enough_room if the sequence is incomplete or utf8::invalid_utf8 for malformed sequences. ```cpp char* twochars = "\xe6\x97\xa5\xd1\x88"; char* w = twochars; int cp = next(w, twochars + 6); assert (cp == 0x65e5); assert (w == twochars + 3); ``` -------------------------------- ### Run the C Integration Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_c_01_hello_world.md Execute the compiled C integration program from the project root directory. This ensures that script paths are resolved correctly. ```none bin\Release\integration_c_01.exe ``` -------------------------------- ### Coroutine Test Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/quirrel/quirrel/doc/source/reference/language/threads.md Demonstrates the creation, calling, suspending, and resuming of a Quirrel thread. Use `newthread` to create a thread, `call` to start it, `suspend` to pause execution, and `wakeup` to resume it. The status of the thread can be checked with `getstatus()`. ```default function coroutine_test(a, b) { println($"{a} {b}") local ret = suspend("suspend 1") println($"the coroutine says {ret}") ret = suspend("suspend 2") println($"the coroutine says {ret}") ret = suspend("suspend 3") println($"the coroutine says {ret}") return "I'm done" } local coro = newthread(coroutine_test) local susparam = coro.call("test","coroutine") //starts the coroutine local i = 1 do { println($"suspend passed {susparam}") susparam = coro.wakeup("ciao "+i) ++i } while(coro.getstatus()=="suspended") println($"return passed {susparam}") ``` ```default test coroutine suspend passed (suspend 1) the coroutine says ciao 1 suspend passed (suspend 2) the coroutine says ciao 2 suspend passed (suspend 3) the coroutine says ciao 3 return passed (I'm done). ``` -------------------------------- ### Unfinished String Literal Error in Squirrel Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/quirrel/quirrel/testData/diagnostics/compilation_errors/lex_errors/unfinished_string.diag.txt This example demonstrates an unfinished string literal. The error occurs because the string started with a double quote but was not closed before the end of the line or file. Ensure all string literals are properly terminated with a closing quote. ```squirrel // EXPECT_ERROR: "unfinished string" let x = "hello ^----- ``` -------------------------------- ### Run Integration C++ Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_c_11_type_introspection.md Execute the compiled C++ integration binary. This will output introspection information. ```none bin/Release/integration_c_11 ``` -------------------------------- ### Running the Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/04_control_flow.md Execute the daScript tutorial file using the daslang.exe compiler. ```shell daslang.exe tutorials/language/04_control_flow.das ``` -------------------------------- ### Overlay Color Gradient Example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/_docs/source/assets/shaders/dng-shaders/rendinst_vcolor_layered.md Demonstrates setting a color gradient for an overlay effect. The 'from' value defines the starting color (e.g., 50% gray), and the 'to' value defines the ending color (e.g., black). This controls how colors blend into the base texture. ```plaintext script:t="overlay_color_from=0.549,0.239,0.239,0" ``` -------------------------------- ### Define Custom AOT Code Generation Macro in CMake Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_cpp_13_aot.md Defines a reusable CMake macro to generate C++ source files from daScript code using the installed SDK's `daslang` executable. This macro handles file paths and custom command setup. ```cmake get_filename_component(DAS_SDK_ROOT "${DAS_DIR}/../../.." ABSOLUTE) macro(MY_AOT input out_var target_name) get_filename_component(_abs "${input}" ABSOLUTE) get_filename_component(_name "${input}" NAME) set(_out_dir "${CMAKE_CURRENT_BINARY_DIR}/_aot_generated") set(_out_src "${_out_dir}/${target_name}_${_name}.cpp") file(MAKE_DIRECTORY "${_out_dir}") add_custom_command( OUTPUT "${_out_src}" DEPENDS "${_abs}" COMMENT "AOT: ${_name}" COMMAND $ "${DAS_SDK_ROOT}/utils/aot/main.das" -- -aot "${_abs}" "${_out_src}" ) set(${out_var} "${_out_src}") set_source_files_properties("${_out_src}" PROPERTIES GENERATED TRUE) endmacro() ``` -------------------------------- ### Running the Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/macros/09_for_loop_macro.md Command to compile and run the tutorial script using the daslang executable. ```none daslang.exe tutorials/macros/09_for_loop_macro.das ``` -------------------------------- ### Running the `when` Macro Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/macros/02_when_macro.md Command to execute the daScript tutorial file for the `when` macro. ```none daslang.exe tutorials/macros/02_when_macro.das ``` -------------------------------- ### Dagor DSHL Shader with Channel Declarations and HLSL Input Struct Source: https://github.com/gaijinentertainment/dagorengine/blob/main/_docs/source/api-references/dagor-dshl/index/channels.rst Example demonstrating channel declarations for vertex position, color, and texture coordinates, along with the corresponding HLSL input struct for the vertex shader. This setup maps DSHL channels to HLSL semantics. ```c shader some_shader { /* Here we declare channels for the vertex shader, which will be used by the shader compiler to generate appropriate vertex shader declaration for this particular shader. */ channel float3 pos=pos; // vertex position channel color8 vcol=vcol; // vertex color channel float3 tc[0] = tc[0]; // vertex texture coordinate channel float3 tc[1] = tc[1]; // another vertex texture coordinate hlsl(vs) { /* This VsInput struct declares vertex information in HLSL-style. Note that for each DSHL channel declared above, there should be a corresponding HLSL semantic matching the declared channel. */ struct VsInput { float4 pos : POSITION; // vertex position float4 color : COLOR0; // vertex color float3 texcoord : TEXCOORD0; // vertex texture coordinate float3 another_texcoord : TEXCOORD1; // another vertex texture coordinate }; } hlsl(vs) { VsOutput some_vs(VsInput input) { // ... } } } ``` -------------------------------- ### Build testGI Sample Source: https://github.com/gaijinentertainment/dagorengine/blob/main/_docs/source/getting-started/how_to_build.md Navigate to the testGI sample's program directory and run the 'jam' command to build the sample. The executable will be placed in the 'testGI/game' directory. ```text jam ``` -------------------------------- ### Install daTest Executable Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/utils/CMakeLists.txt Installs the 'dastest' executable to the designated installation directory, ensuring it exists before proceeding with the installation. ```cmake install(CODE " set(_util_exe \"${_UTIL_INSTALL_PATTERN}/dastest.exe\") if(EXISTS \"${_util_exe}\") file(INSTALL \"${_util_exe}\" DESTINATION \"${CMAKE_INSTALL_PREFIX}/${DAS_INSTALL_BINDIR}\") endif() ") ``` -------------------------------- ### Build and run the C++ integration example Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/integration_cpp_18_dynamic_scripts.md Commands to build the C++ integration project and run the resulting executable. Shows the expected output for verification. ```bash cmake --build build --config Release --target integration_cpp_18 bin/Release/integration_cpp_18 ``` -------------------------------- ### Run daScript Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/07_strings.md Execute a daScript tutorial file using the `daslang.exe` command-line tool. Ensure the executable is in your PATH or provide the full path to it. ```none daslang.exe tutorials/language/07_strings.das ``` -------------------------------- ### Install Utility Executables Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/utils/CMakeLists.txt Iterates through the daScript utilities and installs their executables to the specified installation directory. It checks for the existence of the executable before attempting to install. ```cmake install(CODE " set(_util_exe \"${_UTIL_INSTALL_PATTERN}/${util}.exe\") if(EXISTS \"${_util_exe}\") file(INSTALL \"${_util_exe}\" DESTINATION \"${CMAKE_INSTALL_PREFIX}/${DAS_INSTALL_BINDIR}\") endif() ") ``` -------------------------------- ### Install dasTelegram Package Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/examples/telegram/README.md Installs the dasTelegram package into the modules directory by reading the .das_package file. Alternatively, install directly using `daspkg install dasTelegram`. ```bash daspkg install ``` ```bash daspkg install dasTelegram ``` -------------------------------- ### Running the daslang Tutorial Source: https://github.com/gaijinentertainment/dagorengine/blob/main/prog/1stPartyLibs/daScript/doc/source/reference/tutorials/02_variables.md Execute the daslang compiler with the tutorial file to see the examples in action. ```shell daslang.exe tutorials/language/02_variables.das ```