68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <filesystem>
|
|
#include <string>
|
|
|
|
// Nombre de la aplicación
|
|
constexpr const char* APP_NAME = "Shadertoy";
|
|
|
|
// Prefijo del título de la ventana (estilo aee_2026).
|
|
constexpr const char* WINDOW_TITLE_PREFIX = "\xC2\xA9 2025 Shadertoy \xE2\x80\x94 JailDesigner";
|
|
|
|
// Tamaño de ventana por defecto
|
|
constexpr int WINDOW_WIDTH = 800;
|
|
constexpr int WINDOW_HEIGHT = 800;
|
|
|
|
// 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
|
|
}
|