Primera implementación funcional de shaders
This commit is contained in:
@@ -148,7 +148,6 @@ bool Director::initSDL()
|
||||
|
||||
// Inicializa SDL
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
|
||||
// if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0)
|
||||
{
|
||||
if (options->console)
|
||||
{
|
||||
@@ -166,10 +165,19 @@ bool Director::initSDL()
|
||||
{
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Warning: Nearest texture filtering not enabled!\n";
|
||||
std::cout << "Warning: texture filtering not enabled!\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (options->video.shaders)
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
|
||||
{
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Warning: opengl not enabled!\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Crea la ventana
|
||||
int incW = 0;
|
||||
int incH = 0;
|
||||
@@ -178,7 +186,7 @@ bool Director::initSDL()
|
||||
incW = options->video.border.width * 2;
|
||||
incH = options->video.border.height * 2;
|
||||
}
|
||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (param->gameWidth + incW) * options->video.window.size, (param->gameHeight + incH) * options->video.window.size, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (param->gameWidth + incW) * options->video.window.size, (param->gameHeight + incH) * options->video.window.size, 0);
|
||||
if (window == nullptr)
|
||||
{
|
||||
if (options->console)
|
||||
@@ -195,6 +203,13 @@ bool Director::initSDL()
|
||||
{
|
||||
flags = flags | SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
|
||||
// La aceleración se activa según las opciones
|
||||
if (options->video.shaders)
|
||||
{
|
||||
flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, flags);
|
||||
|
||||
if (renderer == nullptr)
|
||||
@@ -270,6 +285,9 @@ bool Director::setFileList()
|
||||
asset->add(prefix + "/data/sound/powerball.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/notify.wav", t_sound);
|
||||
|
||||
// Shaders
|
||||
asset->add(prefix + "/data/shaders/crtpi.glsl", t_data);
|
||||
|
||||
// Texturas
|
||||
asset->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/balloon1.ani", t_data);
|
||||
@@ -404,6 +422,7 @@ void Director::initOptions()
|
||||
options->video.border.width = 0;
|
||||
options->video.border.height = 0;
|
||||
options->video.border.enabled = false;
|
||||
options->video.shaders = true;
|
||||
|
||||
// Opciones de audio
|
||||
options->audio.music.enabled = true;
|
||||
@@ -617,6 +636,7 @@ bool Director::saveConfigFile()
|
||||
file << "border.enabled=" + boolToString(options->video.border.enabled) + "\n";
|
||||
file << "border.width=" + std::to_string(options->video.border.width) + "\n";
|
||||
file << "border.height=" + std::to_string(options->video.border.height) + "\n";
|
||||
file << "video.shaders=" + boolToString(options->video.shaders) + "\n";
|
||||
|
||||
// Opciones de audio
|
||||
file << "\n## AUDIO\n";
|
||||
@@ -807,6 +827,11 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
||||
options->video.border.height = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "video.shaders")
|
||||
{
|
||||
options->video.shaders = stringToBool(value);
|
||||
}
|
||||
|
||||
// Opciones de audio
|
||||
else if (var == "music.enabled")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user