Reestructura carpetes: src->source, third_party->source/external, shaders->data/shaders
This commit is contained in:
1 parent
cec347a97c
commit
e51ee84167
82 files changed
+36
-39
No files matched your search
@@ -51,9 +51,9 @@ Requires `glslc` (Debian/Ubuntu: `apt install glslang-tools`; macOS: `brew insta
|
|||||||
./shadertoy [SHADER_NAME_OR_PATH] [-F|--fullscreen] [--backend=auto|gpu|opengl]
|
./shadertoy [SHADER_NAME_OR_PATH] [-F|--fullscreen] [--backend=auto|gpu|opengl]
|
||||||
|
|
||||||
# Examples:
|
# Examples:
|
||||||
./shadertoy test # auto backend, shaders/test/
|
./shadertoy test # auto backend, data/shaders/test/
|
||||||
./shadertoy --backend=gpu seascape # force SDL3 GPU (Vulkan/Metal)
|
./shadertoy --backend=gpu seascape # force SDL3 GPU (Vulkan/Metal)
|
||||||
./shadertoy -F shaders/fractal_pyramid # explicit folder path, fullscreen
|
./shadertoy -F data/shaders/fractal_pyramid # explicit folder path, fullscreen
|
||||||
```
|
```
|
||||||
|
|
||||||
**Runtime Controls:**
|
**Runtime Controls:**
|
||||||
@@ -64,22 +64,22 @@ Requires `glslc` (Debian/Ubuntu: `apt install glslang-tools`; macOS: `brew insta
|
|||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
### Layered design
|
### Layered design
|
||||||
- `src/main.cpp` — SDL3 window, event loop, shader-list scanning, dispatch to a backend.
|
- `source/main.cpp` — SDL3 window, event loop, shader-list scanning, dispatch to a backend.
|
||||||
- `src/rendering/shader_backend.hpp` — abstract `IShaderBackend` interface + `ShaderMetadata` / `ShaderUniforms` / `ShaderProgramSpec` shared types. Two factories: `makeOpenGLBackend()`, `makeSdl3GpuBackend()`.
|
- `source/rendering/shader_backend.hpp` — abstract `IShaderBackend` interface + `ShaderMetadata` / `ShaderUniforms` / `ShaderProgramSpec` shared types. Two factories: `makeOpenGLBackend()`, `makeSdl3GpuBackend()`.
|
||||||
- `src/rendering/opengl_shader_backend.{hpp,cpp}` — OpenGL 3.3 implementation. Loads `<folder>/<name>.gl.glsl` at runtime.
|
- `source/rendering/opengl_shader_backend.{hpp,cpp}` — OpenGL 3.3 implementation. Loads `<folder>/<name>.gl.glsl` at runtime.
|
||||||
- `src/rendering/sdl3gpu/sdl3gpu_shader_backend.{hpp,cpp}` — SDL3 GPU implementation. Loads `<folder>/<name>.frag.spv` (Linux/Windows) or `<folder>/<name>.frag.msl` (macOS); shares one passthrough vertex shader from `shaders/_common/passthrough.vert.{spv,msl}`.
|
- `source/rendering/sdl3gpu/sdl3gpu_shader_backend.{hpp,cpp}` — SDL3 GPU implementation. Loads `<folder>/<name>.frag.spv` (Linux/Windows) or `<folder>/<name>.frag.msl` (macOS); shares one passthrough vertex shader from `shaders/_common/passthrough.vert.{spv,msl}`.
|
||||||
- `src/rendering/sdl3gpu/shader_factory.hpp` — small helper that loads a shader binary/source from disk and creates an `SDL_GPUShader`.
|
- `source/rendering/sdl3gpu/shader_factory.hpp` — small helper that loads a shader binary/source from disk and creates an `SDL_GPUShader`.
|
||||||
|
|
||||||
### Shader folder layout
|
### Shader folder layout
|
||||||
One folder per shader, under `shaders/`:
|
One folder per shader, under `data/shaders/`:
|
||||||
```
|
```
|
||||||
shaders/<name>/
|
data/shaders/<name>/
|
||||||
<name>.gl.glsl # OpenGL GLSL 3.30 (handwritten)
|
<name>.gl.glsl # OpenGL GLSL 3.30 (handwritten)
|
||||||
<name>.vk.glsl # Vulkan GLSL 4.50 (handwritten)
|
<name>.vk.glsl # Vulkan GLSL 4.50 (handwritten)
|
||||||
<name>.frag.msl # Metal Shading Language (handwritten)
|
<name>.frag.msl # Metal Shading Language (handwritten)
|
||||||
<name>.frag.spv # generated by `make compile_shaders` from .vk.glsl
|
<name>.frag.spv # generated by `make compile_shaders` from .vk.glsl
|
||||||
meta.txt # Name / Author / iChannelN
|
meta.txt # Name / Author / iChannelN
|
||||||
shaders/_common/
|
data/shaders/_common/
|
||||||
passthrough.vk.glsl # shared fullscreen-triangle vertex (Vulkan)
|
passthrough.vk.glsl # shared fullscreen-triangle vertex (Vulkan)
|
||||||
passthrough.vert.spv # generated
|
passthrough.vert.spv # generated
|
||||||
passthrough.vert.msl # handwritten Metal
|
passthrough.vert.msl # handwritten Metal
|
||||||
@@ -103,7 +103,7 @@ shaders_directory_ // Shaders root path (resolved at startup)
|
|||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
- **SDL3** ≥ 3.2 — windowing, events, GPU API (`SDL_gpu.h`)
|
- **SDL3** ≥ 3.2 — windowing, events, GPU API (`SDL_gpu.h`)
|
||||||
- **GLAD** — OpenGL 3.3 loader (used only by the OpenGL backend, statically linked via `third_party/glad/`)
|
- **GLAD** — OpenGL 3.3 loader (used only by the OpenGL backend, statically linked via `source/external/glad/`)
|
||||||
- **C++17 stdlib** — filesystem, fstream, vector, algorithms
|
- **C++17 stdlib** — filesystem, fstream, vector, algorithms
|
||||||
- Build-time tool: `glslc` (only required to regenerate `.frag.spv`)
|
- Build-time tool: `glslc` (only required to regenerate `.frag.spv`)
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ Uses preprocessor defines (`WINDOWS_BUILD`, `MACOS_BUILD`, `LINUX_BUILD`) for:
|
|||||||
## Shader System
|
## Shader System
|
||||||
|
|
||||||
### Authoring a shader (manual steps)
|
### Authoring a shader (manual steps)
|
||||||
For each new shader, three handwritten files live in `shaders/<name>/`:
|
For each new shader, three handwritten files live in `data/shaders/<name>/`:
|
||||||
1. **`<name>.gl.glsl`** — OpenGL GLSL 3.30 (the original Shadertoy-style format described below).
|
1. **`<name>.gl.glsl`** — OpenGL GLSL 3.30 (the original Shadertoy-style format described below).
|
||||||
2. **`<name>.vk.glsl`** — Vulkan GLSL 4.50 with explicit `layout(set=3, binding=0) uniform ShadertoyUBO { float iTime; vec2 iResolution; } u;` and `layout(set=2, binding=N) uniform sampler2D` for any texture channel.
|
2. **`<name>.vk.glsl`** — Vulkan GLSL 4.50 with explicit `layout(set=3, binding=0) uniform ShadertoyUBO { float iTime; vec2 iResolution; } u;` and `layout(set=2, binding=N) uniform sampler2D` for any texture channel.
|
||||||
3. **`<name>.frag.msl`** — Metal Shading Language. Entry point must be named `<name>_fs`. Uniforms come in via `[[buffer(0)]]`; samplers via `[[texture(N)]] [[sampler(N)]]`.
|
3. **`<name>.frag.msl`** — Metal Shading Language. Entry point must be named `<name>_fs`. Uniforms come in via `[[buffer(0)]]`; samplers via `[[texture(N)]] [[sampler(N)]]`.
|
||||||
@@ -159,7 +159,7 @@ void main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Adding New Shaders
|
### Adding New Shaders
|
||||||
1. Create `.glsl` file in `shaders/` directory (use `.frag.glsl` convention)
|
1. Create `.glsl` file in `data/shaders/<name>/` directory (use `.frag.glsl` convention)
|
||||||
2. Follow required format above
|
2. Follow required format above
|
||||||
3. File automatically appears in runtime shader rotation (arrow keys to navigate)
|
3. File automatically appears in runtime shader rotation (arrow keys to navigate)
|
||||||
4. **No code changes required** - directory is scanned at startup
|
4. **No code changes required** - directory is scanned at startup
|
||||||
|
|||||||
+11
-11
@@ -16,17 +16,17 @@ set(OpenGL_GL_PREFERENCE GLVND)
|
|||||||
|
|
||||||
# --- LISTA EXPLÍCITA DE FUENTES ---
|
# --- LISTA EXPLÍCITA DE FUENTES ---
|
||||||
set(APP_SOURCES
|
set(APP_SOURCES
|
||||||
src/main.cpp
|
source/main.cpp
|
||||||
src/rendering/shader_backend.cpp
|
source/rendering/shader_backend.cpp
|
||||||
src/rendering/opengl_shader_backend.cpp
|
source/rendering/opengl_shader_backend.cpp
|
||||||
src/rendering/sdl3gpu/sdl3gpu_shader_backend.cpp
|
source/rendering/sdl3gpu/sdl3gpu_shader_backend.cpp
|
||||||
src/audio/jail_audio.cpp
|
source/audio/jail_audio.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Fuentes de librerías de terceros
|
# Fuentes de librerías de terceros
|
||||||
set(EXTERNAL_SOURCES
|
set(EXTERNAL_SOURCES
|
||||||
third_party/glad/src/glad.c
|
source/external/glad/src/glad.c
|
||||||
third_party/stb_vorbis_impl.cpp
|
source/external/stb_vorbis_impl.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Configuración de SDL3
|
# Configuración de SDL3
|
||||||
@@ -40,7 +40,7 @@ if(GLSLC_EXE)
|
|||||||
add_custom_target(compile_shaders
|
add_custom_target(compile_shaders
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-D GLSLC=${GLSLC_EXE}
|
-D GLSLC=${GLSLC_EXE}
|
||||||
-D SHADERS_DIR=${CMAKE_SOURCE_DIR}/shaders
|
-D SHADERS_DIR=${CMAKE_SOURCE_DIR}/data/shaders
|
||||||
-P ${CMAKE_SOURCE_DIR}/tools/shaders/compile_shaders.cmake
|
-P ${CMAKE_SOURCE_DIR}/tools/shaders/compile_shaders.cmake
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
COMMENT "Compiling .vk.glsl shaders to SPIR-V")
|
COMMENT "Compiling .vk.glsl shaders to SPIR-V")
|
||||||
@@ -53,9 +53,9 @@ add_executable(${PROJECT_NAME} ${APP_SOURCES} ${EXTERNAL_SOURCES})
|
|||||||
|
|
||||||
# --- DIRECTORIOS DE INCLUSIÓN ---
|
# --- DIRECTORIOS DE INCLUSIÓN ---
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/src"
|
"${CMAKE_SOURCE_DIR}/source"
|
||||||
"${CMAKE_SOURCE_DIR}/third_party/glad/include"
|
"${CMAKE_SOURCE_DIR}/source/external/glad/include"
|
||||||
"${CMAKE_SOURCE_DIR}/third_party"
|
"${CMAKE_SOURCE_DIR}/source/external"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Enlazar la librería SDL3
|
# Enlazar la librería SDL3
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Directorios
|
# Directorios
|
||||||
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
||||||
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)src)
|
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
||||||
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
||||||
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
||||||
|
|
||||||
@@ -35,16 +35,16 @@ LINUX_RELEASE := $(TARGET_NAME)-$(VERSION)-linux.tar.gz
|
|||||||
|
|
||||||
# Lista completa de archivos fuente
|
# Lista completa de archivos fuente
|
||||||
APP_SOURCES := \
|
APP_SOURCES := \
|
||||||
src/main.cpp \
|
source/main.cpp \
|
||||||
src/rendering/shader_backend.cpp \
|
source/rendering/shader_backend.cpp \
|
||||||
src/rendering/opengl_shader_backend.cpp \
|
source/rendering/opengl_shader_backend.cpp \
|
||||||
src/rendering/sdl3gpu/sdl3gpu_shader_backend.cpp \
|
source/rendering/sdl3gpu/sdl3gpu_shader_backend.cpp \
|
||||||
src/audio/jail_audio.cpp \
|
source/audio/jail_audio.cpp \
|
||||||
third_party/glad/src/glad.c \
|
source/external/glad/src/glad.c \
|
||||||
third_party/stb_vorbis_impl.cpp
|
source/external/stb_vorbis_impl.cpp
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
INCLUDES := -Isrc -Ithird_party/glad/include -Ithird_party
|
INCLUDES := -Isource -Isource/external/glad/include -Isource/external
|
||||||
|
|
||||||
# Variables según el sistema operativo
|
# Variables según el sistema operativo
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
@@ -98,8 +98,7 @@ windows_release:
|
|||||||
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force}
|
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force}
|
||||||
powershell if (-not (Test-Path "$(RELEASE_FOLDER)")) {New-Item "$(RELEASE_FOLDER)" -ItemType Directory}
|
powershell if (-not (Test-Path "$(RELEASE_FOLDER)")) {New-Item "$(RELEASE_FOLDER)" -ItemType Directory}
|
||||||
|
|
||||||
# Copia la carpeta 'shaders'
|
# Copia la carpeta 'data' (que ahora contiene shaders y music)
|
||||||
powershell Copy-Item -Path "shaders" -Destination "$(RELEASE_FOLDER)" -recurse -Force
|
|
||||||
powershell Copy-Item -Path "data" -Destination "$(RELEASE_FOLDER)" -recurse -Force
|
powershell Copy-Item -Path "data" -Destination "$(RELEASE_FOLDER)" -recurse -Force
|
||||||
|
|
||||||
# Copia los ficheros que están en la raíz del proyecto
|
# Copia los ficheros que están en la raíz del proyecto
|
||||||
@@ -167,7 +166,6 @@ macos_release:
|
|||||||
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||||
|
|
||||||
# Copia carpetas y ficheros
|
# Copia carpetas y ficheros
|
||||||
cp -R shaders "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
|
||||||
cp -R data "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
cp -R data "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||||
cp -R release/frameworks/SDL3.xcframework "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
cp -R release/frameworks/SDL3.xcframework "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
||||||
cp release/icon.icns "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
cp release/icon.icns "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||||
@@ -225,7 +223,6 @@ linux_release:
|
|||||||
$(MKDIR) "$(RELEASE_FOLDER)"
|
$(MKDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Copia ficheros
|
# Copia ficheros
|
||||||
cp -R shaders "$(RELEASE_FOLDER)"
|
|
||||||
cp -R data "$(RELEASE_FOLDER)"
|
cp -R data "$(RELEASE_FOLDER)"
|
||||||
cp LICENSE "$(RELEASE_FOLDER)"
|
cp LICENSE "$(RELEASE_FOLDER)"
|
||||||
cp README.md "$(RELEASE_FOLDER)"
|
cp README.md "$(RELEASE_FOLDER)"
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -398,7 +398,7 @@ int main(int argc, char** argv) {
|
|||||||
target_folder = arg_path;
|
target_folder = arg_path;
|
||||||
shaders_directory_ = arg_path.parent_path();
|
shaders_directory_ = arg_path.parent_path();
|
||||||
} else {
|
} else {
|
||||||
shaders_directory_ = std::filesystem::path(resources_dir) / "shaders";
|
shaders_directory_ = std::filesystem::path(resources_dir) / "data" / "shaders";
|
||||||
target_folder = shaders_directory_ / shaderPath;
|
target_folder = shaders_directory_ / shaderPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found_shader) {
|
if (!found_shader) {
|
||||||
const std::filesystem::path default_folder = std::filesystem::path(resources_dir) / "shaders" / "test";
|
const std::filesystem::path default_folder = std::filesystem::path(resources_dir) / "data" / "shaders" / "test";
|
||||||
for (size_t i = 0; i < shader_list_.size(); ++i) {
|
for (size_t i = 0; i < shader_list_.size(); ++i) {
|
||||||
if (shader_list_[i].folder == default_folder) {
|
if (shader_list_[i].folder == default_folder) {
|
||||||
initial_index = i;
|
initial_index = i;
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user