Added video vertical sync refresh option to Qt GUI.
This commit is contained in:
parent
9e1564df0d
commit
dd9b911b60
|
@ -156,9 +156,12 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
|||
// Enable New PPU Checkbox
|
||||
new_PPU_ena = new QCheckBox( tr("Enable New PPU") );
|
||||
|
||||
// Enable New PPU Checkbox
|
||||
// Enable Frameskip
|
||||
frmskipcbx = new QCheckBox( tr("Enable Frameskip") );
|
||||
|
||||
// Enable Vertical Sync
|
||||
vsync_ena = new QCheckBox( tr("Enable Vertical Sync") );
|
||||
|
||||
// Use Integer Frame Rate Checkbox
|
||||
intFrameRateCbx = new QCheckBox( tr("Use Integer Frame Rate") );
|
||||
|
||||
|
@ -205,6 +208,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
|||
setCheckBoxFromProperty( autoRegion , "SDL.AutoDetectPAL");
|
||||
setCheckBoxFromProperty( new_PPU_ena , "SDL.NewPPU");
|
||||
setCheckBoxFromProperty( frmskipcbx , "SDL.Frameskip");
|
||||
setCheckBoxFromProperty( vsync_ena , "SDL.VideoVsync");
|
||||
setCheckBoxFromProperty( intFrameRateCbx , "SDL.IntFrameRate");
|
||||
setCheckBoxFromProperty( sprtLimCbx , "SDL.DisableSpriteLimit");
|
||||
setCheckBoxFromProperty( clipSidesCbx , "SDL.ClipSides");
|
||||
|
@ -228,6 +232,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
|||
connect(new_PPU_ena , SIGNAL(clicked(bool)) , this, SLOT(use_new_PPU_changed(bool)) );
|
||||
connect(autoRegion , SIGNAL(stateChanged(int)), this, SLOT(autoRegionChanged(int)) );
|
||||
connect(frmskipcbx , SIGNAL(stateChanged(int)), this, SLOT(frameskip_changed(int)) );
|
||||
connect(vsync_ena , SIGNAL(stateChanged(int)), this, SLOT(vsync_changed(int)) );
|
||||
connect(intFrameRateCbx , SIGNAL(stateChanged(int)), this, SLOT(intFrameRate_changed(int)) );
|
||||
connect(sprtLimCbx , SIGNAL(stateChanged(int)), this, SLOT(useSpriteLimitChanged(int)) );
|
||||
connect(clipSidesCbx , SIGNAL(stateChanged(int)), this, SLOT(clipSidesChanged(int)) );
|
||||
|
@ -245,6 +250,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
|||
vbox1->addWidget( autoRegion );
|
||||
vbox1->addWidget( new_PPU_ena );
|
||||
vbox1->addWidget( frmskipcbx );
|
||||
vbox1->addWidget( vsync_ena );
|
||||
vbox1->addWidget( intFrameRateCbx );
|
||||
vbox1->addWidget( sprtLimCbx );
|
||||
//vbox1->addWidget( drawInputAidsCbx );
|
||||
|
@ -788,6 +794,28 @@ void ConsoleVideoConfDialog_t::frameskip_changed( int value )
|
|||
fceuWrapperUnLock();
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ConsoleVideoConfDialog_t::vsync_changed( int value )
|
||||
{
|
||||
//printf("Value:%i \n", value );
|
||||
bool opt = (value != Qt::Unchecked);
|
||||
g_config->setOption("SDL.VideoVsync", opt );
|
||||
g_config->save ();
|
||||
|
||||
if ( consoleWindow != NULL )
|
||||
{
|
||||
if ( consoleWindow->viewport_GL )
|
||||
{
|
||||
// QOpenGLWidget required full driver reset
|
||||
//consoleWindow->viewport_GL->setVsyncEnable( opt );
|
||||
consoleWindow->loadVideoDriver( 0, true );
|
||||
}
|
||||
if ( consoleWindow->viewport_SDL )
|
||||
{
|
||||
consoleWindow->viewport_SDL->setVsyncEnable( opt );
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ConsoleVideoConfDialog_t::intFrameRate_changed( int value )
|
||||
{
|
||||
//printf("Value:%i \n", value );
|
||||
|
|
|
@ -38,6 +38,7 @@ class ConsoleVideoConfDialog_t : public QDialog
|
|||
QComboBox *aspectSelect;
|
||||
QComboBox *inputDisplaySel;
|
||||
QCheckBox *autoRegion;
|
||||
QCheckBox *vsync_ena;
|
||||
QCheckBox *gl_LF_chkBox;
|
||||
QCheckBox *new_PPU_ena;
|
||||
QCheckBox *frmskipcbx;
|
||||
|
@ -85,6 +86,7 @@ class ConsoleVideoConfDialog_t : public QDialog
|
|||
void aspectEnableChanged( int value );
|
||||
void use_new_PPU_changed( bool value );
|
||||
void frameskip_changed( int value );
|
||||
void vsync_changed( int value );
|
||||
void intFrameRate_changed( int value );
|
||||
void useSpriteLimitChanged( int value );
|
||||
void clipSidesChanged( int value );
|
||||
|
|
|
@ -94,6 +94,7 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
|
|||
memset( localBuf, 0, localBufSize );
|
||||
}
|
||||
|
||||
vsyncEnabled = true;
|
||||
linearFilter = false;
|
||||
|
||||
if ( g_config )
|
||||
|
@ -116,9 +117,20 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
|
|||
{
|
||||
fceuLoadConfigColor( "SDL.VideoBgColor", bgColor );
|
||||
}
|
||||
g_config->getOption ("SDL.VideoVsync", &vsyncEnabled);
|
||||
}
|
||||
|
||||
QSurfaceFormat fmt = format();
|
||||
|
||||
fmt.setSwapInterval( vsyncEnabled ? 1 : 0 );
|
||||
|
||||
setFormat(fmt);
|
||||
|
||||
connect( this, SIGNAL(frameSwapped(void)), this, SLOT(renderFinished(void)) );
|
||||
|
||||
//fmt = format();
|
||||
|
||||
//printf("Format Swap Interval: %i\n", fmt.swapInterval() );
|
||||
}
|
||||
|
||||
ConsoleViewGL_t::~ConsoleViewGL_t(void)
|
||||
|
@ -387,6 +399,22 @@ void ConsoleViewGL_t::setBgColor( QColor &c )
|
|||
}
|
||||
}
|
||||
|
||||
void ConsoleViewGL_t::setVsyncEnable( bool ena )
|
||||
{
|
||||
if ( vsyncEnabled != ena )
|
||||
{
|
||||
QSurfaceFormat fmt = format();
|
||||
|
||||
vsyncEnabled = ena;
|
||||
|
||||
fmt.setSwapInterval( vsyncEnabled ? 1 : 0 );
|
||||
|
||||
setFormat(fmt);
|
||||
|
||||
buildTextures();
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleViewGL_t::setLinearFilterEnable( bool ena )
|
||||
{
|
||||
if ( linearFilter != ena )
|
||||
|
|
|
@ -23,6 +23,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
|
||||
void transfer2LocalBuffer(void);
|
||||
|
||||
void setVsyncEnable( bool ena );
|
||||
void setLinearFilterEnable( bool ena );
|
||||
|
||||
bool getForceAspectOpt(void){ return forceAspect; };
|
||||
|
@ -73,6 +74,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
bool forceAspect;
|
||||
bool autoScaleEna;
|
||||
bool reqPwr2;
|
||||
bool vsyncEnabled;
|
||||
|
||||
unsigned int textureType;
|
||||
unsigned int mouseButtonMask;
|
||||
|
|
|
@ -116,6 +116,7 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
|||
{
|
||||
fceuLoadConfigColor( "SDL.VideoBgColor", bgColor );
|
||||
}
|
||||
g_config->getOption ("SDL.VideoVsync", &vsyncEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,6 +147,16 @@ void ConsoleViewSDL_t::setBgColor( QColor &c )
|
|||
}
|
||||
}
|
||||
|
||||
void ConsoleViewSDL_t::setVsyncEnable( bool ena )
|
||||
{
|
||||
if ( vsyncEnabled != ena )
|
||||
{
|
||||
vsyncEnabled = ena;
|
||||
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleViewSDL_t::setLinearFilterEnable( bool ena )
|
||||
{
|
||||
if ( ena != linearFilter )
|
||||
|
@ -278,6 +289,10 @@ int ConsoleViewSDL_t::init(void)
|
|||
|
||||
SDL_ShowWindow( sdlWindow );
|
||||
|
||||
//if ( vsyncEnabled )
|
||||
//{
|
||||
// printf("Vsync Enabled\n");
|
||||
//}
|
||||
uint32_t baseFlags = vsyncEnabled ? SDL_RENDERER_PRESENTVSYNC : 0;
|
||||
|
||||
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, baseFlags | SDL_RENDERER_ACCELERATED);
|
||||
|
|
|
@ -25,6 +25,7 @@ class ConsoleViewSDL_t : public QWidget
|
|||
|
||||
void transfer2LocalBuffer(void);
|
||||
|
||||
void setVsyncEnable( bool ena );
|
||||
void setLinearFilterEnable( bool ena );
|
||||
|
||||
bool getForceAspectOpt(void){ return forceAspect; };
|
||||
|
|
|
@ -1883,13 +1883,26 @@ void consoleWin_t::createMainMenu(void)
|
|||
#endif
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
int consoleWin_t::loadVideoDriver( int driverId )
|
||||
int consoleWin_t::loadVideoDriver( int driverId, bool force )
|
||||
{
|
||||
if ( driverId )
|
||||
{ // SDL Driver
|
||||
if ( viewport_SDL != NULL )
|
||||
{ // Already Loaded
|
||||
return 0;
|
||||
if ( force )
|
||||
{
|
||||
if ( viewport_SDL == centralWidget() )
|
||||
{
|
||||
takeCentralWidget();
|
||||
}
|
||||
delete viewport_SDL;
|
||||
|
||||
viewport_SDL = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( viewport_GL != NULL )
|
||||
|
@ -1916,7 +1929,20 @@ int consoleWin_t::loadVideoDriver( int driverId )
|
|||
{ // OpenGL Driver
|
||||
if ( viewport_GL != NULL )
|
||||
{ // Already Loaded
|
||||
return 0;
|
||||
if ( force )
|
||||
{
|
||||
if ( viewport_GL == centralWidget() )
|
||||
{
|
||||
takeCentralWidget();
|
||||
}
|
||||
delete viewport_GL;
|
||||
|
||||
viewport_GL = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( viewport_SDL != NULL )
|
||||
|
|
|
@ -153,7 +153,7 @@ class consoleWin_t : public QMainWindow
|
|||
int getMaxSchedPriority(void);
|
||||
#endif
|
||||
|
||||
int loadVideoDriver( int driverId );
|
||||
int loadVideoDriver( int driverId, bool force = false );
|
||||
|
||||
double getRefreshRate(void){ return refreshRate; }
|
||||
|
||||
|
|
|
@ -526,6 +526,7 @@ InitConfig()
|
|||
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
|
||||
config->addOption("videoDriver", "SDL.VideoDriver", 0);
|
||||
config->addOption("SDL.VideoBgColor", "#000000");
|
||||
config->addOption("SDL.VideoVsync", 1);
|
||||
|
||||
// set x/y res to 0 for automatic fullscreen resolution detection (no change)
|
||||
config->addOption('x', "xres", "SDL.XResolution", 0);
|
||||
|
|
Loading…
Reference in New Issue