### Installing glslc - Linux Source: https://github.com/jsoulier/blocks/blob/main/README.md This command installs the glslc compiler on Debian/Ubuntu-based Linux systems using apt, which is a prerequisite for building the 'Blocks' project. ```bash sudo apt install glslc ``` -------------------------------- ### Building Blocks - Linux Source: https://github.com/jsoulier/blocks/blob/main/README.md This snippet outlines the command-line steps to clone, build, and run the 'Blocks' project on Linux. It uses CMake for the build system, setting the build type to Release, and assumes glslc is already installed. ```bash git clone https://github.com/jsoulier/blocks --recurse-submodules cd blocks mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --parallel 8 cd bin ./blocks ``` -------------------------------- ### Building Blocks - Windows Source: https://github.com/jsoulier/blocks/blob/main/README.md This snippet provides the command-line steps to clone, build, and run the 'Blocks' project on Windows. It uses CMake for the build system and specifies a release configuration, requiring the Vulkan SDK for glslc. ```bash git clone https://github.com/jsoulier/blocks --recurse-submodules cd blocks mkdir build cd build cmake .. cmake --build . --parallel 8 --config Release cd bin ./blocks.exe ``` -------------------------------- ### Setting Up CMake Project and Output Directories Source: https://github.com/jsoulier/blocks/blob/main/CMakeLists.txt This snippet initializes the CMake project, sets the minimum required CMake version, and configures various output directories for binaries and libraries. It ensures that compiled executables and libraries are placed in a consistent 'bin' directory within the build output. ```CMake cmake_minimum_required(VERSION 3.24) project(blocks) set(BINARY_DIR ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${BINARY_DIR}) make_directory(${BINARY_DIR}) ``` -------------------------------- ### Copying Project Assets to Binary Directory Source: https://github.com/jsoulier/blocks/blob/main/CMakeLists.txt This section uses `configure_file` to copy essential project assets, such as the LICENSE, README, and texture atlas, directly into the build's binary output directory. This ensures that runtime dependencies and documentation are available alongside the executable. ```CMake configure_file(LICENSE.txt ${BINARY_DIR} COPYONLY) configure_file(README.md ${BINARY_DIR} COPYONLY) configure_file(textures/atlas.png ${BINARY_DIR} COPYONLY) ``` -------------------------------- ### Defining Executable and Linking Libraries for Blocks Source: https://github.com/jsoulier/blocks/blob/main/CMakeLists.txt This section defines the 'blocks' executable, specifying its source files and linking it against required libraries like SDL3. It also conditionally links the 'm' library on Unix-like systems and includes necessary header directories for sqlite3 and stb. ```CMake add_subdirectory(lib/SDL) add_executable(blocks WIN32 lib/sqlite3/sqlite3.c lib/stb/stb.c src/block.c src/camera.c src/chunk.c src/database.c src/helpers.c src/main.c src/noise.c src/pipeline.c src/raycast.c src/voxel.c src/world.c ) target_link_libraries(blocks PUBLIC SDL3::SDL3) if(UNIX) target_link_libraries(blocks PUBLIC m) endif() target_include_directories(blocks PUBLIC lib/sqlite3) target_include_directories(blocks PUBLIC lib/stb) set_target_properties(blocks PROPERTIES C_STANDARD 11) ``` -------------------------------- ### CMake Function for GLSL Shader Compilation Source: https://github.com/jsoulier/blocks/blob/main/CMakeLists.txt This CMake function automates the compilation of GLSL shader files using `glslc`. It defines a custom command to compile a given shader file into the binary directory, sets up dependencies, and creates a custom target to ensure shaders are built before the main executable. ```CMake function(shader FILE) set(SOURCE shaders/${FILE}) set(OUTPUT ${BINARY_DIR}/${FILE}) add_custom_command( OUTPUT ${OUTPUT} COMMAND glslc ${SOURCE} -o ${OUTPUT} -I src WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS ${SOURCE} shaders/helpers.glsl src/config.h COMMENT ${SOURCE} ) string(REPLACE . _ NAME ${FILE}) add_custom_target(${NAME} DEPENDS ${OUTPUT}) add_dependencies(blocks ${NAME}) endfunction() ``` -------------------------------- ### Invoking Shader Compilation for Project Shaders Source: https://github.com/jsoulier/blocks/blob/main/CMakeLists.txt This snippet demonstrates the usage of the `shader` CMake function to compile various GLSL shader files required by the 'blocks' project. Each call to `shader()` processes a specific fragment or vertex shader, ensuring all necessary shaders are compiled and linked. ```CMake shader(composite.frag) shader(fullscreen.vert) shader(opaque.frag) shader(opaque.vert) shader(random.frag) shader(raycast.frag) shader(raycast.vert) shader(shadow.frag) shader(shadow.vert) shader(sky.frag) shader(sky.vert) shader(ssao.frag) shader(transparent.frag) shader(transparent.vert) shader(ui.frag) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.