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

@@ -43,7 +43,7 @@ Ending::Ending()
Screen::get()->setBorderColor(stringToColor("black"));
// Crea la textura para cubrir el texto
cover_surface_ = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height + 8);
cover_surface_ = std::make_shared<Surface>(Screen::get()->getRendererSurface(), options.game.width, options.game.height + 8);
// Rellena la textura para la cortinilla
fillCoverTexture();
@@ -172,8 +172,8 @@ void Ending::iniTexts()
EndingSurface st;
// Crea la textura
st.image_surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), WIDTH, HEIGHT);
Screen::get()->setRenderSurfaceData(st.image_surface);
st.image_surface = std::make_shared<Surface>(Screen::get()->getRendererSurface(), WIDTH, HEIGHT);
Screen::get()->setRendererSurface(st.image_surface);
text->writeDX(TEXT_STROKE, 2, 2, txt.caption, 1, color, 2, color);
// Crea el sprite
@@ -181,29 +181,29 @@ void Ending::iniTexts()
st.image_sprite->setPosition((options.game.width - st.image_surface->getWidth()) / 2, txt.pos);
// Crea la cover_surface
st.cover_surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), WIDTH, HEIGHT + 8);
Screen::get()->setRenderSurfaceData(st.cover_surface);
st.cover_surface = std::make_shared<Surface>(Screen::get()->getRendererSurface(), WIDTH, HEIGHT + 8);
Screen::get()->setRendererSurface(st.cover_surface);
// Rellena la cover_surface con color transparente
Screen::get()->clearSurface(stringToColor("transparent"));
// Crea una malla de 8 pixels de alto
auto surface_data = *(Screen::get()->getRenderSurfaceData());
auto surface = Screen::get()->getRendererSurface();
color = stringToColor("black");
for (int i = 0; i < WIDTH; i += 2)
{
st.cover_surface->putPixel(surface_data, i, 0, color);
st.cover_surface->putPixel(surface_data, i, 2, color);
st.cover_surface->putPixel(surface_data, i, 4, color);
st.cover_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);
st.cover_surface->putPixel(surface_data, i + 1, 5, color);
st.cover_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, WIDTH, HEIGHT};
st.cover_surface->fillRect(surface_data, &rect, color);
surface->fillRect(&rect, color);
// Crea el sprite
st.cover_sprite = std::make_shared<SSprite>(st.cover_surface, 0, 0, st.cover_surface->getWidth(), st.cover_surface->getHeight() - 8);
@@ -215,7 +215,7 @@ void Ending::iniTexts()
st.cover_clip_height = HEIGHT;
sprite_texts_.push_back(st);
Screen::get()->setRenderSurfaceData(nullptr);
Screen::get()->setRendererSurface(nullptr);
}
}
@@ -248,29 +248,29 @@ void Ending::iniPics()
sp.image_sprite->setPosition((options.game.width - WIDTH) / 2, pic.pos);
// Crea la cover_surface
sp.cover_surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), WIDTH, HEIGHT + 8);
Screen::get()->setRenderSurfaceData(sp.cover_surface);
sp.cover_surface = std::make_shared<Surface>(Screen::get()->getRendererSurface(), WIDTH, HEIGHT + 8);
Screen::get()->setRendererSurface(sp.cover_surface);
// Rellena la cover_surface con color transparente
Screen::get()->clearSurface(stringToColor("transparent"));
// Crea una malla en los primeros 8 pixels
auto surface_data = *(Screen::get()->getRenderSurfaceData());
auto surface = Screen::get()->getRendererSurface();
auto color = stringToColor("black");
for (int i = 0; i < WIDTH; i += 2)
{
sp.cover_surface->putPixel(surface_data, i, 0, color);
sp.cover_surface->putPixel(surface_data, i, 2, color);
sp.cover_surface->putPixel(surface_data, i, 4, color);
sp.cover_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);
sp.cover_surface->putPixel(surface_data, i + 1, 5, color);
sp.cover_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, WIDTH, HEIGHT};
sp.cover_surface->fillRect(surface_data, &rect, color);
surface->fillRect(&rect, color);
// Crea el sprite
sp.cover_sprite = std::make_shared<SSprite>(sp.cover_surface, 0, 0, sp.cover_surface->getWidth(), sp.cover_surface->getHeight() - 8);
@@ -282,7 +282,7 @@ void Ending::iniPics()
sp.cover_clip_height = HEIGHT;
sprite_pics_.push_back(sp);
Screen::get()->setRenderSurfaceData(nullptr);
Screen::get()->setRendererSurface(nullptr);
}
}
@@ -472,29 +472,29 @@ void Ending::checkChangeScene()
void Ending::fillCoverTexture()
{
// Rellena la textura que cubre el texto con color transparente
Screen::get()->setRenderSurfaceData(cover_surface_);
Screen::get()->setRendererSurface(cover_surface_);
Screen::get()->clearSurface(stringToColor("transparent"));
// Los primeros 8 pixels crea una malla
const Uint8 color = stringToColor("black");
auto surface_data = *(Screen::get()->getRenderSurfaceData());
auto surface = Screen::get()->getRendererSurface();
for (int i = 0; i < 256; i += 2)
{
cover_surface_->putPixel(surface_data, i + 0, options.game.height + 0, color);
cover_surface_->putPixel(surface_data, i + 1, options.game.height + 1, color);
cover_surface_->putPixel(surface_data, i + 0, options.game.height + 2, color);
cover_surface_->putPixel(surface_data, i + 1, options.game.height + 3, color);
surface->putPixel(i + 0, options.game.height + 0, color);
surface->putPixel(i + 1, options.game.height + 1, color);
surface->putPixel(i + 0, options.game.height + 2, color);
surface->putPixel(i + 1, options.game.height + 3, color);
cover_surface_->putPixel(surface_data, i, options.game.height + 4, color);
cover_surface_->putPixel(surface_data, i, options.game.height + 6, color);
surface->putPixel(i, options.game.height + 4, color);
surface->putPixel(i, options.game.height + 6, color);
}
// El resto se rellena de color sólido
SDL_Rect rect = {0, 0, 256, options.game.height};
cover_surface_->fillRect(surface_data, &rect, color);
surface->fillRect(&rect, color);
Screen::get()->setRenderSurfaceData(nullptr);
Screen::get()->setRendererSurface(nullptr);
}
// Dibuja la cortinilla de cambio de escena