Skip to content

Commit

Permalink
fix remembering video settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed May 20, 2023
1 parent 5dc3aab commit 2ad46d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions bin/Cores/cores.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
},
"dolphin_libretro":{
"name": "Dolphin",
"extensions": "iso|m3u",
"systems": [16,19],
"platforms": "none"
},
Expand Down
28 changes: 17 additions & 11 deletions src/components/Video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ along with RALibretro. If not, see <http://www.gnu.org/licenses/>.

#define TAG "[VID] "

bool Video::init(libretro::LoggerComponent* logger, libretro::VideoContextComponent *ctx, Config* config)
Video::Video()
{
_logger = logger;
_ctx = ctx;
_config = config;

_enabled = true;

_pixelFormat = RETRO_PIXEL_FORMAT_UNKNOWN;
Expand All @@ -51,11 +47,21 @@ bool Video::init(libretro::LoggerComponent* logger, libretro::VideoContextCompon
_preserveAspect = false;
_linearFilter = false;

_program = createProgram(&_posAttribute, &_uvAttribute, &_texUniform);

_hw.enabled = false;
_hw.frameBuffer = _hw.renderBuffer = 0;
_hw.callback = nullptr;
}

bool Video::init(libretro::LoggerComponent* logger, libretro::VideoContextComponent *ctx, Config* config)
{
_logger = logger;
_ctx = ctx;
_config = config;

// NOTE: Video::init is called after Video::deserializeSettings. Make sure not to overwrite anyting
// stored in the .cfg file.

_program = createProgram(&_posAttribute, &_uvAttribute, &_texUniform);

if (!Gl::ok())
{
Expand Down Expand Up @@ -414,11 +420,11 @@ std::string Video::serializeSettings()
{
std::string json("{");

json.append("\"_preserveAspect\":");
json.append("\"preserveAspect\":");
json.append(_preserveAspect ? "true" : "false");
json.append(",");

json.append("\"_linearFilter\":");
json.append("\"linearFilter\":");
json.append(_linearFilter ? "true" : "false");

json.append("}");
Expand Down Expand Up @@ -446,11 +452,11 @@ bool Video::deserializeSettings(const char* json)
}
else if (event == JSONSAX_BOOLEAN)
{
if (ud->key == "_preserveAspect")
if (ud->key == "preserveAspect" || ud->key == "_preserveAspect")
{
ud->self->_preserveAspect = num != 0;
}
if (ud->key == "_linearFilter")
if (ud->key == "linearFilter" || ud->key == "_linearFilter")
{
ud->self->_linearFilter = num != 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Video.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ along with RALibretro. If not, see <http://www.gnu.org/licenses/>.
class Video: public libretro::VideoComponent
{
public:
Video();

bool init(libretro::LoggerComponent* logger, libretro::VideoContextComponent* ctx, Config* config);
void destroy();

Expand Down

0 comments on commit 2ad46d1

Please sign in to comment.