4 Commits

14 changed files with 81 additions and 17 deletions

View File

@@ -9,6 +9,7 @@ TARGET_NAME := shadertoy
TARGET_FILE := $(DIR_BIN)$(TARGET_NAME)
APP_NAME := Shadertoy
RELEASE_FOLDER := shadertoy_release
RESOURCE_FILE := release/shadertoy.res
# Versión automática basada en la fecha actual (específica por SO)
ifeq ($(OS),Windows_NT)
@@ -74,7 +75,8 @@ endif
windows:
@echo off
@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
windows_debug:
@@ -98,8 +100,11 @@ windows_release:
powershell Copy-Item "README.md" -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
$(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
# Crea el fichero .zip
@@ -130,16 +135,20 @@ macos_release:
$(RMFILE) "$(MACOS_APPLE_SILICON_RELEASE)"
# 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/Resources"
# Copia carpetas y ficheros
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 README.md "$(RELEASE_FOLDER)"
# 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
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"

View File

@@ -5,27 +5,27 @@
<key>CFBundleDevelopmentRegion</key>
<string>es</string>
<key>CFBundleDisplayName</key>
<string>ViBe3 Physics</string>
<string>Shadertoy</string>
<key>CFBundleExecutable</key>
<string>vibe3_physics</string>
<string>shadertoy</string>
<key>CFBundleIconFile</key>
<string>icon</string>
<key>CFBundleIconName</key>
<string>icon</string>
<key>CFBundleIdentifier</key>
<string>net.jailgames.vibe3_physics</string>
<string>net.jailgames.shadertoy</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>vibe3_physics</string>
<string>shadertoy</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.00</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.00</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSMinimumSystemVersion</key>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 426 KiB

BIN
release/icon2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
release/icon_b.pxd Normal file

Binary file not shown.

View File

@@ -1,2 +1,2 @@
// coffee.rc
// shadertoy.rc
IDI_ICON1 ICON "icon.ico"

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 MiB

View File

@@ -1,5 +1,8 @@
#pragma once
#include <filesystem>
#include <string>
// Nombre de la aplicación
constexpr const char* APP_NAME = "Shadertoy";
@@ -7,6 +10,55 @@ constexpr const char* APP_NAME = "Shadertoy";
constexpr int WINDOW_WIDTH = 800;
constexpr int WINDOW_HEIGHT = 800;
// Rutas
constexpr const char* SHADERS_FOLDER = "shaders";
constexpr const char* DEFAULT_SHADER = "shaders/test.frag.glsl";
// Includes específicos por plataforma para obtener la ruta del ejecutable
#ifdef _WIN32
#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
}

View File

@@ -283,7 +283,7 @@ int main(int argc, char** argv) {
if (a == "-F" || a == "--fullscreen") { fullscreenFlag = true; continue; }
if (shaderPath.empty()) shaderPath = a;
}
if (shaderPath.empty()) shaderPath = DEFAULT_SHADER;
if (shaderPath.empty()) shaderPath = "test.frag.glsl";
Options_video.fullscreen = fullscreenFlag;
// Inicializar SDL3
@@ -326,12 +326,15 @@ int main(int argc, char** argv) {
return -1;
}
// Obtener directorio de recursos
std::string resources_dir = getResourcesDirectory();
// Determinar carpeta de shaders
std::filesystem::path shaderFile(shaderPath);
if (shaderFile.has_parent_path()) {
shaders_directory_ = shaderFile.parent_path();
} else {
shaders_directory_ = SHADERS_FOLDER;
shaders_directory_ = std::filesystem::path(resources_dir) / "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) {
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) {
if (shader_list_[i] == default_path) {
initial_index = i;