Merge pull request #194 from mjbudd77/master

Added video pixel linear filtering capability for SDL video backend option.
This commit is contained in:
mjbudd77 2020-10-20 07:51:26 -04:00 committed by GitHub
commit 5f4af397d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 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

@ -40,6 +40,8 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
memset( localBuf, 0, localBufSize );
}
linearFilter = false;
if ( g_config )
{
int opt;
@ -133,9 +135,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,15 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
memset( localBuf, 0, localBufSize );
}
linearFilter = false;
if ( g_config )
{
int opt;
g_config->getOption("SDL.OpenGLip", &opt );
linearFilter = (opt) ? true : false;
}
}
ConsoleViewSDL_t::~ConsoleViewSDL_t(void)
@ -56,6 +66,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 +85,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;