Added pixel linear filtering option logic for SDL viewport (for OpenGL and Direct3D backends only)

This commit is contained in:
mjbudd77 2020-10-20 07:19:47 -04:00
parent fd5e68efd0
commit 812ef25629
4 changed files with 39 additions and 2 deletions

View File

@ -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 );
}
}
}
//----------------------------------------------------

View File

@ -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)

View File

@ -7,6 +7,7 @@
#include <unistd.h>
#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");

View File

@ -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;