Skip to content

embed textures and shaders#6

Merged
dawc17 merged 2 commits into
masterfrom
dev
Feb 12, 2026
Merged

embed textures and shaders#6
dawc17 merged 2 commits into
masterfrom
dev

Conversation

@dawc17

@dawc17 dawc17 commented Feb 12, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a new CMake-based system for embedding asset files (textures and shaders) directly into the binary, eliminating the need to load these resources from the filesystem at runtime. It updates the codebase to load all relevant assets from memory, simplifying deployment and improving portability. The changes touch the build system, asset loading logic, and the interface for asset-related functions.

Key changes include:

Build system and asset embedding:

  • Added a new CMake macro (embed_resources.cmake) for converting asset files (textures and shaders) into C++ arrays, and generating corresponding header and source files at build time. (cmake/embed_resources.cmake, src/CMakeLists.txt, [1] [2]
  • Updated the build configuration to include the generated assets in the build output and to add the generated directory to include paths. (src/CMakeLists.txt, .clangd, [1] [2] [3]
  • Removed the previous system for copying shader files at build time, since shaders are now embedded. (src/CMakeLists.txt, src/CMakeLists.txtL47-L76)

Codebase refactoring for embedded assets:

  • Replaced all code that loaded textures and shaders from disk with new logic that loads them from the embedded arrays. This affects texture loading in Renderer.cpp, tool model generation in ToolModelGenerator.cpp, and shader loading in ShaderClass.cpp. (src/core/Renderer.cpp, src/rendering/ToolModelGenerator.cpp, src/rendering/opengl/ShaderClass.cpp, [1] [2] [3]
  • Updated function signatures and usages to accept asset data and size instead of file paths, and removed now-unnecessary path resolution logic. (src/core/MainGlobals.cpp, src/core/MainGlobals.h, [1] [2] [3]

Interface and header changes:

  • Updated function signatures for texture and tool model loading to use embedded data buffers, and removed unused or obsolete interfaces. (src/core/MainGlobals.h, src/rendering/ToolModelGenerator.h, [1] [2]

General code clean-up:

  • Removed error messages and fallback logic related to missing files on disk, since assets are now always available in the binary. (src/core/Renderer.cpp, src/core/Renderer.cppL89)

Source file includes:

  • Added includes for the generated embedded_assets.h where needed. (src/core/MainGlobals.cpp, src/core/Renderer.cpp, src/rendering/ToolModelGenerator.cpp, src/rendering/opengl/ShaderClass.cpp, [1] [2] [3] [4]

Add CMake support to embed asset files into generated embedded_assets.h/.cpp and compile them into the executable. Created cmake/embed_resources.cmake and updated src/CMakeLists.txt to generate/compile embedded assets (textures and shaders) instead of copying runtime files. Updated code to load resources from memory: changed loadHUDIcon signature to accept PNG data/size and use stbi_load_from_memory, switched Renderer to populate textures from embedded PNGs, updated ToolModelGenerator to generate from embedded PNG data, and made ShaderClass read shader sources from embedded data. Removed runtime shader/asset copy steps and filesystem-based texture resolution. Includes small API changes (function signatures) and added embedded_assets.h includes where needed.
@dawc17
dawc17 merged commit ca304b2 into master Feb 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant