6cf990bc1d
Aplicada la directiva "res llegacy" abans d'arrencar la migracio a fisica vectorial + SDL3 GPU. Cada bossa de cruft que arrossegava el port de Pascal queda eliminada. Borrats (huerfanos): - source/core/rendering/primitives.hpp/.cpp (modul/diferencia/angle_punt/ crear_poligon_regular) - source/core/rendering/polygon_renderer.hpp/.cpp (rota_tri/rota_pol) - core::types::Triangle, Poligon, IPunt - Defaults::Entities::MAX_IPUNTS i alias a constants.hpp - EscenaJoc::chatarra_cosmica_ (mai usat) - Bresenham comentat dins de Rendering::linea() Simplificat (parametre 'dibuixar' llegacy que sempre era true): - Rendering::linea(...): treta la signatura bool dibuixar, retorn void - Rendering::render_shape(...): treta la signatura bool dibuixar - 11 callsites de linea() actualitzats (escena_joc, debris_manager) - 12 callsites de render_shape() actualitzats Modernitzats: - 5 fitxers .shp netejats de comentaris polar->cartesia historics - types.hpp queda nomes amb Punt (l'unica coordenada del joc) - debris_manager.hpp afegit include explicit de defaults.hpp Net: 452 linies eliminades, 56 afegides. Compila i enllaca correctament. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
// line_renderer.cpp - Implementació de renderitzat de línies
|
|
// © 1999 Visente i Sergi (versió Pascal)
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#include "core/rendering/line_renderer.hpp"
|
|
|
|
#include "core/rendering/coordinate_transform.hpp"
|
|
|
|
namespace Rendering {
|
|
|
|
// Color global compartit (actualitzat per ColorOscillator via SDLManager)
|
|
SDL_Color g_current_line_color = {255, 255, 255, 255};
|
|
|
|
void linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, float brightness) {
|
|
if (renderer == nullptr) {
|
|
return;
|
|
}
|
|
|
|
// Transformar coordenades lògiques (640x480) a físiques (resolució real)
|
|
const float SCALE = g_current_scale_factor;
|
|
const int PX1 = transform_x(x1, SCALE);
|
|
const int PY1 = transform_y(y1, SCALE);
|
|
const int PX2 = transform_x(x2, SCALE);
|
|
const int PY2 = transform_y(y2, SCALE);
|
|
|
|
// Aplicar brightness al color oscil·lat global
|
|
const auto R = static_cast<uint8_t>(g_current_line_color.r * brightness);
|
|
const auto G = static_cast<uint8_t>(g_current_line_color.g * brightness);
|
|
const auto B = static_cast<uint8_t>(g_current_line_color.b * brightness);
|
|
|
|
SDL_SetRenderDrawColor(renderer, R, G, B, 255);
|
|
SDL_RenderLine(renderer, static_cast<float>(PX1), static_cast<float>(PY1),
|
|
static_cast<float>(PX2), static_cast<float>(PY2));
|
|
}
|
|
|
|
void setLineColor(SDL_Color color) { g_current_line_color = color; }
|
|
|
|
} // namespace Rendering
|