fix: makefile i cmakes
fix: initSDLVideo en opengl de linux
This commit is contained in:
@@ -236,3 +236,24 @@ if(CLANG_FORMAT_EXE)
|
|||||||
else()
|
else()
|
||||||
message(STATUS "clang-format no encontrado - targets 'format' y 'format-check' no disponibles")
|
message(STATUS "clang-format no encontrado - targets 'format' y 'format-check' no disponibles")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# --- 6. PACK RESOURCES TARGETS ---
|
||||||
|
set(PACK_TOOL_SOURCES
|
||||||
|
${CMAKE_SOURCE_DIR}/tools/pack_resources/pack_resources.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/source/core/resources/resource_pack.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(pack_tool ${PACK_TOOL_SOURCES})
|
||||||
|
target_include_directories(pack_tool PRIVATE ${CMAKE_SOURCE_DIR}/source)
|
||||||
|
set_target_properties(pack_tool PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/tools/pack_resources
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(pack
|
||||||
|
COMMAND ${CMAKE_SOURCE_DIR}/tools/pack_resources/pack_tool
|
||||||
|
${CMAKE_SOURCE_DIR}/data
|
||||||
|
${CMAKE_SOURCE_DIR}/resources.pack
|
||||||
|
DEPENDS pack_tool
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Generando resources.pack desde data/..."
|
||||||
|
)
|
||||||
|
|||||||
12
Makefile
12
Makefile
@@ -176,6 +176,8 @@ resources.pack: $(PACK_TOOL)
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
|
@echo Generando version.h...
|
||||||
|
@powershell -Command "$$GIT_HASH = (git rev-parse --short=7 HEAD 2>$$null); if (-not $$GIT_HASH) { $$GIT_HASH = 'unknown' }; (Get-Content source/version.h.in) -replace '@GIT_HASH@', $$GIT_HASH | Set-Content source/version.h"
|
||||||
@echo Compilando para Windows con nombre: "$(WIN_TARGET_FILE).exe"
|
@echo Compilando para Windows con nombre: "$(WIN_TARGET_FILE).exe"
|
||||||
windres release/jdd.rc -O coff -o $(RESOURCE_FILE)
|
windres release/jdd.rc -O coff -o $(RESOURCE_FILE)
|
||||||
g++ $(ALL_SOURCES) $(RESOURCE_FILE) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_TARGET_FILE).exe"
|
g++ $(ALL_SOURCES) $(RESOURCE_FILE) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_TARGET_FILE).exe"
|
||||||
@@ -183,6 +185,8 @@ windows:
|
|||||||
|
|
||||||
windows_debug:
|
windows_debug:
|
||||||
@echo off
|
@echo off
|
||||||
|
@echo Generando version.h...
|
||||||
|
@powershell -Command "$$GIT_HASH = (git rev-parse --short=7 HEAD 2>$$null); if (-not $$GIT_HASH) { $$GIT_HASH = 'unknown' }; (Get-Content source/version.h.in) -replace '@GIT_HASH@', $$GIT_HASH | Set-Content source/version.h"
|
||||||
@echo Compilando version debug para Windows: "$(WIN_TARGET_FILE)_debug.exe"
|
@echo Compilando version debug para Windows: "$(WIN_TARGET_FILE)_debug.exe"
|
||||||
g++ $(ALL_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_debug.exe"
|
g++ $(ALL_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_debug.exe"
|
||||||
|
|
||||||
@@ -226,10 +230,14 @@ windows_release:
|
|||||||
# COMPILACIÓN PARA MACOS
|
# COMPILACIÓN PARA MACOS
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
macos:
|
macos:
|
||||||
|
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
|
||||||
|
sed "s/@GIT_HASH@/$$GIT_HASH/g" source/version.h.in > source/version.h
|
||||||
@echo "Compilando para macOS: $(TARGET_NAME)"
|
@echo "Compilando para macOS: $(TARGET_NAME)"
|
||||||
clang++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
clang++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||||
|
|
||||||
macos_debug:
|
macos_debug:
|
||||||
|
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
|
||||||
|
sed "s/@GIT_HASH@/$$GIT_HASH/g" source/version.h.in > source/version.h
|
||||||
@echo "Compilando version debug para macOS: $(TARGET_NAME)_debug"
|
@echo "Compilando version debug para macOS: $(TARGET_NAME)_debug"
|
||||||
clang++ $(ALL_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
clang++ $(ALL_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||||
|
|
||||||
@@ -329,11 +337,15 @@ macos_release:
|
|||||||
# COMPILACIÓN PARA LINUX
|
# COMPILACIÓN PARA LINUX
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
linux:
|
linux:
|
||||||
|
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
|
||||||
|
sed "s/@GIT_HASH@/$$GIT_HASH/g" source/version.h.in > source/version.h
|
||||||
@echo "Compilando para Linux: $(TARGET_NAME)"
|
@echo "Compilando para Linux: $(TARGET_NAME)"
|
||||||
g++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
g++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||||
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded
|
||||||
|
|
||||||
linux_debug:
|
linux_debug:
|
||||||
|
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
|
||||||
|
sed "s/@GIT_HASH@/$$GIT_HASH/g" source/version.h.in > source/version.h
|
||||||
@echo "Compilando version debug para Linux: $(TARGET_NAME)_debug"
|
@echo "Compilando version debug para Linux: $(TARGET_NAME)_debug"
|
||||||
g++ $(ALL_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
g++ $(ALL_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||||
|
|
||||||
|
|||||||
@@ -538,6 +538,10 @@ auto Screen::initSDLVideo() -> bool {
|
|||||||
const auto WINDOW_HEIGHT = Options::video.border.enabled ? Options::game.height + (Options::video.border.height * 2) : Options::game.height;
|
const auto WINDOW_HEIGHT = Options::video.border.enabled ? Options::game.height + (Options::video.border.height * 2) : Options::game.height;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_METAL;
|
SDL_WindowFlags window_flags = SDL_WINDOW_METAL;
|
||||||
|
#elif defined(LINUX_BUILD)
|
||||||
|
// En Linux, SDL_WINDOW_OPENGL puede entrar en conflicto con el backend del renderer;
|
||||||
|
// el hint SDL_HINT_RENDER_DRIVER="opengl" es suficiente para seleccionar OpenGL.
|
||||||
|
SDL_WindowFlags window_flags = 0;
|
||||||
#else
|
#else
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL;
|
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL;
|
||||||
#endif
|
#endif
|
||||||
@@ -555,11 +559,20 @@ auto Screen::initSDLVideo() -> bool {
|
|||||||
// Crear renderer
|
// Crear renderer
|
||||||
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
||||||
if (renderer_ == nullptr) {
|
if (renderer_ == nullptr) {
|
||||||
std::cerr << "FATAL: Failed to create renderer! SDL Error: " << SDL_GetError() << '\n';
|
// Fallback: reintentar sin forzar OpenGL (SDL elige el mejor disponible)
|
||||||
SDL_DestroyWindow(window_);
|
std::cerr << "WARNING: OpenGL renderer failed (" << SDL_GetError() << "), trying auto-select...\n";
|
||||||
window_ = nullptr;
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "");
|
||||||
SDL_Quit();
|
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
||||||
return false;
|
if (renderer_ == nullptr) {
|
||||||
|
std::cerr << "FATAL: Failed to create renderer! SDL Error: " << SDL_GetError() << '\n';
|
||||||
|
SDL_DestroyWindow(window_);
|
||||||
|
window_ = nullptr;
|
||||||
|
SDL_Quit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Sin OpenGL garantizado, deshabilitar shaders
|
||||||
|
Options::video.shaders = false;
|
||||||
|
std::cout << "WARNING: Shaders disabled (OpenGL not available)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configurar renderer
|
// Configurar renderer
|
||||||
|
|||||||
Reference in New Issue
Block a user