Compare commits
4 Commits
be8be3a48d
...
2025-10-25
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a269449a3 | |||
| 4164cc8e88 | |||
| b625916b18 | |||
| 92093e7b3f |
15
Makefile
15
Makefile
@@ -9,6 +9,7 @@ TARGET_NAME := shadertoy
|
|||||||
TARGET_FILE := $(DIR_BIN)$(TARGET_NAME)
|
TARGET_FILE := $(DIR_BIN)$(TARGET_NAME)
|
||||||
APP_NAME := Shadertoy
|
APP_NAME := Shadertoy
|
||||||
RELEASE_FOLDER := shadertoy_release
|
RELEASE_FOLDER := shadertoy_release
|
||||||
|
RESOURCE_FILE := release/shadertoy.res
|
||||||
|
|
||||||
# Versión automática basada en la fecha actual (específica por SO)
|
# Versión automática basada en la fecha actual (específica por SO)
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
@@ -74,7 +75,8 @@ endif
|
|||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
@echo Compilando para Windows con nombre: "$(APP_NAME).exe"
|
@echo Compilando para Windows con nombre: "$(APP_NAME).exe"
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_TARGET_FILE).exe"
|
windres release/shadertoy.rc -O coff -o $(RESOURCE_FILE)
|
||||||
|
$(CXX) $(APP_SOURCES) $(RESOURCE_FILE) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_TARGET_FILE).exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(WIN_TARGET_FILE).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(WIN_TARGET_FILE).exe" --strip-unneeded
|
||||||
|
|
||||||
windows_debug:
|
windows_debug:
|
||||||
@@ -98,8 +100,11 @@ windows_release:
|
|||||||
powershell Copy-Item "README.md" -Destination "$(RELEASE_FOLDER)"
|
powershell Copy-Item "README.md" -Destination "$(RELEASE_FOLDER)"
|
||||||
powershell Copy-Item "release\*.dll" -Destination "$(RELEASE_FOLDER)"
|
powershell Copy-Item "release\*.dll" -Destination "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
|
# Compila el recurso de icono
|
||||||
|
@windres release/shadertoy.rc -O coff -o $(RESOURCE_FILE)
|
||||||
|
|
||||||
# Compila
|
# Compila
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_RELEASE_FILE).exe"
|
$(CXX) $(APP_SOURCES) $(RESOURCE_FILE) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_RELEASE_FILE).exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(WIN_RELEASE_FILE).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(WIN_RELEASE_FILE).exe" --strip-unneeded
|
||||||
|
|
||||||
# Crea el fichero .zip
|
# Crea el fichero .zip
|
||||||
@@ -130,16 +135,20 @@ macos_release:
|
|||||||
$(RMFILE) "$(MACOS_APPLE_SILICON_RELEASE)"
|
$(RMFILE) "$(MACOS_APPLE_SILICON_RELEASE)"
|
||||||
|
|
||||||
# Crea la carpeta temporal para hacer el trabajo y las carpetas obligatorias para crear una app de macos
|
# Crea la carpeta temporal para hacer el trabajo y las carpetas obligatorias para crear una app de macos
|
||||||
|
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
||||||
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS"
|
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS"
|
||||||
$(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 shaders "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||||
|
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/Info.plist "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents"
|
||||||
cp LICENSE "$(RELEASE_FOLDER)"
|
cp LICENSE "$(RELEASE_FOLDER)"
|
||||||
cp README.md "$(RELEASE_FOLDER)"
|
cp README.md "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Compila la versión para procesadores Apple Silicon
|
# Compila la versión para procesadores Apple Silicon
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -target arm64-apple-macos11
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
||||||
|
|
||||||
# Firma la aplicación
|
# Firma la aplicación
|
||||||
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
||||||
|
|||||||
@@ -5,27 +5,27 @@
|
|||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>es</string>
|
<string>es</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
<string>ViBe3 Physics</string>
|
<string>Shadertoy</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>vibe3_physics</string>
|
<string>shadertoy</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>icon</string>
|
<string>icon</string>
|
||||||
<key>CFBundleIconName</key>
|
<key>CFBundleIconName</key>
|
||||||
<string>icon</string>
|
<string>icon</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>net.jailgames.vibe3_physics</string>
|
<string>net.jailgames.shadertoy</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>vibe3_physics</string>
|
<string>shadertoy</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.00</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0</string>
|
<string>1.00</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
BIN
release/icon.ico
BIN
release/icon.ico
Binary file not shown.
|
Before Width: | Height: | Size: 210 KiB After Width: | Height: | Size: 146 KiB |
BIN
release/icon.png
BIN
release/icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 426 KiB |
BIN
release/icon2.png
Normal file
BIN
release/icon2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 MiB |
BIN
release/icon_b.pxd
Normal file
BIN
release/icon_b.pxd
Normal file
Binary file not shown.
@@ -1,2 +1,2 @@
|
|||||||
// coffee.rc
|
// shadertoy.rc
|
||||||
IDI_ICON1 ICON "icon.ico"
|
IDI_ICON1 ICON "icon.ico"
|
||||||
|
|||||||
Binary file not shown.
BIN
release/temp.png
BIN
release/temp.png
Binary file not shown.
|
Before Width: | Height: | Size: 32 MiB |
@@ -1,5 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// Nombre de la aplicación
|
// Nombre de la aplicación
|
||||||
constexpr const char* APP_NAME = "Shadertoy";
|
constexpr const char* APP_NAME = "Shadertoy";
|
||||||
|
|
||||||
@@ -7,6 +10,55 @@ constexpr const char* APP_NAME = "Shadertoy";
|
|||||||
constexpr int WINDOW_WIDTH = 800;
|
constexpr int WINDOW_WIDTH = 800;
|
||||||
constexpr int WINDOW_HEIGHT = 800;
|
constexpr int WINDOW_HEIGHT = 800;
|
||||||
|
|
||||||
// Rutas
|
// Includes específicos por plataforma para obtener la ruta del ejecutable
|
||||||
constexpr const char* SHADERS_FOLDER = "shaders";
|
#ifdef _WIN32
|
||||||
constexpr const char* DEFAULT_SHADER = "shaders/test.frag.glsl";
|
#include <windows.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <limits.h>
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#else
|
||||||
|
#include <limits.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Función auxiliar para obtener la ruta del directorio del ejecutable
|
||||||
|
inline std::string getExecutableDirectory() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
char buffer[MAX_PATH];
|
||||||
|
GetModuleFileNameA(NULL, buffer, MAX_PATH);
|
||||||
|
std::filesystem::path exe_path(buffer);
|
||||||
|
return exe_path.parent_path().string();
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
uint32_t size = sizeof(buffer);
|
||||||
|
if (_NSGetExecutablePath(buffer, &size) == 0) {
|
||||||
|
std::filesystem::path exe_path(buffer);
|
||||||
|
return exe_path.parent_path().string();
|
||||||
|
}
|
||||||
|
return ".";
|
||||||
|
#else
|
||||||
|
// Linux y otros Unix
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
ssize_t len = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
|
||||||
|
if (len != -1) {
|
||||||
|
buffer[len] = '\0';
|
||||||
|
std::filesystem::path exe_path(buffer);
|
||||||
|
return exe_path.parent_path().string();
|
||||||
|
}
|
||||||
|
return ".";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Función auxiliar para obtener la ruta del directorio de recursos
|
||||||
|
inline std::string getResourcesDirectory() {
|
||||||
|
std::string exe_dir = getExecutableDirectory();
|
||||||
|
|
||||||
|
#ifdef MACOS_BUNDLE
|
||||||
|
// En macOS Bundle: ejecutable está en Contents/MacOS/, recursos en Contents/Resources/
|
||||||
|
std::filesystem::path resources_path = std::filesystem::path(exe_dir) / ".." / "Resources";
|
||||||
|
return resources_path.string();
|
||||||
|
#else
|
||||||
|
// En desarrollo o releases normales: recursos están junto al ejecutable
|
||||||
|
return exe_dir;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
11
src/main.cpp
11
src/main.cpp
@@ -283,7 +283,7 @@ int main(int argc, char** argv) {
|
|||||||
if (a == "-F" || a == "--fullscreen") { fullscreenFlag = true; continue; }
|
if (a == "-F" || a == "--fullscreen") { fullscreenFlag = true; continue; }
|
||||||
if (shaderPath.empty()) shaderPath = a;
|
if (shaderPath.empty()) shaderPath = a;
|
||||||
}
|
}
|
||||||
if (shaderPath.empty()) shaderPath = DEFAULT_SHADER;
|
if (shaderPath.empty()) shaderPath = "test.frag.glsl";
|
||||||
Options_video.fullscreen = fullscreenFlag;
|
Options_video.fullscreen = fullscreenFlag;
|
||||||
|
|
||||||
// Inicializar SDL3
|
// Inicializar SDL3
|
||||||
@@ -326,12 +326,15 @@ int main(int argc, char** argv) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtener directorio de recursos
|
||||||
|
std::string resources_dir = getResourcesDirectory();
|
||||||
|
|
||||||
// Determinar carpeta de shaders
|
// Determinar carpeta de shaders
|
||||||
std::filesystem::path shaderFile(shaderPath);
|
std::filesystem::path shaderFile(shaderPath);
|
||||||
if (shaderFile.has_parent_path()) {
|
if (shaderFile.has_parent_path()) {
|
||||||
shaders_directory_ = shaderFile.parent_path();
|
shaders_directory_ = shaderFile.parent_path();
|
||||||
} else {
|
} else {
|
||||||
shaders_directory_ = SHADERS_FOLDER;
|
shaders_directory_ = std::filesystem::path(resources_dir) / "shaders";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escanear carpeta de shaders
|
// Escanear carpeta de shaders
|
||||||
@@ -358,9 +361,9 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si no se encuentra, intentar con DEFAULT_SHADER
|
// Si no se encuentra, intentar con shader por defecto (test.frag.glsl)
|
||||||
if (!found_shader) {
|
if (!found_shader) {
|
||||||
std::filesystem::path default_path(DEFAULT_SHADER);
|
std::filesystem::path default_path = std::filesystem::path(resources_dir) / "shaders" / "test.frag.glsl";
|
||||||
for (size_t i = 0; i < shader_list_.size(); ++i) {
|
for (size_t i = 0; i < shader_list_.size(); ++i) {
|
||||||
if (shader_list_[i] == default_path) {
|
if (shader_list_[i] == default_path) {
|
||||||
initial_index = i;
|
initial_index = i;
|
||||||
|
|||||||
Reference in New Issue
Block a user