Added logic to further ensure that changes to emulation video settings force an settings change on the Qt console viewer.

This commit is contained in:
mjbudd77 2021-05-15 07:03:53 -04:00
parent 6fda3ca0b3
commit 31608a5c6d
9 changed files with 73 additions and 31 deletions

View File

@ -114,16 +114,23 @@ int ConsoleViewGL_t::init( void )
return 0; return 0;
} }
void ConsoleViewGL_t::reset(void)
{
buildTextures();
return;
}
void ConsoleViewGL_t::buildTextures(void) void ConsoleViewGL_t::buildTextures(void)
{ {
int w, h; int w, h;
glEnable(GL_TEXTURE_RECTANGLE); glEnable(GL_TEXTURE_RECTANGLE);
if ( gltexture ) if ( gltexture )
{ {
glDeleteTextures(1, &gltexture); glDeleteTextures(1, &gltexture);
gltexture=0; gltexture=0;
} }
glGenTextures(1, &gltexture); glGenTextures(1, &gltexture);
//printf("Linear Interpolation on GL Texture: %s \n", linearFilter ? "Enabled" : "Disabled"); //printf("Linear Interpolation on GL Texture: %s \n", linearFilter ? "Enabled" : "Disabled");

View File

@ -16,7 +16,8 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
ConsoleViewGL_t(QWidget *parent = 0); ConsoleViewGL_t(QWidget *parent = 0);
~ConsoleViewGL_t(void); ~ConsoleViewGL_t(void);
int init( void ); int init(void);
void reset(void);
void transfer2LocalBuffer(void); void transfer2LocalBuffer(void);

View File

@ -194,14 +194,14 @@ int ConsoleViewSDL_t::init(void)
{ {
WId windowHandle; WId windowHandle;
if ( linearFilter ) if ( linearFilter )
{ {
SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ); SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" );
} }
else else
{ {
SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "0" ); SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "0" );
} }
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0)
{ {

View File

@ -14,7 +14,7 @@ class ConsoleViewSDL_t : public QWidget
public: public:
ConsoleViewSDL_t(QWidget *parent = 0); ConsoleViewSDL_t(QWidget *parent = 0);
~ConsoleViewSDL_t(void); ~ConsoleViewSDL_t(void);
int init(void); int init(void);
void reset(void); void reset(void);

View File

@ -298,6 +298,34 @@ consoleWin_t::~consoleWin_t(void)
} }
int consoleWin_t::videoInit(void)
{
int ret = 0;
if ( viewport_SDL )
{
ret = viewport_SDL->init();
}
else if ( viewport_GL )
{
ret = viewport_GL->init();
}
return ret;
}
void consoleWin_t::videoReset(void)
{
if ( viewport_SDL )
{
viewport_SDL->reset();
}
else if ( viewport_GL )
{
viewport_GL->reset();
}
return;
}
QSize consoleWin_t::calcRequiredSize(void) QSize consoleWin_t::calcRequiredSize(void)
{ {
QSize out( GL_NES_WIDTH, GL_NES_HEIGHT ); QSize out( GL_NES_WIDTH, GL_NES_HEIGHT );

View File

@ -106,6 +106,8 @@ class consoleWin_t : public QMainWindow
QMutex *mutex; QMutex *mutex;
#endif #endif
int videoInit(void);
void videoReset(void);
void requestClose(void); void requestClose(void);
void QueueErrorMsgWindow( const char *msg ); void QueueErrorMsgWindow( const char *msg );

View File

@ -356,17 +356,27 @@ int LoadGame(const char *path, bool silent)
FCEUI_SetRegion(region); FCEUI_SetRegion(region);
} }
// Always re-calculate video dimensions after setting region.
CalcVideoDimensions();
// Force re-send of video settings to console viewer
if ( consoleWindow )
{
consoleWindow->videoReset();
}
g_config->getOption("SDL.SwapDuty", &id); g_config->getOption("SDL.SwapDuty", &id);
swapDuty = id; swapDuty = id;
std::string filename; // Wave Recording done through menu or hotkeys
g_config->getOption("SDL.Sound.RecordFile", &filename); //std::string filename;
if(filename.size()) { //g_config->getOption("SDL.Sound.RecordFile", &filename);
if(!FCEUI_BeginWaveRecord(filename.c_str())) { //if (filename.size())
g_config->setOption("SDL.Sound.RecordFile", ""); //{
} // if (!FCEUI_BeginWaveRecord(filename.c_str())) {
} // g_config->setOption("SDL.Sound.RecordFile", "");
// }
//}
isloaded = 1; isloaded = 1;
//FCEUD_NetworkConnect(); //FCEUD_NetworkConnect();

View File

@ -118,14 +118,7 @@ int main( int argc, char *argv[] )
consoleWindow->show(); consoleWindow->show();
if ( consoleWindow->viewport_SDL ) consoleWindow->videoInit();
{
consoleWindow->viewport_SDL->init();
}
else
{
consoleWindow->viewport_GL->init();
}
retval = app.exec(); retval = app.exec();

View File

@ -240,6 +240,7 @@ int InitVideo(FCEUGI *gi)
switch ( s_sponge ) switch ( s_sponge )
{ {
default:
case 0: // None case 0: // None
nes_shm->video.scale = 1; nes_shm->video.scale = 1;
break; break;