Añadir parámetros de línea de comandos para resolución
Características: - Parámetros CLI: -w/--width, -h/--height, -f/--fullscreen - Help: --help muestra uso y ejemplos - Validación: mínimo 640x480, con mensajes de error - Defaults: 1280x720 ventana si no se especifica - Fullscreen opcional con flag -f Ejemplos de uso: ./vibe3_physics # Default 1280x720 ./vibe3_physics -w 1920 -h 1080 # Personalizado ./vibe3_physics -w 1920 -h 1080 -f # Fullscreen ./vibe3_physics --help # Ayuda Archivos modificados: - source/main.cpp: Parser de argumentos + printHelp() - source/engine.h: initialize() acepta parámetros - source/engine.cpp: Lógica de ventana configurable - ROADMAP.md: Marcar tarea completada 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -48,15 +48,26 @@ std::string getExecutableDirectory() {
|
||||
}
|
||||
|
||||
// Implementación de métodos públicos
|
||||
bool Engine::initialize() {
|
||||
bool Engine::initialize(int width, int height, bool fullscreen) {
|
||||
bool success = true;
|
||||
|
||||
// Usar parámetros o valores por defecto
|
||||
int window_width = (width > 0) ? width : SCREEN_WIDTH * WINDOW_ZOOM;
|
||||
int window_height = (height > 0) ? height : SCREEN_HEIGHT * WINDOW_ZOOM;
|
||||
int logical_width = (width > 0) ? width : SCREEN_WIDTH;
|
||||
int logical_height = (height > 0) ? height : SCREEN_HEIGHT;
|
||||
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
std::cout << "¡SDL no se pudo inicializar! Error de SDL: " << SDL_GetError() << std::endl;
|
||||
success = false;
|
||||
} else {
|
||||
// Crear ventana principal
|
||||
window_ = SDL_CreateWindow(WINDOW_CAPTION, SCREEN_WIDTH * WINDOW_ZOOM, SCREEN_HEIGHT * WINDOW_ZOOM, SDL_WINDOW_OPENGL);
|
||||
// Crear ventana principal (fullscreen si se especifica)
|
||||
Uint32 window_flags = SDL_WINDOW_OPENGL;
|
||||
if (fullscreen) {
|
||||
window_flags |= SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
|
||||
window_ = SDL_CreateWindow(WINDOW_CAPTION, window_width, window_height, window_flags);
|
||||
if (window_ == nullptr) {
|
||||
std::cout << "¡No se pudo crear la ventana! Error de SDL: " << SDL_GetError() << std::endl;
|
||||
success = false;
|
||||
@@ -70,8 +81,8 @@ bool Engine::initialize() {
|
||||
// Establecer color inicial del renderizador
|
||||
SDL_SetRenderDrawColor(renderer_, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
// Establecer tamaño lógico para el renderizado
|
||||
SDL_SetRenderLogicalPresentation(renderer_, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
||||
// Establecer tamaño lógico para el renderizado (resolución interna)
|
||||
SDL_SetRenderLogicalPresentation(renderer_, logical_width, logical_height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
||||
|
||||
// Configurar V-Sync inicial
|
||||
SDL_SetRenderVSync(renderer_, vsync_enabled_ ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user