Imposible canviar la rendererSurface

This commit is contained in:
2025-03-05 18:51:36 +01:00
parent d41b0cb31c
commit 70a50f5117
16 changed files with 199 additions and 257 deletions

View File

@@ -29,10 +29,10 @@ Credits::Credits()
Screen::get()->setBorderColor(stringToColor("black"));
// Crea la textura para el texto que se escribe en pantalla
text_surface_ = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height);
text_surface_ = std::make_shared<Surface>(Screen::get()->getRendererSurface(), options.game.width, options.game.height);
// Crea la textura para cubrir el rexto
cover_surface_ = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height);
cover_surface_ = std::make_shared<Surface>(Screen::get()->getRendererSurface(), options.game.width, options.game.height);
// Escribe el texto en la textura
fillTexture();
@@ -142,7 +142,7 @@ void Credits::fillTexture()
iniTexts();
// Rellena la textura de texto
Screen::get()->setRenderSurfaceData(text_surface_);
Screen::get()->setRendererSurface(text_surface_);
Screen::get()->clearSurface(stringToColor("black"));
auto text = Resource::get()->getText("smb2");
@@ -164,46 +164,46 @@ void Credits::fillTexture()
// Recoloca el sprite del brillo
shining_sprite_->setPosX(POS_X + 2);
Screen::get()->setRenderSurfaceData(nullptr);
Screen::get()->setRendererSurface(nullptr);
// Rellena la textura que cubre el texto con color transparente
Screen::get()->setRenderSurfaceData(text_surface_);
Screen::get()->setRendererSurface(text_surface_);
Screen::get()->clearSurface(stringToColor("transparent"));
// Los primeros 8 pixels crea una malla
auto surface_data = *(Screen::get()->getRenderSurfaceData());
auto surface = Screen::get()->getRendererSurface();
auto color = stringToColor("black");
for (int i = 0; i < 256; i += 2)
{
text_surface_->putPixel(surface_data, i, 0, color);
text_surface_->putPixel(surface_data, i, 2, color);
text_surface_->putPixel(surface_data, i, 4, color);
text_surface_->putPixel(surface_data, i, 6, color);
surface->putPixel(i, 0, color);
surface->putPixel(i, 2, color);
surface->putPixel(i, 4, color);
surface->putPixel(i, 6, color);
text_surface_->putPixel(surface_data, i + 1, 5, color);
text_surface_->putPixel(surface_data, i + 1, 7, color);
surface->putPixel(i + 1, 5, color);
surface->putPixel(i + 1, 7, color);
}
// El resto se rellena de color sólido
SDL_Rect rect = {0, 8, 256, 192};
text_surface_->fillRect(surface_data, &rect, color);
surface->fillRect(&rect, color);
for (int i = 0; i < 256; i += 2)
{
text_surface_->putPixel(surface_data, i, 0, color);
text_surface_->putPixel(surface_data, i, 2, color);
text_surface_->putPixel(surface_data, i, 4, color);
text_surface_->putPixel(surface_data, i, 6, color);
surface->putPixel(i, 0, color);
surface->putPixel(i, 2, color);
surface->putPixel(i, 4, color);
surface->putPixel(i, 6, color);
text_surface_->putPixel(surface_data, i + 1, 5, color);
text_surface_->putPixel(surface_data, i + 1, 7, color);
surface->putPixel(i + 1, 5, color);
surface->putPixel(i + 1, 7, color);
}
// El resto se rellena de color sólido
rect = {0, 8, 256, 192};
text_surface_->fillRect(surface_data, &rect, color);
surface->fillRect(&rect, color);
Screen::get()->setRenderSurfaceData(nullptr);
Screen::get()->setRendererSurface(nullptr);
}
// Actualiza el contador