Ja funciona correctament el canvi de tamany de finestra, el shaders, i la pantalla completa
This commit is contained in:
@@ -41,6 +41,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
||||
SDL_DisplayMode DM;
|
||||
SDL_GetCurrentDisplayMode(0, &DM);
|
||||
info_resolution_ = std::to_string(DM.w) + " X " + std::to_string(DM.h) + " AT " + std::to_string(DM.refresh_rate) + " HZ";
|
||||
adjustRenderLogicalSize();
|
||||
|
||||
// Inicializa los shaders
|
||||
initShaders();
|
||||
@@ -101,6 +102,8 @@ void Screen::setVideoMode(ScreenVideoMode video_mode)
|
||||
{
|
||||
SDL_SetWindowFullscreen(window_, static_cast<Uint32>(options.video.mode));
|
||||
}
|
||||
|
||||
initShaders();
|
||||
}
|
||||
|
||||
// Camibia entre pantalla completa y ventana
|
||||
@@ -312,17 +315,22 @@ void Screen::renderInfo()
|
||||
}
|
||||
}
|
||||
|
||||
// Reinicia los shaders
|
||||
// Carga el contenido del archivo GLSL
|
||||
void Screen::loadShaders()
|
||||
{
|
||||
const std::string GLSL_FILE = param.game.game_area.rect.h == 256 ? "crtpi_256.glsl" : "crtpi_240.glsl";
|
||||
std::ifstream f(Asset::get()->get(GLSL_FILE).c_str());
|
||||
shaderSource = std::string((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
// Inicializa los shaders
|
||||
void Screen::initShaders()
|
||||
{
|
||||
if (options.video.shaders)
|
||||
if (shaderSource.empty())
|
||||
{
|
||||
const std::string GLSL_FILE = param.game.game_area.rect.h == 256 ? "crtpi_256.glsl" : "crtpi_240.glsl";
|
||||
std::ifstream f(Asset::get()->get(GLSL_FILE).c_str());
|
||||
std::string source((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||
|
||||
shader::init(window_, game_canvas_, source.c_str());
|
||||
loadShaders();
|
||||
}
|
||||
shader::init(window_, game_canvas_, shaderSource.c_str());
|
||||
}
|
||||
|
||||
// Calcula el tamaño de la ventana
|
||||
@@ -350,6 +358,8 @@ void Screen::adjustWindowSize()
|
||||
|
||||
SDL_SetWindowPosition(window_, std::max(NEW_POS_X, WINDOWS_DECORATIONS_), std::max(NEW_POS_Y, 0));
|
||||
SDL_SetWindowSize(window_, WIDTH, HEIGHT);
|
||||
|
||||
initShaders();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user