From 812ef2562924bafe3332a47d7de0af179588aaed Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Tue, 20 Oct 2020 07:19:47 -0400 Subject: [PATCH 1/2] Added pixel linear filtering option logic for SDL viewport (for OpenGL and Direct3D backends only) --- src/drivers/Qt/ConsoleVideoConf.cpp | 4 ++++ src/drivers/Qt/ConsoleViewerGL.cpp | 7 +++++-- src/drivers/Qt/ConsoleViewerSDL.cpp | 27 +++++++++++++++++++++++++++ src/drivers/Qt/ConsoleViewerSDL.h | 3 +++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/drivers/Qt/ConsoleVideoConf.cpp b/src/drivers/Qt/ConsoleVideoConf.cpp index 682a53a2..f85db198 100644 --- a/src/drivers/Qt/ConsoleVideoConf.cpp +++ b/src/drivers/Qt/ConsoleVideoConf.cpp @@ -179,6 +179,10 @@ void ConsoleVideoConfDialog_t::openGL_linearFilterChanged( int value ) { consoleWindow->viewport_GL->setLinearFilterEnable( opt ); } + if ( consoleWindow->viewport_SDL ) + { + consoleWindow->viewport_SDL->setLinearFilterEnable( opt ); + } } } //---------------------------------------------------- diff --git a/src/drivers/Qt/ConsoleViewerGL.cpp b/src/drivers/Qt/ConsoleViewerGL.cpp index 7ac07279..30d269b6 100644 --- a/src/drivers/Qt/ConsoleViewerGL.cpp +++ b/src/drivers/Qt/ConsoleViewerGL.cpp @@ -133,9 +133,12 @@ void ConsoleViewGL_t::resizeGL(int w, int h) void ConsoleViewGL_t::setLinearFilterEnable( bool ena ) { - linearFilter = ena; + if ( linearFilter != ena ) + { + linearFilter = ena; - buildTextures(); + buildTextures(); + } } void ConsoleViewGL_t::transfer2LocalBuffer(void) diff --git a/src/drivers/Qt/ConsoleViewerSDL.cpp b/src/drivers/Qt/ConsoleViewerSDL.cpp index 4f96346e..5e6beb95 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.cpp +++ b/src/drivers/Qt/ConsoleViewerSDL.cpp @@ -7,6 +7,7 @@ #include #include "Qt/nes_shm.h" +#include "Qt/fceuWrapper.h" #include "Qt/ConsoleViewerSDL.h" extern unsigned int gui_draw_area_width; @@ -46,6 +47,13 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent) memset( localBuf, 0, localBufSize ); } + if ( g_config ) + { + int opt; + g_config->getOption("SDL.OpenGLip", &opt ); + + linearFilter = (opt) ? true : false; + } } ConsoleViewSDL_t::~ConsoleViewSDL_t(void) @@ -56,6 +64,16 @@ ConsoleViewSDL_t::~ConsoleViewSDL_t(void) } } +void ConsoleViewSDL_t::setLinearFilterEnable( bool ena ) +{ + if ( ena != linearFilter ) + { + linearFilter = ena; + + reset(); + } +} + void ConsoleViewSDL_t::transfer2LocalBuffer(void) { memcpy( localBuf, nes_shm->pixbuf, localBufSize ); @@ -65,6 +83,15 @@ int ConsoleViewSDL_t::init(void) { WId windowHandle; + if ( linearFilter ) + { + SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ); + } + else + { + SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "0" ); + } + if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { printf("[SDL] Failed to initialize video subsystem.\n"); diff --git a/src/drivers/Qt/ConsoleViewerSDL.h b/src/drivers/Qt/ConsoleViewerSDL.h index 45de62e7..a7ccbd83 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.h +++ b/src/drivers/Qt/ConsoleViewerSDL.h @@ -23,6 +23,8 @@ class ConsoleViewSDL_t : public QWidget void transfer2LocalBuffer(void); + void setLinearFilterEnable( bool ena ); + protected: //void paintEvent(QPaintEvent *event); @@ -39,6 +41,7 @@ class ConsoleViewSDL_t : public QWidget int sdlRendH; bool vsyncEnabled; + bool linearFilter; uint32_t *localBuf; uint32_t localBufSize; From 7c4c524152eff2f22d7aea3ec8998728fbc88a6c Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Tue, 20 Oct 2020 07:28:46 -0400 Subject: [PATCH 2/2] Added a line to ensure that linear filter option is initialized at startup for Qt gui. --- src/drivers/Qt/ConsoleViewerGL.cpp | 2 ++ src/drivers/Qt/ConsoleViewerSDL.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/drivers/Qt/ConsoleViewerGL.cpp b/src/drivers/Qt/ConsoleViewerGL.cpp index 30d269b6..e4258997 100644 --- a/src/drivers/Qt/ConsoleViewerGL.cpp +++ b/src/drivers/Qt/ConsoleViewerGL.cpp @@ -40,6 +40,8 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent) memset( localBuf, 0, localBufSize ); } + linearFilter = false; + if ( g_config ) { int opt; diff --git a/src/drivers/Qt/ConsoleViewerSDL.cpp b/src/drivers/Qt/ConsoleViewerSDL.cpp index 5e6beb95..139d5812 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.cpp +++ b/src/drivers/Qt/ConsoleViewerSDL.cpp @@ -47,6 +47,8 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent) memset( localBuf, 0, localBufSize ); } + linearFilter = false; + if ( g_config ) { int opt;