Retocat el render path d'Screen
This commit is contained in:
@@ -127,23 +127,14 @@ void Screen::start()
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
void Screen::render()
|
||||
{
|
||||
// Renderiza sobre game_surface_ los overlays
|
||||
renderNotifications();
|
||||
// Renderiza todos los overlays
|
||||
renderOverlays();
|
||||
|
||||
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
||||
if (options.video.border.enabled)
|
||||
{
|
||||
setRendererSurface(border_surface_);
|
||||
game_surface_->render(options.video.border.width, options.video.border.height);
|
||||
border_surface_->copyToTexture(renderer_, border_texture_);
|
||||
}
|
||||
else
|
||||
{
|
||||
game_surface_->copyToTexture(renderer_, game_texture_);
|
||||
}
|
||||
// Copia la surface a la textura
|
||||
surfaceToTexture();
|
||||
|
||||
// Muestra el contenido por pantalla
|
||||
renderPresent();
|
||||
// Copia la textura al renderizador
|
||||
textureToRenderer();
|
||||
}
|
||||
|
||||
// Establece el modo de video
|
||||
@@ -245,32 +236,6 @@ void Screen::renderNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
// Muestra el contenido de Screen por pantalla
|
||||
void Screen::renderPresent()
|
||||
{
|
||||
SDL_SetRenderTarget(renderer_, nullptr);
|
||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
|
||||
if (options.video.shaders)
|
||||
{
|
||||
// Aplica shaders y renderiza el contenido
|
||||
shader::render();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.video.border.enabled)
|
||||
{
|
||||
SDL_RenderCopy(renderer_, border_texture_, nullptr, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_RenderCopy(renderer_, game_texture_, nullptr, &game_rect_);
|
||||
}
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
}
|
||||
|
||||
// Cambia el estado de los shaders
|
||||
void Screen::toggleShaders()
|
||||
{
|
||||
@@ -396,4 +361,46 @@ void Screen::processPaletteList()
|
||||
{
|
||||
palette = getFileName(palette);
|
||||
}
|
||||
}
|
||||
|
||||
// Copia la surface a la textura
|
||||
void Screen::surfaceToTexture()
|
||||
{
|
||||
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
||||
if (options.video.border.enabled)
|
||||
{
|
||||
setRendererSurface(border_surface_);
|
||||
game_surface_->render(options.video.border.width, options.video.border.height);
|
||||
border_surface_->copyToTexture(renderer_, border_texture_);
|
||||
}
|
||||
else
|
||||
{
|
||||
game_surface_->copyToTexture(renderer_, game_texture_);
|
||||
}
|
||||
}
|
||||
|
||||
// Copia la textura al renderizador
|
||||
void Screen::textureToRenderer()
|
||||
{
|
||||
|
||||
SDL_SetRenderTarget(renderer_, nullptr);
|
||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
|
||||
if (options.video.shaders)
|
||||
{
|
||||
shader::render();
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Texture *texture_to_render = options.video.border.enabled ? border_texture_ : game_texture_;
|
||||
SDL_RenderCopy(renderer_, texture_to_render, nullptr, nullptr);
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
}
|
||||
|
||||
// Renderiza todos los overlays
|
||||
void Screen::renderOverlays()
|
||||
{
|
||||
renderNotifications();
|
||||
}
|
||||
@@ -46,9 +46,6 @@ private:
|
||||
// Dibuja las notificaciones
|
||||
void renderNotifications();
|
||||
|
||||
// Muestra el contenido de Screen por pantalla
|
||||
void renderPresent();
|
||||
|
||||
// Calcula el tamaño de la ventana
|
||||
void adjustWindowSize();
|
||||
|
||||
@@ -64,6 +61,15 @@ private:
|
||||
// Extrae los nombres de las paletas
|
||||
void processPaletteList();
|
||||
|
||||
// Copia la surface a la textura
|
||||
void surfaceToTexture();
|
||||
|
||||
// Copia la textura al renderizador
|
||||
void textureToRenderer();
|
||||
|
||||
// Renderiza todos los overlays
|
||||
void renderOverlays();
|
||||
|
||||
// Constructor
|
||||
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user