Compare commits
2 Commits
be8be3a48d
...
b625916b18
| Author | SHA1 | Date | |
|---|---|---|---|
| b625916b18 | |||
| 92093e7b3f |
6
Makefile
6
Makefile
@@ -130,16 +130,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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
BIN
release/temp.png
BIN
release/temp.png
Binary file not shown.
|
Before Width: | Height: | Size: 32 MiB |
@@ -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
|
||||
}
|
||||
|
||||
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 (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;
|
||||
|
||||
Reference in New Issue
Block a user