fix: makefile i cmakes
fix: initSDLVideo en opengl de linux
This commit is contained in:
@@ -236,3 +236,24 @@ if(CLANG_FORMAT_EXE)
|
||||
else()
|
||||
message(STATUS "clang-format no encontrado - targets 'format' y 'format-check' no disponibles")
|
||||
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:
|
||||
@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"
|
||||
windres release/jdd.rc -O coff -o $(RESOURCE_FILE)
|
||||
g++ $(ALL_SOURCES) $(RESOURCE_FILE) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_TARGET_FILE).exe"
|
||||
@@ -183,6 +185,8 @@ windows:
|
||||
|
||||
windows_debug:
|
||||
@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"
|
||||
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
|
||||
# ==============================================================================
|
||||
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)"
|
||||
clang++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||
|
||||
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"
|
||||
clang++ $(ALL_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
|
||||
@@ -329,11 +337,15 @@ macos_release:
|
||||
# COMPILACIÓN PARA 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)"
|
||||
g++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded
|
||||
|
||||
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"
|
||||
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;
|
||||
#ifdef __APPLE__
|
||||
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
|
||||
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL;
|
||||
#endif
|
||||
@@ -554,6 +558,11 @@ auto Screen::initSDLVideo() -> bool {
|
||||
|
||||
// Crear renderer
|
||||
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
||||
if (renderer_ == nullptr) {
|
||||
// Fallback: reintentar sin forzar OpenGL (SDL elige el mejor disponible)
|
||||
std::cerr << "WARNING: OpenGL renderer failed (" << SDL_GetError() << "), trying auto-select...\n";
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "");
|
||||
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
||||
if (renderer_ == nullptr) {
|
||||
std::cerr << "FATAL: Failed to create renderer! SDL Error: " << SDL_GetError() << '\n';
|
||||
SDL_DestroyWindow(window_);
|
||||
@@ -561,6 +570,10 @@ auto Screen::initSDLVideo() -> bool {
|
||||
SDL_Quit();
|
||||
return false;
|
||||
}
|
||||
// Sin OpenGL garantizado, deshabilitar shaders
|
||||
Options::video.shaders = false;
|
||||
std::cout << "WARNING: Shaders disabled (OpenGL not available)\n";
|
||||
}
|
||||
|
||||
// Configurar renderer
|
||||
const int EXTRA_WIDTH = Options::video.border.enabled ? Options::video.border.width * 2 : 0;
|
||||
|
||||
Reference in New Issue
Block a user