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
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
void Screen::render()
|
void Screen::render()
|
||||||
{
|
{
|
||||||
// Renderiza sobre game_surface_ los overlays
|
// Renderiza todos los overlays
|
||||||
renderNotifications();
|
renderOverlays();
|
||||||
|
|
||||||
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
// Copia la surface a la textura
|
||||||
if (options.video.border.enabled)
|
surfaceToTexture();
|
||||||
{
|
|
||||||
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_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Muestra el contenido por pantalla
|
// Copia la textura al renderizador
|
||||||
renderPresent();
|
textureToRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el modo de video
|
// 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
|
// Cambia el estado de los shaders
|
||||||
void Screen::toggleShaders()
|
void Screen::toggleShaders()
|
||||||
{
|
{
|
||||||
@@ -397,3 +362,45 @@ void Screen::processPaletteList()
|
|||||||
palette = getFileName(palette);
|
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
|
// Dibuja las notificaciones
|
||||||
void renderNotifications();
|
void renderNotifications();
|
||||||
|
|
||||||
// Muestra el contenido de Screen por pantalla
|
|
||||||
void renderPresent();
|
|
||||||
|
|
||||||
// Calcula el tamaño de la ventana
|
// Calcula el tamaño de la ventana
|
||||||
void adjustWindowSize();
|
void adjustWindowSize();
|
||||||
|
|
||||||
@@ -64,6 +61,15 @@ private:
|
|||||||
// Extrae los nombres de las paletas
|
// Extrae los nombres de las paletas
|
||||||
void processPaletteList();
|
void processPaletteList();
|
||||||
|
|
||||||
|
// Copia la surface a la textura
|
||||||
|
void surfaceToTexture();
|
||||||
|
|
||||||
|
// Copia la textura al renderizador
|
||||||
|
void textureToRenderer();
|
||||||
|
|
||||||
|
// Renderiza todos los overlays
|
||||||
|
void renderOverlays();
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user