Features: - Self-feedback rendering system for shaders with feedback loops - Automatic FBO/texture management for feedback - Metadata parser detects iChannel feedback configuration - Adaptive render loop (with/without feedback) - Water shader from Shadertoy (adapted and working) - Fixed variable initialization issues in shader code Technical details: - FBO creation/destruction on shader switch - Texture binding to iChannel0-3 based on metadata - Auto-resize feedback buffers on window resize - Cleanup on exit and shader switch Files: - src/main.cpp: Feedback system implementation - shaders/water.glsl: Water shader with fixes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
151 lines
5.1 KiB
Python
151 lines
5.1 KiB
Python
#!/usr/bin/env python3
|
||
|
||
import os
|
||
import sys
|
||
import shutil
|
||
import subprocess
|
||
from pathlib import Path
|
||
|
||
|
||
def check_dependencies():
|
||
"""Verifica que ImageMagick esté instalado"""
|
||
try:
|
||
subprocess.run(['magick', '--version'], capture_output=True, check=True)
|
||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||
print("Error: ImageMagick no está instalado o no se encuentra en el PATH")
|
||
print("Instala ImageMagick desde: https://imagemagick.org/script/download.php")
|
||
sys.exit(1)
|
||
|
||
# Verificar iconutil solo en macOS
|
||
if sys.platform == 'darwin':
|
||
try:
|
||
# iconutil no tiene --version, mejor usar which o probar con -h
|
||
result = subprocess.run(['which', 'iconutil'], capture_output=True, check=True)
|
||
if result.returncode == 0:
|
||
print("✓ iconutil disponible - se crearán archivos .ico e .icns")
|
||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||
print("Error: iconutil no está disponible (solo funciona en macOS)")
|
||
print("Solo se creará el archivo .ico")
|
||
else:
|
||
print("ℹ️ Sistema no-macOS detectado - solo se creará archivo .ico")
|
||
|
||
|
||
def create_icons(input_file):
|
||
"""Crea archivos .icns e .ico a partir de un PNG"""
|
||
|
||
# Verificar que el archivo existe
|
||
if not os.path.isfile(input_file):
|
||
print(f"Error: El archivo {input_file} no existe.")
|
||
return False
|
||
|
||
# Obtener información del archivo
|
||
file_path = Path(input_file)
|
||
file_dir = file_path.parent
|
||
file_name = file_path.stem # Nombre sin extensión
|
||
file_extension = file_path.suffix
|
||
|
||
if file_extension.lower() not in ['.png', '.jpg', '.jpeg', '.bmp', '.tiff']:
|
||
print(f"Advertencia: {file_extension} puede no ser compatible. Se recomienda usar PNG.")
|
||
|
||
# Crear archivo .ico usando el método simplificado
|
||
ico_output = file_dir / f"{file_name}.ico"
|
||
try:
|
||
print(f"Creando {ico_output}...")
|
||
subprocess.run([
|
||
'magick', str(input_file),
|
||
'-define', 'icon:auto-resize=256,128,64,48,32,16',
|
||
str(ico_output)
|
||
], check=True)
|
||
print(f"✓ Archivo .ico creado: {ico_output}")
|
||
except subprocess.CalledProcessError as e:
|
||
print(f"Error creando archivo .ico: {e}")
|
||
return False
|
||
|
||
# Crear archivo .icns (solo en macOS)
|
||
if sys.platform == 'darwin':
|
||
try:
|
||
# Crear carpeta temporal para iconset
|
||
temp_folder = file_dir / "icon.iconset"
|
||
|
||
# Eliminar carpeta temporal si existe
|
||
if temp_folder.exists():
|
||
shutil.rmtree(temp_folder)
|
||
|
||
# Crear carpeta temporal
|
||
temp_folder.mkdir(parents=True)
|
||
|
||
# Definir los tamaños y nombres de archivo para .icns
|
||
icon_sizes = [
|
||
(16, "icon_16x16.png"),
|
||
(32, "icon_16x16@2x.png"),
|
||
(32, "icon_32x32.png"),
|
||
(64, "icon_32x32@2x.png"),
|
||
(128, "icon_128x128.png"),
|
||
(256, "icon_128x128@2x.png"),
|
||
(256, "icon_256x256.png"),
|
||
(512, "icon_256x256@2x.png"),
|
||
(512, "icon_512x512.png"),
|
||
(1024, "icon_512x512@2x.png")
|
||
]
|
||
|
||
print("Generando imágenes para .icns...")
|
||
# Crear cada tamaño de imagen
|
||
for size, output_name in icon_sizes:
|
||
output_path = temp_folder / output_name
|
||
subprocess.run([
|
||
'magick', str(input_file),
|
||
'-resize', f'{size}x{size}',
|
||
str(output_path)
|
||
], check=True)
|
||
|
||
# Crear archivo .icns usando iconutil
|
||
icns_output = file_dir / f"{file_name}.icns"
|
||
print(f"Creando {icns_output}...")
|
||
subprocess.run([
|
||
'iconutil', '-c', 'icns',
|
||
str(temp_folder),
|
||
'-o', str(icns_output)
|
||
], check=True)
|
||
|
||
# Limpiar carpeta temporal
|
||
if temp_folder.exists():
|
||
shutil.rmtree(temp_folder)
|
||
|
||
print(f"✓ Archivo .icns creado: {icns_output}")
|
||
|
||
except subprocess.CalledProcessError as e:
|
||
print(f"Error creando archivo .icns: {e}")
|
||
# Limpiar carpeta temporal en caso de error
|
||
if temp_folder.exists():
|
||
shutil.rmtree(temp_folder)
|
||
return False
|
||
else:
|
||
print("ℹ️ Archivo .icns no creado (solo disponible en macOS)")
|
||
|
||
return True
|
||
|
||
|
||
def main():
|
||
"""Función principal"""
|
||
# Verificar argumentos
|
||
if len(sys.argv) != 2:
|
||
print(f"Uso: {sys.argv[0]} ARCHIVO")
|
||
print("Ejemplo: python3 create_icons.py imagen.png")
|
||
sys.exit(0)
|
||
|
||
input_file = sys.argv[1]
|
||
|
||
# Verificar dependencias
|
||
check_dependencies()
|
||
|
||
# Crear iconos
|
||
if create_icons(input_file):
|
||
print("\n✅ Proceso completado exitosamente")
|
||
else:
|
||
print("\n❌ El proceso falló")
|
||
sys.exit(1)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|